I'm a neewby in ESP-IDF .
After many attempts I can't find a text in a table with the indexOf function?
here is my function which logs the response from the server :
- /*************************** HTTP GET ************************************/
- esp_err_t client_event_get_handler(esp_http_client_event_handle_t evt)
- {
- char buf_data[1000];
- switch (evt->event_id)
- {
- case HTTP_EVENT_ON_DATA:
- sprintf(buf_data, "%.*s\n", evt->data_len, (char *)evt->data); // printf("%.*s\n", str_len, str);
- printf(buf_data);
- break;
- default:
- break;
- }
- return ESP_OK;
- }
{"LED1":"1","LED2":"0","LED3":"1","INTER":"1","POTAR1":"1993","POTAR2":"1401"," BUZ":"0","MAJ":"56","MAJ_web":"56","MAJ_ESP":"56"}
I would like to be able to search for the text for example "LED1":"1" to know if I should turn my led on or off.
I have try this :
- /*************************** HTTP GET ************************************/
- esp_err_t client_event_get_handler(esp_http_client_event_handle_t evt)
- {
- char buf_data[1000];
- switch (evt->event_id)
- {
- case HTTP_EVENT_ON_DATA:
- sprintf(buf_data, "%.*s\n", evt->data_len, (char *)evt->data); // printf("%.*s\n", str_len, str);
- printf(buf_data);
- break;
- default:
- break;
- }
- if ( buf_data.IndexOf("LED1\":\"1") > 0)
- {
- gpio_set_level(LED_BLEUE, 1);
- }
- else
- {
- gpio_set_level(LED_BLEUE, 0);
- }
- return ESP_OK;
- }
Can you help me to find a solution ?error: request for member 'IndexOf' in something not a structure or union
143 | if ( buf_data.IndexOf("LED1\":\"1") > 0)
| ^
ninja: build stopped: subcommand failed.
Thanks for reading me
Jérémy