ESP32 not sending data to the webpage and ESP_LOGI not working

Kavish.26
Posts: 3
Joined: Thu Feb 15, 2024 9:12 am

ESP32 not sending data to the webpage and ESP_LOGI not working

Postby Kavish.26 » Thu Feb 15, 2024 9:38 am

Please help,
I am posting a lot of code because I don't know what might be most relevant, I request anyone, please help me understand what I am doing wrong.

I have recently started learning how to use esp-idf for building IoT applications. I was trying to build an application that posts data on a webpage. I started a wifi service, and I have embedded a webpage. the webpage is supposed to allow me to send files or OTA updates, and post the data on it so I can view it. When I tried the OTA update, it worked fine.
all the ESP_LOGI functions were also working, but as soon as I made a new URI handler that is supposed to send the data to a webpage, the ESP_LOGI function inside it stopped working, even after successful installation of the handler. I am pasting multiple codes here, in the hope someone could tell me where and what to change so I successfully view the data because once I can view the data, I have other things In mind I want to post on the webpage for viewing. please know this is me trying to learn.
  1. #include "esp_log.h"
  2. #include "esp_http_server.h"
  3. #include "esp_ota_ops.h"
  4. #include "sys/param.h"
  5. #include "esp_timer.h"
  6. #include <stdbool.h>
  7.  
  8. #include "common_tasks.h"
  9. #include "wifi_app.h"
  10. #include "http_server.h"
  11. #include "adcValues.h"
  12.  
  13. static const char tag[] = "http-server";
  14.  
  15. //firmware update status
  16. static int global_fw_update_status = OTA_UPDATE_PENDING;
  17.  
  18. //ESP32 TIMER CONFIG PASSED TO ESP_TIMER_CREATE
  19. const esp_timer_create_args_t fw_update_reset_args = {
  20.     .callback = &http_server_fw_update_reset_callback,
  21.     .arg = NULL,
  22.     .dispatch_method = ESP_TIMER_TASK,
  23.     .name = "fw_update_reset"
  24. };
  25. esp_timer_handle_t fw_update_reset;
  26.  
  27. //CHECK IF global_fw_update_status IS TRUE, THEN CREATE A RESET TIMER
  28. static void firmware_update_reset_timer(void){
  29.     if(global_fw_update_status == OTA_UPDATE_SUCCESSFUL){
  30.         ESP_LOGI(tag, "HTTP_SERVER_FIRMWARE_UPDATE_RESET_TIMER: FIRMWARE UPDATE SUCCESSFUL, STARTING UPDATE RESET TIMER");
  31.  
  32.         // Give the web page a chance to receive an acknowledge back and initialize the timer
  33.         ESP_ERROR_CHECK(esp_timer_create(&fw_update_reset_args, &fw_update_reset));
  34.         ESP_ERROR_CHECK(esp_timer_start_once(fw_update_reset, 8000000));    //8 seconds
  35.     } else {
  36.         ESP_LOGI(tag, "HTTP_SERVER_FIRMWARE_UPDATE_RESET_TIMER: FIRMWARE UPDATE UNSUCCESSFUL");        
  37.     }
  38. }
  39.  
  40. //HTTP SERVER TASK HANDLE
  41. static httpd_handle_t http_server_handle = NULL;
  42.  
  43. //SERVER MONITOR TASK AND QUEUE HANDLES
  44. static TaskHandle_t task_http_server_monitor_handle = NULL;
  45. static QueueHandle_t http_server_monitor_queue_handle;
  46.  
  47. //In the context of your ESP-IDF project, the declarations you provided are part of a mechanism to embed binary data directly into your program at compile-time.
  48. //This is typically done using a tool or a script that converts binary files into C arrays.
  49.  
  50. extern const uint8_t jquery_3_3_1_min_js_start[]         asm("_binary_jquery_3_3_1_min_js_start");
  51. extern const uint8_t jquery_3_3_1_min_js_end[]           asm("_binary_jquery_3_3_1_min_js_end");
  52.  
  53. //jquery_3_3_1_min_js_start is a pointer that points to the beginning of the binary data for the jQuery library.
  54. //The asm directive gives it a specific name in memory, in this case, "_binary_jquery_3_3_1_min_js_start".
  55. //jquey_3_3_1_min_js_end is a pointer that points to the end of the binary data for the jQuery library.
  56. //Similarly, the asm directive assigns a specific name in memory, "_binary_jquery_3_3_1_min_js_end".
  57. //The actual values of jquery_3_3_1_min_js_start and jquery_3_3_1_min_js_end are determined by the linker script or another mechanism
  58. //that places the binary data into the correct memory addresses.
  59. //When you include these declarations in your code and build your project,
  60. //the linker knows where to place the binary data in memory based on the names given in the asm directive.
  61. //It essentially takes care of the addresses for you. So, you don't need to manually specify where one array ends and the next begins;
  62. //the linker handles the memory layout during the compilation process.
  63.  
  64. extern const uint8_t index_html_start[]                 asm("_binary_index_html_start");
  65. extern const uint8_t index_html_end[]                   asm("_binary_index_html_end");
  66.  
  67. extern const uint8_t app_css_start[]                    asm("_binary_app_css_start");
  68. extern const uint8_t app_css_end[]                      asm("_binary_app_css_end");
  69.  
  70. extern const uint8_t app_js_start[]                     asm("_binary_app_js_start");
  71. extern const uint8_t app_js_end[]                       asm("_binary_app_js_end");
  72.  
  73. extern const uint8_t favicon_ico_start[]                asm("_binary_favicon_ico_start");
  74. extern const uint8_t favicon_ico_end[]                  asm("_binary_favicon_ico_end");
  75.  
  76.  
  77. static esp_err_t http_server_jquery_handler(httpd_req_t *req){
  78.     ESP_LOGI(tag, "JQUERY REQUESTED");
  79.  
  80.     httpd_resp_set_type(req, "application/javascript");
  81.     httpd_resp_send(req, (const char *)jquery_3_3_1_min_js_start, jquery_3_3_1_min_js_end - jquery_3_3_1_min_js_start);
  82.  
  83.     return ESP_OK;
  84. }
  85.  
  86. static esp_err_t http_server_index_html_handler(httpd_req_t *req){
  87.     ESP_LOGI(tag, "INDEX.HTML REQUESTED");
  88.  
  89.     httpd_resp_set_type(req, "text/html");
  90.     httpd_resp_send(req, (const char *)index_html_start, index_html_end - index_html_start);
  91.  
  92.     return ESP_OK;
  93. }
  94.  
  95. static esp_err_t http_server_app_css_handler(httpd_req_t *req){
  96.     ESP_LOGI(tag, "APP.CSS REQUESTED");
  97.  
  98.     httpd_resp_set_type(req, "text/css");
  99.     httpd_resp_send(req, (const char *)app_css_start, app_css_end - app_css_start);
  100.  
  101.     return ESP_OK;
  102. }
  103.  
  104. static esp_err_t http_server_app_js_handler(httpd_req_t *req){
  105.     ESP_LOGI(tag, "APP.JS REQUESTED");
  106.  
  107.     httpd_resp_set_type(req, "application/javascript");
  108.     httpd_resp_send(req, (const char *)app_js_start, app_js_end - app_js_start);
  109.  
  110.     return ESP_OK;
  111. }
  112.  
  113. static esp_err_t http_server_favicon_ico_handler(httpd_req_t *req){
  114.     ESP_LOGI(tag, "FAVICON.ICO REQUESTED");
  115.  
  116.     httpd_resp_set_type(req, "image/x-icon");
  117.     httpd_resp_send(req, (const char *)favicon_ico_start, favicon_ico_end - favicon_ico_start);
  118.  
  119.     return ESP_OK;
  120. }
  121.  
  122. // static esp_err_t http_server_adc_values_handler(httpd_req_t *req){
  123. //     char adc_val[100];
  124. //     ESP_LOGI(tag, "ADC VALUES REQUESTED");
  125.  
  126. //     int adc_value = getValue();
  127. //     sprintf(adc_val, "{\"Value\":%d}", adc_value);
  128.    
  129. //     httpd_resp_set_type(req, "application/json");
  130. //  httpd_resp_send(req, adc_val, strlen(adc_val));
  131.    
  132. //  return ESP_OK;
  133. // }
  134.  
  135. static esp_err_t http_server_get_dht_sensor_readings_json_handler(httpd_req_t *req)
  136. {
  137.     ESP_LOGI(tag, "/dhtSensor.json requested");
  138.  
  139.     char dhtSensorJSON[100];
  140.  
  141.     sprintf(dhtSensorJSON, "{\"temp\":\"%.1f\",\"humidity\":\"%.1f\"}", 1.1, 1.1);
  142.  
  143.     httpd_resp_set_type(req, "application/json");
  144.     httpd_resp_send(req, dhtSensorJSON, strlen(dhtSensorJSON));
  145.  
  146.     return ESP_OK;
  147. }
  148.  
  149. static esp_err_t http_server_ota_update_handler(httpd_req_t *req){
  150.     //recieves the bin files via the webpage and handles the update
  151.     esp_ota_handle_t OTA_handle;
  152.     char OTA_buffer[1024];
  153.  
  154.     int content_length = req->content_len;
  155.     int content_recieved = 0;
  156.     int recv_len;
  157.  
  158.     bool is_req_body_started = false;
  159.     bool flash_success = false;
  160.  
  161.     const esp_partition_t *update_partition = esp_ota_get_next_update_partition(NULL);
  162.  
  163.     do{
  164.         //read data for req.
  165.         if((recv_len = httpd_req_recv(req, OTA_buffer, MIN(content_length, sizeof(OTA_buffer)))) < 0){
  166.             if(recv_len == HTTPD_SOCK_ERR_TIMEOUT){
  167.                 ESP_LOGI(tag, "HTTP SERVER OTA UPDATE HANDLER: SOCKET TIMEOUT");
  168.                 continue;
  169.                 //retry recieveing if timeout occured
  170.             }
  171.  
  172.             ESP_LOGI(tag, "OTA UPDATE HANDLER RECIEVED OTHER OTA ERROR %d", recv_len);
  173.             return ESP_FAIL;
  174.         }
  175.  
  176.         printf("HTTP_SERVER_OTA_UPDATE_HANDLER: OTA RX: %d of %d\r", content_recieved, content_length);
  177.  
  178.         //IF THIS IS THE FIRST DATA WE ARE RECIEVEING
  179.         //IF SO, IT HAS THE INFO IN HEADER THAT WE NEED
  180.  
  181.         if(!is_req_body_started){
  182.             is_req_body_started = true;
  183.  
  184.             //GETS THE LOCATION OF BIN FILE CONTENT
  185.             //MEANS REMOVE WEB FORM DATA
  186.  
  187.             char *body_start_p = strstr(OTA_buffer, "\r\n\r\n") + 4;
  188.             int body_part_len = recv_len - (body_start_p - OTA_buffer);
  189.            
  190.             printf("HTTP_SERVER_OTA_UPDATE_HANDLER: OTA FILE SIZE: %d\r\n", content_length);
  191.  
  192.             esp_err_t err = esp_ota_begin(update_partition, OTA_SIZE_UNKNOWN, &OTA_handle);
  193.  
  194.             if(err != ESP_OK){
  195.                 printf("HTTP_SERVER_OTA_UPDATE_HANDLER: ERROR WITH OTA BEGIN, CANCELLING OTA\r\n");
  196.                 return ESP_FAIL;
  197.             } else {
  198.                 printf("HTTP_SERVER_OTA_UPDATE_HANDLER: WRITING TO PARTITION SUBTYPE %d AT OFFSET 0x%lx\r\n", update_partition->subtype, update_partition->address);
  199.             }
  200.  
  201.             //WRITE FIRST PART OF THE DATA
  202.             esp_ota_write(OTA_handle, body_start_p, body_part_len);
  203.             content_recieved += body_part_len;
  204.         } else {
  205.             //WRITE OTA DATA
  206.             esp_ota_write(OTA_handle, OTA_buffer, recv_len);
  207.             content_recieved += recv_len;
  208.         }
  209.  
  210.     } while ( recv_len > 0 && content_recieved < content_length);
  211.  
  212.     if(esp_ota_end(OTA_handle) == ESP_OK){
  213.         if(esp_ota_set_boot_partition(update_partition) == ESP_OK){
  214.             const esp_partition_t *boot_partition = esp_ota_get_boot_partition();
  215.             ESP_LOGI(tag, "HTTP_SERVER_OTA_UPDATE_HANDLER; NEXT BOOT Next BOOT PARTITION SUBTYPE %d AT OFFSET 0x%lx", boot_partition->subtype, boot_partition->address);
  216.             flash_success = true;
  217.         } else {
  218.             ESP_LOGI(tag, "HTTP_SERVER_OTA_UPDATE_HANDLER: FLASHED ERROR!!!");
  219.         }
  220.     } else {
  221.         ESP_LOGI(tag, "HTTP_SERVER_OTA_UPDATE_HANDLER: esp_ota_end ERROR!!!");
  222.     }
  223.  
  224.     //WE WONT UPDATE GLOBAL VARIABLES THROUGHOUT THE FILE
  225.     if(flash_success) http_monitor_msg(HTTP_MSG_OTA_UPDATE_PASS);
  226.     else http_monitor_msg(HTTP_MSG_OTA_UPDATE_FAIL);
  227.  
  228.     return ESP_OK;
  229. }
  230.  
  231. //OTA status handler responds with the firmware update status after the OTA update is started
  232. //and responds with the compile time/date when the page is first requested
  233. static esp_err_t http_server_ota_status_handler(httpd_req_t *req){
  234.     char OTA_JSON_BUFF[100];
  235.     ESP_LOGI(tag, "OTA STATUS REQUESTED");
  236.  
  237.     sprintf(OTA_JSON_BUFF, "\"ota_update_status\":%d,\"COMPILE_TIME\":\"%s\",\"COMPILE_DATE\":\"%s\"}", global_fw_update_status, __TIME__, __DATE__);
  238.  
  239.     httpd_resp_set_type(req, "application/json");
  240.     httpd_resp_send(req, OTA_JSON_BUFF, strlen(OTA_JSON_BUFF));
  241.  
  242.     return ESP_OK;
  243. }
  244.  
  245. static void http_server_monitor(void *pvParameters){
  246.     //used to track events of http server
  247.     http_server_queue_msg_t message;
  248.  
  249.     //infinite loop means the task will go on infinitely
  250.     for(;;){
  251.         if(xQueueReceive(http_server_monitor_queue_handle, &message, portMAX_DELAY)){
  252.             switch(message.msgID){
  253.                 case HTTP_MSG_WIFI_CONN_INIT:
  254.                     ESP_LOGI(tag, "HTTP_MSG_WIFI_CONN_INIT");
  255.                     break;
  256.                
  257.                 case HTTP_MSG_WIFI_CONN_SUCCESS:
  258.                     ESP_LOGI(tag, "HTTP_MSG_WIFI_CONN_SUCCESS");
  259.                     break;
  260.  
  261.                 case HTTP_MSG_WIFI_CONN_FAIL:
  262.                     ESP_LOGI(tag, "HTTP_MSG_WIFI_CONN_FAIL");
  263.                     break;
  264.                    
  265.                 case HTTP_MSG_OTA_UPDATE_PASS:
  266.                     ESP_LOGI(tag, "HTTP_MSG_OTA_UPDATE_PASS");
  267.                     global_fw_update_status = OTA_UPDATE_SUCCESSFUL;
  268.                     firmware_update_reset_timer();
  269.                     break;
  270.                    
  271.                 case HTTP_MSG_OTA_UPDATE_FAIL:
  272.                     ESP_LOGI(tag, "HTTP_MSG_OTA_UPDATE_FAIL");
  273.                     global_fw_update_status = OTA_UPDATE_FAIL;
  274.                     break;
  275.  
  276.                 default:
  277.                     break;
  278.             }
  279.         }
  280.     }
  281. }
  282.  
  283. static httpd_handle_t http_server_configure(void){
  284.     httpd_config_t http_config = HTTPD_DEFAULT_CONFIG();
  285.  
  286.     http_server_monitor_queue_handle = xQueueCreate(5, sizeof(http_server_queue_msg_t));
  287.  
  288.     xTaskCreatePinnedToCore(&http_server_monitor, "HTTP SERVER MONITOR", HTTP_SERVER_MONITOR_STACK_SIZE, NULL, HTTP_SERVER_MONITOR_STACK_SIZE, &task_http_server_monitor_handle, HTTP_SERVER_MONITOR_CORE_ID);
  289.  
  290.     //update vertain values
  291.     http_config.core_id = HTTP_SERVER_CORE_ID;
  292.     http_config.task_priority = HTTP_SERVER_TASK_PRIORITY;
  293.     http_config.stack_size = HTTP_SERVER_TASK_STACK_SIZE;
  294.     http_config.max_uri_handlers = 100;
  295.     http_config.recv_wait_timeout = 10;
  296.     http_config.recv_wait_timeout = 10;
  297.  
  298.     ESP_LOGI(tag, "HTTP_SERVER_CONFIGURE : STARTING SERVER ON PORT: '%d' WITH TASK PRIORITY : '%d'" , http_config.server_port, http_config.task_priority);
  299.  
  300.     if(httpd_start(&http_server_handle, &http_config) == ESP_OK){
  301.  
  302.         httpd_uri_t jquery_js = {
  303.             .uri = "/jquery-3.3.1.min.js",
  304.             .method = HTTP_GET,
  305.             .handler = http_server_jquery_handler,
  306.             .user_ctx = NULL
  307.         };
  308.         httpd_register_uri_handler(http_server_handle, &jquery_js);
  309.  
  310.         httpd_uri_t index_html = {
  311.             .uri = "/",
  312.             .method = HTTP_GET,
  313.             .handler = http_server_index_html_handler,
  314.             .user_ctx = NULL
  315.         };
  316.         httpd_register_uri_handler(http_server_handle, &index_html);
  317.  
  318.         httpd_uri_t app_css = {
  319.             .uri = "/app.css",
  320.             .method = HTTP_GET,
  321.             .handler = http_server_app_css_handler,
  322.             .user_ctx = NULL
  323.         };
  324.         httpd_register_uri_handler(http_server_handle, &app_css);
  325.  
  326.         httpd_uri_t app_js = {
  327.             .uri = "/app.js",
  328.             .method = HTTP_GET,
  329.             .handler = http_server_app_js_handler,
  330.             .user_ctx = NULL
  331.         };
  332.         httpd_register_uri_handler(http_server_handle, &app_js);
  333.  
  334.         httpd_uri_t favicon_ico = {
  335.             .uri = "/favicon.ico",
  336.             .method = HTTP_GET,
  337.             .handler = http_server_favicon_ico_handler,
  338.             .user_ctx = NULL
  339.         };
  340.         httpd_register_uri_handler(http_server_handle, &favicon_ico);
  341.  
  342.         httpd_uri_t OTA_update = {
  343.             .uri = "/OTAupdate",
  344.             .method = HTTP_POST,
  345.             .handler = http_server_ota_update_handler,
  346.             .user_ctx = NULL
  347.         };
  348.         httpd_register_uri_handler(http_server_handle, &OTA_update);
  349.  
  350.         httpd_uri_t OTA_status = {
  351.             .uri = "/OTAstatus",
  352.             .method = HTTP_POST,
  353.             .handler = http_server_ota_status_handler,
  354.             .user_ctx = NULL
  355.         };
  356.         httpd_register_uri_handler(http_server_handle, &OTA_status);
  357.  
  358.         // httpd_uri_t ADC_Values = {
  359.         //     .uri = "/adcValues.json",
  360.         //     .method = HTTP_POST,
  361.         //     .handler = http_server_adc_values_handler,
  362.         //     .user_ctx = NULL
  363.         // };
  364.         // httpd_register_uri_handler(http_server_handle, &ADC_Values);
  365.  
  366.         httpd_uri_t dht_sensor_json = {
  367.                 .uri = "/dhtSensor.json",
  368.                 .method = HTTP_GET,
  369.                 .handler = http_server_get_dht_sensor_readings_json_handler,
  370.                 .user_ctx = NULL
  371.         };
  372.         httpd_register_uri_handler(http_server_handle, &dht_sensor_json);
  373.        
  374.         ESP_LOGI(tag, "REGISTERING URI HANDLERS");
  375.  
  376.         return http_server_handle;
  377.     }
  378.  
  379.     return NULL;
  380. }
  381.  
  382. void start_http_server(void){
  383.     if(http_server_handle == NULL) http_server_handle = http_server_configure();
  384. }
  385.  
  386. void stop_http_server(void){
  387.     esp_log_level_set("HTTP", ESP_LOG_VERBOSE);
  388.  
  389.     if(http_server_handle){
  390.         httpd_stop(http_server_handle);
  391.         ESP_LOGI(tag, "HTTP_SERVER_STOP ; Stopping HTTP server");
  392.         http_server_handle = NULL;
  393.     }
  394.     if(task_http_server_monitor_handle){
  395.         vTaskDelete(task_http_server_monitor_handle);
  396.         ESP_LOGI(tag, "STOPPING HTTP SERVER");
  397.         task_http_server_monitor_handle = NULL;
  398.     }
  399. }
  400.  
  401. BaseType_t http_monitor_msg(http_server_msg_e msgID){
  402.     http_server_queue_msg_t msg;
  403.     msg.msgID = msgID;
  404.     return xQueueSend(http_server_monitor_queue_handle, &msg, portMAX_DELAY);
  405. }
  406.  
  407. void http_server_fw_update_reset_callback(void *args){
  408.     ESP_LOGI(tag, "HTTP_SERVER_FIRMWARE_UPDATE_RESET_TIMER: TIMER TIMED OUT, RESTARTING DEVICE");
  409.     esp_restart();
  410. }
