@@ -803,8 +803,19 @@ static esp_err_t check_status_handler(httpd_req_t *req)
803
803
cJSON_AddStringToObject (root , "mqtt_tx_topic" , device_config .mqtt_tx_topic );
804
804
cJSON_AddStringToObject (root , "mqtt_rx_topic" , device_config .mqtt_rx_topic );
805
805
cJSON_AddStringToObject (root , "mqtt_status_topic" , device_config .mqtt_status_topic );
806
- const char * resp_str = cJSON_Print (root );
806
+ cJSON_AddStringToObject (root , "device_id" , device_id );
807
+
808
+ if (autopid_get_ecu_status ())
809
+ {
810
+ cJSON_AddStringToObject (root , "ecu_status" , "online" );
811
+ }
812
+ else
813
+ {
814
+ cJSON_AddStringToObject (root , "ecu_status" , "offline" );
815
+ }
816
+ const char * resp_str = cJSON_PrintUnformatted (root );
807
817
818
+ httpd_resp_set_type (req , "application/json" );
808
819
httpd_resp_send (req , resp_str , HTTPD_RESP_USE_STRLEN );
809
820
810
821
free ((void * )resp_str );
@@ -1281,27 +1292,6 @@ esp_err_t autopid_data_handler(httpd_req_t *req)
1281
1292
return ESP_OK ;
1282
1293
}
1283
1294
1284
- esp_err_t device_status_handler (httpd_req_t * req )
1285
- {
1286
- const char * status_ecu_online_rsp = "{\"wican_status\":\"online\",\"ecu_status\":\"online\"}" ;
1287
- const char * status_ecu_offline_rsp = "{\"wican_status\":\"online\",\"ecu_status\":\"offline\"}" ;
1288
-
1289
- httpd_resp_set_type (req , "application/json" );
1290
-
1291
- if (autopid_get_ecu_status ())
1292
- {
1293
- httpd_resp_send (req , status_ecu_online_rsp , strlen (status_ecu_online_rsp ));
1294
- ESP_LOGI (TAG , "Device status sent: %s" , status_ecu_online_rsp );
1295
- }
1296
- else
1297
- {
1298
- httpd_resp_send (req , status_ecu_offline_rsp , strlen (status_ecu_offline_rsp ));
1299
- ESP_LOGI (TAG , "Device status sent: %s" , status_ecu_offline_rsp );
1300
- }
1301
-
1302
- return ESP_OK ;
1303
- }
1304
-
1305
1295
static const httpd_uri_t index_uri = {
1306
1296
.uri = "/" ,
1307
1297
.method = HTTP_GET ,
@@ -1416,12 +1406,6 @@ static const httpd_uri_t autopid_data = {
1416
1406
.handler = autopid_data_handler ,
1417
1407
.user_ctx = & server_data // Pass server data as context
1418
1408
};
1419
- static const httpd_uri_t device_status_data = {
1420
- .uri = "/status" , // Match all URIs of type /upload/path/to/file
1421
- .method = HTTP_GET ,
1422
- .handler = device_status_handler ,
1423
- .user_ctx = & server_data // Pass server data as context
1424
- };
1425
1409
1426
1410
static void config_server_load_cfg (char * cfg )
1427
1411
{
@@ -2029,7 +2013,7 @@ static httpd_handle_t config_server_init(void)
2029
2013
);
2030
2014
2031
2015
// Start the httpd server
2032
- config .max_uri_handlers = 16 ;
2016
+ config .max_uri_handlers = 15 ;
2033
2017
ESP_LOGI (TAG , "Starting server on port: '%d'" , config .server_port );
2034
2018
if (httpd_start (& server , & config ) == ESP_OK )
2035
2019
{
@@ -2050,7 +2034,6 @@ static httpd_handle_t config_server_init(void)
2050
2034
httpd_register_uri_handler (server , & load_pid_auto_conf_uri );
2051
2035
httpd_register_uri_handler (server , & upload_car_data );
2052
2036
httpd_register_uri_handler (server , & autopid_data );
2053
- httpd_register_uri_handler (server , & device_status_data );
2054
2037
#if CONFIG_EXAMPLE_BASIC_AUTH
2055
2038
httpd_register_basic_auth (server );
2056
2039
#endif
0 commit comments