Skip to content

Commit 5f3f45b

Browse files
committed
Merge branch 'idf-v5.3'
2 parents 254b88c + 4931e2f commit 5f3f45b

10 files changed

+762
-290
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,5 @@ Mkfile.old
5454
dkms.conf
5555

5656
#Vehicle Profiles
57-
.vehicle_profiles/node_modules/
57+
.vehicle_profiles/node_modules/
58+
.vscode/

.vscode/c_cpp_properties.json

-17
This file was deleted.

.vscode/settings.json

-24
This file was deleted.

CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ cmake_minimum_required(VERSION 3.5)
44

55

66
set(PROJECT_PREF "wican-fw")
7-
set(PROJECT_VER "v331_hv300")
7+
set(PROJECT_VER "v332_hv300")
88
#set(PROJECT_VER "v155_hv210")
99

1010
# set(PROJECT_PREF "wican-fw-usb")
11-
# set(PROJECT_VER "v331_hv150")
11+
# set(PROJECT_VER "v332_hv150")
1212

1313
set(PROJECT_VERU ${PROJECT_VER})
1414
set(PROJECT_BIN "${PROJECT_PREF}_${PROJECT_VERU}")

main/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ idf_component_register(
88
PRIV_INCLUDE_DIRS # optional, add here private include directories
99
REQUIRES "${requires}" # optional, list the public requirements (component names)
1010
PRIV_REQUIRES # optional, list the private requirements
11-
EMBED_FILES "homepage.html" "../vehicle_profiles.json"
11+
EMBED_FILES "homepage.html"
1212
)

main/autopid.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "cJSON.h"
3636
#include "config_server.h"
3737
#include "autopid.h"
38+
#include <math.h>
3839

3940
#define TAG __func__
4041

@@ -511,7 +512,7 @@ static void autopid_task(void *pvParameters)
511512
sprintf(hex_rsponse + (j * 2), "%02X", response.data[j]);
512513
}
513514
hex_rsponse[response.length * 2] = '\0';
514-
515+
result = round(result * 100.0) / 100.0;
515516
// Add the name and result to the JSON object
516517
cJSON_AddNumberToObject(rsp_json, pid_req[i].name, result);
517518
cJSON_AddStringToObject(rsp_json, "raw", hex_rsponse);
@@ -610,6 +611,7 @@ static void autopid_task(void *pvParameters)
610611
}
611612
hex_rsponse[response.length * 2] = '\0';
612613

614+
result = round(result * 100.0) / 100.0;
613615
// Add the name and result to the JSON object
614616
cJSON_AddNumberToObject(rsp_json, car.pids[i].parameters[j].name, result);
615617
ESP_LOGI(TAG, "Expression result, Name: %s: %lf", car.pids[i].parameters[j].name, result);

main/config_server.c

+13-30
Original file line numberDiff line numberDiff line change
@@ -803,8 +803,19 @@ static esp_err_t check_status_handler(httpd_req_t *req)
803803
cJSON_AddStringToObject(root, "mqtt_tx_topic", device_config.mqtt_tx_topic);
804804
cJSON_AddStringToObject(root, "mqtt_rx_topic", device_config.mqtt_rx_topic);
805805
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);
807817

818+
httpd_resp_set_type(req, "application/json");
808819
httpd_resp_send(req, resp_str, HTTPD_RESP_USE_STRLEN);
809820

810821
free((void *)resp_str);
@@ -1281,27 +1292,6 @@ esp_err_t autopid_data_handler(httpd_req_t *req)
12811292
return ESP_OK;
12821293
}
12831294

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-
13051295
static const httpd_uri_t index_uri = {
13061296
.uri = "/",
13071297
.method = HTTP_GET,
@@ -1416,12 +1406,6 @@ static const httpd_uri_t autopid_data = {
14161406
.handler = autopid_data_handler,
14171407
.user_ctx = &server_data // Pass server data as context
14181408
};
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-
};
14251409

14261410
static void config_server_load_cfg(char *cfg)
14271411
{
@@ -2029,7 +2013,7 @@ static httpd_handle_t config_server_init(void)
20292013
);
20302014

20312015
// Start the httpd server
2032-
config.max_uri_handlers = 16;
2016+
config.max_uri_handlers = 15;
20332017
ESP_LOGI(TAG, "Starting server on port: '%d'", config.server_port);
20342018
if (httpd_start(&server, &config) == ESP_OK)
20352019
{
@@ -2050,7 +2034,6 @@ static httpd_handle_t config_server_init(void)
20502034
httpd_register_uri_handler(server, &load_pid_auto_conf_uri);
20512035
httpd_register_uri_handler(server, &upload_car_data);
20522036
httpd_register_uri_handler(server, &autopid_data);
2053-
httpd_register_uri_handler(server, &device_status_data);
20542037
#if CONFIG_EXAMPLE_BASIC_AUTH
20552038
httpd_register_basic_auth(server);
20562039
#endif

0 commit comments

Comments
 (0)