in the above code, the 8th URI handle - dht_sensor_json, is where i am acing issues.

this is my app.js file, which is using jquery -
  1. /**
  2.  * Initialize functions here.
  3.  */
  4. $(document).ready(function(){
  5.     getUpdateStatus();
  6.     startDHTSensorInterval();
  7. });  
  8. ................
  9. function getDHTSensorValues()
  10. {
  11.     $.getJSON('/dhtSensor.json', function(data) {
  12.         $("#temperature_reading").text(data["temp"]);
  13.         $("#humidity_reading").text(data["humidity"]);
  14.     });
  15. }
  16.  
  17. function startDHTSensorInterval()
  18. {
  19.     setInterval(getDHTSensorValues, 5000);    
  20. }
i have only pasted the relevant code of app.js since the rest seems to be working properly

this is my HTML div for reference -
  1.    
  2. <div id="DHT22Sensor">
  3.         <h2>DHT22 Sensor Readings</h2>
  4.         <label for="temperature_reading">Temperature: </label>
  5.         <div id="temperature_reading"></div>
  6.         <label for="humidity_reading">Humidity: </label>
  7.         <div id="humidity_reading"></div>
  8.     </div>
  9.     <hr>
the problem is, when after 5 seconds the function supposed to call or values to be printed(currently containing dummy values)
does not initialize of even if it does, the handler doesn't seem to work, as the ESP_LOGI statement doest get logged or is stopping or is blocking i don't know.?

