From 3a36a8d7f87edfdd0bb5a3b40825305b0489a095 Mon Sep 17 00:00:00 2001 From: Luca Burelli Date: Wed, 7 Feb 2024 10:56:21 +0100 Subject: [PATCH 1/3] fix(platform): use numbers in all recipe hooks (#9220) The Arduino Platform Specification requires that the recipe hooks are distinguished by a number and does not endorse using text labels. Fix all the usages of recipe hooks to use numbers. Closes arduino/arduino-cli#2369 . --- platform.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/platform.txt b/platform.txt index 0ff2eae7395..20189bd2010 100644 --- a/platform.txt +++ b/platform.txt @@ -146,13 +146,13 @@ recipe.hooks.prebuild.6.pattern.windows=cmd /c if not exist "{build.path}\build_ # Set -DARDUINO_CORE_BUILD only on core file compilation file_opts.path={build.path}/file_opts -recipe.hooks.prebuild.set_core_build_flag.pattern=/usr/bin/env bash -c ": > '{file_opts.path}'" -recipe.hooks.core.prebuild.set_core_build_flag.pattern=/usr/bin/env bash -c "echo -DARDUINO_CORE_BUILD > '{file_opts.path}'" -recipe.hooks.core.postbuild.set_core_build_flag.pattern=/usr/bin/env bash -c ": > '{file_opts.path}'" +recipe.hooks.prebuild.7.pattern=/usr/bin/env bash -c ": > '{file_opts.path}'" +recipe.hooks.core.prebuild.1.pattern=/usr/bin/env bash -c "echo -DARDUINO_CORE_BUILD > '{file_opts.path}'" +recipe.hooks.core.postbuild.1.pattern=/usr/bin/env bash -c ": > '{file_opts.path}'" -recipe.hooks.prebuild.set_core_build_flag.pattern.windows=cmd /c type nul > "{file_opts.path}" -recipe.hooks.core.prebuild.set_core_build_flag.pattern.windows=cmd /c echo "-DARDUINO_CORE_BUILD" > "{file_opts.path}" -recipe.hooks.core.postbuild.set_core_build_flag.pattern.windows=cmd /c type nul > "{file_opts.path}" +recipe.hooks.prebuild.7.pattern.windows=cmd /c type nul > "{file_opts.path}" +recipe.hooks.core.prebuild.1.pattern.windows=cmd /c echo "-DARDUINO_CORE_BUILD" > "{file_opts.path}" +recipe.hooks.core.postbuild.1.pattern.windows=cmd /c type nul > "{file_opts.path}" # Generate debug.cfg (must be postbuild) recipe.hooks.postbuild.1.pattern=/usr/bin/env bash -c "[ {build.copy_jtag_files} -eq 0 ] || cp -f "{debug.server.openocd.scripts_dir}"board/{build.openocdscript} "{build.source.path}"/debug.cfg" From 7d595547e86ffc1f6a0183d34d3f3f6ccf0bd6e6 Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Wed, 7 Feb 2024 09:43:54 -0300 Subject: [PATCH 2/3] SPI (fix): Adds SPI 3 to the ESP32-S2 and adds comments about it (#9216) * SPI (fix): Adds SPI 3 to the ESP32-S2 and adds comments about it * SPI (fix): added a space - typo error, simple fix. --- cores/esp32/esp32-hal-spi.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/cores/esp32/esp32-hal-spi.h b/cores/esp32/esp32-hal-spi.h index 2c0a6329dc9..5c8eb58d059 100644 --- a/cores/esp32/esp32-hal-spi.h +++ b/cores/esp32/esp32-hal-spi.h @@ -31,12 +31,15 @@ extern "C" { #if CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32S3 #define FSPI 0 #define HSPI 1 -#else -#define FSPI 1 //SPI bus attached to the flash (can use the same data lines but different SS) -#define HSPI 2 //SPI bus normally mapped to pins 12 - 15, but can be matrixed to any pins -#if CONFIG_IDF_TARGET_ESP32 -#define VSPI 3 //SPI bus normally attached to pins 5, 18, 19 and 23, but can be matrixed to any pins -#endif +#elif CONFIG_IDF_TARGET_ESP32S2 +#define FSPI 1 //SPI 1 bus. ESP32S2: for external memory only (can use the same data lines but different SS) +#define HSPI 2 //SPI 2 bus. ESP32S2: external memory or device - it can be matrixed to any pins +#define SPI2 2 // Another name for ESP32S2 SPI 2 +#define SPI3 3 //SPI 3 bus. ESP32S2: device only - it can be matrixed to any pins +#elif CONFIG_IDF_TARGET_ESP32 +#define FSPI 1 //SPI 1 bus attached to the flash (can use the same data lines but different SS) +#define HSPI 2 //SPI 2 bus normally mapped to pins 12 - 15, but can be matrixed to any pins +#define VSPI 3 //SPI 3 bus normally attached to pins 5, 18, 19 and 23, but can be matrixed to any pins #endif // This defines are not representing the real Divider of the ESP32 From e1a3525b5aa5ebce09436b0a5443849bfad274c5 Mon Sep 17 00:00:00 2001 From: LiveSparks Date: Wed, 7 Feb 2024 18:15:27 +0530 Subject: [PATCH 3/3] fix(esp32): Added a timeout option to the BLEClient's connect function (#9005) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(esp32): Added timeout to BLEClient.connect fn * Update libraries/BLE/src/BLEClient.cpp Co-authored-by: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com> --------- Co-authored-by: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com> Co-authored-by: Jan Procházka <90197375+P-R-O-C-H-Y@users.noreply.github.com> --- libraries/BLE/src/BLEClient.cpp | 18 +++++++++++++++--- libraries/BLE/src/BLEClient.h | 3 ++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/libraries/BLE/src/BLEClient.cpp b/libraries/BLE/src/BLEClient.cpp index ae82c2417a1..60ee53c0fa0 100644 --- a/libraries/BLE/src/BLEClient.cpp +++ b/libraries/BLE/src/BLEClient.cpp @@ -92,12 +92,23 @@ bool BLEClient::connect(BLEAdvertisedDevice* device) { return connect(address, type); } +/** + * Add overloaded function to ease connect to peer device with not public address + */ +bool BLEClient::connectTimeout(BLEAdvertisedDevice* device, uint32_t timeoutMs) { + BLEAddress address = device->getAddress(); + esp_ble_addr_type_t type = device->getAddressType(); + return connect(address, type, timeoutMs); +} + /** * @brief Connect to the partner (BLE Server). * @param [in] address The address of the partner. + * @param [in] type The type of the address. + * @param [in] timeoutMs The number of milliseconds to wait for the connection to complete. * @return True on success. */ -bool BLEClient::connect(BLEAddress address, esp_ble_addr_type_t type) { +bool BLEClient::connect(BLEAddress address, esp_ble_addr_type_t type, uint32_t timeoutMs) { log_v(">> connect(%s)", address.toString().c_str()); // We need the connection handle that we get from registering the application. We register the app @@ -142,9 +153,10 @@ bool BLEClient::connect(BLEAddress address, esp_ble_addr_type_t type) { return false; } - rc = m_semaphoreOpenEvt.wait("connect"); // Wait for the connection to complete. + bool got_sem = m_semaphoreOpenEvt.timedWait("connect", timeoutMs); // Wait for the connection to complete. + rc = m_semaphoreOpenEvt.value(); // check the status of the connection and cleanup in case of failure - if (rc != ESP_GATT_OK) { + if (!got_sem || rc != ESP_GATT_OK) { BLEDevice::removePeerDevice(m_appId, true); esp_ble_gattc_app_unregister(m_gattc_if); m_gattc_if = ESP_GATT_IF_NONE; diff --git a/libraries/BLE/src/BLEClient.h b/libraries/BLE/src/BLEClient.h index 0207a214b66..2c8bc2c4ab9 100644 --- a/libraries/BLE/src/BLEClient.h +++ b/libraries/BLE/src/BLEClient.h @@ -37,7 +37,8 @@ class BLEClient { ~BLEClient(); bool connect(BLEAdvertisedDevice* device); - bool connect(BLEAddress address, esp_ble_addr_type_t type = BLE_ADDR_TYPE_PUBLIC); // Connect to the remote BLE Server + bool connectTimeout(BLEAdvertisedDevice* device, uint32_t timeoutMS = portMAX_DELAY); + bool connect(BLEAddress address, esp_ble_addr_type_t type = BLE_ADDR_TYPE_PUBLIC, uint32_t timeoutMS = portMAX_DELAY); // Connect to the remote BLE Server void disconnect(); // Disconnect from the remote BLE Server BLEAddress getPeerAddress(); // Get the address of the remote BLE Server int getRssi(); // Get the RSSI of the remote BLE Server