diff --git a/components/esp_rainmaker/CHANGELOG.md b/components/esp_rainmaker/CHANGELOG.md index b1756c9..7be28f7 100644 --- a/components/esp_rainmaker/CHANGELOG.md +++ b/components/esp_rainmaker/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 1.7.0 + +### Other changes + +- Removed legacy code for esp idf versions < 5.1 as they have reached their end of life. + ## 1.6.7 ### Minor Change diff --git a/components/esp_rainmaker/CMakeLists.txt b/components/esp_rainmaker/CMakeLists.txt index 1cd4609..53f3b6d 100644 --- a/components/esp_rainmaker/CMakeLists.txt +++ b/components/esp_rainmaker/CMakeLists.txt @@ -18,22 +18,14 @@ set(core_srcs "src/core/esp_rmaker_core.c" set(priv_req protobuf-c json_parser json_generator nvs_flash esp_http_client app_update esp-tls mbedtls esp_https_ota - console esp_local_ctrl esp_https_server mdns esp_schedule efuse driver rmaker_common wifi_provisioning) + console esp_local_ctrl esp_https_server mdns esp_schedule efuse driver rmaker_common) # Add CBOR for MQTT OTA support if (CONFIG_ESP_RMAKER_OTA_USE_MQTT) list(APPEND priv_req cbor) endif() -if ("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "5.0") - list(APPEND priv_req esp_app_format) -endif() - -if ("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "5.1") - # NAT64 and DNS64 features were introduced for openthread component in IDF v5.1 - # Network Provisioning component is supported for IDF v5.1+ - list(APPEND priv_req openthread network_provisioning) -endif() +list(APPEND priv_req esp_app_format openthread network_provisioning) if(CONFIG_ESP_RMAKER_ENABLE_CHALLENGE_RESPONSE) list(APPEND core_srcs diff --git a/components/esp_rainmaker/Kconfig.projbuild b/components/esp_rainmaker/Kconfig.projbuild index b7c1feb..011bb31 100644 --- a/components/esp_rainmaker/Kconfig.projbuild +++ b/components/esp_rainmaker/Kconfig.projbuild @@ -494,12 +494,5 @@ menu "ESP RainMaker Config" endmenu - config ESP_RMAKER_USING_NETWORK_PROV - bool "Using Network Provisioning" - default y - help - RainMaker will use network_provisioning component to provision a device to a Wi-Fi/Thread network if enabling this option. - If the option is not enabled, it will use wifi_provisioning instead. This option only works when IDF verson is later than - v5.1. endmenu diff --git a/components/esp_rainmaker/idf_component.yml b/components/esp_rainmaker/idf_component.yml index 74a2493..01f6398 100644 --- a/components/esp_rainmaker/idf_component.yml +++ b/components/esp_rainmaker/idf_component.yml @@ -1,5 +1,5 @@ ## IDF Component Manager Manifest File -version: "1.6.7" +version: "1.7.0" description: ESP RainMaker firmware agent url: https://github.com/espressif/esp-rainmaker/tree/master/components/esp_rainmaker repository: https://github.com/espressif/esp-rainmaker.git @@ -7,30 +7,24 @@ issues: https://github.com/espressif/esp-rainmaker/issues documentation: https://rainmaker.espressif.com/ discussion: https://www.esp32.com/viewforum.php?f=41 dependencies: + idf: ">=5.1" espressif/mdns: version: "^1.2.0" - rules: - - if: "idf_version >=5.0" espressif/esp_secure_cert_mgr: version: "^2.2.1" - rules: - - if: "idf_version >=4.3" espressif/rmaker_common: - version: "~1.4.12" + version: "~1.5.0" espressif/json_parser: version: "~1.0.3" espressif/json_generator: version: "~1.1.1" espressif/esp_schedule: - version: "~1.2.0" + version: "~1.3.0" + override_path: '../esp_schedule' espressif/network_provisioning: version: "~1.0.0" - rules: - - if: "idf_version >= 5.1" espressif/esp_rcp_update: # This allows all the minor version updates version: "^1.2.0" - rules: - - if: "idf_version >= 5.1" espressif/cbor: version: "~0.6" diff --git a/components/esp_rainmaker/src/console/esp_rmaker_commands.c b/components/esp_rainmaker/src/console/esp_rmaker_commands.c index a5a3a46..ea7de4a 100644 --- a/components/esp_rainmaker/src/console/esp_rmaker_commands.c +++ b/components/esp_rainmaker/src/console/esp_rmaker_commands.c @@ -26,11 +26,7 @@ #include #include -#if RMAKER_USING_NETWORK_PROV #include -#else -#include -#endif static const char *TAG = "esp_rmaker_commands"; @@ -91,17 +87,9 @@ static int wifi_prov_handler(int argc, char** argv) /* If device is still provisioning, use network_prov_mgr_configure_wifi_sta/wifi_prov_mgr_configure_sta */ bool provisioned = false; -#if RMAKER_USING_NETWORK_PROV network_prov_mgr_is_wifi_provisioned(&provisioned); -#else - wifi_prov_mgr_is_provisioned(&provisioned); -#endif if (!provisioned) { // provisioning in progress -#if RMAKER_USING_NETWORK_PROV network_prov_mgr_configure_wifi_sta(&wifi_config); -#else - wifi_prov_mgr_configure_sta(&wifi_config); -#endif return ESP_OK; } diff --git a/components/esp_rainmaker/src/core/esp_rmaker_chal_resp.c b/components/esp_rainmaker/src/core/esp_rmaker_chal_resp.c index 7fb73a3..2197ab0 100644 --- a/components/esp_rainmaker/src/core/esp_rmaker_chal_resp.c +++ b/components/esp_rainmaker/src/core/esp_rmaker_chal_resp.c @@ -10,11 +10,7 @@ #include "esp_rmaker_chal_resp.pb-c.h" #include "esp_rmaker_internal.h" #include -#if RMAKER_USING_NETWORK_PROV #include -#else -#include -#endif static const char *TAG = "esp_rmaker_chal_resp"; @@ -196,27 +192,18 @@ cleanup: esp_err_t esp_rmaker_chal_resp_endpoint_create(void) { -#if RMAKER_USING_NETWORK_PROV return network_prov_mgr_endpoint_create(CHAL_RESP_ENDPOINT); -#else - return wifi_prov_mgr_endpoint_create(CHAL_RESP_ENDPOINT); -#endif } esp_err_t esp_rmaker_chal_resp_endpoint_register(void) { -#if RMAKER_USING_NETWORK_PROV return network_prov_mgr_endpoint_register(CHAL_RESP_ENDPOINT, esp_rmaker_chal_resp_handler, NULL); -#else - return wifi_prov_mgr_endpoint_register(CHAL_RESP_ENDPOINT, esp_rmaker_chal_resp_handler, NULL); -#endif } static void esp_rmaker_chal_resp_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data) { static const char *capabilities[] = {"ch_resp"}; -#if RMAKER_USING_NETWORK_PROV if (event_base == NETWORK_PROV_EVENT) { switch (event_id) { case NETWORK_PROV_INIT: { @@ -236,57 +223,23 @@ static void esp_rmaker_chal_resp_event_handler(void *arg, esp_event_base_t event break; } } -#else - if (event_base == WIFI_PROV_EVENT) { - switch (event_id) { - case WIFI_PROV_INIT: { - wifi_prov_mgr_set_app_info(RMAKER_EXTRA_APP_NAME, RMAKER_EXTRA_APP_VERSION, capabilities, 1); - if (esp_rmaker_chal_resp_endpoint_create() != ESP_OK) { - ESP_LOGE(TAG, "Failed to create challenge response endpoint."); - } - break; - } - case WIFI_PROV_START: { - if (esp_rmaker_chal_resp_endpoint_register() != ESP_OK) { - ESP_LOGE(TAG, "Failed to register challenge response endpoint."); - } - break; - } - default: - break; - } - } -#endif /* RMAKER_USING_NETWORK_PROV */ } esp_err_t esp_rmaker_chal_resp_init(void) { /* Register for Wi-Fi Provisioning events */ -#if RMAKER_USING_NETWORK_PROV esp_err_t err = esp_event_handler_register(NETWORK_PROV_EVENT, NETWORK_PROV_INIT, &esp_rmaker_chal_resp_event_handler, NULL); if (err != ESP_OK) { return err; } err = esp_event_handler_register(NETWORK_PROV_EVENT, NETWORK_PROV_START, &esp_rmaker_chal_resp_event_handler, NULL); -#else - esp_err_t err = esp_event_handler_register(WIFI_PROV_EVENT, WIFI_PROV_INIT, &esp_rmaker_chal_resp_event_handler, NULL); - if (err != ESP_OK) { - return err; - } - err = esp_event_handler_register(WIFI_PROV_EVENT, WIFI_PROV_START, &esp_rmaker_chal_resp_event_handler, NULL); -#endif return err; } esp_err_t esp_rmaker_chal_resp_deinit(void) { /* Unregister the event handler */ -#if RMAKER_USING_NETWORK_PROV esp_event_handler_unregister(NETWORK_PROV_EVENT, NETWORK_PROV_INIT, &esp_rmaker_chal_resp_event_handler); esp_event_handler_unregister(NETWORK_PROV_EVENT, NETWORK_PROV_START, &esp_rmaker_chal_resp_event_handler); -#else - esp_event_handler_unregister(WIFI_PROV_EVENT, WIFI_PROV_INIT, &esp_rmaker_chal_resp_event_handler); - esp_event_handler_unregister(WIFI_PROV_EVENT, WIFI_PROV_START, &esp_rmaker_chal_resp_event_handler); -#endif return ESP_OK; } diff --git a/components/esp_rainmaker/src/core/esp_rmaker_claim.c b/components/esp_rainmaker/src/core/esp_rmaker_claim.c index ec1e99e..a544a07 100644 --- a/components/esp_rainmaker/src/core/esp_rmaker_claim.c +++ b/components/esp_rainmaker/src/core/esp_rmaker_claim.c @@ -55,31 +55,14 @@ #include "esp_rmaker_client_data.h" #include "esp_rmaker_claim.h" -#if RMAKER_USING_NETWORK_PROV #include -#else -#include -#endif - -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 4, 0) -// Features supported in 4.4+ #ifdef CONFIG_ESP_RMAKER_USE_CERT_BUNDLE #define ESP_RMAKER_USE_CERT_BUNDLE #include #endif -#else - -#ifdef CONFIG_ESP_RMAKER_USE_CERT_BUNDLE -#warning "Certificate Bundle not supported below IDF v4.4. Using provided certificate instead." -#endif - -#endif /* !IDF4.4 */ - -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0) #include "esp_mac.h" -#endif static const char *TAG = "esp_claim"; @@ -288,18 +271,10 @@ static esp_err_t generate_claim_init_request(esp_rmaker_claim_data_t *claim_data return ESP_ERR_INVALID_STATE; } uint8_t mac_addr[6]; -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0) - /* ESP_MAC_BASE was introduced in ESP-IDF v5.1. It is the same as the Wi-Fi Station MAC address - * for chips supporting Wi-Fi. We can use base MAC address to generate claim init request for both + /* ESP_MAC_BASE provides the base MAC address for all chips, supporting both * Wi-Fi and Thread devices */ esp_err_t err = esp_read_mac(mac_addr, ESP_MAC_BASE); -#else - /* Thread was officially supported in ESP-IDF v5.1. Use Wi-Fi Station MAC address to generate claim - * init request. - */ - esp_err_t err = esp_wifi_get_mac(WIFI_IF_STA, mac_addr); -#endif if (err != ESP_OK) { ESP_LOGE(TAG, "Could not fetch MAC address."); return err; @@ -828,7 +803,6 @@ esp_err_t esp_rmaker_claiming_handler(uint32_t session_id, const uint8_t *inbuf, static void event_handler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data) { -#if RMAKER_USING_NETWORK_PROV if (event_base == NETWORK_PROV_EVENT) { switch (event_id) { case NETWORK_PROV_INIT: { @@ -848,27 +822,6 @@ static void event_handler(void* arg, esp_event_base_t event_base, break; } } -#else - if (event_base == WIFI_PROV_EVENT) { - switch (event_id) { - case WIFI_PROV_INIT: { - static const char *capabilities[] = {"claim"}; - wifi_prov_mgr_set_app_info("rmaker", "1.0", capabilities, 1); - if (wifi_prov_mgr_endpoint_create(CLAIM_ENDPOINT) != ESP_OK) { - ESP_LOGE(TAG, "Failed to create claim end point."); - } - break; - } - case WIFI_PROV_START: - if (wifi_prov_mgr_endpoint_register(CLAIM_ENDPOINT, esp_rmaker_claiming_handler, arg) != ESP_OK) { - ESP_LOGE(TAG, "Failed to register claim end point."); - } - break; - default: - break; - } - } -#endif /* RMAKER_USING_NETWORK_PROV */ } #endif /* CONFIG_ESP_RMAKER_ASSISTED_CLAIM */ esp_err_t __esp_rmaker_claim_init(esp_rmaker_claim_data_t *claim_data) @@ -1012,13 +965,8 @@ esp_err_t esp_rmaker_assisted_claim_perform(esp_rmaker_claim_data_t *claim_data) if (claim_data->state == RMAKER_CLAIM_STATE_VERIFY_DONE) { err = ESP_OK; } -#if RMAKER_USING_NETWORK_PROV esp_event_handler_unregister(NETWORK_PROV_EVENT, NETWORK_PROV_INIT, &event_handler); esp_event_handler_unregister(NETWORK_PROV_EVENT, NETWORK_PROV_START, &event_handler); -#else - esp_event_handler_unregister(WIFI_PROV_EVENT, WIFI_PROV_INIT, &event_handler); - esp_event_handler_unregister(WIFI_PROV_EVENT, WIFI_PROV_START, &event_handler); -#endif esp_rmaker_claim_data_free(claim_data); vEventGroupDelete(claim_event_group); return err; @@ -1028,13 +976,8 @@ esp_rmaker_claim_data_t *esp_rmaker_assisted_claim_init(void) ESP_LOGI(TAG, "Initialising Assisted Claiming. This may take time."); esp_rmaker_claim_data_t *claim_data = esp_rmaker_claim_init(); if (claim_data) { -#if RMAKER_USING_NETWORK_PROV esp_event_handler_register(NETWORK_PROV_EVENT, NETWORK_PROV_INIT, &event_handler, claim_data); esp_event_handler_register(NETWORK_PROV_EVENT, NETWORK_PROV_START, &event_handler, claim_data); -#else - esp_event_handler_register(WIFI_PROV_EVENT, WIFI_PROV_INIT, &event_handler, claim_data); - esp_event_handler_register(WIFI_PROV_EVENT, WIFI_PROV_START, &event_handler, claim_data); -#endif } return claim_data; } diff --git a/components/esp_rainmaker/src/core/esp_rmaker_core.c b/components/esp_rainmaker/src/core/esp_rmaker_core.c index 57e39df..ab28589 100644 --- a/components/esp_rainmaker/src/core/esp_rmaker_core.c +++ b/components/esp_rainmaker/src/core/esp_rmaker_core.c @@ -50,9 +50,7 @@ static const int WIFI_CONNECTED_EVENT = BIT0; static const int THREAD_SET_DNS_SEVER_EVENT = BIT0; #endif -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0) #include "esp_mac.h" -#endif static const int MQTT_CONNECTED_EVENT = BIT1; static EventGroupHandle_t rmaker_core_event_group; @@ -185,18 +183,10 @@ static char *esp_rmaker_populate_node_id(bool use_claiming) #ifdef ESP_RMAKER_CLAIM_ENABLED if (!node_id && use_claiming) { uint8_t mac_addr[6]; -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0) - /* ESP_MAC_BASE was introduced in ESP-IDF v5.1. It is the same as the Wi-Fi Station MAC address - * for chips supporting Wi-Fi. We can use base MAC address to generate claim init request for both + /* ESP_MAC_BASE provides the base MAC address for all chips, supporting both * Wi-Fi and Thread devices */ esp_err_t err = esp_read_mac(mac_addr, ESP_MAC_BASE); -#else - /* Thread was officially supported in ESP-IDF v5.1. Use Wi-Fi Station MAC address to generate claim - * init request. - */ - esp_err_t err = esp_wifi_get_mac(WIFI_IF_STA, mac_addr); -#endif if (err != ESP_OK) { ESP_LOGE(TAG, "Could not fetch MAC address."); diff --git a/components/esp_rainmaker/src/core/esp_rmaker_internal.h b/components/esp_rainmaker/src/core/esp_rmaker_internal.h index 035db18..d351961 100644 --- a/components/esp_rainmaker/src/core/esp_rmaker_internal.h +++ b/components/esp_rainmaker/src/core/esp_rmaker_internal.h @@ -23,11 +23,6 @@ #define RMAKER_PARAM_FLAG_VALUE_NOTIFY (1 << 1) #define ESP_RMAKER_NVS_PART_NAME "nvs" -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0) && defined(CONFIG_ESP_RMAKER_USING_NETWORK_PROV) -#define RMAKER_USING_NETWORK_PROV 1 -#else -#define RMAKER_USING_NETWORK_PROV 0 -#endif typedef enum { ESP_RMAKER_STATE_DEINIT = 0, diff --git a/components/esp_rainmaker/src/core/esp_rmaker_local_ctrl.c b/components/esp_rainmaker/src/core/esp_rmaker_local_ctrl.c index 44de249..a64000a 100644 --- a/components/esp_rainmaker/src/core/esp_rmaker_local_ctrl.c +++ b/components/esp_rainmaker/src/core/esp_rmaker_local_ctrl.c @@ -35,26 +35,10 @@ #include -#if RMAKER_USING_NETWORK_PROV #include -#else -#include -#endif - -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 2, 0) -// Features supported in 4.2 #define ESP_RMAKER_LOCAL_CTRL_SECURITY_TYPE CONFIG_ESP_RMAKER_LOCAL_CTRL_SECURITY -#else - -#if CONFIG_ESP_RMAKER_LOCAL_CTRL_SECURITY != 0 -#warning "Local control security type is not supported in idf versions below 4.2. Using sec0 by default." -#endif -#define ESP_RMAKER_LOCAL_CTRL_SECURITY_TYPE 0 - -#endif /* !IDF4.2 */ - static const char * TAG = "esp_rmaker_local"; /* Random Port number that will be used by the local control http instance @@ -426,11 +410,7 @@ static esp_err_t __esp_rmaker_start_local_ctrl_service(const char *serv_name) }; /* If sec1, add security type details to the config */ -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) #define PROTOCOMM_SEC_DATA protocomm_security1_params_t -#else -#define PROTOCOMM_SEC_DATA protocomm_security_pop_t -#endif /* ESP_IDF_VERSION */ PROTOCOMM_SEC_DATA *pop = NULL; #if ESP_RMAKER_LOCAL_CTRL_SECURITY_TYPE == 1 char *pop_str = esp_rmaker_local_ctrl_get_pop(); @@ -451,11 +431,7 @@ static esp_err_t __esp_rmaker_start_local_ctrl_service(const char *serv_name) config.proto_sec.version = sec_ver; config.proto_sec.custom_handle = NULL; -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) config.proto_sec.sec_params = pop; -#else - config.proto_sec.pop = pop; -#endif /* ESP_IDF_VERSION */ #endif /* Start esp_local_ctrl service */ @@ -513,24 +489,12 @@ static void esp_rmaker_local_ctrl_prov_event_handler(void* arg, esp_event_base_t int32_t event_id, void* event_data) { ESP_LOGI(TAG, "Event %"PRIu32, event_id); -#if RMAKER_USING_NETWORK_PROV if (event_base == NETWORK_PROV_EVENT) { -#else - if (event_base == WIFI_PROV_EVENT) { -#endif switch (event_id) { -#if RMAKER_USING_NETWORK_PROV case NETWORK_PROV_START: -#else - case WIFI_PROV_START: -#endif wait_for_provisioning = true; break; -#if RMAKER_USING_NETWORK_PROV case NETWORK_PROV_DEINIT: -#else - case WIFI_PROV_DEINIT: -#endif if (wait_for_provisioning == true) { wait_for_provisioning = false; if (g_serv_name) { @@ -539,13 +503,8 @@ static void esp_rmaker_local_ctrl_prov_event_handler(void* arg, esp_event_base_t g_serv_name = NULL; } } -#if RMAKER_USING_NETWORK_PROV esp_event_handler_unregister(NETWORK_PROV_EVENT, NETWORK_PROV_START, &esp_rmaker_local_ctrl_prov_event_handler); esp_event_handler_unregister(NETWORK_PROV_EVENT, NETWORK_PROV_DEINIT, &esp_rmaker_local_ctrl_prov_event_handler); -#else - esp_event_handler_unregister(WIFI_PROV_EVENT, WIFI_PROV_START, &esp_rmaker_local_ctrl_prov_event_handler); - esp_event_handler_unregister(WIFI_PROV_EVENT, WIFI_PROV_DEINIT, &esp_rmaker_local_ctrl_prov_event_handler); -#endif break; default: break; @@ -569,13 +528,8 @@ esp_err_t esp_rmaker_init_local_ctrl_service(void) * what provisioning transport is being used and hence this logic will come into picture for both, * SoftAP and BLE provisioning. */ -#if RMAKER_USING_NETWORK_PROV esp_event_handler_register(NETWORK_PROV_EVENT, NETWORK_PROV_START, &esp_rmaker_local_ctrl_prov_event_handler, NULL); esp_event_handler_register(NETWORK_PROV_EVENT, NETWORK_PROV_DEINIT, &esp_rmaker_local_ctrl_prov_event_handler, NULL); -#else - esp_event_handler_register(WIFI_PROV_EVENT, WIFI_PROV_START, &esp_rmaker_local_ctrl_prov_event_handler, NULL); - esp_event_handler_register(WIFI_PROV_EVENT, WIFI_PROV_DEINIT, &esp_rmaker_local_ctrl_prov_event_handler, NULL); -#endif return ESP_OK; } @@ -618,13 +572,8 @@ esp_err_t esp_rmaker_local_ctrl_disable(void) free(g_serv_name); g_serv_name = NULL; } -#if RMAKER_USING_NETWORK_PROV esp_event_handler_unregister(NETWORK_PROV_EVENT, NETWORK_PROV_START, &esp_rmaker_local_ctrl_prov_event_handler); esp_event_handler_unregister(NETWORK_PROV_EVENT, NETWORK_PROV_DEINIT, &esp_rmaker_local_ctrl_prov_event_handler); -#else - esp_event_handler_unregister(WIFI_PROV_EVENT, WIFI_PROV_START, &esp_rmaker_local_ctrl_prov_event_handler); - esp_event_handler_unregister(WIFI_PROV_EVENT, WIFI_PROV_DEINIT, &esp_rmaker_local_ctrl_prov_event_handler); -#endif if (!g_local_ctrl_is_started) { return ESP_OK; } diff --git a/components/esp_rainmaker/src/core/esp_rmaker_node.c b/components/esp_rainmaker/src/core/esp_rmaker_node.c index 04a5131..3c2d9ff 100644 --- a/components/esp_rainmaker/src/core/esp_rmaker_node.c +++ b/components/esp_rainmaker/src/core/esp_rmaker_node.c @@ -15,11 +15,7 @@ #include #include "esp_idf_version.h" #include -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) #include -#else -#include -#endif #include #include #include @@ -131,11 +127,7 @@ esp_rmaker_node_t *esp_rmaker_node_create(const char *name, const char *type) node->info->name = strdup(name); node->info->type = strdup(type); const esp_app_desc_t *app_desc; -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) app_desc = esp_app_get_description(); -#else - app_desc = esp_ota_get_app_description(); -#endif node->info->fw_version = strdup(app_desc->version); node->info->model = strdup(app_desc->project_name); if (esp_secure_boot_enabled()) { diff --git a/components/esp_rainmaker/src/core/esp_rmaker_node_auth.c b/components/esp_rainmaker/src/core/esp_rmaker_node_auth.c index ab2c90c..7c0a5c7 100644 --- a/components/esp_rainmaker/src/core/esp_rmaker_node_auth.c +++ b/components/esp_rainmaker/src/core/esp_rmaker_node_auth.c @@ -3,8 +3,6 @@ * * SPDX-License-Identifier: Apache-2.0 */ -#include -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 4, 0) #include #include #include "mbedtls/platform.h" @@ -91,11 +89,7 @@ esp_err_t esp_rmaker_node_auth_sign_msg(const void *challenge, size_t inlen, voi /* Sign the hash using RSA or ECDSA */ mbedtls_pk_context pk_ctx; mbedtls_pk_init(&pk_ctx); -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) int ret = mbedtls_pk_parse_key(&pk_ctx, (uint8_t *)priv_key, priv_key_len, NULL, 0, NULL, 0); -#else /* !(ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)) */ - int ret = mbedtls_pk_parse_key(&pk_ctx, (uint8_t *)priv_key, priv_key_len, NULL, 0); -#endif /* ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) */ uint8_t *signature = NULL; if (mbedtls_pk_get_type(&pk_ctx) == MBEDTLS_PK_RSA) { ESP_LOGI(TAG, "RSA key found"); @@ -113,11 +107,7 @@ esp_err_t esp_rmaker_node_auth_sign_msg(const void *challenge, size_t inlen, voi } size_t slen = 0; if (mbedtls_pk_get_type(&pk_ctx) == MBEDTLS_PK_ECKEY) { -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) ret = mbedtls_ecdsa_write_signature(mbedtls_pk_ec(pk_ctx), MBEDTLS_MD_SHA256, hash, sizeof(hash), signature, MBEDTLS_ECDSA_MAX_LEN, &slen, myrand, NULL); -#else /* !(ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)) */ - ret = mbedtls_ecdsa_write_signature(mbedtls_pk_ec(pk_ctx), MBEDTLS_MD_SHA256, hash, sizeof(hash), signature, &slen, myrand, NULL); -#endif /* (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)) */ if (ret != 0) { ESP_LOGE(TAG, "Error in writing signature. err = %d", ret); free(signature); @@ -188,4 +178,3 @@ esp_err_t esp_rmaker_node_auth_sign_msg(const void *challenge, size_t inlen, voi *outlen = 2 * slen; /* hex encoding takes 2 bytes per input byte */ return ESP_OK; } -#endif /* ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 3, 0) */ diff --git a/components/esp_rainmaker/src/core/esp_rmaker_node_config.c b/components/esp_rainmaker/src/core/esp_rmaker_node_config.c index df279d1..372a6ec 100644 --- a/components/esp_rainmaker/src/core/esp_rmaker_node_config.c +++ b/components/esp_rainmaker/src/core/esp_rmaker_node_config.c @@ -22,11 +22,7 @@ #include "esp_rmaker_mqtt_topics.h" #include -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) #include -#else -#include -#endif #define NODE_CONFIG_TOPIC_SUFFIX "config" @@ -46,11 +42,7 @@ static esp_err_t esp_rmaker_report_info(json_gen_str_t *jptr) } json_gen_obj_set_string(jptr, "model", info->model); const esp_app_desc_t *app_desc; -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) app_desc = esp_app_get_description(); -#else - app_desc = esp_ota_get_app_description(); -#endif json_gen_obj_set_string(jptr, "project_name", (char *)app_desc->project_name); json_gen_obj_set_string(jptr, "platform", CONFIG_IDF_TARGET); #ifdef CONFIG_SECURE_BOOT_V2_ENABLED diff --git a/components/esp_rainmaker/src/core/esp_rmaker_secure_boot_digest.c b/components/esp_rainmaker/src/core/esp_rmaker_secure_boot_digest.c index bb0ed95..6b0fe9d 100644 --- a/components/esp_rainmaker/src/core/esp_rmaker_secure_boot_digest.c +++ b/components/esp_rainmaker/src/core/esp_rmaker_secure_boot_digest.c @@ -47,17 +47,9 @@ esp_err_t esp_rmaker_secure_boot_digest_free(char **digest) char** esp_rmaker_get_secure_boot_digest() { char **secure_boot_digest = NULL; -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) esp_secure_boot_key_digests_t trusted_keys; -#else - ets_secure_boot_key_digests_t trusted_keys; -#endif -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 4, 0) esp_err_t ret = esp_secure_boot_read_key_digests(&trusted_keys); -#else - esp_err_t ret = ets_secure_boot_read_key_digests(&trusted_keys); -#endif if (ret != ESP_OK) { ESP_LOGE(TAG, "Could not read the secure boot key digests from efuse."); return NULL; diff --git a/components/esp_rainmaker/src/core/esp_rmaker_user_mapping.c b/components/esp_rainmaker/src/core/esp_rmaker_user_mapping.c index 8d8b5ed..50275a6 100644 --- a/components/esp_rainmaker/src/core/esp_rmaker_user_mapping.c +++ b/components/esp_rainmaker/src/core/esp_rmaker_user_mapping.c @@ -29,11 +29,7 @@ #include "esp_rmaker_user_mapping.pb-c.h" #include "esp_rmaker_internal.h" #include "esp_rmaker_mqtt_topics.h" -#if RMAKER_USING_NETWORK_PROV #include -#else -#include -#endif static const char *TAG = "esp_rmaker_user_mapping"; @@ -167,7 +163,6 @@ static void user_mapping_schedule_retry(void) static void esp_rmaker_user_mapping_event_handler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data) { -#if RMAKER_USING_NETWORK_PROV if (event_base == NETWORK_PROV_EVENT) { switch (event_id) { case NETWORK_PROV_INIT: { @@ -184,24 +179,6 @@ static void esp_rmaker_user_mapping_event_handler(void* arg, esp_event_base_t ev default: break; } -#else - if (event_base == WIFI_PROV_EVENT) { - switch (event_id) { - case WIFI_PROV_INIT: { - if (esp_rmaker_user_mapping_endpoint_create() != ESP_OK) { - ESP_LOGE(TAG, "Failed to create user mapping end point."); - } - break; - } - case WIFI_PROV_START: - if (esp_rmaker_user_mapping_endpoint_register() != ESP_OK) { - ESP_LOGE(TAG, "Failed to register user mapping end point."); - } - break; - default: - break; - } -#endif } else if ((event_base == RMAKER_COMMON_EVENT) && (event_id == RMAKER_MQTT_EVENT_PUBLISHED)) { /* Checking for the PUBACK for the user node association message to be sure that the message * has indeed reached the RainMaker cloud. @@ -468,51 +445,30 @@ int esp_rmaker_user_mapping_handler(uint32_t session_id, const uint8_t *inbuf, s } esp_err_t esp_rmaker_user_mapping_endpoint_create(void) { -#if RMAKER_USING_NETWORK_PROV esp_err_t err = network_prov_mgr_endpoint_create(USER_MAPPING_ENDPOINT); -#else - esp_err_t err = wifi_prov_mgr_endpoint_create(USER_MAPPING_ENDPOINT); -#endif return err; } esp_err_t esp_rmaker_user_mapping_endpoint_register(void) { -#if RMAKER_USING_NETWORK_PROV return network_prov_mgr_endpoint_register(USER_MAPPING_ENDPOINT, esp_rmaker_user_mapping_handler, NULL); -#else - return wifi_prov_mgr_endpoint_register(USER_MAPPING_ENDPOINT, esp_rmaker_user_mapping_handler, NULL); -#endif } esp_err_t esp_rmaker_user_mapping_prov_init(void) { int ret = ESP_OK; -#if RMAKER_USING_NETWORK_PROV ret = esp_event_handler_register(NETWORK_PROV_EVENT, NETWORK_PROV_INIT, &esp_rmaker_user_mapping_event_handler, NULL); -#else - ret = esp_event_handler_register(WIFI_PROV_EVENT, WIFI_PROV_INIT,&esp_rmaker_user_mapping_event_handler, NULL); -#endif if (ret != ESP_OK) { return ret; } -#if RMAKER_USING_NETWORK_PROV ret = esp_event_handler_register(NETWORK_PROV_EVENT, NETWORK_PROV_START, &esp_rmaker_user_mapping_event_handler, NULL); -#else - ret = esp_event_handler_register(WIFI_PROV_EVENT, WIFI_PROV_START,&esp_rmaker_user_mapping_event_handler, NULL); -#endif return ret; } esp_err_t esp_rmaker_user_mapping_prov_deinit(void) { -#if RMAKER_USING_NETWORK_PROV esp_event_handler_unregister(NETWORK_PROV_EVENT, NETWORK_PROV_INIT, &esp_rmaker_user_mapping_event_handler); esp_event_handler_unregister(NETWORK_PROV_EVENT, NETWORK_PROV_START, &esp_rmaker_user_mapping_event_handler); -#else - esp_event_handler_unregister(WIFI_PROV_EVENT, WIFI_PROV_INIT, &esp_rmaker_user_mapping_event_handler); - esp_event_handler_unregister(WIFI_PROV_EVENT, WIFI_PROV_START, &esp_rmaker_user_mapping_event_handler); -#endif return ESP_OK; } diff --git a/components/esp_rainmaker/src/ota/esp_rmaker_ota.c b/components/esp_rainmaker/src/ota/esp_rmaker_ota.c index e358446..c5f4213 100644 --- a/components/esp_rainmaker/src/ota/esp_rmaker_ota.c +++ b/components/esp_rainmaker/src/ota/esp_rmaker_ota.c @@ -39,21 +39,10 @@ static esp_err_t esp_rmaker_ota_handle_metadata_common(esp_rmaker_ota_handle_t o static esp_err_t esp_rmaker_ota_success_reboot_sequence(esp_rmaker_ota_handle_t ota_handle, const char *protocol_name, int attempt_count); -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 4, 0) -// Features supported in 4.4+ - #ifdef CONFIG_ESP_RMAKER_USE_CERT_BUNDLE #define ESP_RMAKER_USE_CERT_BUNDLE #include #endif - -#else - -#ifdef CONFIG_ESP_RMAKER_USE_CERT_BUNDLE -#warning "Certificate Bundle not supported below IDF v4.4. Using provided certificate instead." -#endif - -#endif /* !IDF4.4 */ static const char *TAG = "esp_rmaker_ota"; /* OTA reboot timer and NVS constants */ diff --git a/components/rmaker_common b/components/rmaker_common index 9ffa8b4..b313e85 160000 --- a/components/rmaker_common +++ b/components/rmaker_common @@ -1 +1 @@ -Subproject commit 9ffa8b4e3cb25061322fcbe069df26c773e3aa63 +Subproject commit b313e85dbb49ebbc476842372856fc9c18d63508