this is my terminal output -

Code: Select all

I (3016) esp_netif_lwip: DHCP server started on interface WIFI_AP_DEF with IP: 192.168.0.1
D (3016) esp_netif_lwip: check: local, if=0x3ffc6b30 fn=0x400f6268
0x400f6268: esp_netif_update_default_netif_lwip at D:/ESP_IDF/v5.1.2/esp-idf/components/esp_netif/lwip/esp_netif_lwip.c:327


D (3026) esp_netif_lwip: esp_netif_update_default_netif_lwip 0x3ffc6b30
V (3036) esp_netif_lwip: esp_netif_is_netif_up esp_netif:0x3ffc6b30
D (3036) esp_netif_lwip: call api in lwip: ret=0x0, give sem
D (3046) event: no handlers have been registered for event ESP_HTTP_SERVER_EVENT:1 posted to loop 0x3ffbc5d0
D (3056) httpd_uri: httpd_register_uri_handler: [0] exists /jquery-3.3.1.min.js
D (3066) httpd_uri: httpd_register_uri_handler: [1] installed /
D (3066) httpd_uri: httpd_find_uri_handler: [0] = /jquery-3.3.1.min.js
D (3076) httpd_uri: httpd_find_uri_handler: [1] = /
D (3076) httpd_uri: httpd_register_uri_handler: [0] exists /jquery-3.3.1.min.js
D (3086) httpd_uri: httpd_register_uri_handler: [1] exists /
D (3096) httpd_uri: httpd_register_uri_handler: [2] installed /app.css
D (3096) httpd_uri: httpd_find_uri_handler: [0] = /jquery-3.3.1.min.js
D (3106) httpd_uri: httpd_find_uri_handler: [1] = /
D (3106) httpd_uri: httpd_find_uri_handler: [2] = /app.css
D (3116) httpd_uri: httpd_register_uri_handler: [0] exists /jquery-3.3.1.min.js
D (3126) httpd_uri: httpd_register_uri_handler: [1] exists /
D (3126) httpd_uri: httpd_register_uri_handler: [2] exists /app.css
D (3136) httpd_uri: httpd_register_uri_handler: [3] installed /app.js
D (3146) httpd_uri: httpd_find_uri_handler: [0] = /jquery-3.3.1.min.js
D (3146) httpd_uri: httpd_find_uri_handler: [1] = /
D (3156) httpd_uri: httpd_find_uri_handler: [2] = /app.css
D (3156) httpd_uri: httpd_find_uri_handler: [3] = /app.js
D (3166) httpd_uri: httpd_register_uri_handler: [0] exists /jquery-3.3.1.min.js
D (3176) httpd_uri: httpd_register_uri_handler: [1] exists /
D (3176) httpd_uri: httpd_register_uri_handler: [2] exists /app.css
D (3186) httpd_uri: httpd_register_uri_handler: [3] exists /app.js
D (3186) httpd_uri: httpd_register_uri_handler: [4] installed /favicon.ico
D (3196) httpd_uri: httpd_find_uri_handler: [0] = /jquery-3.3.1.min.js
D (3206) httpd_uri: httpd_find_uri_handler: [1] = /
D (3206) httpd_uri: httpd_find_uri_handler: [2] = /app.css
D (3216) httpd_uri: httpd_find_uri_handler: [3] = /app.js
D (3216) httpd_uri: httpd_find_uri_handler: [4] = /favicon.ico
D (3226) httpd_uri: httpd_register_uri_handler: [0] exists /jquery-3.3.1.min.js
D (3236) httpd_uri: httpd_register_uri_handler: [1] exists /
D (3236) httpd_uri: httpd_register_uri_handler: [2] exists /app.css
D (3246) httpd_uri: httpd_register_uri_handler: [3] exists /app.js
D (3246) httpd_uri: httpd_register_uri_handler: [4] exists /favicon.ico
D (3256) httpd_uri: httpd_register_uri_handler: [5] installed /OTAupdate
D (3266) httpd_uri: httpd_find_uri_handler: [0] = /jquery-3.3.1.min.js
D (3266) httpd_uri: httpd_find_uri_handler: [1] = /
D (3276) httpd_uri: httpd_find_uri_handler: [2] = /app.css
D (3286) httpd_uri: httpd_find_uri_handler: [3] = /app.js
D (3286) httpd_uri: httpd_find_uri_handler: [4] = /favicon.ico
D (3296) httpd_uri: httpd_find_uri_handler: [5] = /OTAupdate
D (3296) httpd_uri: httpd_register_uri_handler: [0] exists /jquery-3.3.1.min.js
D (3306) httpd_uri: httpd_register_uri_handler: [1] exists /
D (3316) httpd_uri: httpd_register_uri_handler: [2] exists /app.css
D (3316) httpd_uri: httpd_register_uri_handler: [3] exists /app.js
D (3326) httpd_uri: httpd_register_uri_handler: [4] exists /favicon.ico
D (3326) httpd_uri: httpd_register_uri_handler: [5] exists /OTAupdate
D (3336) httpd_uri: httpd_register_uri_handler: [6] installed /OTAstatus
D (3346) httpd_uri: httpd_find_uri_handler: [0] = /jquery-3.3.1.min.js
D (3346) httpd_uri: httpd_find_uri_handler: [1] = /
D (3356) httpd_uri: httpd_find_uri_handler: [2] = /app.css
D (3366) httpd_uri: httpd_find_uri_handler: [3] = /app.js
D (3366) httpd_uri: httpd_find_uri_handler: [4] = /favicon.ico
D (3376) httpd_uri: httpd_find_uri_handler: [5] = /OTAupdate
D (3376) httpd_uri: httpd_find_uri_handler: [6] = /OTAstatus
D (3386) httpd_uri: httpd_register_uri_handler: [0] exists /jquery-3.3.1.min.js
D (3396) httpd_uri: httpd_register_uri_handler: [1] exists /
D (3396) httpd_uri: httpd_register_uri_handler: [2] exists /app.css
D (3406) httpd_uri: httpd_register_uri_handler: [3] exists /app.js
D (3406) httpd_uri: httpd_register_uri_handler: [4] exists /favicon.ico
D (3416) httpd_uri: httpd_register_uri_handler: [5] exists /OTAupdate
D (3426) httpd_uri: httpd_register_uri_handler: [6] exists /OTAstatus
D (3426) httpd_uri: httpd_register_uri_handler: [7] installed /dhtSensor.json
I (3436) http-server: REGISTERING URI HANDLERS
D (2896) httpd: httpd_thread: web server started
D (3446) httpd: httpd_server: doing select maxfd+1 = 56
after connecting -

