Skip to content

Commit

Permalink
Merge branch 'master' into ci/style_check
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasssvaz authored Feb 7, 2024
2 parents bb75101 + e1a3525 commit 455c8fd
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 16 deletions.
15 changes: 9 additions & 6 deletions cores/esp32/esp32-hal-spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 15 additions & 3 deletions libraries/BLE/src/BLEClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion libraries/BLE/src/BLEClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions platform.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 455c8fd

Please sign in to comment.