|
|
|
@ -10,6 +10,7 @@
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <strings.h>
|
|
|
|
#include <strings.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include "sdkconfig.h"
|
|
|
|
#include "sdkconfig.h"
|
|
|
|
#include "freertos/FreeRTOS.h"
|
|
|
|
#include "freertos/FreeRTOS.h"
|
|
|
|
#include "freertos/task.h"
|
|
|
|
#include "freertos/task.h"
|
|
|
|
@ -50,8 +51,19 @@ static void https_request_task(void *pvparameters){
|
|
|
|
vTaskDelete(NULL);
|
|
|
|
vTaskDelete(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//static lwjson_token_t tokens[1100];
|
|
|
|
void get_json_string(char* buf, char* name, char* dest){
|
|
|
|
//static lwjson_t lwjson;
|
|
|
|
char* element = strstr(buf, name);
|
|
|
|
|
|
|
|
char *ptr= element;
|
|
|
|
|
|
|
|
while(*ptr != ':') ptr++;
|
|
|
|
|
|
|
|
while(*ptr != '"') ptr++;
|
|
|
|
|
|
|
|
ptr++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char *end=ptr;
|
|
|
|
|
|
|
|
while(*end != '"') end++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
strncpy(dest, ptr, end-ptr);
|
|
|
|
|
|
|
|
dest[end-ptr]=0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t json_ok = 0;
|
|
|
|
uint8_t json_ok = 0;
|
|
|
|
static void json_parse_task(void *pvparameters){
|
|
|
|
static void json_parse_task(void *pvparameters){
|
|
|
|
@ -63,15 +75,27 @@ static void json_parse_task(void *pvparameters){
|
|
|
|
ESP_LOGI("bsvg", "start at %ld: \"%.10s\"", (uint32_t)start, start);
|
|
|
|
ESP_LOGI("bsvg", "start at %ld: \"%.10s\"", (uint32_t)start, start);
|
|
|
|
//departureList = cJSON_Parse(start);
|
|
|
|
//departureList = cJSON_Parse(start);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t line = 0;
|
|
|
|
char *item = start;
|
|
|
|
char *item = start;
|
|
|
|
|
|
|
|
char txt[5][50];
|
|
|
|
while((item = strstr(item+1, "{ \"stopID\":")) != 0){
|
|
|
|
while((item = strstr(item+1, "{ \"stopID\":")) != 0){
|
|
|
|
char *symbol = strstr(item, "\"symbol\"");
|
|
|
|
char symbol[10];
|
|
|
|
char *direction = strstr(item, "\"direction\"");
|
|
|
|
get_json_string(item, "symbol", symbol);
|
|
|
|
char *countdown = strstr(item, "\"countdown\"");
|
|
|
|
|
|
|
|
if(symbol && direction && countdown)
|
|
|
|
char direction[50];
|
|
|
|
printf("%.15s\t%.30s\t%.15s\n", symbol, direction, countdown);
|
|
|
|
get_json_string(item, "direction", direction);
|
|
|
|
else
|
|
|
|
|
|
|
|
printf("cant find symbol\n");
|
|
|
|
char countdown[10] ;
|
|
|
|
|
|
|
|
get_json_string(item, "countdown", countdown);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(line < 6){
|
|
|
|
|
|
|
|
sprintf(txt[line], "%.3s %.15s %.3s", symbol, direction, countdown);
|
|
|
|
|
|
|
|
printf("line = %d\n", line);
|
|
|
|
|
|
|
|
printf("text = %s\n", txt[line]);
|
|
|
|
|
|
|
|
put_line(fb, line, txt[line], 1, 1);
|
|
|
|
|
|
|
|
//printf("\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
line++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//lwjson_init(&lwjson, tokens, LWJSON_ARRAYSIZE(tokens));
|
|
|
|
//lwjson_init(&lwjson, tokens, LWJSON_ARRAYSIZE(tokens));
|
|
|
|
@ -91,8 +115,6 @@ static void json_parse_task(void *pvparameters){
|
|
|
|
// ESP_LOGI("bsvg", "parse fail");
|
|
|
|
// ESP_LOGI("bsvg", "parse fail");
|
|
|
|
//}
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
printf("free heap: %d\n", heap_caps_get_free_size( MALLOC_CAP_DEFAULT) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
json_ok = 1;
|
|
|
|
json_ok = 1;
|
|
|
|
vTaskDelete(NULL);
|
|
|
|
vTaskDelete(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|