Code: Select all

D (117286) wifi:join success bss=0x3ffb962c, ap send assoc response
D (117346) event: running post WIFI_EVENT:14 with handler 0x400d7c00 and context 0x3ffbd51c on loop 0x3ffbc5d0
0x400d7c00: wifi_app_event_handler at D:/test_projects/LEDs/main/wifi_app.c:38

I (117346) wifi-app: WIFI_EVENT_AP_STACONNECTED
D (118636) esp_netif_lwip: esp_netif_dhcps_cb esp_netif:0x3ffc6b30
I (118636) esp_netif_lwip: DHCP server assigned IP to a client, IP is: 192.168.0.2        
D (118636) esp_netif_lwip: Client's MAC: 6e:ff:73:89:3:7d
D (118646) event: running post IP_EVENT:2 with handler 0x400d7c00 and context 0x3ffbd550 on loop 0x3ffbc5d0
0x400d7c00: wifi_app_event_handler at D:/test_projects/LEDs/main/wifi_app.c:38

I (120716) wifi:<ba-add>idx:2 (ifx:1, 6e:ff:73:89:03:7d), tid:0, ssn:2, winSize:64
I (125026) wifi:<ba-add>idx:3 (ifx:1, 6e:ff:73:89:03:7d), tid:1, ssn:0, winSize:64
I (125256) wifi:<ba-add>idx:4 (ifx:1, 6e:ff:73:89:03:7d), tid:5, ssn:0, winSize:64
after opening webpage on phone -

