From 7bd29fe04a83468c12dba14e28335e660a00b03f Mon Sep 17 00:00:00 2001 From: Assaf Inbal Date: Sat, 20 Apr 2024 20:28:09 +0300 Subject: [PATCH] Update to ESP-IDF v5.2.1 --- .github/workflows/main.yml | 2 +- CMakeLists.txt | 1 - README.md | 2 +- main/ble.c | 3 ++- main/mqtt.c | 2 +- main/wifi.c | 23 ++++++++++++----------- sdkconfig.defaults | 1 + 7 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fdbb4ce..e6ea0eb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,7 +21,7 @@ jobs: - name: ESP-IDF Build uses: espressif/esp-idf-ci-action@v1.1.0 with: - esp_idf_version: v5.0 + esp_idf_version: v5.2.1 command: idf.py image - name: Upload Application Image diff --git a/CMakeLists.txt b/CMakeLists.txt index e0f43c3..3337a85 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,6 @@ execute_process( OUTPUT_VARIABLE PROJECT_VER OUTPUT_STRIP_TRAILING_WHITESPACE) include($ENV{IDF_PATH}/tools/cmake/project.cmake) -add_compile_definitions(BTA_GATTC_NOTIF_REG_MAX=32) project(ble2mqtt) diff --git a/README.md b/README.md index f5bd38e..17ef527 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This project is a BLE to MQTT bridge, i.e. it exposes BLE GATT characteristics as MQTT topics for bidirectional communication. It's developed for the ESP32 SoC -and is based on [ESP-IDF](https://github.com/espressif/esp-idf) release v5.0. +and is based on [ESP-IDF](https://github.com/espressif/esp-idf) release v5.2.1. Note that using any other ESP-IDF version might not be stable or even compile. For example, if a device with a MAC address of `a0:e6:f8:50:72:53` exposes the diff --git a/main/ble.c b/main/ble.c index c465981..db35bd8 100644 --- a/main/ble.c +++ b/main/ble.c @@ -1025,7 +1025,8 @@ int ble_initialize(void) esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); ESP_ERROR_CHECK(esp_bt_controller_init(&bt_cfg)); ESP_ERROR_CHECK(esp_bt_controller_enable(ESP_BT_MODE_BLE)); - ESP_ERROR_CHECK(esp_bluedroid_init()); + esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT(); + ESP_ERROR_CHECK(esp_bluedroid_init_with_cfg(&bluedroid_cfg)); ESP_ERROR_CHECK(esp_bluedroid_enable()); ESP_ERROR_CHECK(esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_DEFAULT, ESP_PWR_LVL_P9)); diff --git a/main/mqtt.c b/main/mqtt.c index 2e66b27..fb2a691 100644 --- a/main/mqtt.c +++ b/main/mqtt.c @@ -162,7 +162,7 @@ int mqtt_subscribe(const char *topic, int qos, mqtt_on_message_received_cb_t cb, return -1; ESP_LOGD(TAG, "Subscribing to %s", topic); - if (esp_mqtt_client_subscribe(mqtt_handle, topic, qos) < 0) + if (esp_mqtt_client_subscribe_single(mqtt_handle, topic, qos) < 0) { ESP_LOGE(TAG, "Failed subscribing to %s", topic); return -1; diff --git a/main/wifi.c b/main/wifi.c index 4679977..a6bce2d 100644 --- a/main/wifi.c +++ b/main/wifi.c @@ -1,9 +1,9 @@ #include "wifi.h" +#include #include #include #include #include -#include #include #include #include @@ -156,28 +156,29 @@ int wifi_connect(const char *ssid, const char *password, { if (ca_cert) { - ESP_ERROR_CHECK(esp_wifi_sta_wpa2_ent_set_ca_cert((uint8_t *)ca_cert, + ESP_ERROR_CHECK(esp_eap_client_set_ca_cert((uint8_t *)ca_cert, strlen(ca_cert))); } if (client_cert) { - ESP_ERROR_CHECK(esp_wifi_sta_wpa2_ent_set_cert_key((uint8_t *)client_cert, - strlen(client_cert), (uint8_t *)client_key, - client_key ? strlen(client_key) : 0, NULL, 0)); + ESP_ERROR_CHECK(esp_eap_client_set_certificate_and_key( + (uint8_t *)client_cert, strlen(client_cert), + (uint8_t *)client_key, client_key ? strlen(client_key) : 0, + NULL, 0)); } if (eap_identity) { - ESP_ERROR_CHECK(esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)eap_identity, + ESP_ERROR_CHECK(esp_eap_client_set_identity((uint8_t *)eap_identity, strlen(eap_identity))); } if (eap_method == EAP_PEAP || eap_method == EAP_TTLS) { if (eap_username || eap_password) { - ESP_ERROR_CHECK(esp_wifi_sta_wpa2_ent_set_username((uint8_t *)eap_username, - strlen(eap_username))); - ESP_ERROR_CHECK(esp_wifi_sta_wpa2_ent_set_password((uint8_t *)eap_password, - strlen(eap_password))); + ESP_ERROR_CHECK(esp_eap_client_set_username( + (uint8_t *)eap_username, strlen(eap_username))); + ESP_ERROR_CHECK(esp_eap_client_set_password( + (uint8_t *)eap_password, strlen(eap_password))); } else { @@ -185,7 +186,7 @@ int wifi_connect(const char *ssid, const char *password, "Tunneled TLS or Protected EAP"); } } - ESP_ERROR_CHECK(esp_wifi_sta_wpa2_ent_enable()); + ESP_ERROR_CHECK(esp_wifi_sta_enterprise_enable()); } ESP_LOGI(TAG, "Connecting to SSID %s", wifi_config.sta.ssid); ESP_ERROR_CHECK(esp_wifi_start()); diff --git a/sdkconfig.defaults b/sdkconfig.defaults index e24f6de..9033a81 100644 --- a/sdkconfig.defaults +++ b/sdkconfig.defaults @@ -7,6 +7,7 @@ CONFIG_COMPILER_OPTIMIZATION_SIZE=y CONFIG_BT_ENABLED=y # CONFIG_BT_GATTS_ENABLE is not set CONFIG_BT_GATTC_MAX_CACHE_CHAR=100 +CONFIG_BT_GATTC_NOTIF_REG_MAX=32 CONFIG_BT_ACL_CONNECTIONS=7 CONFIG_BTDM_CTRL_BLE_MAX_CONN=9 # CONFIG_BTDM_BLE_SCAN_DUPL is not set