mirror of
https://github.com/h2zero/esp-nimble-cpp.git
synced 2024-12-18 01:00:47 +01:00
Fix compilation with esp32p4 (#253)
This commit is contained in:
parent
6c85cfa6c3
commit
b5b46661e0
6 changed files with 24 additions and 21 deletions
11
.github/workflows/build.yml
vendored
11
.github/workflows/build.yml
vendored
|
@ -17,16 +17,13 @@ jobs:
|
|||
# See https://hub.docker.com/r/espressif/idf/tags and
|
||||
# https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-docker-image.html
|
||||
# for details.
|
||||
idf_ver: ["release-v4.4", "release-v5.1"]
|
||||
idf_target: ["esp32", "esp32s3", "esp32c2", "esp32c3", "esp32c6", "esp32h2"]
|
||||
idf_ver: ["release-v4.4", "release-v5.1", "release-v5.3"]
|
||||
idf_target: ["esp32", "esp32s3", "esp32c2", "esp32c3", "esp32c6", "esp32h2", "esp32p4"]
|
||||
example:
|
||||
- Advanced/NimBLE_Client
|
||||
- Advanced/NimBLE_Server
|
||||
- Continuous_scan
|
||||
- Bluetooth_5/NimBLE_extended_client
|
||||
- Bluetooth_5/NimBLE_extended_server
|
||||
- Bluetooth_5/NimBLE_multi_advertiser
|
||||
- NimBLE_server_get_client_name
|
||||
exclude:
|
||||
- idf_target: "esp32"
|
||||
example: Bluetooth_5/NimBLE_extended_client
|
||||
|
@ -40,6 +37,10 @@ jobs:
|
|||
idf_target: "esp32c6"
|
||||
- idf_ver: release-v4.4
|
||||
idf_target: "esp32h2"
|
||||
- idf_ver: release-v4.4
|
||||
idf_target: "esp32p4"
|
||||
- idf_ver: release-v5.1
|
||||
idf_target: "esp32p4"
|
||||
|
||||
container: espressif/idf:${{ matrix.idf_ver }}
|
||||
steps:
|
||||
|
|
|
@ -341,7 +341,7 @@ void app_main (void){
|
|||
NimBLEDevice::setSecurityAuth(/*BLE_SM_PAIR_AUTHREQ_BOND | BLE_SM_PAIR_AUTHREQ_MITM |*/ BLE_SM_PAIR_AUTHREQ_SC);
|
||||
|
||||
/** Optional: set the transmit power, default is -3db */
|
||||
NimBLEDevice::setPower(ESP_PWR_LVL_P9); /** 12db */
|
||||
NimBLEDevice::setPower(9); // 9dbm
|
||||
|
||||
/** create new scan */
|
||||
NimBLEScan* pScan = NimBLEDevice::getScan();
|
||||
|
|
|
@ -14,7 +14,7 @@ extern "C" void app_main(void);
|
|||
#define SERVICE_UUID "ABCD"
|
||||
#define CHARACTERISTIC_UUID "1234"
|
||||
|
||||
static NimBLEAdvertisedDevice* advDevice;
|
||||
static const NimBLEAdvertisedDevice* advDevice;
|
||||
static bool doConnect = false;
|
||||
static uint32_t scanTime = 10 * 1000; // In milliseconds, 0 = scan forever
|
||||
|
||||
|
@ -37,7 +37,7 @@ class ClientCallbacks : public NimBLEClientCallbacks {
|
|||
|
||||
/* Define a class to handle the callbacks when advertisements are received */
|
||||
class scanCallbacks: public NimBLEScanCallbacks {
|
||||
void onResult(NimBLEAdvertisedDevice* advertisedDevice) {
|
||||
void onResult(const NimBLEAdvertisedDevice* advertisedDevice) {
|
||||
printf("Advertised Device found: %s\n", advertisedDevice->toString().c_str());
|
||||
if(advertisedDevice->isAdvertisingService(NimBLEUUID("ABCD")))
|
||||
{
|
||||
|
@ -52,7 +52,7 @@ class scanCallbacks: public NimBLEScanCallbacks {
|
|||
}
|
||||
|
||||
/** Callback to process the results of the completed scan or restart it */
|
||||
void onScanEnd(NimBLEScanResults results) {
|
||||
void onScanEnd(const NimBLEScanResults& results, int rc) {
|
||||
printf("Scan Ended\n");
|
||||
}
|
||||
};
|
||||
|
|
|
@ -48,7 +48,7 @@ class scanCallbacks : public NimBLEScanCallbacks {
|
|||
}
|
||||
}
|
||||
|
||||
void onScanEnd(NimBLEScanResults results) {
|
||||
void onScanEnd(const NimBLEScanResults&, int reason) {
|
||||
printf("Scan Ended\n");
|
||||
NimBLEDevice::getScan()->start(scanTimeMs);
|
||||
}
|
||||
|
|
|
@ -422,16 +422,13 @@ std::vector<NimBLEClient*> NimBLEDevice::getConnectedClients() {
|
|||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
# ifdef ESP_PLATFORM
|
||||
# ifndef CONFIG_IDF_TARGET_ESP32P4
|
||||
/**
|
||||
* @brief Get the transmission power.
|
||||
* @return The power level currently used in esp_power_level_t.
|
||||
*/
|
||||
esp_power_level_t NimBLEDevice::getPowerLevel(esp_ble_power_type_t powerType) {
|
||||
# ifdef CONFIG_IDF_TARGET_ESP32P4
|
||||
return 0xFF; // CONFIG_IDF_TARGET_ESP32P4 does not support esp_ble_tx_power_get
|
||||
# else
|
||||
return esp_ble_tx_power_get(powerType);
|
||||
# endif
|
||||
} // getPowerLevel
|
||||
|
||||
/**
|
||||
|
@ -440,19 +437,16 @@ esp_power_level_t NimBLEDevice::getPowerLevel(esp_ble_power_type_t powerType) {
|
|||
* @return True if the power level was set successfully.
|
||||
*/
|
||||
bool NimBLEDevice::setPowerLevel(esp_power_level_t powerLevel, esp_ble_power_type_t powerType) {
|
||||
# ifdef CONFIG_IDF_TARGET_ESP32P4
|
||||
return false; // CONFIG_IDF_TARGET_ESP32P4 does not support esp_ble_tx_power_set
|
||||
# else
|
||||
esp_err_t errRc = esp_ble_tx_power_set(powerType, powerLevel);
|
||||
if (errRc != ESP_OK) {
|
||||
NIMBLE_LOGE(LOG_TAG, "esp_ble_tx_power_set: rc=%d", errRc);
|
||||
}
|
||||
|
||||
return errRc == ESP_OK;
|
||||
# endif
|
||||
} // setPowerLevel
|
||||
# endif // !CONFIG_IDF_TARGET_ESP32P4
|
||||
# endif // ESP_PLATFORM
|
||||
|
||||
# endif
|
||||
/**
|
||||
* @brief Set the transmission power.
|
||||
* @param [in] dbm The power level to set in dBm.
|
||||
|
@ -460,10 +454,14 @@ bool NimBLEDevice::setPowerLevel(esp_power_level_t powerLevel, esp_ble_power_typ
|
|||
*/
|
||||
bool NimBLEDevice::setPower(int8_t dbm) {
|
||||
# ifdef ESP_PLATFORM
|
||||
# ifdef CONFIG_IDF_TARGET_ESP32P4
|
||||
return false; // CONFIG_IDF_TARGET_ESP32P4 does not support esp_ble_tx_power_set
|
||||
# else
|
||||
if (dbm % 3 == 2) {
|
||||
dbm++; // round up to the next multiple of 3 to be able to target 20dbm
|
||||
}
|
||||
return setPowerLevel(static_cast<esp_power_level_t>(dbm / 3 + ESP_PWR_LVL_N0));
|
||||
# endif
|
||||
# else
|
||||
NIMBLE_LOGD(LOG_TAG, ">> setPower: %d", dbm);
|
||||
ble_hci_vs_set_tx_pwr_cp cmd{dbm};
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
#include "nimconfig.h"
|
||||
#if defined(CONFIG_BT_ENABLED)
|
||||
# ifdef ESP_PLATFORM
|
||||
# include <esp_bt.h>
|
||||
# ifndef CONFIG_IDF_TARGET_ESP32P4
|
||||
# include <esp_bt.h>
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
||||
|
@ -136,9 +138,11 @@ class NimBLEDevice {
|
|||
static int getPower();
|
||||
static bool setPower(int8_t dbm);
|
||||
|
||||
# if defined(ESP_PLATFORM)
|
||||
# ifdef ESP_PLATFORM
|
||||
# ifndef CONFIG_IDF_TARGET_ESP32P4
|
||||
static esp_power_level_t getPowerLevel(esp_ble_power_type_t powerType = ESP_BLE_PWR_TYPE_DEFAULT);
|
||||
static bool setPowerLevel(esp_power_level_t powerLevel, esp_ble_power_type_t powerType = ESP_BLE_PWR_TYPE_DEFAULT);
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
||||
|
|
Loading…
Reference in a new issue