Code: Select all

.............
D (161276) httpd_parse: cb_on_body: body begins
D (161276) httpd_parse: httpd_parse_req: parsing complete
D (161286) httpd_uri: httpd_uri: request for /OTAstatus with type 3
D (161286) httpd_uri: httpd_find_uri_handler: [0] = /jquery-3.3.1.min.js
D (161296) httpd_uri: httpd_find_uri_handler: [1] = /
D (161296) httpd_uri: httpd_find_uri_handler: [2] = /app.css
D (161306) httpd_uri: httpd_find_uri_handler: [3] = /app.js
D (161316) httpd_uri: httpd_find_uri_handler: [4] = /favicon.ico
D (161316) httpd_uri: httpd_find_uri_handler: [5] = /OTAupdate
D (161326) httpd_uri: httpd_find_uri_handler: [6] = /OTAstatus
I (161326) http-server: OTA STATUS REQUESTED
D (161336) httpd_txrx: httpd_send_all: sent = 69
D (161336) httpd_txrx: httpd_send_all: sent = 2
D (161346) event: no handlers have been registered for event ESP_HTTP_SERVER_EVENT:4 posted to loop 0x3ffbc5d0
D (161356) httpd_txrx: httpd_send_all: sent = 77
D (161356) event: no handlers have been registered for event ESP_HTTP_SERVER_EVENT:6 posted to loop 0x3ffbc5d0
D (161366) httpd_sess: httpd_sess_process: httpd_req_delete
D (161376) httpd_txrx: httpd_req_recv: remaining length = 17
D (161376) httpd_txrx: httpd_recv_with_opt: requested length = 17
D (161386) httpd_txrx: httpd_recv_with_opt: pending length = 17
D (161396) httpd_txrx: httpd_req_recv: received length = 17
D (161396) event: no handlers have been registered for event ESP_HTTP_SERVER_EVENT:5 posted to loop 0x3ffbc5d0
D (161406) httpd_parse: httpd_req_delete: purging data size : 17 bytes
D (161416) httpd_sess: httpd_sess_process: success
D (161416) httpd: httpd_server: doing select maxfd+1 = 60
D (191406) httpd: httpd_process_session: processing socket 57
D (191406) httpd_sess: httpd_sess_process: httpd_req_new
D (191406) httpd_txrx: httpd_recv_with_opt: requested length = 128
D (191406) httpd_txrx: httpd_recv_with_opt: received length = 0
D (191416) httpd_parse: read_block: connection closed
D (191416) httpd_sess: httpd_sess_delete: fd = 57
D (191426) event: no handlers have been registered for event ESP_HTTP_SERVER_EVENT:7 posted to loop 0x3ffbc5d0
D (191436) httpd_sess: httpd_sess_delete: active sockets: 2
D (191446) httpd: httpd_server: doing select maxfd+1 = 60
D (191446) httpd: httpd_process_session: processing socket 58
D (191456) httpd_sess: httpd_sess_process: httpd_req_new
D (191456) httpd_txrx: httpd_recv_with_opt: requested length = 128
D (191466) httpd_txrx: httpd_recv_with_opt: received length = 0
D (191466) httpd_parse: read_block: connection closed
D (191476) httpd_sess: httpd_sess_delete: fd = 58
D (191486) event: no handlers have been registered for event ESP_HTTP_SERVER_EVENT:7 posted to loop 0x3ffbc5d0
D (191486) httpd_sess: httpd_sess_delete: active sockets: 1
D (191496) httpd: httpd_process_session: processing socket 59
D (191506) httpd_sess: httpd_sess_process: httpd_req_new
D (191506) httpd_txrx: httpd_recv_with_opt: requested length = 128
D (191516) httpd_txrx: httpd_recv_with_opt: received length = 0
D (191516) httpd_parse: read_block: connection closed
D (191526) httpd_sess: httpd_sess_delete: fd = 59
D (191536) event: no handlers have been registered for event ESP_HTTP_SERVER_EVENT:7 posted to loop 0x3ffbc5d0
D (191536) httpd_sess: httpd_sess_delete: active sockets: 0
D (191546) httpd: httpd_server: doing select maxfd+1 = 56
till "I (161326) http-server: OTA STATUS REQUESTED" all is displayed, but after this, where the dhtSensor.json is requested should come, there is no output, not on the logging screen, not on the webpage.

