From 7df8b330cd62560088af01110d1ba8a779bcc783 Mon Sep 17 00:00:00 2001 From: Krishna Kumar Sah Date: Tue, 23 Apr 2024 14:55:56 +0545 Subject: [PATCH 01/36] added task handle for registration task, used to prevent multiple creation of task --- .../ezlopi_cloud_registration.c | 24 +++--- ezlopi-core/ezlopi-core-nvs/ezlopi_core_nvs.c | 73 ++++++++++--------- .../ezlopi-service-uart/ezlopi_service_uart.c | 1 + .../ezlopi_service_webprov.c | 11 +-- 4 files changed, 61 insertions(+), 48 deletions(-) diff --git a/ezlopi-cloud/ezlopi-cloud-registration/ezlopi_cloud_registration.c b/ezlopi-cloud/ezlopi-cloud-registration/ezlopi_cloud_registration.c index a4eff9b48..684979413 100644 --- a/ezlopi-cloud/ezlopi-cloud-registration/ezlopi_cloud_registration.c +++ b/ezlopi-cloud/ezlopi-cloud-registration/ezlopi_cloud_registration.c @@ -17,27 +17,32 @@ #include "ezlopi_service_webprov.h" -static void registration_process(void *pv); +static TaskHandle_t __registration_task_handle = NULL; + +static void registration_process(void* pv); void registration_init(void) { - xTaskCreate(registration_process, "registration_process", 2 * 2048, NULL, 2, NULL); + if (NULL == __registration_task_handle) + { + xTaskCreate(registration_process, "registration_process", 2 * 2048, NULL, 2, &__registration_task_handle); + } } -void register_repeat(cJSON *cj_request, cJSON *cj_response) +void register_repeat(cJSON* cj_request, cJSON* cj_response) { registration_init(); } -void registered(cJSON *cj_request, cJSON *cj_response) +void registered(cJSON* cj_request, cJSON* cj_response) { TRACE_S("Device registration successful."); ezlopi_event_group_set_event(EZLOPI_EVENT_NMA_REG); } -static void registration_process(void *pv) +static void registration_process(void* pv) { - cJSON *cj_register = cJSON_CreateObject(); + cJSON* cj_register = cJSON_CreateObject(); if (cj_register) { char mac_str[18]; @@ -45,12 +50,12 @@ static void registration_process(void *pv) esp_read_mac(mac_addr, ESP_MAC_WIFI_STA); snprintf(mac_str, sizeof(mac_str), "%02X:%02X:%02X:%02X:%02X:%02X", - mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]); + mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]); cJSON_AddStringToObject(cj_register, "id", "__ID__"); cJSON_AddStringToObject(cj_register, ezlopi_method_str, "register"); - cJSON *cj_params = cJSON_AddObjectToObject(cj_register, ezlopi_params_str); + cJSON* cj_params = cJSON_AddObjectToObject(cj_register, ezlopi_params_str); if (cj_params) { @@ -70,7 +75,7 @@ static void registration_process(void *pv) while (ezlopi_event_group_wait_for_event(EZLOPI_EVENT_NMA_REG, 5000, false) <= 0) { // CJSON_TRACE("----------------- broadcasting - cj_register", cj_register); - cJSON *cj_register_dup = cJSON_CreateObjectReference(cj_register->child); + cJSON* cj_register_dup = cJSON_CreateObjectReference(cj_register->child); if (cj_register_dup) { if (!ezlopi_core_ezlopi_broadcast_add_to_queue(cj_register_dup)) @@ -83,5 +88,6 @@ static void registration_process(void *pv) cJSON_Delete(cj_register); } + __registration_task_handle = NULL; vTaskDelete(NULL); } diff --git a/ezlopi-core/ezlopi-core-nvs/ezlopi_core_nvs.c b/ezlopi-core/ezlopi-core-nvs/ezlopi_core_nvs.c index e228ffbd8..3282efa2a 100644 --- a/ezlopi-core/ezlopi-core-nvs/ezlopi_core_nvs.c +++ b/ezlopi-core/ezlopi-core-nvs/ezlopi_core_nvs.c @@ -43,7 +43,7 @@ int ezlopi_nvs_init(void) if (ESP_ERR_NVS_NO_FREE_PAGES == err || ESP_ERR_NVS_NEW_VERSION_FOUND == err) { - TRACE_D("NVS Init Failed once!, Error: %s", esp_err_to_name(err)); + TRACE_D("```nvs_flash_init``` Failed once!, Error: %s", esp_err_to_name(err)); ESP_ERROR_CHECK(nvs_flash_erase()); err = nvs_flash_init(); } @@ -51,13 +51,13 @@ int ezlopi_nvs_init(void) err = nvs_open(storage_name, NVS_READWRITE, &ezlopi_nvs_handle); if (ESP_OK != err) { - TRACE_E("NVS Open Error!"); + TRACE_E("```nvs_open``` Error!"); // vTaskDelay(2000 / portTICK_RATE_MS); } else { ret = 1; - TRACE_D("NVS Open success"); + TRACE_D("```nvs_open``` success"); } } else @@ -75,11 +75,10 @@ uint32_t ezlopi_nvs_config_info_update_time_get(void) { esp_err_t err = nvs_get_u32(ezlopi_nvs_handle, config_info_update_time_name, &ret); TRACE_S("config-update-time-get: %d", ret); - TRACE_D("Error nvs_get_blob: %s", esp_err_to_name(err)); if (ESP_OK != err) { ret = 0; - TRACE_W("nvs_set_u32 - error: %s", esp_err_to_name(err)); + TRACE_W("(nvs_get_u32)-%s:: error: %s", config_info_update_time_name, esp_err_to_name(err)); } } return ret; @@ -88,17 +87,19 @@ uint32_t ezlopi_nvs_config_info_update_time_get(void) uint32_t ezlopi_nvs_config_info_version_number_get(void) { uint32_t ret = 0; + if (ezlopi_nvs_init()) { esp_err_t err = nvs_get_u32(ezlopi_nvs_handle, config_info_version_number, &ret); TRACE_S("config-version-number-get: %d", ret); - TRACE_D("Error nvs_get_blob: %s", esp_err_to_name(err)); + if (ESP_OK != err) { ret = 0; - TRACE_W("nvs_set_u32 - error: %s", esp_err_to_name(err)); + TRACE_W("(nvs_get_u32)-%s:: error: %s", config_info_version_number, esp_err_to_name(err)); } } + return ret; } @@ -108,7 +109,7 @@ void ezlopi_nvs_config_info_update_time_set(uint32_t value) { nvs_erase_key(ezlopi_nvs_handle, config_info_update_time_name); esp_err_t err = nvs_set_u32(ezlopi_nvs_handle, config_info_update_time_name, value); - TRACE_W("nvs_set_u32 - error: %s", esp_err_to_name(err)); + TRACE_W("(nvs_set_u32)-%s:: error: %s", config_info_update_time_name, esp_err_to_name(err)); } } @@ -117,7 +118,7 @@ void ezlopi_nvs_config_info_version_number_set(uint32_t value) if (ezlopi_nvs_init()) { esp_err_t err = nvs_set_u32(ezlopi_nvs_handle, config_info_version_number, value); - TRACE_W("nvs_set_u32 - error: %s", esp_err_to_name(err)); + TRACE_W("(nvs_set_u32)-%s:: - error: %s", config_info_version_number, esp_err_to_name(err)); } } @@ -212,7 +213,7 @@ int ezlopi_nvs_read_ble_passkey(uint32_t* passkey) { esp_err_t err = ESP_OK; err = nvs_get_u32(ezlopi_nvs_handle, passkey_nvs_name, passkey); - TRACE_W("nvs_get_u32 - error: %s", esp_err_to_name(err)); + TRACE_W("(nvs_get_u32)-%s:: error: %s", passkey_nvs_name, esp_err_to_name(err)); if (ESP_OK == err) { @@ -238,7 +239,7 @@ int ezlopi_nvs_write_ble_passkey(uint32_t passkey) { esp_err_t err = ESP_OK; err = nvs_set_u32(ezlopi_nvs_handle, passkey_nvs_name, passkey); - TRACE_W("nvs_set_u32 - error: %s", esp_err_to_name(err)); + TRACE_W("(nvs_set_u32)-passkey_nvs_name:: error: %s", esp_err_to_name(err)); if (ESP_OK == err) { @@ -264,7 +265,8 @@ int ezlopi_nvs_read_wifi(char* wifi_info, uint32_t len) if ((ESP_OK == err) && (len >= required_size)) { err = nvs_get_blob(ezlopi_nvs_handle, wifi_info_nvs_name, wifi_info, &required_size); - TRACE_W("Error nvs_get_blob: %s", esp_err_to_name(err)); + TRACE_W("(nvs_get_blob)-%s:: Error: %s", wifi_info_nvs_name, esp_err_to_name(err)); + if (ESP_OK == err) { ret = 1; @@ -425,23 +427,24 @@ uint8_t ezlopi_nvs_write_int32(int32_t i, const char* key_name) esp_err_t err = nvs_set_i32(ezlopi_nvs_handle, key_name, i); if (ESP_OK != err) { - TRACE_W("nvs_set_i32 - error: %s", esp_err_to_name(err)); + TRACE_W("(nvs_set_i32)-%s:: error: %s", key_name, esp_err_to_name(err)); } else { err = nvs_commit(ezlopi_nvs_handle); if (ESP_OK != err) { - TRACE_E("NVS commit error - error: %s", esp_err_to_name(err)); + TRACE_E("(nvs_commit)-%s:: error: %s", key_name, esp_err_to_name(err)); ret = 0; } else { - TRACE_D("Commit successful."); + TRACE_D("(nvs_commit)-%s successful.", key_name); ret = 1; } } } + return ret; } @@ -457,7 +460,7 @@ uint8_t ezlopi_nvs_read_int32(int32_t* i, const char* key_name) } else { - TRACE_W("nvs_get_i32 - error: %s", esp_err_to_name(err)); + TRACE_W("(nvs_get_i32)-%s:: error: %s", key_name, esp_err_to_name(err)); } } return ret; @@ -471,19 +474,19 @@ uint8_t ezlopi_nvs_write_uint32(uint32_t i, const char* key_name) esp_err_t err = nvs_set_u32(ezlopi_nvs_handle, key_name, (uint32_t)i); if (ESP_OK != err) { - TRACE_W("nvs_set_i32 - error: %s", esp_err_to_name(err)); + TRACE_W("(nvs_set_i32)-%s:: error: %s", key_name, esp_err_to_name(err)); } else { err = nvs_commit(ezlopi_nvs_handle); if (ESP_OK != err) { - TRACE_E("NVS commit error - error: %s", esp_err_to_name(err)); + TRACE_W("(nvs_commit)-%s:: error: %s", key_name, esp_err_to_name(err)); ret = 0; } else { - TRACE_D("Commit successful."); + TRACE_D("(nvs_commit)-%s:: Success.", key_name); ret = 1; } } @@ -499,12 +502,12 @@ uint8_t ezlopi_nvs_read_uint32(uint32_t* i, const char* key_name) esp_err_t err = nvs_get_u32(ezlopi_nvs_handle, key_name, (uint32_t*)i); if (ESP_OK == err) { - TRACE_D("NVS read success"); + TRACE_D("(nvs_get_i32)-%s - NVS read success", key_name); ret = 1; } else { - TRACE_E("nvs_get_i32 - error: %s", esp_err_to_name(err)); + TRACE_E("(nvs_get_i32)-%s - error: %s", key_name, esp_err_to_name(err)); } } return ret; @@ -521,19 +524,19 @@ uint8_t ezlopi_nvs_write_float32(float f, const char* key_name) esp_err_t err = nvs_set_u32(ezlopi_nvs_handle, key_name, value); if (err != ESP_OK) { - TRACE_W("nvs_set_u32 - error: %s", esp_err_to_name(err)); + TRACE_W("(nvs_set_u32)-%s:: error: %s", key_name, esp_err_to_name(err)); } else { err = nvs_commit(ezlopi_nvs_handle); if (ESP_OK != err) { - TRACE_E("NVS commit error - error: %s", esp_err_to_name(err)); + TRACE_W("(nvs_commit)-%s:: error: %s", key_name, esp_err_to_name(err)); ret = 0; } else { - TRACE_D("Commit successful."); + TRACE_D("(nvs_commit)-%s:: Success", key_name); ret = 1; } } @@ -556,7 +559,7 @@ uint8_t ezlopi_nvs_read_float32(float* f, const char* key_name) } else { - TRACE_W("nvs_get_u32 - error: %s", esp_err_to_name(err)); + TRACE_W("(nvs_get_u32)-%s:: error: %s", key_name, esp_err_to_name(err)); } } return ret; @@ -582,19 +585,19 @@ uint8_t ezlopi_nvs_write_bool(bool b, const char* key_name) if (ESP_OK != err) { - TRACE_W("nvs_set_u8 - error: %s", esp_err_to_name(err)); + TRACE_W("(nvs_set_u8)-%s:: error: %s", key_name, esp_err_to_name(err)); } else { err = nvs_commit(ezlopi_nvs_handle); if (ESP_OK != err) { - TRACE_E("NVS commit error - error: %s", esp_err_to_name(err)); + TRACE_W("(nvs_commit)-%s:: error: %s", key_name, esp_err_to_name(err)); ret = 0; } else { - TRACE_D("Commit successful."); + TRACE_W("(nvs_commit)-%s:: Success.", key_name); ret = 1; } } @@ -623,7 +626,7 @@ uint8_t ezlopi_nvs_read_bool(bool* b, const char* key_name) } else { - TRACE_W("nvs_get_u8 - error: %s", esp_err_to_name(err)); + TRACE_W("(nvs_get_u8)-%s:: error: %s", key_name, esp_err_to_name(err)); } } return ret; @@ -644,16 +647,16 @@ int ezlopi_nvs_write_str(const char* data, uint32_t len, const char* nvs_name) if (ESP_OK == err) { ret = 1; - TRACE_D("%s commit success.", nvs_name); + TRACE_D("(nvs_commit)-%s:: Success.", nvs_name); } else { - TRACE_E("%s commit error: %s", nvs_name, esp_err_to_name(err)); + TRACE_E("(nvs_commit)-%s:: error: %s", nvs_name, esp_err_to_name(err)); } } else { - TRACE_E("%s write error: %s", nvs_name, esp_err_to_name(err)); + TRACE_W("(nvs_set_str)-%s:: error: %s", nvs_name, esp_err_to_name(err)); } } } @@ -684,11 +687,12 @@ char* ezlopi_nvs_read_str(const char* nvs_name) if (ESP_OK == err) { + TRACE_D("(nvs_get_str)-%s:: Success.", nvs_name); // TRACE_D("%s read success. \r\nData[%d]: \r\n%s", nvs_name, buf_len_needed, return_str); } else { - TRACE_E("%s read error: %s", nvs_name, esp_err_to_name(err)); + TRACE_E("(nvs_get_str)-%s:: error: %s", nvs_name, esp_err_to_name(err)); free(return_str); return_str = NULL; } @@ -722,7 +726,8 @@ void ezlopi_nvs_delete_stored_data_by_name(char* nvs_name) esp_err_t err = ESP_OK; if (ESP_OK != (err = nvs_erase_key(ezlopi_nvs_handle, nvs_name))) { - TRACE_E("Erasing nvs-key '%s' failed!, error: %s", nvs_name, esp_err_to_name(err)); + + TRACE_E("(nvs_erase_key)-%s:: error: %s", nvs_name, esp_err_to_name(err)); } } } diff --git a/ezlopi-services/ezlopi-service-uart/ezlopi_service_uart.c b/ezlopi-services/ezlopi-service-uart/ezlopi_service_uart.c index b6ef550b6..1f13c1a90 100644 --- a/ezlopi-services/ezlopi-service-uart/ezlopi_service_uart.c +++ b/ezlopi-services/ezlopi-service-uart/ezlopi_service_uart.c @@ -702,6 +702,7 @@ static void ezlopi_service_uart_get_info() get_ezlopi_device_newtwork_info(cj_info); cJSON_AddItemToObject(cj_get_info, ezlopi_info_str, cj_info); + char* serial_data_json_string = cJSON_Print(cj_get_info); if (serial_data_json_string) { diff --git a/ezlopi-services/ezlopi-service-webprov/ezlopi_service_webprov.c b/ezlopi-services/ezlopi-service-webprov/ezlopi_service_webprov.c index 607d7605f..40df46d07 100644 --- a/ezlopi-services/ezlopi-service-webprov/ezlopi_service_webprov.c +++ b/ezlopi-services/ezlopi-service-webprov/ezlopi_service_webprov.c @@ -145,6 +145,7 @@ static void __fetch_wss_endpoint(void* pv) free(ca_certificate); free(ssl_shared_key); free(ssl_private_key); + vTaskDelay(2000 / portTICK_RATE_MS); vTaskDelay(2000 / portTICK_RATE_MS); } @@ -250,8 +251,7 @@ static void __config_check(void* pv) if (NULL != provisioning_server) { int prov_url_len = strlen(provisioning_server); - - if (prov_url_len >= 5 && strcmp(&provisioning_server[prov_url_len - 5], ".com/") == 0) + if ((prov_url_len >= 5) && (0 == strcmp(&provisioning_server[prov_url_len - 5], ".com/"))) { provisioning_server[prov_url_len - 1] = '\0'; // Remove trailing "/" } @@ -327,9 +327,10 @@ static void __config_check(void* pv) vTaskDelay(50000 / portTICK_RATE_MS); } - free(ca_certificate); - free(provision_token); - free(provisioning_server); + ezlopi_factory_info_v3_free(ca_certificate); + ezlopi_factory_info_v3_free(provision_token); + ezlopi_factory_info_v3_free(provisioning_server); + vTaskDelete(NULL); } From 9e47998f3c3ee3d67cccf977fab59d6f2024ba5b Mon Sep 17 00:00:00 2001 From: Krishna Kumar Sah Date: Tue, 23 Apr 2024 15:25:47 +0545 Subject: [PATCH 02/36] added low-heap-timeout in main __blinky task, reboots controller if heap remains below 10kB for over 15 seconds --- .../ezlopi_cloud_registration.c | 3 ++- .../ezlopi-core-api/ezlopi_core_api_macros.h | 2 +- ezlopi-core/ezlopi-core-nvs/ezlopi_core_nvs.c | 6 ++--- ezlopi-main/ezlopi_main.c | 25 +++++++++++++------ 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/ezlopi-cloud/ezlopi-cloud-registration/ezlopi_cloud_registration.c b/ezlopi-cloud/ezlopi-cloud-registration/ezlopi_cloud_registration.c index 684979413..38cdad75c 100644 --- a/ezlopi-cloud/ezlopi-cloud-registration/ezlopi_cloud_registration.c +++ b/ezlopi-cloud/ezlopi-cloud-registration/ezlopi_cloud_registration.c @@ -74,12 +74,13 @@ static void registration_process(void* pv) while (ezlopi_event_group_wait_for_event(EZLOPI_EVENT_NMA_REG, 5000, false) <= 0) { - // CJSON_TRACE("----------------- broadcasting - cj_register", cj_register); cJSON* cj_register_dup = cJSON_CreateObjectReference(cj_register->child); if (cj_register_dup) { + CJSON_TRACE("----------------- sent to broadcast - cj_register_dup", cj_register_dup); if (!ezlopi_core_ezlopi_broadcast_add_to_queue(cj_register_dup)) { + TRACE_E("Error adding to broadcast queue!"); cJSON_Delete(cj_register_dup); } } diff --git a/ezlopi-core/ezlopi-core-api/ezlopi_core_api_macros.h b/ezlopi-core/ezlopi-core-api/ezlopi_core_api_macros.h index 3f220ea78..8ff3a505e 100644 --- a/ezlopi-core/ezlopi-core-api/ezlopi_core_api_macros.h +++ b/ezlopi-core/ezlopi-core-api/ezlopi_core_api_macros.h @@ -68,7 +68,7 @@ CLOUD_METHOD("hub.scenes.block.data.list", scenes_block_data_list, NULL) CLOUD_METHOD("hub.scenes.enabled.set", scenes_enable_set, scene_changed) CLOUD_METHOD("hub.scenes.notification.add", scenes_notification_add, scene_changed) CLOUD_METHOD("hub.scenes.notification.remove", scenes_notification_remove, scene_changed) -// CLOUD_METHOD("hub.scenes.status.get", scenes_status_get, NULL) // Incomplete +CLOUD_METHOD("hub.scenes.status.get", scenes_status_get, NULL) // Incomplete #endif CLOUD_METHOD("hub.room.list", room_list, NULL) diff --git a/ezlopi-core/ezlopi-core-nvs/ezlopi_core_nvs.c b/ezlopi-core/ezlopi-core-nvs/ezlopi_core_nvs.c index 3282efa2a..7954f1e29 100644 --- a/ezlopi-core/ezlopi-core-nvs/ezlopi_core_nvs.c +++ b/ezlopi-core/ezlopi-core-nvs/ezlopi_core_nvs.c @@ -474,7 +474,7 @@ uint8_t ezlopi_nvs_write_uint32(uint32_t i, const char* key_name) esp_err_t err = nvs_set_u32(ezlopi_nvs_handle, key_name, (uint32_t)i); if (ESP_OK != err) { - TRACE_W("(nvs_set_i32)-%s:: error: %s", key_name, esp_err_to_name(err)); + TRACE_W("(nvs_set_u32)-%s:: error: %s", key_name, esp_err_to_name(err)); } else { @@ -502,12 +502,12 @@ uint8_t ezlopi_nvs_read_uint32(uint32_t* i, const char* key_name) esp_err_t err = nvs_get_u32(ezlopi_nvs_handle, key_name, (uint32_t*)i); if (ESP_OK == err) { - TRACE_D("(nvs_get_i32)-%s - NVS read success", key_name); + TRACE_D("(nvs_get_u32)-%s - NVS read success", key_name); ret = 1; } else { - TRACE_E("(nvs_get_i32)-%s - error: %s", key_name, esp_err_to_name(err)); + TRACE_E("(nvs_get_u32)-%s - error: %s", key_name, esp_err_to_name(err)); } } return ret; diff --git a/ezlopi-main/ezlopi_main.c b/ezlopi-main/ezlopi_main.c index 3f9a76c22..6a992e930 100644 --- a/ezlopi-main/ezlopi_main.c +++ b/ezlopi-main/ezlopi_main.c @@ -83,19 +83,28 @@ static void __blinky(void* pv) { uint32_t count = 0; + uint32_t low_heap_start_time = xTaskGetTickCount(); while (1) { - if (count++ > 1000) - { - count = 0; + uint32_t free_heap_kb = esp_get_free_heap_size() / 1024.0; + + trace_wb("----------------------------------------------"); + trace_wb("esp_get_free_heap_size - %.02f kB", free_heap_kb); + trace_wb("esp_get_minimum_free_heap_size: %.02f kB", esp_get_minimum_free_heap_size() / 1024.0); + trace_wb("----------------------------------------------"); - trace_wb("----------------------------------------------"); - trace_wb("esp_get_free_heap_size - %f kB", esp_get_free_heap_size() / 1024.0); - trace_wb("esp_get_minimum_free_heap_size: %f kB", esp_get_minimum_free_heap_size() / 1024.0); - trace_wb("----------------------------------------------"); + if (free_heap_kb >= 10) + { + low_heap_start_time = xTaskGetTickCount(); + } + else if ((xTaskGetTickCount() - low_heap_start_time) > (15000 / portTICK_PERIOD_MS)) + { + TRACE_E("ERROR: low heap time-out detected!"); + TRACE_W("Rebooting....."); + esp_restart(); } - vTaskDelay(5 / portTICK_PERIOD_MS); + vTaskDelay(5000 / portTICK_PERIOD_MS); } } From d1546b162120e4b190614e0ee4bfe9e7386d2f6c Mon Sep 17 00:00:00 2001 From: Krishna Kumar Sah Date: Wed, 24 Apr 2024 22:43:05 +0545 Subject: [PATCH 03/36] debugging memory-leak using heap-utility --- .editorconfig | 2 +- ezlopi-components/Bosch_BSEC2/bsec2.c | 1 + ezlopi-components/cjext/cjext.c | 78 ++++++-- ezlopi-components/cjext/cjext.h | 9 + .../ezlopi-core-ble/ezlopi_core_ble_buffer.c | 1 + .../ezlopi-core-ble/ezlopi_core_ble_gap.c | 1 + .../ezlopi-core-ble/ezlopi_core_ble_profile.c | 1 + .../ezlopi-core-buffer/ezlopi_core_buffer.c | 7 +- .../ezlopi-core-devices/ezlopi_core_devices.c | 51 +---- .../ezlopi_core_ezlopi_broadcast.c | 5 + .../ezlopi_core_factory_info.c | 37 ++-- .../ezlopi-core-http/ezlopi_core_http.c | 1 + .../ezlopi-core-mdns/ezlopi_core_mdns.c | 1 + .../ezlopi_core_modes_cjson.c | 1 + ezlopi-core/ezlopi-core-nvs/ezlopi_core_nvs.c | 2 +- ezlopi-core/ezlopi-core-ota/ezlopi_core_ota.c | 1 + .../ezlopi-core-room/ezlopi_core_room.c | 1 + .../ezlopi_core_scenes_expressions.c | 1 + .../ezlopi_core_scenes_populate.c | 1 + .../ezlopi_core_scenes_scripts.c | 1 + .../ezlopi_core_scenes_then_methods.c | 1 + ...opi_core_scenes_then_methods_helper_func.c | 1 + .../ezlopi_core_scenes_v2.c | 1 + ...ore_scenes_when_methods_helper_functions.c | 1 + .../ezlopi-core-timer/ezlopi_core_timer.c | 3 +- .../ezlopi_core_websocket_client.c | 1 + .../ezlopi-core-wifi/ezlopi_core_wifi.c | 1 + ezlopi-hal/ezlopi-hal-adc/ezlopi_hal_adc.c | 1 + ezlopi-hal/ezlopi-hal-pwm/ezlopi_hal_pwm.c | 2 + ezlopi-hal/ezlopi-hal-uart/ezlopi_hal_uart.c | 1 + ezlopi-main/CMakeLists.txt | 1 + ezlopi-main/Kconfig.projbuild | 6 + ezlopi-main/ezlopi_main.c | 28 ++- .../device_0001_digitalOut_generic.c | 1 + .../device_0009_other_RMT_SK6812.c | 3 + .../device_0022_PWM_dimmable_lamp.c | 1 + .../device_0036_PWM_servo_MG996R.c | 1 + .../device_0038_other_RGB.c | 5 +- .../sensor_0005_I2C_MPU6050.c | 1 + .../sensor_0006_I2C_ADXL345.c | 1 + .../sensor_0007_I2C_GY271.c | 1 + .../sensor_0008_I2C_LTR303ALS.c | 1 + .../sensor_0010_I2C_BME680.c | 1 + .../sensor_0012_I2C_BME280.c | 1 + .../sensor_0015_oneWire_DHT11.c | 1 + .../sensor_0016_oneWire_DHT22.c | 1 + .../sensor_0017_ADC_potentiometer.c | 3 + .../sensor_0018_other_internal_hall_effect.c | 1 + .../sensor_0020_other_2axis_joystick.c | 1 + .../sensor_0021_UART_MB1013.c | 1 + .../sensor_0024_other_HCSR04.c | 1 + .../sensor_0028_other_GY61.c | 1 + .../sensor-0029-I2C-GXHTC3/gxhtc3.c | 1 + .../sensor_0029_I2C_GXHTC3.c | 1 + .../sensor_0030_oneWire_DS18B20.c | 1 + .../sensor_0031_other_JSNSR04T.c | 1 + .../sensor_0032_ADC_soilMoisture.c | 1 + .../sensor_0033_ADC_turbidity.c | 1 + .../pms_dev_items_prepare.c | 1 + .../sensor_0040_other_TCS230.c | 1 + .../sensor_0041_ADC_FC28_soilMoisture.c | 1 + .../sensor_0042_ADC_shunt_voltmeter.c | 1 + .../sensor_0043_ADC_GYML8511_UV_intensity.c | 1 + .../sensor_0044_I2C_TSL256_luminosity.c | 1 + .../sensor_0046_ADC_ACS712_05B_currentmeter.c | 2 + .../sensor_0047_other_HX711_loadcell.c | 2 + .../sensor_0048_other_MQ4_CH4_detector.c | 2 + .../sensor_0049_other_MQ2_LPG_detector.c | 1 + .../sensor_0050_other_MQ3_alcohol_detector.c | 2 + .../sensor_0051_other_MQ8_H2_detector.c | 2 + .../sensor_0052_other_MQ135_NH3_detector.c | 2 + .../sensor-0053-UART-GYGPS6MV2/gyGPS6MV2.c | 1 + .../sensor_0053_UART_GYGPS6MV2.c | 1 + .../sensor_0054_PWM_YFS201_flowmeter.c | 3 + .../sensor_0055_ADC_FlexResistor.c | 1 + ...sensor_0056_ADC_Force_Sensitive_Resistor.c | 1 + .../sensor_0057_other_KY026_FlameDetector.c | 1 + .../sensor_0059_other_MQ6_LPG_detector.c | 1 + .../sensor_0062_other_MQ7_CO_detector.c | 1 + ...or_0063_other_MQ9_LPG_flameable_detector.c | 1 + .../R307_AS606.c | 1 + .../sensor_0066_other_R307_FingerPrint.c | 3 + .../hilink_presence_sensor_setting.c | 2 + .../sensor_0067_hilink_presence_sensor.c | 1 + .../ens160.c | 1 + .../sensor_0068_ENS160_gas_sensor.c | 1 + .../sensor_0068_ENS160_gas_sensor_settings.c | 1 + .../sensor_0069_ze08_ch02_gas_sensor.c | 1 + .../ezlopi_service_ble_dynamic_config.c | 1 + .../ezlopi_service_ble_provisioning.c | 1 + .../ezlopi_service_gpioisr..c | 1 + .../ezlopi_service_meshbot.c | 3 +- .../ezlopi-service-uart/ezlopi_service_uart.c | 125 ++++++++---- .../ezlopi-service-uri/ezlopi_service_uri.c | 1 + .../ezlopi_service_webprov.c | 1 + .../ezlopi_service_ws_server.c | 1 + .../ezlopi_service_ws_server_clients.c | 1 + ezlopi-user-config/CMakeLists.txt | 4 +- ezlopi-user-config/EZLOPI_USER_CONFIG.h | 25 +++ ezlopi-util/ezlopi-util-heap/CMakeLists.txt | 10 + .../ezlopi-util-heap/ezlopi_util_heap.c | 184 ++++++++++++++++++ .../ezlopi-util-heap/ezlopi_util_heap.h | 16 ++ shell_script/provision_write.sh | 29 ++- 103 files changed, 586 insertions(+), 142 deletions(-) create mode 100644 ezlopi-util/ezlopi-util-heap/CMakeLists.txt create mode 100644 ezlopi-util/ezlopi-util-heap/ezlopi_util_heap.c create mode 100644 ezlopi-util/ezlopi-util-heap/ezlopi_util_heap.h diff --git a/.editorconfig b/.editorconfig index 163988705..5eee654d8 100644 --- a/.editorconfig +++ b/.editorconfig @@ -54,6 +54,6 @@ cpp_space_after_semicolon=false cpp_space_remove_around_unary_operator=true cpp_space_around_binary_operator=insert cpp_space_around_assignment_operator=insert -cpp_space_pointer_reference_alignment=left +cpp_space_pointer_reference_alignment=ignore cpp_space_around_ternary_operator=insert cpp_wrap_preserve_blocks=one_liners diff --git a/ezlopi-components/Bosch_BSEC2/bsec2.c b/ezlopi-components/Bosch_BSEC2/bsec2.c index a8b31f4fa..0b4628570 100644 --- a/ezlopi-components/Bosch_BSEC2/bsec2.c +++ b/ezlopi-components/Bosch_BSEC2/bsec2.c @@ -37,6 +37,7 @@ */ #include "bsec2.h" +#include "EZLOPI_USER_CONFIG.h" /* Stores the version of the BSEC algorithm */ static bsec_version_t version; diff --git a/ezlopi-components/cjext/cjext.c b/ezlopi-components/cjext/cjext.c index ebf91c165..2c052abba 100644 --- a/ezlopi-components/cjext/cjext.c +++ b/ezlopi-components/cjext/cjext.c @@ -58,6 +58,7 @@ #include "cjext.h" #include "ezlopi_util_trace.h" +#include "EZLOPI_USER_CONFIG.h" /* define our own boolean type */ #ifdef true @@ -166,25 +167,26 @@ typedef struct internal_hooks void* (CJSON_CDECL* reallocate)(void* pointer, size_t size); } internal_hooks; -#if defined(_MSC_VER) -/* work around MSVC error C2322: '...' address of dllimport '...' is not static */ -static void* CJSON_CDECL internal_malloc(size_t size) -{ - return malloc(size); -} -static void CJSON_CDECL internal_free(void* pointer) -{ - free(pointer); -} -static void* CJSON_CDECL internal_realloc(void* pointer, size_t size) -{ - return realloc(pointer, size); -} -#else +// #if defined(_MSC_VER) +// /* work around MSVC error C2322: '...' address of dllimport '...' is not static */ +// static void* CJSON_CDECL internal_malloc(size_t size) +// { +// return malloc(size); +// } +// static void CJSON_CDECL internal_free(void* pointer) +// { +// free(pointer); +// } +// static void* CJSON_CDECL internal_realloc(void* pointer, size_t size) +// { +// return realloc(pointer, size); +// } +// #elif defined(CONFIG) +// #else #define internal_malloc malloc #define internal_free free #define internal_realloc realloc -#endif +// #endif /* strlen of character literals resolved at compile time */ #define static_strlen(string_literal) (sizeof(string_literal) - sizeof("")) @@ -2558,6 +2560,7 @@ static cJSON_bool add_item_to_object(cJSON* const object, const char* const stri return add_item_to_array(object, item); } + CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObject(cJSON* object, const char* string, cJSON* item) { @@ -2658,6 +2661,20 @@ cJSON_AddNumberToObject(cJSON* const object, const char* const name, const doubl return NULL; } + +CJSON_PUBLIC(cJSON*) +cJSON_AddNumberToObjectWithRef(cJSON* const object, const char* const name, const double number) +{ + cJSON* number_item = cJSON_CreateNumber(number); + if (add_item_to_object(object, name, number_item, &global_hooks, true)) + { + return number_item; + } + + cJSON_Delete(number_item); + return NULL; +} + CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON* const object, const char* const name, const char* const string) { @@ -2671,6 +2688,19 @@ cJSON_AddStringToObject(cJSON* const object, const char* const name, const char* return NULL; } +CJSON_PUBLIC(cJSON*) +cJSON_AddStringToObjectWithRef(cJSON* const object, const char* const name, const char* const string) +{ + cJSON* string_item = cJSON_CreateStringReference(string); + if (add_item_to_object(object, name, string_item, &global_hooks, true)) + { + return string_item; + } + + cJSON_Delete(string_item); + return NULL; +} + CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON* const object, const char* const name, const char* const raw) { @@ -2697,6 +2727,19 @@ cJSON_AddObjectToObject(cJSON* const object, const char* const name) return NULL; } +CJSON_PUBLIC(cJSON*) +cJSON_AddObjectToObjectWithRef(cJSON* const object, const char* const name) +{ + cJSON* object_item = cJSON_CreateObject(); + if (add_item_to_object(object, name, object_item, &global_hooks, true)) + { + return object_item; + } + + cJSON_Delete(object_item); + return NULL; +} + CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON* const object, const char* const name) { @@ -3028,7 +3071,8 @@ cJSON_CreateStringReference(const char* string) if (item != NULL) { item->type = cJSON_String | cJSON_IsReference; - item->valuestring = (char*)cast_away_const(string); + item->valuestring = string; + item->str_value_len = strlen(string); } return item; diff --git a/ezlopi-components/cjext/cjext.h b/ezlopi-components/cjext/cjext.h index a0e6aa649..36124cc64 100644 --- a/ezlopi-components/cjext/cjext.h +++ b/ezlopi-components/cjext/cjext.h @@ -386,6 +386,15 @@ extern "C" CJSON_PUBLIC(int) cJSON_EstimatePrintLength(cJSON *item); + + +CJSON_PUBLIC(cJSON*) +cJSON_AddStringToObjectWithRef(cJSON* const object, const char* const name, const char* const string); +CJSON_PUBLIC(cJSON*) +cJSON_AddNumberToObjectWithRef(cJSON* const object, const char* const name, const double number); +CJSON_PUBLIC(cJSON*) +cJSON_AddObjectToObjectWithRef(cJSON* const object, const char* const name); + #ifdef __cplusplus } #endif diff --git a/ezlopi-core/ezlopi-core-ble/ezlopi_core_ble_buffer.c b/ezlopi-core/ezlopi-core-ble/ezlopi_core_ble_buffer.c index a9ab5c140..33f76fd3e 100644 --- a/ezlopi-core/ezlopi-core-ble/ezlopi_core_ble_buffer.c +++ b/ezlopi-core/ezlopi-core-ble/ezlopi_core_ble_buffer.c @@ -1,6 +1,7 @@ #include #include "ezlopi_core_ble_buffer.h" +#include "EZLOPI_USER_CONFIG.h" s_linked_buffer_t *ezlopi_ble_buffer_create(esp_ble_gatts_cb_param_t *param) { diff --git a/ezlopi-core/ezlopi-core-ble/ezlopi_core_ble_gap.c b/ezlopi-core/ezlopi-core-ble/ezlopi_core_ble_gap.c index b7494de99..e3c2273c3 100644 --- a/ezlopi-core/ezlopi-core-ble/ezlopi_core_ble_gap.c +++ b/ezlopi-core/ezlopi-core-ble/ezlopi_core_ble_gap.c @@ -6,6 +6,7 @@ #include "ezlopi_core_ble_profile.h" #include "ezlopi_cloud_constants.h" +#include "EZLOPI_USER_CONFIG.h" static uint8_t adv_config_done = 0; #define ADV_CONFIG_FLAG (1 << 0) diff --git a/ezlopi-core/ezlopi-core-ble/ezlopi_core_ble_profile.c b/ezlopi-core/ezlopi-core-ble/ezlopi_core_ble_profile.c index 34797950d..368465fbd 100644 --- a/ezlopi-core/ezlopi-core-ble/ezlopi_core_ble_profile.c +++ b/ezlopi-core/ezlopi-core-ble/ezlopi_core_ble_profile.c @@ -6,6 +6,7 @@ #include "ezlopi_core_ble_profile.h" #include "ezlopi_cloud_constants.h" +#include "EZLOPI_USER_CONFIG.h" static s_gatt_service_t* gatt_head_service = NULL; diff --git a/ezlopi-core/ezlopi-core-buffer/ezlopi_core_buffer.c b/ezlopi-core/ezlopi-core-buffer/ezlopi_core_buffer.c index 0387bcd93..fe1c502ff 100644 --- a/ezlopi-core/ezlopi-core-buffer/ezlopi_core_buffer.c +++ b/ezlopi-core/ezlopi-core-buffer/ezlopi_core_buffer.c @@ -4,6 +4,7 @@ #include "ezlopi_util_trace.h" #include "ezlopi_core_buffer.h" +#include "EZLOPI_USER_CONFIG.h" static char *__buffer = NULL; static uint32_t __buffer_len = 0; @@ -98,7 +99,11 @@ char *ezlopi_core_buffer_acquire(uint32_t *len, uint32_t wait_to_acquired_ms) { if (pdTRUE == xSemaphoreTake(__buffer_lock, wait_to_acquired_ms / portTICK_RATE_MS)) { - TRACE_I("acquired in: %d", xTaskGetTickCount() - start_time); + if (xTaskGetTickCount() - start_time) + { + TRACE_I("acquired in: %d", xTaskGetTickCount() - start_time); + } + ret = __buffer; *len = __buffer_len; __buffer_lock_state = EZ_BUFFER_STATE_BUSY; diff --git a/ezlopi-core/ezlopi-core-devices/ezlopi_core_devices.c b/ezlopi-core/ezlopi-core-devices/ezlopi_core_devices.c index 2c56ea39d..f2a30f318 100644 --- a/ezlopi-core/ezlopi-core-devices/ezlopi_core_devices.c +++ b/ezlopi-core/ezlopi-core-devices/ezlopi_core_devices.c @@ -5,6 +5,7 @@ #include "ezlopi_cloud_items.h" #include "ezlopi_cloud_constants.h" +#include "EZLOPI_USER_CONFIG.h" static l_ezlopi_device_t* l_device_head = NULL; static volatile uint32_t g_store_dev_config_with_id = 0; @@ -588,56 +589,6 @@ static void ezlopi_device_parse_json_v3(cJSON* cjson_config) TRACE_I("---------------------------------------------"); } } - -#if 0 - ezlopi_device_print_controller_cloud_information_v3(); - - int device_count = 0; - l_ezlopi_device_t* tm_device_l_list = l_device_head; - while (tm_device_l_list) - { - TRACE_D("|~~~~~~~~~~~~~~~~ Device - %d ~~~~~~~~~~~~~~~~|", device_count + 1); - // TRACE_D("|- Device Pointer: %p", tm_device_l_list); - TRACE_D("|- Name: %.*s", 32, isprint(tm_device_l_list->cloud_properties.device_name[0]) ? tm_device_l_list->cloud_properties.device_name : ezlopi_null_str); - TRACE_D("|- Id: %08X", tm_device_l_list->cloud_properties.device_id); - TRACE_D("|- Parent Device ID: %08X", tm_device_l_list->cloud_properties.parent_device_id); - TRACE_D("|- Category: %s", tm_device_l_list->cloud_properties.category ? tm_device_l_list->cloud_properties.category : ezlopi_null_str); - TRACE_D("|- Sub-category: %s", tm_device_l_list->cloud_properties.subcategory ? tm_device_l_list->cloud_properties.subcategory : ezlopi_null_str); - TRACE_D("|- Device-type: %s", tm_device_l_list->cloud_properties.device_type ? tm_device_l_list->cloud_properties.device_type : ezlopi_null_str); - - int item_count = 0; - l_ezlopi_item_t* tm_itme_l_list = tm_device_l_list->items; - while (tm_itme_l_list) - { - TRACE_D("|~~~|--------------- Item - %d ---------------|", item_count + 1); - TRACE_D("|~~~|- Id: %08X", tm_itme_l_list->cloud_properties.item_id); - TRACE_D("|~~~|- Category: %s", tm_itme_l_list->cloud_properties.item_name ? tm_itme_l_list->cloud_properties.item_name : ezlopi_null_str); - // TRACE_D("|~~~|- Value: %s", tm_itme_l_list->cloud_properties.value_type ? tm_itme_l_list->cloud_properties.value_type : "null"); - // TRACE_D("|~~~|- Device-type: %.*s", 32, tm_device_l_list->cloud_properties.device_type ? tm_device_l_list->cloud_properties.device_type : "null"); - - TRACE_D("|~~~|- Interface-type: %d", tm_itme_l_list->interface_type); - ezlopi_device_print_interface_type(tm_itme_l_list); - - tm_itme_l_list = tm_itme_l_list->next; - item_count++; - } - - TRACE_D("|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|"); - - tm_device_l_list = tm_device_l_list->next; - device_count++; - } -#endif - -#if 0 - l_ezlopi_configured_devices_t* current_head = ezlopi_devices_list_get_configured_items(); - while (NULL != current_head) - { - ezlopi_device_print_properties(current_head->properties); - TRACE_I("Device name: %.*s", sizeof(current_head->properties->ezlopi_cloud.device_name), current_head->properties->ezlopi_cloud.device_name); - current_head = current_head->next; - } -#endif } static void ezlopi_device_free_item(l_ezlopi_item_t* items) diff --git a/ezlopi-core/ezlopi-core-ezlopi/ezlopi_core_ezlopi_broadcast.c b/ezlopi-core/ezlopi-core-ezlopi/ezlopi_core_ezlopi_broadcast.c index 8d379bf10..0d4ad7c2f 100644 --- a/ezlopi-core/ezlopi-core-ezlopi/ezlopi_core_ezlopi_broadcast.c +++ b/ezlopi-core/ezlopi-core-ezlopi/ezlopi_core_ezlopi_broadcast.c @@ -11,6 +11,7 @@ #include "ezlopi_util_trace.h" #include "ezlopi_core_buffer.h" #include "ezlopi_core_ezlopi_broadcast.h" +#include "EZLOPI_USER_CONFIG.h" // static uint32_t __message_count = 0; static l_broadcast_method_t* __method_head = NULL; @@ -31,6 +32,10 @@ int ezlopi_core_ezlopi_broadcast_add_to_queue(cJSON* cj_data) { ret = __broadcast_queue_func(cj_data); } + else + { + TRACE_E("cj_data: %p, __broadcast_queue_func: %p", cj_data, __broadcast_queue_func); + } return ret; } diff --git a/ezlopi-core/ezlopi-core-factory-info/ezlopi_core_factory_info.c b/ezlopi-core/ezlopi-core-factory-info/ezlopi_core_factory_info.c index 376e7863a..5a68e9e08 100644 --- a/ezlopi-core/ezlopi-core-factory-info/ezlopi_core_factory_info.c +++ b/ezlopi-core/ezlopi-core-factory-info/ezlopi_core_factory_info.c @@ -5,6 +5,7 @@ #include "ezlopi_core_nvs.h" #include "ezlopi_core_factory_info.h" +#include "EZLOPI_USER_CONFIG.h" #define UPDATE_STRING_VALUE(buffer, data, offset, length) \ { \ @@ -59,12 +60,13 @@ uint32_t ezlopi_factory_info_v3_get_abs_address(uint32_t relative_offset, e_fact } } -static char *ezlopi_factory_info_v3_read_string(e_ezlopi_factory_info_v3_offset_t offset, e_ezlopi_factory_info_v3_length_t length) +static char *ezlopi_factory_info_v3_read_string(const char * name, e_ezlopi_factory_info_v3_offset_t offset, e_ezlopi_factory_info_v3_length_t length) { char *read_string = NULL; if (ezlopi_factory_info_v3_init()) { + TRACE_D("%s", name); char *tmp_buffer = (char *)malloc(length); if (tmp_buffer) { @@ -214,7 +216,7 @@ uint16_t ezlopi_factory_info_v3_get_version(void) char *ezlopi_factory_info_v3_get_name(void) { - char *read_data = ezlopi_factory_info_v3_read_string(ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_DEVICE_NAME, E_EZLOPI_FACTORY_INFO_HUB_DATA), EZLOPI_FINFO_LEN_DEVICE_NAME); + char *read_data = ezlopi_factory_info_v3_read_string("name", ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_DEVICE_NAME, E_EZLOPI_FACTORY_INFO_HUB_DATA), EZLOPI_FINFO_LEN_DEVICE_NAME); if (read_data) { if (!isprint(read_data[0])) @@ -228,7 +230,7 @@ char *ezlopi_factory_info_v3_get_name(void) char *ezlopi_factory_info_v3_get_manufacturer(void) { - char *read_data = ezlopi_factory_info_v3_read_string(ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_MANUF_NAME, E_EZLOPI_FACTORY_INFO_HUB_DATA), EZLOPI_FINFO_LEN_MANUF_NAME); + char *read_data = ezlopi_factory_info_v3_read_string("manufacturer", ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_MANUF_NAME, E_EZLOPI_FACTORY_INFO_HUB_DATA), EZLOPI_FINFO_LEN_MANUF_NAME); if (read_data) { @@ -243,7 +245,7 @@ char *ezlopi_factory_info_v3_get_manufacturer(void) char *ezlopi_factory_info_v3_get_brand(void) { - char *read_data = ezlopi_factory_info_v3_read_string(ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_BRAND_NAME, E_EZLOPI_FACTORY_INFO_HUB_DATA), EZLOPI_FINFO_LEN_BRAND_NAME); + char *read_data = ezlopi_factory_info_v3_read_string("brand", ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_BRAND_NAME, E_EZLOPI_FACTORY_INFO_HUB_DATA), EZLOPI_FINFO_LEN_BRAND_NAME); if (read_data) { @@ -258,7 +260,7 @@ char *ezlopi_factory_info_v3_get_brand(void) char *ezlopi_factory_info_v3_get_model(void) { - char *read_data = ezlopi_factory_info_v3_read_string(ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_MODEL_NAME, E_EZLOPI_FACTORY_INFO_HUB_DATA), EZLOPI_FINFO_LEN_MODEL_NAME); + char *read_data = ezlopi_factory_info_v3_read_string("model", ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_MODEL_NAME, E_EZLOPI_FACTORY_INFO_HUB_DATA), EZLOPI_FINFO_LEN_MODEL_NAME); if (read_data) { if (!isprint(read_data[0])) @@ -272,7 +274,7 @@ char *ezlopi_factory_info_v3_get_model(void) char *ezlopi_factory_info_get_v3_provision_token(void) { - char *read_data = ezlopi_factory_info_v3_read_string(ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_PROVISIONING_TOKEN, E_EZLOPI_FACTORY_INFO_CONN_DATA), EZLOPI_FINFO_LEN_PROVISIONING_TOKEN); + char *read_data = ezlopi_factory_info_v3_read_string("prov-token", ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_PROVISIONING_TOKEN, E_EZLOPI_FACTORY_INFO_CONN_DATA), EZLOPI_FINFO_LEN_PROVISIONING_TOKEN); if (read_data) { if (!isprint(read_data[0])) @@ -320,7 +322,7 @@ unsigned long long ezlopi_factory_info_v3_get_id(void) char *ezlopi_factory_info_v3_get_device_uuid(void) { - char *read_data = ezlopi_factory_info_v3_read_string(ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_DEVICE_UUID, E_EZLOPI_FACTORY_INFO_CONN_DATA), EZLOPI_FINFO_LEN_DEVICE_UUID); + char *read_data = ezlopi_factory_info_v3_read_string("dev-uuid", ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_DEVICE_UUID, E_EZLOPI_FACTORY_INFO_CONN_DATA), EZLOPI_FINFO_LEN_DEVICE_UUID); if (read_data) { if (!isprint(read_data[0])) @@ -334,7 +336,7 @@ char *ezlopi_factory_info_v3_get_device_uuid(void) char *ezlopi_factory_info_v3_get_provisioning_uuid(void) { - char *read_data = ezlopi_factory_info_v3_read_string(ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_PROVISIONING_UUID, E_EZLOPI_FACTORY_INFO_CONN_DATA), EZLOPI_FINFO_LEN_PROV_UUID); + char *read_data = ezlopi_factory_info_v3_read_string("prov-uuid", ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_PROVISIONING_UUID, E_EZLOPI_FACTORY_INFO_CONN_DATA), EZLOPI_FINFO_LEN_PROV_UUID); if (read_data) { if (!isprint(read_data[0])) @@ -348,7 +350,7 @@ char *ezlopi_factory_info_v3_get_provisioning_uuid(void) char *ezlopi_factory_info_v3_get_ssid(void) { - char *read_data = ezlopi_factory_info_v3_read_string(ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_WIFI_SSID, E_EZLOPI_FACTORY_INFO_HUB_DATA), EZLOPI_FINFO_LEN_WIFI_SSID); + char *read_data = ezlopi_factory_info_v3_read_string("ssid", ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_WIFI_SSID, E_EZLOPI_FACTORY_INFO_HUB_DATA), EZLOPI_FINFO_LEN_WIFI_SSID); if (read_data) { if (!isprint(read_data[0])) @@ -363,7 +365,7 @@ char *ezlopi_factory_info_v3_get_ssid(void) char *ezlopi_factory_info_v3_get_password(void) { - char *read_data = ezlopi_factory_info_v3_read_string(ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_WIFI_PASS, E_EZLOPI_FACTORY_INFO_HUB_DATA), EZLOPI_FINFO_LEN_WIFI_PASS); + char *read_data = ezlopi_factory_info_v3_read_string("pass", ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_WIFI_PASS, E_EZLOPI_FACTORY_INFO_HUB_DATA), EZLOPI_FINFO_LEN_WIFI_PASS); if (read_data) { if (!isprint(read_data[0])) @@ -379,7 +381,7 @@ char *ezlopi_factory_info_v3_get_password(void) char *ezlopi_factory_info_v3_get_ezlopi_mac(void) { - char *read_data = ezlopi_factory_info_v3_read_string(ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_DEVICE_MAC, E_EZLOPI_FACTORY_INFO_HUB_DATA), EZLOPI_FINFO_LEN_DEVICE_MAC); + char *read_data = ezlopi_factory_info_v3_read_string("mac", ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_DEVICE_MAC, E_EZLOPI_FACTORY_INFO_HUB_DATA), EZLOPI_FINFO_LEN_DEVICE_MAC); if (read_data) { if (!isprint(read_data[0])) @@ -393,7 +395,7 @@ char *ezlopi_factory_info_v3_get_ezlopi_mac(void) char *ezlopi_factory_info_v3_get_cloud_server(void) { - char *cloud_server = ezlopi_factory_info_v3_read_string(ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_CLOUD_SERVER_URL, E_EZLOPI_FACTORY_INFO_CONN_DATA), EZLOPI_FINFO_LEN_CLOUD_SERVER_URL); + char *cloud_server = ezlopi_factory_info_v3_read_string("c-server", ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_CLOUD_SERVER_URL, E_EZLOPI_FACTORY_INFO_CONN_DATA), EZLOPI_FINFO_LEN_CLOUD_SERVER_URL); if (cloud_server && strstr(cloud_server, "https://")) { g_provisioning_status = 1; @@ -403,7 +405,7 @@ char *ezlopi_factory_info_v3_get_cloud_server(void) char *ezlopi_factory_info_v3_get_provisioning_server(void) { - char *provisioning_server = ezlopi_factory_info_v3_read_string(ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_PROVISIONING_SERVER_URL, E_EZLOPI_FACTORY_INFO_CONN_DATA), EZLOPI_FINFO_LEN_PROVISIONING_SERVER_URL); + char *provisioning_server = ezlopi_factory_info_v3_read_string("p-server", ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_PROVISIONING_SERVER_URL, E_EZLOPI_FACTORY_INFO_CONN_DATA), EZLOPI_FINFO_LEN_PROVISIONING_SERVER_URL); if (provisioning_server && strstr(provisioning_server, "https://")) { return provisioning_server; @@ -422,23 +424,22 @@ const char *ezlopi_factory_info_v3_get_device_type(void) char *ezlopi_factory_info_v3_get_ca_certificate(void) { - return ezlopi_factory_info_v3_read_string(ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_CA_CERTIFICATE, E_EZLOPI_FACTORY_INFO_CONN_DATA), EZLOPI_FINFO_LEN_CA_CERTIFICATE); + return ezlopi_factory_info_v3_read_string("ca-cert", ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_CA_CERTIFICATE, E_EZLOPI_FACTORY_INFO_CONN_DATA), EZLOPI_FINFO_LEN_CA_CERTIFICATE); } char *ezlopi_factory_info_v3_get_ssl_private_key(void) { - return ezlopi_factory_info_v3_read_string(ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_SSL_PRIVATE_KEY, E_EZLOPI_FACTORY_INFO_CONN_DATA), EZLOPI_FINFO_LEN_SSL_PRIVATE_KEY); + return ezlopi_factory_info_v3_read_string("pvt-key", ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_SSL_PRIVATE_KEY, E_EZLOPI_FACTORY_INFO_CONN_DATA), EZLOPI_FINFO_LEN_SSL_PRIVATE_KEY); } char *ezlopi_factory_info_v3_get_ssl_shared_key(void) { - - return ezlopi_factory_info_v3_read_string(ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_SSL_SHARED_KEY, E_EZLOPI_FACTORY_INFO_CONN_DATA), EZLOPI_FINFO_LEN_SSL_SHARED_KEY); + return ezlopi_factory_info_v3_read_string("srd-key", ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_SSL_SHARED_KEY, E_EZLOPI_FACTORY_INFO_CONN_DATA), EZLOPI_FINFO_LEN_SSL_SHARED_KEY); } char *ezlopi_factory_info_v3_get_ezlopi_config(void) { - char *ret = ezlopi_factory_info_v3_read_string(ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_EZLOPI_CONFIG_JSON, E_EZLOPI_FACTORY_INFO_CONN_DATA), EZLOPI_FINFO_LEN_EZLOPI_CONFIG_JSON); + char *ret = ezlopi_factory_info_v3_read_string("ez-config", ezlopi_factory_info_v3_get_abs_address(EZLOPI_FINFO_REL_OFFSET_EZLOPI_CONFIG_JSON, E_EZLOPI_FACTORY_INFO_CONN_DATA), EZLOPI_FINFO_LEN_EZLOPI_CONFIG_JSON); if (false == isprint(ret[0])) { if (ret) diff --git a/ezlopi-core/ezlopi-core-http/ezlopi_core_http.c b/ezlopi-core/ezlopi-core-http/ezlopi_core_http.c index 83a2bbfd0..e56f91f89 100644 --- a/ezlopi-core/ezlopi-core-http/ezlopi_core_http.c +++ b/ezlopi-core/ezlopi-core-http/ezlopi_core_http.c @@ -16,6 +16,7 @@ #include "ezlopi_core_http.h" #include "ezlopi_core_event_group.h" +#include "EZLOPI_USER_CONFIG.h" static void ezlopi_http_free_rx_data(s_rx_data_t* rx_data); diff --git a/ezlopi-core/ezlopi-core-mdns/ezlopi_core_mdns.c b/ezlopi-core/ezlopi-core-mdns/ezlopi_core_mdns.c index de558a0da..fddbe9b36 100644 --- a/ezlopi-core/ezlopi-core-mdns/ezlopi_core_mdns.c +++ b/ezlopi-core/ezlopi-core-mdns/ezlopi_core_mdns.c @@ -16,6 +16,7 @@ #include "ezlopi_cloud_keywords.h" #include "ezlopi_util_trace.h" #include "ezlopi_core_mdns.h" +#include "EZLOPI_USER_CONFIG.h" const char* ezlopi_mdns_instance_name = "EzloPi, an Open Source IoT Platform"; diff --git a/ezlopi-core/ezlopi-core-modes/ezlopi_core_modes_cjson.c b/ezlopi-core/ezlopi-core-modes/ezlopi_core_modes_cjson.c index f27ad3e88..eb9859bf9 100644 --- a/ezlopi-core/ezlopi-core-modes/ezlopi_core_modes_cjson.c +++ b/ezlopi-core/ezlopi-core-modes/ezlopi_core_modes_cjson.c @@ -10,6 +10,7 @@ #include "ezlopi_core_cjson_macros.h" #include "ezlopi_cloud_constants.h" +#include "EZLOPI_USER_CONFIG.h" #if defined(CONFIG_EZLPI_SERV_ENABLE_MODES) diff --git a/ezlopi-core/ezlopi-core-nvs/ezlopi_core_nvs.c b/ezlopi-core/ezlopi-core-nvs/ezlopi_core_nvs.c index 7954f1e29..a61d13d6b 100644 --- a/ezlopi-core/ezlopi-core-nvs/ezlopi_core_nvs.c +++ b/ezlopi-core/ezlopi-core-nvs/ezlopi_core_nvs.c @@ -6,8 +6,8 @@ #include "freertos/task.h" #include "ezlopi_util_trace.h" - #include "ezlopi_core_nvs.h" +#include "EZLOPI_USER_CONFIG.h" static nvs_handle_t ezlopi_nvs_handle = 0; static const char* storage_name = "storage"; diff --git a/ezlopi-core/ezlopi-core-ota/ezlopi_core_ota.c b/ezlopi-core/ezlopi-core-ota/ezlopi_core_ota.c index 06472d248..977234d3b 100644 --- a/ezlopi-core/ezlopi-core-ota/ezlopi_core_ota.c +++ b/ezlopi-core/ezlopi-core-ota/ezlopi_core_ota.c @@ -20,6 +20,7 @@ #include "ezlopi_core_factory_info.h" #include "ezlopi_service_ota.h" +#include "EZLOPI_USER_CONFIG.h" #if defined(CONFIG_EZPI_ENABLE_OTA) diff --git a/ezlopi-core/ezlopi-core-room/ezlopi_core_room.c b/ezlopi-core/ezlopi-core-room/ezlopi_core_room.c index dc6b3c88e..7c866e838 100644 --- a/ezlopi-core/ezlopi-core-room/ezlopi_core_room.c +++ b/ezlopi-core/ezlopi-core-room/ezlopi_core_room.c @@ -7,6 +7,7 @@ #include "ezlopi_core_ezlopi_broadcast.h" #include "ezlopi_cloud_constants.h" +#include "EZLOPI_USER_CONFIG.h" // #include "ezlopi_service_webprov.h" diff --git a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_expressions.c b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_expressions.c index 5b78500c7..fb02288d1 100644 --- a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_expressions.c +++ b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_expressions.c @@ -8,6 +8,7 @@ #include "ezlopi_core_scenes_expressions.h" #include "ezlopi_cloud_constants.h" +#include "EZLOPI_USER_CONFIG.h" static s_ezlopi_expressions_t* l_expressions_head = NULL; diff --git a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_populate.c b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_populate.c index b96474ebe..b75f70ee4 100644 --- a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_populate.c +++ b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_populate.c @@ -3,6 +3,7 @@ #include "ezlopi_core_scenes_populate.h" #include "ezlopi_cloud_constants.h" +#include "EZLOPI_USER_CONFIG.h" void ezlopi_scenes_populate_scene(l_scenes_list_v2_t* new_scene, cJSON* cj_scene, uint32_t scene_id) { diff --git a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_scripts.c b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_scripts.c index a88713d9e..741f34130 100755 --- a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_scripts.c +++ b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_scripts.c @@ -17,6 +17,7 @@ #include "ezlopi_core_scenes_scripts_custom_libs_includes.h" #include "ezlopi_cloud_constants.h" +#include "EZLOPI_USER_CONFIG.h" static l_ezlopi_scenes_script_t* script_head = NULL; diff --git a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_then_methods.c b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_then_methods.c index b66b4b09c..6c2f6e35a 100755 --- a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_then_methods.c +++ b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_then_methods.c @@ -14,6 +14,7 @@ #include "ezlopi_core_scenes_then_methods_helper_func.h" #include "ezlopi_cloud_constants.h" +#include "EZLOPI_USER_CONFIG.h" int ezlopi_scene_then_set_item_value(l_scenes_list_v2_t* curr_scene, void* arg) { diff --git a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_then_methods_helper_func.c b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_then_methods_helper_func.c index 7f6663172..a60eb4543 100644 --- a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_then_methods_helper_func.c +++ b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_then_methods_helper_func.c @@ -3,6 +3,7 @@ #include "ezlopi_core_http.h" #include "ezlopi_core_scenes_v2.h" #include "ezlopi_core_scenes_then_methods_helper_func.h" +#include "EZLOPI_USER_CONFIG.h" #define STR_SIZE(str) ((NULL != str) ? (strlen(str)) : 0) diff --git a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_v2.c b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_v2.c index 3abd787d9..b2917a95b 100644 --- a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_v2.c +++ b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_v2.c @@ -17,6 +17,7 @@ #include "ezlopi_cloud_constants.h" #include "ezlopi_service_meshbot.h" +#include "EZLOPI_USER_CONFIG.h" static l_scenes_list_v2_t* scenes_list_head_v2 = NULL; diff --git a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_when_methods_helper_functions.c b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_when_methods_helper_functions.c index 85824b1c3..06ba7aae6 100644 --- a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_when_methods_helper_functions.c +++ b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_when_methods_helper_functions.c @@ -4,6 +4,7 @@ #include "ezlopi_core_scenes_v2.h" #include "ezlopi_core_event_group.h" #include "ezlopi_core_scenes_when_methods_helper_functions.h" +#include "EZLOPI_USER_CONFIG.h" //------------------------------- ezlopi_scene_when_is_date --------------------------------------------- diff --git a/ezlopi-core/ezlopi-core-timer/ezlopi_core_timer.c b/ezlopi-core/ezlopi-core-timer/ezlopi_core_timer.c index 522c97064..2b9f909d4 100644 --- a/ezlopi-core/ezlopi-core-timer/ezlopi_core_timer.c +++ b/ezlopi-core/ezlopi-core-timer/ezlopi_core_timer.c @@ -37,6 +37,7 @@ #include "ezlopi_core_timer.h" #include "ezlopi_core_event_queue.h" +#include "EZLOPI_USER_CONFIG.h" typedef struct s_ezlopi_timer { @@ -205,7 +206,7 @@ static void ezlopi_timer_init_timer_event(int timer_num, int time_ms, e_ezlopi_a { if (timer_num < MAX_TIMER) { - s_ezlopi_timer_t* timer_config = malloc(sizeof(s_ezlopi_timer_t)); + s_ezlopi_timer_t* timer_config = malloc(sizeof(s_ezlopi_timer_t)); // can't be freed, used by timer-upcall to re-configure timer if (timer_config) { diff --git a/ezlopi-core/ezlopi-core-websocket_client/ezlopi_core_websocket_client.c b/ezlopi-core/ezlopi-core-websocket_client/ezlopi_core_websocket_client.c index c2689d608..e9e99b8b8 100644 --- a/ezlopi-core/ezlopi-core-websocket_client/ezlopi_core_websocket_client.c +++ b/ezlopi-core/ezlopi-core-websocket_client/ezlopi_core_websocket_client.c @@ -15,6 +15,7 @@ #include "ezlopi_core_factory_info.h" #include "ezlopi_core_websocket_client.h" +#include "EZLOPI_USER_CONFIG.h" static esp_websocket_client_handle_t client = NULL; static void (*__msg_upcall)(const char*, uint32_t) = NULL; diff --git a/ezlopi-core/ezlopi-core-wifi/ezlopi_core_wifi.c b/ezlopi-core/ezlopi-core-wifi/ezlopi_core_wifi.c index fd745138a..deaaf2b20 100644 --- a/ezlopi-core/ezlopi-core-wifi/ezlopi_core_wifi.c +++ b/ezlopi-core/ezlopi-core-wifi/ezlopi_core_wifi.c @@ -31,6 +31,7 @@ #include "ezlopi_core_device_value_updated.h" #include "ezlopi_service_uart.h" +#include "EZLOPI_USER_CONFIG.h" #define EXAMPLE_ESP_MAXIMUM_RETRY 5 diff --git a/ezlopi-hal/ezlopi-hal-adc/ezlopi_hal_adc.c b/ezlopi-hal/ezlopi-hal-adc/ezlopi_hal_adc.c index 8d7621d64..3861defbd 100644 --- a/ezlopi-hal/ezlopi-hal-adc/ezlopi_hal_adc.c +++ b/ezlopi-hal/ezlopi-hal-adc/ezlopi_hal_adc.c @@ -8,6 +8,7 @@ #include "ezlopi_util_trace.h" #include "ezlopi_hal_adc.h" +#include "EZLOPI_USER_CONFIG.h" typedef struct s_ezlopi_analog_object { diff --git a/ezlopi-hal/ezlopi-hal-pwm/ezlopi_hal_pwm.c b/ezlopi-hal/ezlopi-hal-pwm/ezlopi_hal_pwm.c index 44e766c70..2beaadfbf 100644 --- a/ezlopi-hal/ezlopi-hal-pwm/ezlopi_hal_pwm.c +++ b/ezlopi-hal/ezlopi-hal-pwm/ezlopi_hal_pwm.c @@ -4,6 +4,7 @@ #include "ezlopi_hal_pwm.h" #include "ezlopi_util_trace.h" +#include "EZLOPI_USER_CONFIG.h" struct s_ezlopi_pwm_object { @@ -69,6 +70,7 @@ s_ezlopi_channel_speed_t *ezlopi_pwm_init(uint8_t pwm_gpio_num, uint8_t pwm_resl { TRACE_S("LEDC channel configured successfully."); } + ezlopi_channel_speed->channel = channel; ezlopi_channel_speed->speed_mode = ezlopi_pwm_channel_cfg.speed_mode; } diff --git a/ezlopi-hal/ezlopi-hal-uart/ezlopi_hal_uart.c b/ezlopi-hal/ezlopi-hal-uart/ezlopi_hal_uart.c index 5265f4f2b..89ea6f20f 100644 --- a/ezlopi-hal/ezlopi-hal-uart/ezlopi_hal_uart.c +++ b/ezlopi-hal/ezlopi-hal-uart/ezlopi_hal_uart.c @@ -10,6 +10,7 @@ #include "ezlopi_util_trace.h" #include "ezlopi_hal_uart.h" +#include "EZLOPI_USER_CONFIG.h" static void ezlopi_uart_channel_task(void *args); static ezlo_uart_channel_t get_available_channel(); diff --git a/ezlopi-main/CMakeLists.txt b/ezlopi-main/CMakeLists.txt index a93fb8d97..968607800 100644 --- a/ezlopi-main/CMakeLists.txt +++ b/ezlopi-main/CMakeLists.txt @@ -12,6 +12,7 @@ set(EZLOPI_SDK_COMPONENTS # Define ezlopi-components set(EZLOPI_COMPONENTS pt + ezlopi-util-heap ezlopi-util-trace ) diff --git a/ezlopi-main/Kconfig.projbuild b/ezlopi-main/Kconfig.projbuild index 498c0fd67..270d36c62 100644 --- a/ezlopi-main/Kconfig.projbuild +++ b/ezlopi-main/Kconfig.projbuild @@ -35,6 +35,12 @@ menu "EzloPi User Config" endchoice + config EZPI_HEAP_ENABLE + bool "Enable ezlopi heap" + default n + help + Enables the allocation and free via ezlopi-util, helpful to track-down any memory leak in the stack + config EZPI_DEV_TYPE_TEST bool "Run device in test mode" default n diff --git a/ezlopi-main/ezlopi_main.c b/ezlopi-main/ezlopi_main.c index 6a992e930..16800884a 100644 --- a/ezlopi-main/ezlopi_main.c +++ b/ezlopi-main/ezlopi_main.c @@ -24,6 +24,7 @@ #include "ezlopi_service_ws_server.h" #include "ezlopi_service_broadcast.h" #include "ezlopi_service_led_indicator.h" +#include "ezlopi_util_heap.h" #include "pt.h" @@ -32,6 +33,7 @@ static void __blinky(void* pv); void app_main(void) { + #if 1 ezlopi_service_led_indicator_init(); gpio_install_isr_service(0); @@ -40,7 +42,7 @@ void app_main(void) ezlopi_init(); #if defined(CONFIG_EZPI_ENABLE_UART_PROVISIONING) - EZPI_SERVICE_uart_init(); + // EZPI_SERVICE_uart_init(); #endif timer_service_init(); @@ -49,7 +51,7 @@ void app_main(void) ezlopi_ble_service_init(); #endif -#if defined(CONFIG_EZPI_LOCAL_WEBSOCKET_SERVER) || defined(EZPI_WEBSOCKET_CLIENT) +#if defined(CONFIG_EZPI_LOCAL_WEBSOCKET_SERVER) || defined(CONFIG_EZPI_WEBSOCKET_CLIENT) ezlopi_service_broadcast_init(); #endif @@ -74,37 +76,45 @@ void app_main(void) #if CONFIG_EZPI_SERV_ENABLE_MESHBOTS ezlopi_scenes_meshbot_init(); #endif - +#endif xTaskCreate(__blinky, "__blinky", 2 * 2048, NULL, 0, NULL); } static void __blinky(void* pv) { - - uint32_t count = 0; uint32_t low_heap_start_time = xTaskGetTickCount(); while (1) { - uint32_t free_heap_kb = esp_get_free_heap_size() / 1024.0; + float free_heap_kb = esp_get_free_heap_size() / 1024.0; trace_wb("----------------------------------------------"); trace_wb("esp_get_free_heap_size - %.02f kB", free_heap_kb); trace_wb("esp_get_minimum_free_heap_size: %.02f kB", esp_get_minimum_free_heap_size() / 1024.0); trace_wb("----------------------------------------------"); - if (free_heap_kb >= 10) + ezlopi_util_heap_trace(); + + if (free_heap_kb <= 10) { - low_heap_start_time = xTaskGetTickCount(); + TRACE_W("CRITICAL-WARNING: low heap detected.."); + ezlopi_util_heap_trace(); } else if ((xTaskGetTickCount() - low_heap_start_time) > (15000 / portTICK_PERIOD_MS)) { - TRACE_E("ERROR: low heap time-out detected!"); + ezlopi_util_heap_trace(); + vTaskDelay(2000 / portTICK_RATE_MS); + TRACE_E("CRITICAL-ERROR: low heap time-out detected!"); TRACE_W("Rebooting....."); esp_restart(); } + else + { + low_heap_start_time = xTaskGetTickCount(); + } + ezlopi_util_heap_flush(); vTaskDelay(5000 / portTICK_PERIOD_MS); } } diff --git a/ezlopi-sensors-devices/device-0001-digitalOut-generic/device_0001_digitalOut_generic.c b/ezlopi-sensors-devices/device-0001-digitalOut-generic/device_0001_digitalOut_generic.c index f394e439e..a3b4b75c0 100644 --- a/ezlopi-sensors-devices/device-0001-digitalOut-generic/device_0001_digitalOut_generic.c +++ b/ezlopi-sensors-devices/device-0001-digitalOut-generic/device_0001_digitalOut_generic.c @@ -15,6 +15,7 @@ #include "ezlopi_service_gpioisr.h" #include "device_0001_digitalOut_generic.h" +#include "EZLOPI_USER_CONFIG.h" // #define DEV_TEST_SETTINGS_EN diff --git a/ezlopi-sensors-devices/device-0009-other-RMT-SK6812/device_0009_other_RMT_SK6812.c b/ezlopi-sensors-devices/device-0009-other-RMT-SK6812/device_0009_other_RMT_SK6812.c index 453094ec1..307d3fb35 100644 --- a/ezlopi-sensors-devices/device-0009-other-RMT-SK6812/device_0009_other_RMT_SK6812.c +++ b/ezlopi-sensors-devices/device-0009-other-RMT-SK6812/device_0009_other_RMT_SK6812.c @@ -19,6 +19,9 @@ #include "color_codes.h" #include "device_0009_other_RMT_SK6812.h" +#include "EZLOPI_USER_CONFIG.h" + + typedef struct s_dimmer_args { led_strip_t sk6812_strip; diff --git a/ezlopi-sensors-devices/device-0022-PWM-dimmable-lamp/device_0022_PWM_dimmable_lamp.c b/ezlopi-sensors-devices/device-0022-PWM-dimmable-lamp/device_0022_PWM_dimmable_lamp.c index db72772a9..59c4558a5 100644 --- a/ezlopi-sensors-devices/device-0022-PWM-dimmable-lamp/device_0022_PWM_dimmable_lamp.c +++ b/ezlopi-sensors-devices/device-0022-PWM-dimmable-lamp/device_0022_PWM_dimmable_lamp.c @@ -13,6 +13,7 @@ #include "ezlopi_cloud_constants.h" #include "device_0022_PWM_dimmable_lamp.h" +#include "EZLOPI_USER_CONFIG.h" typedef struct s_dimmable_bulb_properties { diff --git a/ezlopi-sensors-devices/device-0036-PWM-servo-MG996R/device_0036_PWM_servo_MG996R.c b/ezlopi-sensors-devices/device-0036-PWM-servo-MG996R/device_0036_PWM_servo_MG996R.c index 7e9507133..95ab3ad4f 100644 --- a/ezlopi-sensors-devices/device-0036-PWM-servo-MG996R/device_0036_PWM_servo_MG996R.c +++ b/ezlopi-sensors-devices/device-0036-PWM-servo-MG996R/device_0036_PWM_servo_MG996R.c @@ -12,6 +12,7 @@ #include "ezlopi_cloud_constants.h" #include "device_0036_PWM_servo_MG996R.h" +#include "EZLOPI_USER_CONFIG.h" static int __prepare(void* arg); static int __init(l_ezlopi_item_t* item); diff --git a/ezlopi-sensors-devices/device-0038-other-RGB/device_0038_other_RGB.c b/ezlopi-sensors-devices/device-0038-other-RGB/device_0038_other_RGB.c index 67de59db0..bd7e641ba 100644 --- a/ezlopi-sensors-devices/device-0038-other-RGB/device_0038_other_RGB.c +++ b/ezlopi-sensors-devices/device-0038-other-RGB/device_0038_other_RGB.c @@ -12,6 +12,7 @@ #include "ezlopi_cloud_constants.h" #include "device_0038_other_RGB.h" +#include "EZLOPI_USER_CONFIG.h" typedef struct s_rgb_args { @@ -215,10 +216,6 @@ static int __init(l_ezlopi_item_t* item) rgb_args->RGB_LED_initialized = true; ret = 1; } - else - { - ret = -1; - } } else { diff --git a/ezlopi-sensors-devices/sensor-0005-I2C-MPU6050/sensor_0005_I2C_MPU6050.c b/ezlopi-sensors-devices/sensor-0005-I2C-MPU6050/sensor_0005_I2C_MPU6050.c index f71028446..1b6feb621 100644 --- a/ezlopi-sensors-devices/sensor-0005-I2C-MPU6050/sensor_0005_I2C_MPU6050.c +++ b/ezlopi-sensors-devices/sensor-0005-I2C-MPU6050/sensor_0005_I2C_MPU6050.c @@ -13,6 +13,7 @@ #include "ezlopi_cloud_constants.h" #include "sensor_0005_I2C_MPU6050.h" +#include "EZLOPI_USER_CONFIG.h" static int __prepare(void* arg); static int __init(l_ezlopi_item_t* item); diff --git a/ezlopi-sensors-devices/sensor-0006-I2C-ADXL345/sensor_0006_I2C_ADXL345.c b/ezlopi-sensors-devices/sensor-0006-I2C-ADXL345/sensor_0006_I2C_ADXL345.c index 714d9270b..dc0cfa1be 100644 --- a/ezlopi-sensors-devices/sensor-0006-I2C-ADXL345/sensor_0006_I2C_ADXL345.c +++ b/ezlopi-sensors-devices/sensor-0006-I2C-ADXL345/sensor_0006_I2C_ADXL345.c @@ -13,6 +13,7 @@ #include "ezlopi_cloud_constants.h" #include "sensor_0006_I2C_ADXL345.h" +#include "EZLOPI_USER_CONFIG.h" static int __prepare(void* arg); static int __init(l_ezlopi_item_t* item); diff --git a/ezlopi-sensors-devices/sensor-0007-I2C-GY271/sensor_0007_I2C_GY271.c b/ezlopi-sensors-devices/sensor-0007-I2C-GY271/sensor_0007_I2C_GY271.c index 1f644680e..85034a923 100644 --- a/ezlopi-sensors-devices/sensor-0007-I2C-GY271/sensor_0007_I2C_GY271.c +++ b/ezlopi-sensors-devices/sensor-0007-I2C-GY271/sensor_0007_I2C_GY271.c @@ -13,6 +13,7 @@ #include "ezlopi_cloud_constants.h" #include "sensor_0007_I2C_GY271.h" +#include "EZLOPI_USER_CONFIG.h" //------------------------------------------------------------------------------------------------------------------------------------------------------------ static int __prepare(void* arg); diff --git a/ezlopi-sensors-devices/sensor-0008-I2C-LTR303ALS/sensor_0008_I2C_LTR303ALS.c b/ezlopi-sensors-devices/sensor-0008-I2C-LTR303ALS/sensor_0008_I2C_LTR303ALS.c index fcc92fb20..5dd7ce12f 100644 --- a/ezlopi-sensors-devices/sensor-0008-I2C-LTR303ALS/sensor_0008_I2C_LTR303ALS.c +++ b/ezlopi-sensors-devices/sensor-0008-I2C-LTR303ALS/sensor_0008_I2C_LTR303ALS.c @@ -16,6 +16,7 @@ #include "ALS_LTR303.h" #include "sensor_0008_I2C_LTR303ALS.h" +#include "EZLOPI_USER_CONFIG.h" static int __prepare(void* arg); static int __init(l_ezlopi_item_t* item); diff --git a/ezlopi-sensors-devices/sensor-0010-I2C-BME680/sensor_0010_I2C_BME680.c b/ezlopi-sensors-devices/sensor-0010-I2C-BME680/sensor_0010_I2C_BME680.c index 82e9c347c..c459bf855 100644 --- a/ezlopi-sensors-devices/sensor-0010-I2C-BME680/sensor_0010_I2C_BME680.c +++ b/ezlopi-sensors-devices/sensor-0010-I2C-BME680/sensor_0010_I2C_BME680.c @@ -14,6 +14,7 @@ #include "bme680_bsec.h" #include "sensor_0010_I2C_BME680.h" +#include "EZLOPI_USER_CONFIG.h" static int __prepare(void* arg); static int __init(l_ezlopi_item_t* item); diff --git a/ezlopi-sensors-devices/sensor-0012-I2C-BME280/sensor_0012_I2C_BME280.c b/ezlopi-sensors-devices/sensor-0012-I2C-BME280/sensor_0012_I2C_BME280.c index 6613654d5..9d221513b 100644 --- a/ezlopi-sensors-devices/sensor-0012-I2C-BME280/sensor_0012_I2C_BME280.c +++ b/ezlopi-sensors-devices/sensor-0012-I2C-BME280/sensor_0012_I2C_BME280.c @@ -13,6 +13,7 @@ #include "ezlopi_cloud_constants.h" #include "sensor_0012_I2C_BME280.h" +#include "EZLOPI_USER_CONFIG.h" typedef struct s_ezlopi_bmp280 { diff --git a/ezlopi-sensors-devices/sensor-0015-oneWire-DHT11/sensor_0015_oneWire_DHT11.c b/ezlopi-sensors-devices/sensor-0015-oneWire-DHT11/sensor_0015_oneWire_DHT11.c index c2d72d1ab..9ac8d5fef 100644 --- a/ezlopi-sensors-devices/sensor-0015-oneWire-DHT11/sensor_0015_oneWire_DHT11.c +++ b/ezlopi-sensors-devices/sensor-0015-oneWire-DHT11/sensor_0015_oneWire_DHT11.c @@ -13,6 +13,7 @@ #include "dht11.h" #include "sensor_0015_oneWire_DHT11.h" +#include "EZLOPI_USER_CONFIG.h" typedef struct s_ezlopi_dht11_data { diff --git a/ezlopi-sensors-devices/sensor-0016-oneWire-DHT22/sensor_0016_oneWire_DHT22.c b/ezlopi-sensors-devices/sensor-0016-oneWire-DHT22/sensor_0016_oneWire_DHT22.c index 9bbfa7f4d..a1e25219c 100644 --- a/ezlopi-sensors-devices/sensor-0016-oneWire-DHT22/sensor_0016_oneWire_DHT22.c +++ b/ezlopi-sensors-devices/sensor-0016-oneWire-DHT22/sensor_0016_oneWire_DHT22.c @@ -13,6 +13,7 @@ #include "dht22.h" #include "sensor_0016_oneWire_DHT22.h" +#include "EZLOPI_USER_CONFIG.h" typedef struct s_ezlopi_dht22_data { diff --git a/ezlopi-sensors-devices/sensor-0017-ADC-potentiometer/sensor_0017_ADC_potentiometer.c b/ezlopi-sensors-devices/sensor-0017-ADC-potentiometer/sensor_0017_ADC_potentiometer.c index 1ce78c9f5..f2aa3a873 100644 --- a/ezlopi-sensors-devices/sensor-0017-ADC-potentiometer/sensor_0017_ADC_potentiometer.c +++ b/ezlopi-sensors-devices/sensor-0017-ADC-potentiometer/sensor_0017_ADC_potentiometer.c @@ -13,6 +13,9 @@ #include "ezlopi_cloud_constants.h" #include "sensor_0017_ADC_potentiometer.h" +#include "EZLOPI_USER_CONFIG.h" + + typedef struct s_potentiometer { float pot_val; diff --git a/ezlopi-sensors-devices/sensor-0018-other-internal-hall-effect/sensor_0018_other_internal_hall_effect.c b/ezlopi-sensors-devices/sensor-0018-other-internal-hall-effect/sensor_0018_other_internal_hall_effect.c index 1df00bd9e..62c52d9cb 100644 --- a/ezlopi-sensors-devices/sensor-0018-other-internal-hall-effect/sensor_0018_other_internal_hall_effect.c +++ b/ezlopi-sensors-devices/sensor-0018-other-internal-hall-effect/sensor_0018_other_internal_hall_effect.c @@ -18,6 +18,7 @@ #include "ezlopi_cloud_constants.h" #include "sensor_0018_other_internal_hall_effect.h" +#include "EZLOPI_USER_CONFIG.h" const char* hall_door_window_states[] = { "dw_is_opened", diff --git a/ezlopi-sensors-devices/sensor-0020-other-2axis-joystick/sensor_0020_other_2axis_joystick.c b/ezlopi-sensors-devices/sensor-0020-other-2axis-joystick/sensor_0020_other_2axis_joystick.c index d8feae088..c389a086f 100644 --- a/ezlopi-sensors-devices/sensor-0020-other-2axis-joystick/sensor_0020_other_2axis_joystick.c +++ b/ezlopi-sensors-devices/sensor-0020-other-2axis-joystick/sensor_0020_other_2axis_joystick.c @@ -17,6 +17,7 @@ #include "ezlopi_service_gpioisr.h" #include "sensor_0020_other_2axis_joystick.h" +#include "EZLOPI_USER_CONFIG.h" typedef struct s_joystick_data { diff --git a/ezlopi-sensors-devices/sensor-0021-UART-MB1013/sensor_0021_UART_MB1013.c b/ezlopi-sensors-devices/sensor-0021-UART-MB1013/sensor_0021_UART_MB1013.c index 3422bd1e4..97b565c8a 100644 --- a/ezlopi-sensors-devices/sensor-0021-UART-MB1013/sensor_0021_UART_MB1013.c +++ b/ezlopi-sensors-devices/sensor-0021-UART-MB1013/sensor_0021_UART_MB1013.c @@ -13,6 +13,7 @@ #include "ezlopi_cloud_constants.h" #include "sensor_0021_UART_MB1013.h" +#include "EZLOPI_USER_CONFIG.h" typedef struct s_mb1013_args { diff --git a/ezlopi-sensors-devices/sensor-0024-other-HCSR04/sensor_0024_other_HCSR04.c b/ezlopi-sensors-devices/sensor-0024-other-HCSR04/sensor_0024_other_HCSR04.c index 5318beb2a..f2ce7f22f 100644 --- a/ezlopi-sensors-devices/sensor-0024-other-HCSR04/sensor_0024_other_HCSR04.c +++ b/ezlopi-sensors-devices/sensor-0024-other-HCSR04/sensor_0024_other_HCSR04.c @@ -17,6 +17,7 @@ #include "ezlopi_service_gpioisr.h" #include "sensor_0024_other_HCSR04.h" +#include "EZLOPI_USER_CONFIG.h" static portMUX_TYPE mux = portMUX_INITIALIZER_UNLOCKED; diff --git a/ezlopi-sensors-devices/sensor-0028-other-GY61/sensor_0028_other_GY61.c b/ezlopi-sensors-devices/sensor-0028-other-GY61/sensor_0028_other_GY61.c index 8421371b5..c4887c8a9 100644 --- a/ezlopi-sensors-devices/sensor-0028-other-GY61/sensor_0028_other_GY61.c +++ b/ezlopi-sensors-devices/sensor-0028-other-GY61/sensor_0028_other_GY61.c @@ -14,6 +14,7 @@ #include "ezlopi_cloud_constants.h" #include "sensor_0028_other_GY61.h" +#include "EZLOPI_USER_CONFIG.h" //-------------------------------------------------------------------------------------------------------- typedef struct s_gy61_data diff --git a/ezlopi-sensors-devices/sensor-0029-I2C-GXHTC3/gxhtc3.c b/ezlopi-sensors-devices/sensor-0029-I2C-GXHTC3/gxhtc3.c index 8a39a924c..11b8a2f0e 100644 --- a/ezlopi-sensors-devices/sensor-0029-I2C-GXHTC3/gxhtc3.c +++ b/ezlopi-sensors-devices/sensor-0029-I2C-GXHTC3/gxhtc3.c @@ -2,6 +2,7 @@ #include "gxhtc3.h" #include "driver/i2c.h" #include "ezlopi_util_trace.h" +#include "EZLOPI_USER_CONFIG.h" static uint8_t gxhtc3_get_crc8(uint8_t *data, int len) { diff --git a/ezlopi-sensors-devices/sensor-0029-I2C-GXHTC3/sensor_0029_I2C_GXHTC3.c b/ezlopi-sensors-devices/sensor-0029-I2C-GXHTC3/sensor_0029_I2C_GXHTC3.c index 805cad894..c2d454da9 100644 --- a/ezlopi-sensors-devices/sensor-0029-I2C-GXHTC3/sensor_0029_I2C_GXHTC3.c +++ b/ezlopi-sensors-devices/sensor-0029-I2C-GXHTC3/sensor_0029_I2C_GXHTC3.c @@ -13,6 +13,7 @@ #include "ezlopi_cloud_constants.h" #include "sensor_0029_I2C_GXHTC3.h" +#include "EZLOPI_USER_CONFIG.h" static int __prepare(void* arg); static int __get_cjson_value(l_ezlopi_item_t* item, void* arg); diff --git a/ezlopi-sensors-devices/sensor-0030-oneWire-DS18B20/sensor_0030_oneWire_DS18B20.c b/ezlopi-sensors-devices/sensor-0030-oneWire-DS18B20/sensor_0030_oneWire_DS18B20.c index c51820516..be42404f7 100644 --- a/ezlopi-sensors-devices/sensor-0030-oneWire-DS18B20/sensor_0030_oneWire_DS18B20.c +++ b/ezlopi-sensors-devices/sensor-0030-oneWire-DS18B20/sensor_0030_oneWire_DS18B20.c @@ -12,6 +12,7 @@ #include "ds18b20_onewire.h" #include "sensor_0030_oneWire_DS18B20.h" +#include "EZLOPI_USER_CONFIG.h" static int __prepare(void* arg); static int __init(l_ezlopi_item_t* item); diff --git a/ezlopi-sensors-devices/sensor-0031-other-JSNSR04T/sensor_0031_other_JSNSR04T.c b/ezlopi-sensors-devices/sensor-0031-other-JSNSR04T/sensor_0031_other_JSNSR04T.c index 416deda6c..165fd7441 100644 --- a/ezlopi-sensors-devices/sensor-0031-other-JSNSR04T/sensor_0031_other_JSNSR04T.c +++ b/ezlopi-sensors-devices/sensor-0031-other-JSNSR04T/sensor_0031_other_JSNSR04T.c @@ -11,6 +11,7 @@ #include "jsn_sr04t.h" #include "sensor_0031_other_JSNSR04T.h" +#include "EZLOPI_USER_CONFIG.h" static int __prepare(void* arg); static int __init(l_ezlopi_item_t* item); diff --git a/ezlopi-sensors-devices/sensor-0032-ADC-soilMoisture/sensor_0032_ADC_soilMoisture.c b/ezlopi-sensors-devices/sensor-0032-ADC-soilMoisture/sensor_0032_ADC_soilMoisture.c index 92084dd63..f080cfe68 100644 --- a/ezlopi-sensors-devices/sensor-0032-ADC-soilMoisture/sensor_0032_ADC_soilMoisture.c +++ b/ezlopi-sensors-devices/sensor-0032-ADC-soilMoisture/sensor_0032_ADC_soilMoisture.c @@ -14,6 +14,7 @@ #include "ezlopi_cloud_constants.h" #include "sensor_0032_ADC_soilMoisture.h" +#include "EZLOPI_USER_CONFIG.h" static int __prepare(void* arg); static int __init(l_ezlopi_item_t* item); diff --git a/ezlopi-sensors-devices/sensor-0033-ADC-turbidity/sensor_0033_ADC_turbidity.c b/ezlopi-sensors-devices/sensor-0033-ADC-turbidity/sensor_0033_ADC_turbidity.c index c6e717bf8..e8844f70d 100644 --- a/ezlopi-sensors-devices/sensor-0033-ADC-turbidity/sensor_0033_ADC_turbidity.c +++ b/ezlopi-sensors-devices/sensor-0033-ADC-turbidity/sensor_0033_ADC_turbidity.c @@ -12,6 +12,7 @@ #include "ezlopi_cloud_constants.h" #include "sensor_0033_ADC_turbidity.h" +#include "EZLOPI_USER_CONFIG.h" static int __prepare(void* arg); static int __init(l_ezlopi_item_t* item); diff --git a/ezlopi-sensors-devices/sensor-0037-pms5003-sensor/pms_dev_items_prepare.c b/ezlopi-sensors-devices/sensor-0037-pms5003-sensor/pms_dev_items_prepare.c index d93262165..41e9b6964 100644 --- a/ezlopi-sensors-devices/sensor-0037-pms5003-sensor/pms_dev_items_prepare.c +++ b/ezlopi-sensors-devices/sensor-0037-pms5003-sensor/pms_dev_items_prepare.c @@ -10,6 +10,7 @@ #include "pms5003.h" #include "sensor_0037_pms5003_sensor.h" +#include "EZLOPI_USER_CONFIG.h" // Device 0 static int __prepare_particulate_matter_particles_0_dot_3_um_device_and_items(cJSON *cj_properties, uint32_t *parent_id, void *user_arg) diff --git a/ezlopi-sensors-devices/sensor-0040-other-TCS230/sensor_0040_other_TCS230.c b/ezlopi-sensors-devices/sensor-0040-other-TCS230/sensor_0040_other_TCS230.c index f9822fa0b..cc5002098 100644 --- a/ezlopi-sensors-devices/sensor-0040-other-TCS230/sensor_0040_other_TCS230.c +++ b/ezlopi-sensors-devices/sensor-0040-other-TCS230/sensor_0040_other_TCS230.c @@ -16,6 +16,7 @@ #include "ezlopi_cloud_constants.h" #include "sensor_0040_other_TCS230.h" +#include "EZLOPI_USER_CONFIG.h" static int __0040_prepare(void* arg); static int __0040_init(l_ezlopi_item_t* item); diff --git a/ezlopi-sensors-devices/sensor-0041-ADC-FC28-soilMoisture/sensor_0041_ADC_FC28_soilMoisture.c b/ezlopi-sensors-devices/sensor-0041-ADC-FC28-soilMoisture/sensor_0041_ADC_FC28_soilMoisture.c index 4868a42b9..22dce5741 100644 --- a/ezlopi-sensors-devices/sensor-0041-ADC-FC28-soilMoisture/sensor_0041_ADC_FC28_soilMoisture.c +++ b/ezlopi-sensors-devices/sensor-0041-ADC-FC28-soilMoisture/sensor_0041_ADC_FC28_soilMoisture.c @@ -14,6 +14,7 @@ #include "ezlopi_cloud_constants.h" #include "sensor_0041_ADC_FC28_soilMoisture.h" +#include "EZLOPI_USER_CONFIG.h" typedef struct s_fc28_data { diff --git a/ezlopi-sensors-devices/sensor-0042-ADC-shunt-voltmeter/sensor_0042_ADC_shunt_voltmeter.c b/ezlopi-sensors-devices/sensor-0042-ADC-shunt-voltmeter/sensor_0042_ADC_shunt_voltmeter.c index 96b6ae1e7..1452c6ea4 100644 --- a/ezlopi-sensors-devices/sensor-0042-ADC-shunt-voltmeter/sensor_0042_ADC_shunt_voltmeter.c +++ b/ezlopi-sensors-devices/sensor-0042-ADC-shunt-voltmeter/sensor_0042_ADC_shunt_voltmeter.c @@ -13,6 +13,7 @@ #include "ezlopi_cloud_constants.h" #include "sensor_0042_ADC_shunt_voltmeter.h" +#include "EZLOPI_USER_CONFIG.h" typedef struct s_voltmeter { diff --git a/ezlopi-sensors-devices/sensor-0043-ADC-GYML8511-UV-intensity/sensor_0043_ADC_GYML8511_UV_intensity.c b/ezlopi-sensors-devices/sensor-0043-ADC-GYML8511-UV-intensity/sensor_0043_ADC_GYML8511_UV_intensity.c index 7e758bd43..75bde3364 100644 --- a/ezlopi-sensors-devices/sensor-0043-ADC-GYML8511-UV-intensity/sensor_0043_ADC_GYML8511_UV_intensity.c +++ b/ezlopi-sensors-devices/sensor-0043-ADC-GYML8511-UV-intensity/sensor_0043_ADC_GYML8511_UV_intensity.c @@ -13,6 +13,7 @@ #include "ezlopi_cloud_constants.h" #include "sensor_0043_ADC_GYML8511_UV_intensity.h" +#include "EZLOPI_USER_CONFIG.h" //-------------------------------------------------------------------------------------------------------- typedef struct s_gyml8511_data diff --git a/ezlopi-sensors-devices/sensor-0044-I2C-TSL256-luminosity/sensor_0044_I2C_TSL256_luminosity.c b/ezlopi-sensors-devices/sensor-0044-I2C-TSL256-luminosity/sensor_0044_I2C_TSL256_luminosity.c index 6ae308136..a680bb3a9 100644 --- a/ezlopi-sensors-devices/sensor-0044-I2C-TSL256-luminosity/sensor_0044_I2C_TSL256_luminosity.c +++ b/ezlopi-sensors-devices/sensor-0044-I2C-TSL256-luminosity/sensor_0044_I2C_TSL256_luminosity.c @@ -13,6 +13,7 @@ #include "ezlopi_cloud_constants.h" #include "sensor_0044_I2C_TSL256_luminosity.h" +#include "EZLOPI_USER_CONFIG.h" //----------------------------------------------------------------------- static int __prepare(void* arg); diff --git a/ezlopi-sensors-devices/sensor-0046-ADC-ACS712-05B-currentmeter/sensor_0046_ADC_ACS712_05B_currentmeter.c b/ezlopi-sensors-devices/sensor-0046-ADC-ACS712-05B-currentmeter/sensor_0046_ADC_ACS712_05B_currentmeter.c index b97487bf4..a86b56502 100644 --- a/ezlopi-sensors-devices/sensor-0046-ADC-ACS712-05B-currentmeter/sensor_0046_ADC_ACS712_05B_currentmeter.c +++ b/ezlopi-sensors-devices/sensor-0046-ADC-ACS712-05B-currentmeter/sensor_0046_ADC_ACS712_05B_currentmeter.c @@ -12,6 +12,8 @@ #include "ezlopi_cloud_constants.h" #include "sensor_0046_ADC_ACS712_05B_currentmeter.h" +#include "EZLOPI_USER_CONFIG.h" + typedef struct s_currentmeter { float amp_value; diff --git a/ezlopi-sensors-devices/sensor-0047-other-HX711-loadcell/sensor_0047_other_HX711_loadcell.c b/ezlopi-sensors-devices/sensor-0047-other-HX711-loadcell/sensor_0047_other_HX711_loadcell.c index bd36eab54..0488cb331 100644 --- a/ezlopi-sensors-devices/sensor-0047-other-HX711-loadcell/sensor_0047_other_HX711_loadcell.c +++ b/ezlopi-sensors-devices/sensor-0047-other-HX711-loadcell/sensor_0047_other_HX711_loadcell.c @@ -11,6 +11,8 @@ #include "ezlopi_cloud_constants.h" #include "sensor_0047_other_HX711_loadcell.h" +#include "EZLOPI_USER_CONFIG.h" + /********************************************************************************/ /* global defines */ /********************************************************************************/ diff --git a/ezlopi-sensors-devices/sensor-0048-other-MQ4-CH4-detector/sensor_0048_other_MQ4_CH4_detector.c b/ezlopi-sensors-devices/sensor-0048-other-MQ4-CH4-detector/sensor_0048_other_MQ4_CH4_detector.c index 15d339a83..f285412b3 100644 --- a/ezlopi-sensors-devices/sensor-0048-other-MQ4-CH4-detector/sensor_0048_other_MQ4_CH4_detector.c +++ b/ezlopi-sensors-devices/sensor-0048-other-MQ4-CH4-detector/sensor_0048_other_MQ4_CH4_detector.c @@ -13,6 +13,8 @@ #include "ezlopi_cloud_constants.h" #include "sensor_0048_other_MQ4_CH4_detector.h" +#include "EZLOPI_USER_CONFIG.h" + //************************************************************************* // Declaration //************************************************************************* diff --git a/ezlopi-sensors-devices/sensor-0049-other-MQ2-LPG-detector/sensor_0049_other_MQ2_LPG_detector.c b/ezlopi-sensors-devices/sensor-0049-other-MQ2-LPG-detector/sensor_0049_other_MQ2_LPG_detector.c index 8b9295f56..8c3b7dee6 100644 --- a/ezlopi-sensors-devices/sensor-0049-other-MQ2-LPG-detector/sensor_0049_other_MQ2_LPG_detector.c +++ b/ezlopi-sensors-devices/sensor-0049-other-MQ2-LPG-detector/sensor_0049_other_MQ2_LPG_detector.c @@ -13,6 +13,7 @@ #include "ezlopi_cloud_constants.h" #include "sensor_0049_other_MQ2_LPG_detector.h" +#include "EZLOPI_USER_CONFIG.h" //************************************************************************* // Declaration diff --git a/ezlopi-sensors-devices/sensor-0050-other-MQ3-alcohol-detector/sensor_0050_other_MQ3_alcohol_detector.c b/ezlopi-sensors-devices/sensor-0050-other-MQ3-alcohol-detector/sensor_0050_other_MQ3_alcohol_detector.c index 178ccba7d..83b7272d4 100644 --- a/ezlopi-sensors-devices/sensor-0050-other-MQ3-alcohol-detector/sensor_0050_other_MQ3_alcohol_detector.c +++ b/ezlopi-sensors-devices/sensor-0050-other-MQ3-alcohol-detector/sensor_0050_other_MQ3_alcohol_detector.c @@ -13,6 +13,8 @@ #include "ezlopi_cloud_constants.h" #include "sensor_0050_other_MQ3_alcohol_detector.h" +#include "EZLOPI_USER_CONFIG.h" + //************************************************************************* // Declaration //************************************************************************* diff --git a/ezlopi-sensors-devices/sensor-0051-other-MQ8-H2-detector/sensor_0051_other_MQ8_H2_detector.c b/ezlopi-sensors-devices/sensor-0051-other-MQ8-H2-detector/sensor_0051_other_MQ8_H2_detector.c index 81e625579..792de3a3e 100644 --- a/ezlopi-sensors-devices/sensor-0051-other-MQ8-H2-detector/sensor_0051_other_MQ8_H2_detector.c +++ b/ezlopi-sensors-devices/sensor-0051-other-MQ8-H2-detector/sensor_0051_other_MQ8_H2_detector.c @@ -13,6 +13,8 @@ #include "ezlopi_cloud_constants.h" #include "sensor_0051_other_MQ8_H2_detector.h" +#include "EZLOPI_USER_CONFIG.h" + //************************************************************************* // Declaration //************************************************************************* diff --git a/ezlopi-sensors-devices/sensor-0052-other-MQ135-NH3-detector/sensor_0052_other_MQ135_NH3_detector.c b/ezlopi-sensors-devices/sensor-0052-other-MQ135-NH3-detector/sensor_0052_other_MQ135_NH3_detector.c index fd8483650..fb6655f83 100644 --- a/ezlopi-sensors-devices/sensor-0052-other-MQ135-NH3-detector/sensor_0052_other_MQ135_NH3_detector.c +++ b/ezlopi-sensors-devices/sensor-0052-other-MQ135-NH3-detector/sensor_0052_other_MQ135_NH3_detector.c @@ -13,6 +13,8 @@ #include "ezlopi_cloud_constants.h" #include "sensor_0052_other_MQ135_NH3_detector.h" +#include "EZLOPI_USER_CONFIG.h" + //************************************************************************* // Declaration //************************************************************************* diff --git a/ezlopi-sensors-devices/sensor-0053-UART-GYGPS6MV2/gyGPS6MV2.c b/ezlopi-sensors-devices/sensor-0053-UART-GYGPS6MV2/gyGPS6MV2.c index a72cc0ed0..6680191dd 100644 --- a/ezlopi-sensors-devices/sensor-0053-UART-GYGPS6MV2/gyGPS6MV2.c +++ b/ezlopi-sensors-devices/sensor-0053-UART-GYGPS6MV2/gyGPS6MV2.c @@ -1,6 +1,7 @@ #include #include "ezlopi_util_trace.h" #include "gyGPS6MV2.h" +#include "EZLOPI_USER_CONFIG.h" //------------------------------------------------------------------------- // GPGGA MESSAGE PARSING FUNCTION diff --git a/ezlopi-sensors-devices/sensor-0053-UART-GYGPS6MV2/sensor_0053_UART_GYGPS6MV2.c b/ezlopi-sensors-devices/sensor-0053-UART-GYGPS6MV2/sensor_0053_UART_GYGPS6MV2.c index 8a8f278df..07a3c9261 100644 --- a/ezlopi-sensors-devices/sensor-0053-UART-GYGPS6MV2/sensor_0053_UART_GYGPS6MV2.c +++ b/ezlopi-sensors-devices/sensor-0053-UART-GYGPS6MV2/sensor_0053_UART_GYGPS6MV2.c @@ -14,6 +14,7 @@ #include "gyGPS6MV2.h" #include "sensor_0053_UART_GYGPS6MV2.h" +#include "EZLOPI_USER_CONFIG.h" //------------------------------------------------------------------------ static int __0053_prepare(void* arg); diff --git a/ezlopi-sensors-devices/sensor-0054-PWM-YFS201-flowmeter/sensor_0054_PWM_YFS201_flowmeter.c b/ezlopi-sensors-devices/sensor-0054-PWM-YFS201-flowmeter/sensor_0054_PWM_YFS201_flowmeter.c index 12195e555..8aec376b9 100644 --- a/ezlopi-sensors-devices/sensor-0054-PWM-YFS201-flowmeter/sensor_0054_PWM_YFS201_flowmeter.c +++ b/ezlopi-sensors-devices/sensor-0054-PWM-YFS201-flowmeter/sensor_0054_PWM_YFS201_flowmeter.c @@ -14,6 +14,9 @@ #include "ezlopi_cloud_constants.h" #include "sensor_0054_PWM_YFS201_flowmeter.h" +#include "EZLOPI_USER_CONFIG.h" + + //************************************************************************* // Declaration //************************************************************************* diff --git a/ezlopi-sensors-devices/sensor-0055-ADC-FlexResistor/sensor_0055_ADC_FlexResistor.c b/ezlopi-sensors-devices/sensor-0055-ADC-FlexResistor/sensor_0055_ADC_FlexResistor.c index e383b48a4..6bb0dd299 100644 --- a/ezlopi-sensors-devices/sensor-0055-ADC-FlexResistor/sensor_0055_ADC_FlexResistor.c +++ b/ezlopi-sensors-devices/sensor-0055-ADC-FlexResistor/sensor_0055_ADC_FlexResistor.c @@ -11,6 +11,7 @@ #include "ezlopi_cloud_constants.h" #include "sensor_0055_ADC_FlexResistor.h" +#include "EZLOPI_USER_CONFIG.h" //-------------------------------------------------------------------------------------------------------- static int __0055_prepare(void* arg); diff --git a/ezlopi-sensors-devices/sensor-0056-ADC-Force-Sensitive-Resistor/sensor_0056_ADC_Force_Sensitive_Resistor.c b/ezlopi-sensors-devices/sensor-0056-ADC-Force-Sensitive-Resistor/sensor_0056_ADC_Force_Sensitive_Resistor.c index bc09b28f0..a114336dd 100644 --- a/ezlopi-sensors-devices/sensor-0056-ADC-Force-Sensitive-Resistor/sensor_0056_ADC_Force_Sensitive_Resistor.c +++ b/ezlopi-sensors-devices/sensor-0056-ADC-Force-Sensitive-Resistor/sensor_0056_ADC_Force_Sensitive_Resistor.c @@ -12,6 +12,7 @@ #include "ezlopi_cloud_constants.h" #include "sensor_0056_ADC_Force_Sensitive_Resistor.h" +#include "EZLOPI_USER_CONFIG.h" //------------------------------------------------------------------------------------------------------------------------------ static int __0056_prepare(void* arg); diff --git a/ezlopi-sensors-devices/sensor-0057-other-KY026-FlameDetector/sensor_0057_other_KY026_FlameDetector.c b/ezlopi-sensors-devices/sensor-0057-other-KY026-FlameDetector/sensor_0057_other_KY026_FlameDetector.c index 7c232c935..0281569be 100644 --- a/ezlopi-sensors-devices/sensor-0057-other-KY026-FlameDetector/sensor_0057_other_KY026_FlameDetector.c +++ b/ezlopi-sensors-devices/sensor-0057-other-KY026-FlameDetector/sensor_0057_other_KY026_FlameDetector.c @@ -12,6 +12,7 @@ #include "ezlopi_cloud_constants.h" #include "sensor_0057_other_KY026_FlameDetector.h" +#include "EZLOPI_USER_CONFIG.h" //------------------------------------------------------------------------------ const char* ky206_sensor_heat_alarm_token[] = { diff --git a/ezlopi-sensors-devices/sensor-0059-other-MQ6-LPG-detector/sensor_0059_other_MQ6_LPG_detector.c b/ezlopi-sensors-devices/sensor-0059-other-MQ6-LPG-detector/sensor_0059_other_MQ6_LPG_detector.c index 48f5ae99d..23abc08c4 100644 --- a/ezlopi-sensors-devices/sensor-0059-other-MQ6-LPG-detector/sensor_0059_other_MQ6_LPG_detector.c +++ b/ezlopi-sensors-devices/sensor-0059-other-MQ6-LPG-detector/sensor_0059_other_MQ6_LPG_detector.c @@ -13,6 +13,7 @@ #include "ezlopi_cloud_constants.h" #include "sensor_0059_other_MQ6_LPG_detector.h" +#include "EZLOPI_USER_CONFIG.h" //************************************************************************* // Declaration diff --git a/ezlopi-sensors-devices/sensor-0062-other-MQ7-CO-detector/sensor_0062_other_MQ7_CO_detector.c b/ezlopi-sensors-devices/sensor-0062-other-MQ7-CO-detector/sensor_0062_other_MQ7_CO_detector.c index ade6882cd..9016bbba5 100644 --- a/ezlopi-sensors-devices/sensor-0062-other-MQ7-CO-detector/sensor_0062_other_MQ7_CO_detector.c +++ b/ezlopi-sensors-devices/sensor-0062-other-MQ7-CO-detector/sensor_0062_other_MQ7_CO_detector.c @@ -14,6 +14,7 @@ #include "ezlopi_cloud_constants.h" #include "sensor_0062_other_MQ7_CO_detector.h" +#include "EZLOPI_USER_CONFIG.h" //************************************************************************* // Declaration diff --git a/ezlopi-sensors-devices/sensor-0063-other-MQ9-LPG-flameable-detector/sensor_0063_other_MQ9_LPG_flameable_detector.c b/ezlopi-sensors-devices/sensor-0063-other-MQ9-LPG-flameable-detector/sensor_0063_other_MQ9_LPG_flameable_detector.c index ffb7cfff2..a9773941b 100644 --- a/ezlopi-sensors-devices/sensor-0063-other-MQ9-LPG-flameable-detector/sensor_0063_other_MQ9_LPG_flameable_detector.c +++ b/ezlopi-sensors-devices/sensor-0063-other-MQ9-LPG-flameable-detector/sensor_0063_other_MQ9_LPG_flameable_detector.c @@ -13,6 +13,7 @@ #include "ezlopi_cloud_constants.h" #include "sensor_0063_other_MQ9_LPG_flameable_detector.h" +#include "EZLOPI_USER_CONFIG.h" //************************************************************************* // Declaration diff --git a/ezlopi-sensors-devices/sensor-0066-other-R307-FingerPrint/R307_AS606.c b/ezlopi-sensors-devices/sensor-0066-other-R307-FingerPrint/R307_AS606.c index 72afab406..56bc7455b 100644 --- a/ezlopi-sensors-devices/sensor-0066-other-R307-FingerPrint/R307_AS606.c +++ b/ezlopi-sensors-devices/sensor-0066-other-R307-FingerPrint/R307_AS606.c @@ -2,6 +2,7 @@ #include "ezlopi_util_trace.h" #include "ezlopi_hal_uart.h" #include "sensor_0066_other_R307_FingerPrint.h" +#include "EZLOPI_USER_CONFIG.h" //---------------------------------------------------------------------------------------------------------------- // !< Custom tx-packet > diff --git a/ezlopi-sensors-devices/sensor-0066-other-R307-FingerPrint/sensor_0066_other_R307_FingerPrint.c b/ezlopi-sensors-devices/sensor-0066-other-R307-FingerPrint/sensor_0066_other_R307_FingerPrint.c index ab71a9698..46e5243d9 100644 --- a/ezlopi-sensors-devices/sensor-0066-other-R307-FingerPrint/sensor_0066_other_R307_FingerPrint.c +++ b/ezlopi-sensors-devices/sensor-0066-other-R307-FingerPrint/sensor_0066_other_R307_FingerPrint.c @@ -18,6 +18,9 @@ #include "ezlopi_service_gpioisr.h" #include "sensor_0066_other_R307_FingerPrint.h" +#include "EZLOPI_USER_CONFIG.h" + + //--------------------------------------------------------------------------------------------------------------- static void IRAM_ATTR gpio_notify_isr(void* param) { diff --git a/ezlopi-sensors-devices/sensor-0067-UART-hilink-presence-sensor/hilink_presence_sensor_setting.c b/ezlopi-sensors-devices/sensor-0067-UART-hilink-presence-sensor/hilink_presence_sensor_setting.c index 2ba162e02..86763f123 100644 --- a/ezlopi-sensors-devices/sensor-0067-UART-hilink-presence-sensor/hilink_presence_sensor_setting.c +++ b/ezlopi-sensors-devices/sensor-0067-UART-hilink-presence-sensor/hilink_presence_sensor_setting.c @@ -13,6 +13,8 @@ #include "hilink_presence_sensor_setting.h" #include "sensor_0067_hilink_presence_sensor.h" +#include "EZLOPI_USER_CONFIG.h" + static const char* nvs_key_hilink_presence_sensor_predefined_setting = "predef"; static const char* nvs_key_hilink_presence_sensor_userdefined_setting = "userdef"; diff --git a/ezlopi-sensors-devices/sensor-0067-UART-hilink-presence-sensor/sensor_0067_hilink_presence_sensor.c b/ezlopi-sensors-devices/sensor-0067-UART-hilink-presence-sensor/sensor_0067_hilink_presence_sensor.c index 49a23c2a5..a15c1d534 100644 --- a/ezlopi-sensors-devices/sensor-0067-UART-hilink-presence-sensor/sensor_0067_hilink_presence_sensor.c +++ b/ezlopi-sensors-devices/sensor-0067-UART-hilink-presence-sensor/sensor_0067_hilink_presence_sensor.c @@ -15,6 +15,7 @@ #include "sensor_0067_hilink_presence_sensor.h" #include "hilink_presence_sensor_setting.h" +#include "EZLOPI_USER_CONFIG.h" static const char* hilink_presence_sensor_motion_direction_enum[] = { "unknown", diff --git a/ezlopi-sensors-devices/sensor-0068-I2C-ENS160-gas-sensor/ens160.c b/ezlopi-sensors-devices/sensor-0068-I2C-ENS160-gas-sensor/ens160.c index 17bd8e090..b27c369f4 100644 --- a/ezlopi-sensors-devices/sensor-0068-I2C-ENS160-gas-sensor/ens160.c +++ b/ezlopi-sensors-devices/sensor-0068-I2C-ENS160-gas-sensor/ens160.c @@ -15,6 +15,7 @@ #include "freertos/task.h" #include "ens160.h" +#include "EZLOPI_USER_CONFIG.h" static const char* TAG = "ENS160"; diff --git a/ezlopi-sensors-devices/sensor-0068-I2C-ENS160-gas-sensor/sensor_0068_ENS160_gas_sensor.c b/ezlopi-sensors-devices/sensor-0068-I2C-ENS160-gas-sensor/sensor_0068_ENS160_gas_sensor.c index 482279d99..a371e4d8d 100644 --- a/ezlopi-sensors-devices/sensor-0068-I2C-ENS160-gas-sensor/sensor_0068_ENS160_gas_sensor.c +++ b/ezlopi-sensors-devices/sensor-0068-I2C-ENS160-gas-sensor/sensor_0068_ENS160_gas_sensor.c @@ -21,6 +21,7 @@ #include "sensor_0068_ENS160_gas_sensor.h" #include "sensor_0068_ENS160_gas_sensor_settings.h" +#include "EZLOPI_USER_CONFIG.h" /* {\ diff --git a/ezlopi-sensors-devices/sensor-0068-I2C-ENS160-gas-sensor/sensor_0068_ENS160_gas_sensor_settings.c b/ezlopi-sensors-devices/sensor-0068-I2C-ENS160-gas-sensor/sensor_0068_ENS160_gas_sensor_settings.c index 0af971bbd..79a381d73 100644 --- a/ezlopi-sensors-devices/sensor-0068-I2C-ENS160-gas-sensor/sensor_0068_ENS160_gas_sensor_settings.c +++ b/ezlopi-sensors-devices/sensor-0068-I2C-ENS160-gas-sensor/sensor_0068_ENS160_gas_sensor_settings.c @@ -13,6 +13,7 @@ #include "ens160.h" #include "sensor_0068_ENS160_gas_sensor_settings.h" +#include "EZLOPI_USER_CONFIG.h" static const char* nvs_key_ens160_gas_sensor_ambient_temperature_setting = "enstemp"; static const char* nvs_key_ens160_gas_sensor_relative_humidity_setting = "enshmd"; diff --git a/ezlopi-sensors-devices/sensor-0069-UART-ze08-ch02-gas-sensor/sensor_0069_ze08_ch02_gas_sensor.c b/ezlopi-sensors-devices/sensor-0069-UART-ze08-ch02-gas-sensor/sensor_0069_ze08_ch02_gas_sensor.c index 8c06f1504..7d43c10c5 100644 --- a/ezlopi-sensors-devices/sensor-0069-UART-ze08-ch02-gas-sensor/sensor_0069_ze08_ch02_gas_sensor.c +++ b/ezlopi-sensors-devices/sensor-0069-UART-ze08-ch02-gas-sensor/sensor_0069_ze08_ch02_gas_sensor.c @@ -16,6 +16,7 @@ #include "sensor_0069_ze08_ch02_gas_sensor.h" #include "ze08_ch2o.h" +#include "EZLOPI_USER_CONFIG.h" static int __prepare(void* arg, void* user_arg); static int __init(l_ezlopi_item_t* item); diff --git a/ezlopi-services/ezlopi-service-ble/ezlopi_service_ble_dynamic_config.c b/ezlopi-services/ezlopi-service-ble/ezlopi_service_ble_dynamic_config.c index e735fc280..dab38eee1 100644 --- a/ezlopi-services/ezlopi-service-ble/ezlopi_service_ble_dynamic_config.c +++ b/ezlopi-services/ezlopi-service-ble/ezlopi_service_ble_dynamic_config.c @@ -23,6 +23,7 @@ #include "ezlopi_service_ble_ble_auth.h" #include "ezlopi_service_ble.h" +#include "EZLOPI_USER_CONFIG.h" #define CJ_GET_STRING(name) cJSON_GetStringValue(cJSON_GetObjectItem(root, name)) #define CJ_GET_NUMBER(name) cJSON_GetNumberValue(cJSON_GetObjectItem(root, name)) diff --git a/ezlopi-services/ezlopi-service-ble/ezlopi_service_ble_provisioning.c b/ezlopi-services/ezlopi-service-ble/ezlopi_service_ble_provisioning.c index 85addca1a..f3cba0436 100644 --- a/ezlopi-services/ezlopi-service-ble/ezlopi_service_ble_provisioning.c +++ b/ezlopi-services/ezlopi-service-ble/ezlopi_service_ble_provisioning.c @@ -23,6 +23,7 @@ #include "ezlopi_service_ble_ble_auth.h" #include "ezlopi_service_ble.h" +#include "EZLOPI_USER_CONFIG.h" #define CJ_GET_STRING(name) cJSON_GetStringValue(cJSON_GetObjectItem(root, name)) #define CJ_GET_NUMBER(name) cJSON_GetNumberValue(cJSON_GetObjectItem(root, name)) diff --git a/ezlopi-services/ezlopi-service-gpioisr/ezlopi_service_gpioisr..c b/ezlopi-services/ezlopi-service-gpioisr/ezlopi_service_gpioisr..c index 7e64bdfb0..5ffb50ade 100644 --- a/ezlopi-services/ezlopi-service-gpioisr/ezlopi_service_gpioisr..c +++ b/ezlopi-services/ezlopi-service-gpioisr/ezlopi_service_gpioisr..c @@ -11,6 +11,7 @@ #include "ezlopi_core_device_value_updated.h" #include "ezlopi_service_gpioisr.h" +#include "EZLOPI_USER_CONFIG.h" static QueueHandle_t gpio_evt_queue = NULL; static const uint32_t default_debounce_time = 1000; diff --git a/ezlopi-services/ezlopi-service-meshbot/ezlopi_service_meshbot.c b/ezlopi-services/ezlopi-service-meshbot/ezlopi_service_meshbot.c index 977a21922..97469b60a 100644 --- a/ezlopi-services/ezlopi-service-meshbot/ezlopi_service_meshbot.c +++ b/ezlopi-services/ezlopi-service-meshbot/ezlopi_service_meshbot.c @@ -8,8 +8,9 @@ #include "ezlopi_cloud_constants.h" -#include "ezlopi_service_meshbot.h" #include "pt.h" +#include "ezlopi_service_meshbot.h" +#include "EZLOPI_USER_CONFIG.h" typedef struct s_thread_ctx { diff --git a/ezlopi-services/ezlopi-service-uart/ezlopi_service_uart.c b/ezlopi-services/ezlopi-service-uart/ezlopi_service_uart.c index 1f13c1a90..85737f230 100644 --- a/ezlopi-services/ezlopi-service-uart/ezlopi_service_uart.c +++ b/ezlopi-services/ezlopi-service-uart/ezlopi_service_uart.c @@ -21,12 +21,13 @@ #include "ezlopi_util_version.h" #include "ezlopi_core_nvs.h" +#include "ezlopi_core_net.h" #include "ezlopi_core_wifi.h" #include "ezlopi_core_reset.h" -#include "ezlopi_core_net.h" +#include "ezlopi_core_buffer.h" +#include "ezlopi_core_event_group.h" #include "ezlopi_core_factory_info.h" #include "ezlopi_core_cjson_macros.h" -#include "ezlopi_core_event_group.h" #include "ezlopi_hal_system_info.h" @@ -216,72 +217,115 @@ static void serial_init(void) uart_set_pin(UART_NUM_0, TXD_PIN, RXD_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE); } -static char* ezlopi_esp_reset_reason_str(esp_reset_reason_t reason) +static const char* ezlopi_esp_reset_reason_str(esp_reset_reason_t reason) { + const char * ret = ezlopi__str; + switch (reason) { case ESP_RST_UNKNOWN: - return "unknown"; + { + ret = "unknown"; break; + } case ESP_RST_POWERON: - return "Power ON"; + { + ret = "Power ON"; break; + } case ESP_RST_EXT: - return "External pin"; + { + ret = "External pin"; break; + } case ESP_RST_SW: - return "Software Reset via esp_restart"; + { + ret = "Software Reset via esp_restart"; break; + } case ESP_RST_PANIC: - return "Software reset due to exception/panic"; + { + ret = "Software reset due to exception/panic"; break; + } case ESP_RST_INT_WDT: - return "Interrupt watchdog"; + { + ret = "Interrupt watchdog"; break; + } case ESP_RST_TASK_WDT: - return "Task watchdog"; + { + ret = "Task watchdog"; break; + } case ESP_RST_WDT: - return "Other watchdogs"; + { + ret = "Other watchdogs"; break; + } case ESP_RST_DEEPSLEEP: - return "Reset after exiting deep sleep mode"; + { + ret = "Reset after exiting deep sleep mode"; break; + } case ESP_RST_BROWNOUT: - return "Brownout reset"; + { + ret = "Brownout reset"; break; + } case ESP_RST_SDIO: - return "Reset over SDIO"; + { + ret = "Reset over SDIO"; break; + } default: - return "unknown"; + { + ret = "unknown"; break; } + } + + return ret; } -static char* ezlopi_chip_type_str(int chip_type) +static const char* ezlopi_chip_type_str(int chip_type) { + const char * ret = ezlopi__str; switch (chip_type) { case CHIP_ESP32: - return "ESP32"; + { + ret = "ESP32"; break; + } case CHIP_ESP32S2: - return "ESP32-S2"; + { + ret = "ESP32-S2"; break; + } case CHIP_ESP32S3: - return "ESP32-S3"; + { + ret = "ESP32-S3"; break; + } case CHIP_ESP32C3: - return "ESP32-C3"; + { + ret = "ESP32-C3"; break; + } case CHIP_ESP32H2: - return "ESP32-H2"; + { + ret = "ESP32-H2"; break; + } default: - return "UNKNOWN"; + { + ret = "UNKNOWN"; break; } + } + + return ret; } static int ezlopi_service_uart_execute_command_0(cJSON* root) @@ -355,7 +399,7 @@ static int ezlopi_service_uart_read_uart_params(const cJSON* root) static int qt_serial_parse_rx_data(const char* data) { - cJSON* root = cJSON_Parse(data); + cJSON* root = cJSON_ParseWithRef(data); if (root) { @@ -422,34 +466,43 @@ static void ezlopi_service_uart_rx_task(void* arg) { static const char* RX_TASK_TAG = "RX_TASK"; esp_log_level_set(RX_TASK_TAG, ESP_LOG_INFO); - uint8_t* data = (uint8_t*)malloc(RX_BUF_SIZE + 1); - memset(data, 0, RX_BUF_SIZE + 1); - + while (1) { - int rxBytes = uart_read_bytes(UART_NUM_0, data, RX_BUF_SIZE, 1000 / portTICK_RATE_MS); + uint32_t buffer_len = 0; + char * buffer = ezlopi_core_buffer_acquire(&buffer_len, 5000); + if (buffer && buffer_len) + { + int rxBytes = uart_read_bytes(UART_NUM_0, buffer, buffer_len, 1000 / portTICK_RATE_MS); + + if (rxBytes > 0) + { + buffer[rxBytes] = 0; + TRACE_I("%s", buffer); + qt_serial_parse_rx_data((const char*)buffer); + } - if (rxBytes > 0) + ezlopi_core_buffer_release(); + } + else { - data[rxBytes] = 0; - TRACE_I("%s", data); - qt_serial_parse_rx_data((const char*)data); + TRACE_W("buffer acquiring failed!"); } } - free(data); vTaskDelete(NULL); } static int get_ezlopi_firmware_info(cJSON* parent) { int ret = 0; - cJSON* cj_firmware_info = cJSON_AddObjectToObject(parent, "ezlopi_firmware"); + static const char * _ezlopi_firmware_str = "ezlopi_firmware"; + cJSON* cj_firmware_info = cJSON_AddObjectToObjectWithRef(parent, _ezlopi_firmware_str); if (cj_firmware_info) { - cJSON_AddStringToObject(cj_firmware_info, ezlopi_version_str, VERSION_STR); - cJSON_AddNumberToObject(cj_firmware_info, ezlopi_build_str, BUILD); - cJSON_AddNumberToObject(cj_firmware_info, ezlopi_build_date_str, BUILD_DATE); + cJSON_AddStringToObjectWithRef(cj_firmware_info, ezlopi_version_str, VERSION_STR); + cJSON_AddNumberToObjectWithRef(cj_firmware_info, ezlopi_build_str, BUILD); + cJSON_AddNumberToObjectWithRef(cj_firmware_info, ezlopi_build_date_str, BUILD_DATE); ret = 1; } return ret; diff --git a/ezlopi-services/ezlopi-service-uri/ezlopi_service_uri.c b/ezlopi-services/ezlopi-service-uri/ezlopi_service_uri.c index a7c667692..2cf7b15e5 100755 --- a/ezlopi-services/ezlopi-service-uri/ezlopi_service_uri.c +++ b/ezlopi-services/ezlopi-service-uri/ezlopi_service_uri.c @@ -10,6 +10,7 @@ #include "dns_hijacking.h" #include "ezlopi_service_uri.h" +#include "EZLOPI_USER_CONFIG.h" static const char* error_page_data = "\ \ diff --git a/ezlopi-services/ezlopi-service-webprov/ezlopi_service_webprov.c b/ezlopi-services/ezlopi-service-webprov/ezlopi_service_webprov.c index 40df46d07..2bbd5a0a7 100644 --- a/ezlopi-services/ezlopi-service-webprov/ezlopi_service_webprov.c +++ b/ezlopi-services/ezlopi-service-webprov/ezlopi_service_webprov.c @@ -22,6 +22,7 @@ #include "ezlopi_core_ezlopi_broadcast.h" #include "ezlopi_service_webprov.h" +#include "EZLOPI_USER_CONFIG.h" #if defined(CONFIG_EZPI_WEBSOCKET_CLIENT) diff --git a/ezlopi-services/ezlopi-service-ws-server/ezlopi_service_ws_server.c b/ezlopi-services/ezlopi-service-ws-server/ezlopi_service_ws_server.c index 176c5db2e..0e1f1347d 100644 --- a/ezlopi-services/ezlopi-service-ws-server/ezlopi_service_ws_server.c +++ b/ezlopi-services/ezlopi-service-ws-server/ezlopi_service_ws_server.c @@ -35,6 +35,7 @@ #include "ezlopi_service_ws_server.h" #include "ezlopi_service_ws_server_clients.h" +#include "EZLOPI_USER_CONFIG.h" // #if defined(CONFIG_EZPI_LOCAL_WEBSOCKET_SERVER) diff --git a/ezlopi-services/ezlopi-service-ws-server/ezlopi_service_ws_server_clients.c b/ezlopi-services/ezlopi-service-ws-server/ezlopi_service_ws_server_clients.c index 52c607726..a545a7f9d 100644 --- a/ezlopi-services/ezlopi-service-ws-server/ezlopi_service_ws_server_clients.c +++ b/ezlopi-services/ezlopi-service-ws-server/ezlopi_service_ws_server_clients.c @@ -4,6 +4,7 @@ #include "ezlopi_util_trace.h" #include "ezlopi_service_ws_server.h" #include "ezlopi_service_ws_server_clients.h" +#include "EZLOPI_USER_CONFIG.h" static uint32_t __number_of_clients = 0; static l_ws_server_client_conn_t *l_client_conn_head = NULL; diff --git a/ezlopi-user-config/CMakeLists.txt b/ezlopi-user-config/CMakeLists.txt index 97774200d..267f2facd 100644 --- a/ezlopi-user-config/CMakeLists.txt +++ b/ezlopi-user-config/CMakeLists.txt @@ -1,4 +1,4 @@ - idf_component_register(SRCS INCLUDE_DIRS "." - ) + REQUIRES ezlopi-util-heap +) diff --git a/ezlopi-user-config/EZLOPI_USER_CONFIG.h b/ezlopi-user-config/EZLOPI_USER_CONFIG.h index a7a8fa843..44b0c8d29 100644 --- a/ezlopi-user-config/EZLOPI_USER_CONFIG.h +++ b/ezlopi-user-config/EZLOPI_USER_CONFIG.h @@ -3,6 +3,7 @@ #if 1 #include "../build/config/sdkconfig.h" +#include "ezlopi_util_heap.h" #if defined(CONFIG_EZPI_DISTRO_FULL_OPTION) #define CONFIG_EZPI_DISTRO_NAME "EZPI_DISTRO_FULL_OPTION" @@ -26,6 +27,30 @@ #define CONFIG_EZPI_DISTRO_NAME "EZLOPI_DISTRO_CUSTOM" #endif +#if defined(CONFIG_EZPI_HEAP_ENABLE) +#ifdef malloc +#undef malloc +#endif +#define malloc(x) ezlopi_util_heap_malloc(x, __FILENAME__, __LINE__) + +#ifdef calloc +#undef calloc +#endif +#define calloc(x, y) ezlopi_util_heap_calloc(x, y, __FILENAME__, __LINE__) + +#ifdef free +#undef free +#endif +#define free(x) ezlopi_util_heap_free(x, __FILENAME__, __LINE__) + +#ifdef realloc +#undef realloc +#endif +#define realloc(x, y) ezlopi_util_heap_realloc(x, y, __FILENAME__, __LINE__) + +#endif + + #define EZLOPI_SERIAL_API_VERSION "1.0.0" diff --git a/ezlopi-util/ezlopi-util-heap/CMakeLists.txt b/ezlopi-util/ezlopi-util-heap/CMakeLists.txt new file mode 100644 index 000000000..bf76c9a25 --- /dev/null +++ b/ezlopi-util/ezlopi-util-heap/CMakeLists.txt @@ -0,0 +1,10 @@ +# set(config_src "config.cpp") + +file(GLOB_RECURSE config_src "./*.c") + +idf_component_register(SRCS "${config_src}" + INCLUDE_DIRS "." + REQUIRES + ezlopi-util-trace + ezlopi-user-config +) \ No newline at end of file diff --git a/ezlopi-util/ezlopi-util-heap/ezlopi_util_heap.c b/ezlopi-util/ezlopi-util-heap/ezlopi_util_heap.c new file mode 100644 index 000000000..a43e3a317 --- /dev/null +++ b/ezlopi-util/ezlopi-util-heap/ezlopi_util_heap.c @@ -0,0 +1,184 @@ +#include +#include +#include + +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" + +#include "ezlopi_util_heap.h" + +typedef struct s_initiator { + const char * file_name; + uint32_t line_number; +} s_initiator_t; + +typedef struct s_heap_trace { + void* ptr; + bool freed; + uint32_t size; + uint32_t time_ms; + s_initiator_t freer; + s_initiator_t allocator; + + struct s_heap_trace* next; + +} s_heap_trace_t; + + +static s_heap_trace_t* heap_head = NULL; + +static s_heap_trace_t * __create_list(void); +static void __remove_node_if_freed(s_heap_trace_t * heap_node); + +void ezlopi_util_heap_free(void *ptr, const char * __file_name, uint32_t line_number) +{ + if (ptr) + { + s_heap_trace_t* curr_node = heap_head; + while (curr_node) + { + if ((curr_node->ptr == ptr) && (0 == curr_node->freed)) + { + printf("\x1B[34mfreed at %s:%u, size: %u\x1B[0m\r\n", __file_name, line_number, curr_node->size); + free(curr_node->ptr); + + curr_node->freed = true; + curr_node->time_ms = (xTaskGetTickCount() - curr_node->time_ms); + curr_node->freer.file_name = __file_name; + curr_node->freer.line_number = line_number; + break; + } + curr_node = curr_node->next; + } + + } +} + +void* ezlopi_util_heap_malloc(uint32_t size, const char * file_name, uint32_t line_no) +{ + void* ret = NULL; + + if (size) + { + s_heap_trace_t * new_heap = __create_list(); + if (new_heap) + { + // \x1B[%sm %s[%d]:" X "\x1B[0m\r\n" + printf("\x1B[34mmalloc at %s:%u, size: %u\x1B[0m\r\n", file_name, line_no, size); + ret = malloc(size); + if (ret) + { + new_heap->ptr = ret; + new_heap->size = size; + new_heap->allocator.file_name = file_name; + new_heap->allocator.line_number = line_no; + new_heap->time_ms = xTaskGetTickCount(); + } + } + } + + return ret; +} + +void* ezlopi_util_heap_calloc(uint32_t count, uint32_t size, const char * file_name, uint32_t line_no) +{ + return ezlopi_util_heap_malloc((count * size), file_name, line_no); +} + +void* ezlopi_util_heap_realloc(void *ptr, uint32_t new_size, const char * file_name, uint32_t line_no) +{ + printf("REALLOC\r\n"); + ezlopi_util_heap_free(ptr, file_name, line_no); + return ezlopi_util_heap_malloc(new_size, file_name, line_no); +} + +void ezlopi_util_heap_flush(void) +{ + __remove_node_if_freed(heap_head); + + if (heap_head->freed) + { + s_heap_trace_t * free_node = heap_head; + heap_head = heap_head->next; + free(free_node); + } +} + +void ezlopi_util_heap_trace(void) +{ + s_heap_trace_t * curr_node = heap_head; + + printf("\r\n\r\n**************************************************************************\r\n"); + printf("****************************** CURRENT HEAP ******************************\r\n"); + + uint32_t count = 0; + uint32_t total_allocated_memory = 0; + + while (curr_node) + { + if (curr_node->freed) + { + printf("%d. --\r\n", count); + printf("%s(%d): ptr: %u, size %u, hold-time-ms: %u\r\n", curr_node->allocator.file_name, curr_node->allocator.line_number, (uint32_t)curr_node->ptr, curr_node->size, curr_node->time_ms); + printf("%s(%d): freed.\r\n", curr_node->freer.file_name, curr_node->freer.line_number); + } + else + { + total_allocated_memory += curr_node->size; + // printf("\033[38:2:255:165:0m%d. --\x1B[0m\r\n", count); + printf("\033[38:2:255:165:0m%d -> %s(%d): ptr: %u, size %u, hold-time-ms: %u\x1B[0m\r\n", count, curr_node->allocator.file_name, curr_node->allocator.line_number, (uint32_t)curr_node->ptr, curr_node->size, (xTaskGetTickCount() - curr_node->time_ms)); + } + + curr_node = curr_node->next; + count++; + } + + printf("--------> total allocated ram: %u\r\n", total_allocated_memory); + printf("**************************************************************************\r\n\r\n\r\n"); +} + +/// @brief /////////////// +/// @param +/// @return +static s_heap_trace_t * __create_list(void) +{ + s_heap_trace_t* new_node = (s_heap_trace_t*)malloc(sizeof(s_heap_trace_t)); + + if (new_node) + { + memset(new_node, 0, sizeof(s_heap_trace_t)); + + if (heap_head) + { + s_heap_trace_t* curr_node = heap_head; + while (curr_node->next) + { + curr_node = curr_node->next; + } + + curr_node->next = new_node; + } + else + { + heap_head = new_node; + } + } + + return new_node; +} + + +static void __remove_node_if_freed(s_heap_trace_t * heap_node) +{ + if (heap_node->next) + { + __remove_node_if_freed(heap_node->next); + + if ( heap_node->next->freed) + { + s_heap_trace_t * free_node = heap_node->next; + heap_node->next = heap_node->next->next; + free(free_node); + } + } +} \ No newline at end of file diff --git a/ezlopi-util/ezlopi-util-heap/ezlopi_util_heap.h b/ezlopi-util/ezlopi-util-heap/ezlopi_util_heap.h new file mode 100644 index 000000000..c6e9d1050 --- /dev/null +++ b/ezlopi-util/ezlopi-util-heap/ezlopi_util_heap.h @@ -0,0 +1,16 @@ +#ifndef __EZLOPI_UTIL_HEAP_TRACE_H__ +#define __EZLOPI_UTIL_HEAP_TRACE_H__ + +#include +#include +#include + +void ezlopi_util_heap_flush(void); +void ezlopi_util_heap_trace(void); + +void ezlopi_util_heap_free(void *ptr, const char * __file_name, uint32_t line_number); +void* ezlopi_util_heap_malloc(uint32_t size, const char * file_name, uint32_t line_no); +void* ezlopi_util_heap_calloc(uint32_t count, uint32_t size, const char * file_name, uint32_t line_no); +void* ezlopi_util_heap_realloc(void *ptr, uint32_t new_size, const char * file_name, uint32_t line_no); + +#endif // __EZLOPI_UTIL_HEAP_TRACE_H__ diff --git a/shell_script/provision_write.sh b/shell_script/provision_write.sh index dc3f98e7d..20153c1de 100644 --- a/shell_script/provision_write.sh +++ b/shell_script/provision_write.sh @@ -1,2 +1,29 @@ . ~/esp/esp-idf/export.sh -esptool.py -p /dev/ttyUSB0 -b 921600 write_flash 0x18000 ./shell_script/prov_102002011.bin \ No newline at end of file + + +speed=921600 +port="/dev/ttyUSB0" +bin="prov_102002011.bin" + +while getopts s:p:b:h: flag +do + case "${flag}" in + s) speed=${OPTARG};; + p) port=${OPTARG};; + b) bin=${OPTARG};; + h) echo "run ${0}