I do not know where the program is getting stuck or why is it happening, please help me.

chegewara
Posts: 2364
Joined: Wed Jun 14, 2017 9:00 pm

Re: ESP32 not sending data to the webpage and ESP_LOGI not working

Postby chegewara » Fri Feb 16, 2024 5:10 am

Did you try this value to set something more reasonable, like 10?
http_config.max_uri_handlers = 100;

Kavish.26
Posts: 3
Joined: Thu Feb 15, 2024 9:12 am

Re: ESP32 not sending data to the webpage and ESP_LOGI not working

Postby Kavish.26 » Sun Feb 18, 2024 11:46 pm

chegewara wrote:
Fri Feb 16, 2024 5:10 am
Did you try this value to set something more reasonable, like 10?
http_config.max_uri_handlers = 100;
Yes sir, I have tried to keep it as low as I could, like 20, because I also had in mind to use the SNTP protocol, wifi ceds, etc. but after 7th handler - OTAStatus, it just doesn't work after it for some reason.

I am thankful for the reply, and any help, I could get.

And, I am still looking for help. I appreciate any one who tries to help me, it means a lot to me.

chegewara
Posts: 2364
Joined: Wed Jun 14, 2017 9:00 pm

Re: ESP32 not sending data to the webpage and ESP_LOGI not working

Postby chegewara » Mon Feb 19, 2024 11:22 pm

Probably not related, but who knows.
Try to fix this json string please (missing opening `{`):

Code: Select all

sprintf(OTA_JSON_BUFF, "\"ota_update_status\":%d,\"COMPILE_TIME\":\"%s\",\"COMPILE_DATE\":\"%s\"}", global_fw_update_status, __TIME__, __DATE__);

Kavish.26
Posts: 3
Joined: Thu Feb 15, 2024 9:12 am

Re: ESP32 not sending data to the webpage and ESP_LOGI not working

Postby Kavish.26 » Tue Feb 20, 2024 8:47 am

Thank you for the suggestion sir,
As instructed, I fixed the string, and I updated a few variables to match my background js file.
To my surprise, no more blocking happened, and I was able to get the readings.

Thank you for your help sir.
Thank you.

Who is online

Users browsing this forum: Bing [Bot] and 90 guests