diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7ba890f2..efe09577 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -78,11 +78,11 @@ jobs: [env:esp32c3] board = esp32-c3-devkitm-1 - build_flags = '-DCONFIG_BT_NIMBLE_EXT_ADV=1' + build_flags = '-DMYNEWT_VAL_BLE_EXT_ADV=1' [env:esp32s3] board = esp32-s3-devkitc-1 - build_flags = '-DCONFIG_BT_NIMBLE_EXT_ADV=1' + build_flags = '-DMYNEWT_VAL_BLE_EXT_ADV=1' EOF cp ${{ matrix.example }}/* example/src/ platformio run -d example @@ -163,19 +163,19 @@ jobs: [env:esp32c3] board = esp32-c3-devkitm-1 - build_flags = '-DCONFIG_BT_NIMBLE_EXT_ADV=1' + build_flags = '-DMYNEWT_VAL_BLE_EXT_ADV=1' [env:esp32s3] board = esp32-s3-devkitc-1 - build_flags = '-DCONFIG_BT_NIMBLE_EXT_ADV=1' + build_flags = '-DMYNEWT_VAL_BLE_EXT_ADV=1' [env:esp32c6] board = esp32-c6-devkitc-1 - build_flags = '-DCONFIG_BT_NIMBLE_EXT_ADV=1' + build_flags = '-DMYNEWT_VAL_BLE_EXT_ADV=1' [env:esp32h2] board = esp32-h2-devkitm-1 - build_flags = '-DCONFIG_BT_NIMBLE_EXT_ADV=1' + build_flags = '-DMYNEWT_VAL_BLE_EXT_ADV=1' EOF cp ${{ matrix.example }}/* example/src/ platformio run -d example @@ -224,7 +224,7 @@ jobs: - uses: actions/checkout@v4 - name: Set config for BT5 run: | - sed -i '0,/#include \"nimconfig_rename.h\"/a #define CONFIG_BT_NIMBLE_EXT_ADV 1' ./src/nimconfig.h + sed -i '0,/#include \"nimconfig_rename.h\"/a #define MYNEWT_VAL_BLE_EXT_ADV 1' ./src/nimconfig.h - name: Build BT5 arduino-esp32 uses: arduino/compile-sketches@v1.1.0 with: @@ -276,7 +276,7 @@ jobs: - uses: actions/checkout@v4 - name: Set config for BT5 run: | - echo "-DCONFIG_BT_NIMBLE_EXT_ADV=1" > ${{ matrix.example }}/build_opt.h + echo "-DMYNEWT_VAL_BLE_EXT_ADV=1" > ${{ matrix.example }}/build_opt.h - name: Build BT5 n-able Arduino uses: arduino/compile-sketches@v1.1.0 with: diff --git a/docs/Doxyfile b/docs/Doxyfile index 1181cfcb..682c5a4e 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -2416,7 +2416,7 @@ INCLUDE_FILE_PATTERNS = # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. PREDEFINED = _DOXYGEN_ \ - CONFIG_BT_ENABLED \ + CONFIG_BT_NIMBLE_ENABLED \ CONFIG_BT_NIMBLE_ROLE_CENTRAL \ CONFIG_BT_NIMBLE_ROLE_OBSERVER \ CONFIG_BT_NIMBLE_ROLE_PERIPHERAL \ diff --git a/examples/Bluetooth_5/NimBLE_extended_client/NimBLE_extended_client.ino b/examples/Bluetooth_5/NimBLE_extended_client/NimBLE_extended_client.ino index 5062d403..93c9ce53 100644 --- a/examples/Bluetooth_5/NimBLE_extended_client/NimBLE_extended_client.ino +++ b/examples/Bluetooth_5/NimBLE_extended_client/NimBLE_extended_client.ino @@ -10,7 +10,7 @@ #include #include -#if !CONFIG_BT_NIMBLE_EXT_ADV +#if !MYNEWT_VAL(BLE_EXT_ADV) # error Must enable extended advertising, see nimconfig.h file. #endif diff --git a/examples/Bluetooth_5/NimBLE_extended_scan/NimBLE_extended_scan.ino b/examples/Bluetooth_5/NimBLE_extended_scan/NimBLE_extended_scan.ino index 31a2688c..a9947b99 100644 --- a/examples/Bluetooth_5/NimBLE_extended_scan/NimBLE_extended_scan.ino +++ b/examples/Bluetooth_5/NimBLE_extended_scan/NimBLE_extended_scan.ino @@ -9,7 +9,7 @@ #include #include -#if !CONFIG_BT_NIMBLE_EXT_ADV +#if !MYNEWT_VAL(BLE_EXT_ADV) # error Must enable extended advertising, see nimconfig.h file. #endif diff --git a/examples/Bluetooth_5/NimBLE_extended_server/NimBLE_extended_server.ino b/examples/Bluetooth_5/NimBLE_extended_server/NimBLE_extended_server.ino index 3c7e4fc4..732b0d8e 100644 --- a/examples/Bluetooth_5/NimBLE_extended_server/NimBLE_extended_server.ino +++ b/examples/Bluetooth_5/NimBLE_extended_server/NimBLE_extended_server.ino @@ -14,7 +14,7 @@ #include #include -#if !CONFIG_BT_NIMBLE_EXT_ADV +#if !MYNEWT_VAL(BLE_EXT_ADV) # error Must enable extended advertising, see nimconfig.h file. #endif diff --git a/examples/Bluetooth_5/NimBLE_multi_advertiser/NimBLE_multi_advertiser.ino b/examples/Bluetooth_5/NimBLE_multi_advertiser/NimBLE_multi_advertiser.ino index 6938dc92..0affdb9f 100644 --- a/examples/Bluetooth_5/NimBLE_multi_advertiser/NimBLE_multi_advertiser.ino +++ b/examples/Bluetooth_5/NimBLE_multi_advertiser/NimBLE_multi_advertiser.ino @@ -14,7 +14,7 @@ #include #include -#if !CONFIG_BT_NIMBLE_EXT_ADV +#if !MYNEWT_VAL(BLE_EXT_ADV) # error Must enable extended advertising, see nimconfig.h file. #endif diff --git a/examples/L2CAP/L2CAP_Client/L2CAP_Client.ino b/examples/L2CAP/L2CAP_Client/L2CAP_Client.ino index 6d923c27..46444cdc 100644 --- a/examples/L2CAP/L2CAP_Client/L2CAP_Client.ino +++ b/examples/L2CAP/L2CAP_Client/L2CAP_Client.ino @@ -5,8 +5,8 @@ #include #include -#if CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM <= 0 -# error "CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM must be set to 1 or greater" +#if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) < 1 +# error "MYNEWT_VAL_BLE_L2CAP_COC_MAX_NUM must be set to 1 or greater" #endif // See the following for generating UUIDs: diff --git a/examples/NimBLE_Client/NimBLE_Client.ino b/examples/NimBLE_Client/NimBLE_Client.ino index 1209310b..aa6f8a4c 100644 --- a/examples/NimBLE_Client/NimBLE_Client.ino +++ b/examples/NimBLE_Client/NimBLE_Client.ino @@ -113,7 +113,7 @@ bool connectToServer() { /** No client to reuse? Create a new one. */ if (!pClient) { - if (NimBLEDevice::getCreatedClientCount() >= NIMBLE_MAX_CONNECTIONS) { + if (NimBLEDevice::getCreatedClientCount() >= MYNEWT_VAL(BLE_MAX_CONNECTIONS)) { Serial.printf("Max clients reached - no more connections available\n"); return false; } diff --git a/src/NimBLE2904.cpp b/src/NimBLE2904.cpp index 24075139..323faad8 100644 --- a/src/NimBLE2904.cpp +++ b/src/NimBLE2904.cpp @@ -16,7 +16,7 @@ */ #include "NimBLE2904.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL) NimBLE2904::NimBLE2904(NimBLECharacteristic* pChr) : NimBLEDescriptor(NimBLEUUID((uint16_t)0x2904), BLE_GATT_CHR_F_READ, sizeof(NimBLE2904Data), pChr) { @@ -69,4 +69,4 @@ void NimBLE2904::setUnit(uint16_t unit) { setValue(m_data); } // setUnit -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL) diff --git a/src/NimBLE2904.h b/src/NimBLE2904.h index 1c10e3b5..ad97ea66 100644 --- a/src/NimBLE2904.h +++ b/src/NimBLE2904.h @@ -18,8 +18,8 @@ #ifndef NIMBLE_CPP_2904_H_ #define NIMBLE_CPP_2904_H_ -#include "nimconfig.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +#include "syscfg/syscfg.h" +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL) # include "NimBLEDescriptor.h" @@ -79,5 +79,5 @@ class NimBLE2904 : public NimBLEDescriptor { NimBLE2904Data m_data{}; }; // NimBLE2904 -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL) #endif // NIMBLE_CPP_2904_H_ diff --git a/src/NimBLEAddress.cpp b/src/NimBLEAddress.cpp index 0ff46e19..b0094913 100644 --- a/src/NimBLEAddress.cpp +++ b/src/NimBLEAddress.cpp @@ -16,7 +16,7 @@ */ #include "NimBLEAddress.h" -#if CONFIG_BT_ENABLED +#if CONFIG_BT_NIMBLE_ENABLED # include "NimBLELog.h" diff --git a/src/NimBLEAddress.h b/src/NimBLEAddress.h index 58f00132..89d19ab8 100644 --- a/src/NimBLEAddress.h +++ b/src/NimBLEAddress.h @@ -18,8 +18,8 @@ #ifndef NIMBLE_CPP_ADDRESS_H_ #define NIMBLE_CPP_ADDRESS_H_ -#include "nimconfig.h" -#if CONFIG_BT_ENABLED +#include "syscfg/syscfg.h" +#if CONFIG_BT_NIMBLE_ENABLED # if defined(CONFIG_NIMBLE_CPP_IDF) # include "nimble/ble.h" @@ -67,5 +67,5 @@ class NimBLEAddress : private ble_addr_t { operator uint64_t() const; }; -#endif // CONFIG_BT_ENABLED +#endif // CONFIG_BT_NIMBLE_ENABLED #endif // NIMBLE_CPP_ADDRESS_H_ diff --git a/src/NimBLEAdvertisedDevice.cpp b/src/NimBLEAdvertisedDevice.cpp index 191b5c00..3b89768e 100644 --- a/src/NimBLEAdvertisedDevice.cpp +++ b/src/NimBLEAdvertisedDevice.cpp @@ -16,7 +16,7 @@ */ #include "NimBLEAdvertisedDevice.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_OBSERVER +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_OBSERVER) # include "NimBLEDevice.h" # include "NimBLEUtils.h" @@ -31,7 +31,7 @@ static const char* LOG_TAG = "NimBLEAdvertisedDevice"; * @param [in] event The advertisement event data. */ NimBLEAdvertisedDevice::NimBLEAdvertisedDevice(const ble_gap_event* event, uint8_t eventType) -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_EXT_ADV) : m_address{event->ext_disc.addr}, m_advType{eventType}, m_rssi{event->ext_disc.rssi}, @@ -58,7 +58,7 @@ NimBLEAdvertisedDevice::NimBLEAdvertisedDevice(const ble_gap_event* event, uint8 * @param [in] event The advertisement event data. */ void NimBLEAdvertisedDevice::update(const ble_gap_event* event, uint8_t eventType) { -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_EXT_ADV) const auto& disc = event->ext_disc; m_isLegacyAdv = disc.props & BLE_HCI_ADV_LEGACY_MASK; # else @@ -580,7 +580,7 @@ bool NimBLEAdvertisedDevice::haveTXPower() const { return findAdvField(BLE_HS_ADV_TYPE_TX_PWR_LVL) > 0; } // haveTXPower -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_EXT_ADV) /** * @brief Get the set ID of the extended advertisement. * @return The set ID. @@ -751,7 +751,7 @@ uint8_t NimBLEAdvertisedDevice::getAddressType() const { * @return True if the device is connectable. */ bool NimBLEAdvertisedDevice::isConnectable() const { -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_EXT_ADV) if (m_isLegacyAdv) { return m_advType == BLE_HCI_ADV_RPT_EVTYPE_ADV_IND || m_advType == BLE_HCI_ADV_RPT_EVTYPE_DIR_IND; } @@ -772,7 +772,7 @@ bool NimBLEAdvertisedDevice::isScannable() const { * @return True if legacy (Bluetooth 4.x), false if extended (bluetooth 5.x). */ bool NimBLEAdvertisedDevice::isLegacyAdvertisement() const { -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_EXT_ADV) return m_isLegacyAdv; # else return true; @@ -813,4 +813,4 @@ const std::vector::const_iterator NimBLEAdvertisedDevice::end() const { return m_payload.cend(); } -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_OBSERVER +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_OBSERVER) diff --git a/src/NimBLEAdvertisedDevice.h b/src/NimBLEAdvertisedDevice.h index 2348e8ae..1384b112 100644 --- a/src/NimBLEAdvertisedDevice.h +++ b/src/NimBLEAdvertisedDevice.h @@ -18,8 +18,8 @@ #ifndef NIMBLE_CPP_ADVERTISED_DEVICE_H_ #define NIMBLE_CPP_ADVERTISED_DEVICE_H_ -#include "nimconfig.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_OBSERVER +#include "syscfg/syscfg.h" +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_OBSERVER) # include "NimBLEAddress.h" # include "NimBLEScan.h" @@ -87,7 +87,7 @@ class NimBLEAdvertisedDevice { bool isConnectable() const; bool isScannable() const; bool isLegacyAdvertisement() const; -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_EXT_ADV) uint8_t getSetId() const; uint8_t getPrimaryPhy() const; uint8_t getSecondaryPhy() const; @@ -163,7 +163,7 @@ class NimBLEAdvertisedDevice { uint8_t m_callbackSent{}; uint8_t m_advLength{}; -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_EXT_ADV) bool m_isLegacyAdv{}; uint8_t m_sid{}; uint8_t m_primPhy{}; @@ -174,5 +174,5 @@ class NimBLEAdvertisedDevice { std::vector m_payload; }; -#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_OBSERVER */ +#endif /* CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_OBSERVER) */ #endif /* NIMBLE_CPP_ADVERTISED_DEVICE_H_ */ diff --git a/src/NimBLEAdvertisementData.cpp b/src/NimBLEAdvertisementData.cpp index 7d4c391a..f45ba3e7 100644 --- a/src/NimBLEAdvertisementData.cpp +++ b/src/NimBLEAdvertisementData.cpp @@ -16,7 +16,7 @@ */ #include "NimBLEAdvertisementData.h" -#if (CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && !CONFIG_BT_NIMBLE_EXT_ADV) || defined(_DOXYGEN_) +#if (CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER) && !MYNEWT_VAL(BLE_EXT_ADV)) || defined(_DOXYGEN_) # include "NimBLEDevice.h" # include "NimBLEUtils.h" @@ -583,4 +583,4 @@ std::string NimBLEAdvertisementData::toString() const { return str; } // toString -#endif // (CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && !CONFIG_BT_NIMBLE_EXT_ADV) || defined(_DOXYGEN_) +#endif // (CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER) && !MYNEWT_VAL(BLE_EXT_ADV)) || defined(_DOXYGEN_) diff --git a/src/NimBLEAdvertisementData.h b/src/NimBLEAdvertisementData.h index d1004744..9c1ae3f7 100644 --- a/src/NimBLEAdvertisementData.h +++ b/src/NimBLEAdvertisementData.h @@ -18,8 +18,8 @@ #ifndef NIMBLE_CPP_ADVERTISEMENT_DATA_H_ #define NIMBLE_CPP_ADVERTISEMENT_DATA_H_ -#include "nimconfig.h" -#if (CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && !CONFIG_BT_NIMBLE_EXT_ADV) || defined(_DOXYGEN_) +#include "syscfg/syscfg.h" +#if (CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER) && !MYNEWT_VAL(BLE_EXT_ADV)) || defined(_DOXYGEN_) # include # include @@ -74,5 +74,5 @@ class NimBLEAdvertisementData { std::vector m_payload{}; }; // NimBLEAdvertisementData -#endif // (CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && !CONFIG_BT_NIMBLE_EXT_ADV) || defined(_DOXYGEN_) +#endif // (CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER) && !MYNEWT_VAL(BLE_EXT_ADV)) || defined(_DOXYGEN_) #endif // NIMBLE_CPP_ADVERTISEMENT_DATA_H_ diff --git a/src/NimBLEAdvertising.cpp b/src/NimBLEAdvertising.cpp index f17d930d..a93e9eef 100644 --- a/src/NimBLEAdvertising.cpp +++ b/src/NimBLEAdvertising.cpp @@ -16,7 +16,7 @@ */ #include "NimBLEAdvertising.h" -#if (CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && !CONFIG_BT_NIMBLE_EXT_ADV) || defined(_DOXYGEN_) +#if (CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER) && !MYNEWT_VAL(BLE_EXT_ADV)) || defined(_DOXYGEN_) # if defined(CONFIG_NIMBLE_CPP_IDF) # include "services/gap/ble_svc_gap.h" @@ -42,7 +42,7 @@ NimBLEAdvertising::NimBLEAdvertising() m_duration{BLE_HS_FOREVER}, m_scanResp{false}, m_advDataSet{false} { -# if !CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +# if !MYNEWT_VAL(BLE_ROLE_PERIPHERAL) m_advParams.conn_mode = BLE_GAP_CONN_MODE_NON; # else m_advParams.conn_mode = BLE_GAP_CONN_MODE_UND; @@ -195,7 +195,7 @@ bool NimBLEAdvertising::start(uint32_t duration, const NimBLEAddress* dirAddr) { return true; } -# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +# if MYNEWT_VAL(BLE_ROLE_PERIPHERAL) NimBLEServer* pServer = NimBLEDevice::getServer(); if (pServer != nullptr) { pServer->start(); // make sure the GATT server is ready before advertising @@ -220,7 +220,7 @@ bool NimBLEAdvertising::start(uint32_t duration, const NimBLEAddress* dirAddr) { duration = BLE_HS_FOREVER; } -# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +# if MYNEWT_VAL(BLE_ROLE_PERIPHERAL) int rc = ble_gap_adv_start(NimBLEDevice::m_ownAddrType, (dirAddr != nullptr) ? dirAddr->getBase() : NULL, duration, @@ -620,4 +620,4 @@ bool NimBLEAdvertising::setServiceData(const NimBLEUUID& uuid, const std::string return setServiceData(uuid, reinterpret_cast(data.data()), data.length()); } // setServiceData -#endif // (CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && !CONFIG_BT_NIMBLE_EXT_ADV) || defined(_DOXYGEN_) +#endif // (CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER) && !MYNEWT_VAL(BLE_EXT_ADV)) || defined(_DOXYGEN_) diff --git a/src/NimBLEAdvertising.h b/src/NimBLEAdvertising.h index b5a243cf..c2811454 100644 --- a/src/NimBLEAdvertising.h +++ b/src/NimBLEAdvertising.h @@ -18,8 +18,8 @@ #ifndef NIMBLE_CPP_ADVERTISING_H_ #define NIMBLE_CPP_ADVERTISING_H_ -#include "nimconfig.h" -#if (CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && !CONFIG_BT_NIMBLE_EXT_ADV) || defined(_DOXYGEN_) +#include "syscfg/syscfg.h" +#if (CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER) && !MYNEWT_VAL(BLE_EXT_ADV)) || defined(_DOXYGEN_) # if defined(CONFIG_NIMBLE_CPP_IDF) # include "host/ble_gap.h" @@ -105,5 +105,5 @@ class NimBLEAdvertising { bool m_advDataSet : 1; }; -#endif // (CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && !CONFIG_BT_NIMBLE_EXT_ADV) || defined(_DOXYGEN_) +#endif // (CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER) && !MYNEWT_VAL(BLE_EXT_ADV)) || defined(_DOXYGEN_) #endif // NIMBLE_CPP_ADVERTISING_H_ diff --git a/src/NimBLEAttValue.cpp b/src/NimBLEAttValue.cpp index fbc164c9..e4e4993e 100644 --- a/src/NimBLEAttValue.cpp +++ b/src/NimBLEAttValue.cpp @@ -16,7 +16,7 @@ */ #include "NimBLEAttValue.h" -#if CONFIG_BT_ENABLED +#if CONFIG_BT_NIMBLE_ENABLED # if defined(CONFIG_NIMBLE_CPP_IDF) # include "nimble/nimble_npl.h" @@ -24,6 +24,7 @@ # include "nimble/nimble/include/nimble/nimble_npl.h" # endif +# include "NimBLEUtils.h" # include "NimBLELog.h" static const char* LOG_TAG = "NimBLEAttValue"; @@ -159,4 +160,4 @@ uint8_t NimBLEAttValue::operator[](int pos) const { return m_attr_value[pos]; } -#endif // CONFIG_BT_ENABLED +#endif // CONFIG_BT_NIMBLE_ENABLED diff --git a/src/NimBLEAttValue.h b/src/NimBLEAttValue.h index 24b64c83..0a3807d2 100644 --- a/src/NimBLEAttValue.h +++ b/src/NimBLEAttValue.h @@ -18,8 +18,8 @@ #ifndef NIMBLE_CPP_ATTVALUE_H #define NIMBLE_CPP_ATTVALUE_H -#include "nimconfig.h" -#if CONFIG_BT_ENABLED +#include "syscfg/syscfg.h" +#if CONFIG_BT_NIMBLE_ENABLED # ifdef NIMBLE_CPP_ARDUINO_STRING_AVAILABLE # include @@ -363,5 +363,5 @@ class NimBLEAttValue { # endif }; -#endif // CONFIG_BT_ENABLED +#endif // CONFIG_BT_NIMBLE_ENABLED #endif // NIMBLE_CPP_ATTVALUE_H_ diff --git a/src/NimBLEAttribute.h b/src/NimBLEAttribute.h index 7ba95c7d..81221d7a 100644 --- a/src/NimBLEAttribute.h +++ b/src/NimBLEAttribute.h @@ -18,8 +18,8 @@ #ifndef NIMBLE_CPP_ATTRIBUTE_H_ #define NIMBLE_CPP_ATTRIBUTE_H_ -#include "nimconfig.h" -#if CONFIG_BT_ENABLED && (CONFIG_BT_NIMBLE_ROLE_PERIPHERAL || CONFIG_BT_NIMBLE_ROLE_CENTRAL) +#include "syscfg/syscfg.h" +#if CONFIG_BT_NIMBLE_ENABLED && (MYNEWT_VAL(BLE_ROLE_PERIPHERAL) || MYNEWT_VAL(BLE_ROLE_CENTRAL)) # include "NimBLEUUID.h" @@ -56,5 +56,5 @@ class NimBLEAttribute { uint16_t m_handle{0}; }; -#endif // CONFIG_BT_ENABLED && (CONFIG_BT_NIMBLE_ROLE_PERIPHERAL || CONFIG_BT_NIMBLE_ROLE_CENTRAL) +#endif // CONFIG_BT_NIMBLE_ENABLED && (MYNEWT_VAL(BLE_ROLE_PERIPHERAL) || MYNEWT_VAL(BLE_ROLE_CENTRAL)) #endif // NIMBLE_CPP_ATTRIBUTE_H_ diff --git a/src/NimBLEBeacon.cpp b/src/NimBLEBeacon.cpp index e9b93617..997b4116 100644 --- a/src/NimBLEBeacon.cpp +++ b/src/NimBLEBeacon.cpp @@ -16,7 +16,7 @@ */ #include "NimBLEBeacon.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER) # include "NimBLEUUID.h" # include "NimBLELog.h" @@ -137,4 +137,4 @@ void NimBLEBeacon::setSignalPower(int8_t signalPower) { m_beaconData.signalPower = signalPower; } // setSignalPower -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER) diff --git a/src/NimBLEBeacon.h b/src/NimBLEBeacon.h index 061e1f60..1607ef66 100644 --- a/src/NimBLEBeacon.h +++ b/src/NimBLEBeacon.h @@ -18,8 +18,8 @@ #ifndef NIMBLE_CPP_BEACON_H_ #define NIMBLE_CPP_BEACON_H_ -#include "nimconfig.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER +#include "syscfg/syscfg.h" +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER) class NimBLEUUID; @@ -65,5 +65,5 @@ class NimBLEBeacon { BeaconData m_beaconData; }; // NimBLEBeacon -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL) #endif // NIMBLE_CPP_BEACON_H_ diff --git a/src/NimBLECharacteristic.cpp b/src/NimBLECharacteristic.cpp index 26ce838e..0e2736d0 100644 --- a/src/NimBLECharacteristic.cpp +++ b/src/NimBLECharacteristic.cpp @@ -16,7 +16,7 @@ */ # include "NimBLECharacteristic.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL) # include "NimBLE2904.h" # include "NimBLEDevice.h" @@ -414,4 +414,4 @@ void NimBLECharacteristicCallbacks::onSubscribe(NimBLECharacteristic* pCharacter NIMBLE_LOGD("NimBLECharacteristicCallbacks", "onSubscribe: default"); } -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL) diff --git a/src/NimBLECharacteristic.h b/src/NimBLECharacteristic.h index 02ae89a7..789d21d7 100644 --- a/src/NimBLECharacteristic.h +++ b/src/NimBLECharacteristic.h @@ -18,8 +18,8 @@ #ifndef NIMBLE_CPP_CHARACTERISTIC_H_ #define NIMBLE_CPP_CHARACTERISTIC_H_ -#include "nimconfig.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +#include "syscfg/syscfg.h" +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL) class NimBLECharacteristicCallbacks; class NimBLEService; @@ -254,5 +254,5 @@ class NimBLECharacteristicCallbacks { virtual void onSubscribe(NimBLECharacteristic* pCharacteristic, NimBLEConnInfo& connInfo, uint16_t subValue); }; -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL) #endif // NIMBLE_CPP_CHARACTERISTIC_H_ diff --git a/src/NimBLEClient.cpp b/src/NimBLEClient.cpp index 909b3511..f2120232 100644 --- a/src/NimBLEClient.cpp +++ b/src/NimBLEClient.cpp @@ -16,7 +16,7 @@ */ #include "NimBLEClient.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL) # include "NimBLERemoteService.h" # include "NimBLERemoteCharacteristic.h" @@ -68,7 +68,7 @@ NimBLEClient::NimBLEClient(const NimBLEAddress& peerAddress) m_terminateFailCount{0}, m_asyncSecureAttempt{0}, m_config{}, -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_EXT_ADV) m_phyMask{BLE_GAP_LE_PHY_1M_MASK | BLE_GAP_LE_PHY_2M_MASK | BLE_GAP_LE_PHY_CODED_MASK}, # endif m_connParams{16, @@ -125,7 +125,7 @@ size_t NimBLEClient::deleteService(const NimBLEUUID& uuid) { return m_svcVec.size(); } // deleteService -# if CONFIG_BT_NIMBLE_ROLE_OBSERVER +# if MYNEWT_VAL(BLE_ROLE_OBSERVER) /** * @brief Connect to an advertising device. * @param [in] pDevice A pointer to the advertised device instance to connect to. @@ -204,7 +204,7 @@ bool NimBLEClient::connect(const NimBLEAddress& address, bool deleteAttributes, m_config.exchangeMTU = exchangeMTU; do { -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_EXT_ADV) rc = ble_gap_ext_connect(NimBLEDevice::m_ownAddrType, peerAddr, m_connectTimeout, @@ -228,7 +228,7 @@ bool NimBLEClient::connect(const NimBLEAddress& address, bool deleteAttributes, break; case BLE_HS_EBUSY: -# if CONFIG_BT_NIMBLE_ROLE_OBSERVER +# if MYNEWT_VAL(BLE_ROLE_OBSERVER) // Scan was active, stop it through the NimBLEScan API to release any tasks and call the callback. if (!NimBLEDevice::getScan()->stop()) { @@ -402,7 +402,7 @@ void NimBLEClient::setConfig(NimBLEClient::Config config) { m_config = config; } // setConfig -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_EXT_ADV) /** * @brief Set the PHY types to use when connecting to a server. * @param [in] mask A bitmask indicating what PHYS to connect with.\n @@ -1311,4 +1311,4 @@ void NimBLEClientCallbacks::onPhyUpdate(NimBLEClient* pClient, uint8_t txPhy, ui } // onPhyUpdate # -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL) diff --git a/src/NimBLEClient.h b/src/NimBLEClient.h index eb205e2e..2dac6563 100644 --- a/src/NimBLEClient.h +++ b/src/NimBLEClient.h @@ -18,8 +18,8 @@ #ifndef NIMBLE_CPP_CLIENT_H_ #define NIMBLE_CPP_CLIENT_H_ -#include "nimconfig.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL +#include "syscfg/syscfg.h" +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL) # if defined(CONFIG_NIMBLE_CPP_IDF) # include "host/ble_gap.h" @@ -48,7 +48,7 @@ struct NimBLETaskData; */ class NimBLEClient { public: -# if CONFIG_BT_NIMBLE_ROLE_OBSERVER +# if MYNEWT_VAL(BLE_ROLE_OBSERVER) bool connect(const NimBLEAdvertisedDevice* device, bool deleteAttributes = true, bool asyncConnect = false, @@ -95,7 +95,7 @@ class NimBLEClient { const NimBLEAttValue& value, bool response = false); -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_EXT_ADV) void setConnectPhy(uint8_t phyMask); # endif bool updatePhy(uint8_t txPhysMask, uint8_t rxPhysMask, uint16_t phyOptions = 0); @@ -137,7 +137,7 @@ class NimBLEClient { mutable uint8_t m_asyncSecureAttempt; Config m_config; -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_EXT_ADV) uint8_t m_phyMask; # endif ble_gap_conn_params m_connParams; @@ -229,5 +229,5 @@ class NimBLEClientCallbacks { virtual void onPhyUpdate(NimBLEClient* pClient, uint8_t txPhy, uint8_t rxPhy); }; -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL) #endif // NIMBLE_CPP_CLIENT_H_ diff --git a/src/NimBLEDescriptor.cpp b/src/NimBLEDescriptor.cpp index d85d1d1a..8f1bb41e 100644 --- a/src/NimBLEDescriptor.cpp +++ b/src/NimBLEDescriptor.cpp @@ -16,7 +16,7 @@ */ #include "NimBLEDescriptor.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL) # include "NimBLEService.h" # include "NimBLELog.h" @@ -147,4 +147,4 @@ void NimBLEDescriptorCallbacks::onWrite(NimBLEDescriptor* pDescriptor, NimBLECon NIMBLE_LOGD("NimBLEDescriptorCallbacks", "onWrite: default"); } // onWrite -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL) diff --git a/src/NimBLEDescriptor.h b/src/NimBLEDescriptor.h index 907ad09c..b6e9b8f2 100644 --- a/src/NimBLEDescriptor.h +++ b/src/NimBLEDescriptor.h @@ -18,8 +18,8 @@ #ifndef NIMBLE_CPP_DESCRIPTOR_H_ #define NIMBLE_CPP_DESCRIPTOR_H_ -#include "nimconfig.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +#include "syscfg/syscfg.h" +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL) # include "NimBLELocalValueAttribute.h" # include @@ -72,5 +72,5 @@ class NimBLEDescriptorCallbacks { # include "NimBLE2904.h" -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL) #endif // NIMBLE_CPP_DESCRIPTOR_H_ diff --git a/src/NimBLEDevice.cpp b/src/NimBLEDevice.cpp index 4b20674d..087ccf5d 100644 --- a/src/NimBLEDevice.cpp +++ b/src/NimBLEDevice.cpp @@ -16,7 +16,7 @@ */ #include "NimBLEDevice.h" -#if CONFIG_BT_ENABLED +#if CONFIG_BT_NIMBLE_ENABLED # ifdef ESP_PLATFORM # include "esp_err.h" @@ -68,27 +68,27 @@ extern "C" void ble_store_config_init(void); NimBLEDeviceCallbacks NimBLEDevice::defaultDeviceCallbacks{}; NimBLEDeviceCallbacks* NimBLEDevice::m_pDeviceCallbacks = &defaultDeviceCallbacks; -# if CONFIG_BT_NIMBLE_ROLE_OBSERVER +# if MYNEWT_VAL(BLE_ROLE_OBSERVER) NimBLEScan* NimBLEDevice::m_pScan = nullptr; # endif -# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +# if MYNEWT_VAL(BLE_ROLE_PERIPHERAL) NimBLEServer* NimBLEDevice::m_pServer = nullptr; -# if CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM > 0 +# if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) NimBLEL2CAPServer* NimBLEDevice::m_pL2CAPServer = nullptr; # endif # endif -# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_ROLE_BROADCASTER) +# if MYNEWT_VAL(BLE_EXT_ADV) NimBLEExtAdvertising* NimBLEDevice::m_bleAdvertising = nullptr; # else NimBLEAdvertising* NimBLEDevice::m_bleAdvertising = nullptr; # endif # endif -# if CONFIG_BT_NIMBLE_ROLE_CENTRAL -std::array NimBLEDevice::m_pClients{}; +# if MYNEWT_VAL(BLE_ROLE_CENTRAL) +std::array NimBLEDevice::m_pClients{}; # endif bool NimBLEDevice::m_initialized{false}; @@ -118,7 +118,7 @@ extern "C" int ble_vhci_disc_duplicate_mode_enable(int mode); /* SERVER FUNCTIONS */ /* -------------------------------------------------------------------------- */ -# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +# if MYNEWT_VAL(BLE_ROLE_PERIPHERAL) /** * @brief Create an instance of a server. * @return A pointer to the instance of the server. @@ -142,7 +142,7 @@ NimBLEServer* NimBLEDevice::getServer() { return m_pServer; } // getServer -# if CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM +# if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) /** * @brief Create an instance of a L2CAP server. * @return A pointer to the instance of the L2CAP server. @@ -161,15 +161,15 @@ NimBLEL2CAPServer* NimBLEDevice::createL2CAPServer() { NimBLEL2CAPServer* NimBLEDevice::getL2CAPServer() { return m_pL2CAPServer; } // getL2CAPServer -# endif // #if CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM -# endif // #if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +# endif // #if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) +# endif // #if MYNEWT_VAL(BLE_ROLE_PERIPHERAL) /* -------------------------------------------------------------------------- */ /* ADVERTISING FUNCTIONS */ /* -------------------------------------------------------------------------- */ -# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_ROLE_BROADCASTER) +# if MYNEWT_VAL(BLE_EXT_ADV) /** * @brief Get the instance of the extended advertising object. * @return A pointer to the extended advertising object. @@ -203,7 +203,7 @@ bool NimBLEDevice::stopAdvertising(uint8_t instId) { } // stopAdvertising # endif -# if !CONFIG_BT_NIMBLE_EXT_ADV || defined(_DOXYGEN_) +# if !MYNEWT_VAL(BLE_EXT_ADV) || defined(_DOXYGEN_) /** * @brief Get the instance of the advertising object. * @return A pointer to the advertising object. @@ -232,7 +232,7 @@ bool NimBLEDevice::startAdvertising(uint32_t duration) { bool NimBLEDevice::stopAdvertising() { return getAdvertising()->stop(); } // stopAdvertising -# endif // #if CONFIG_BT_NIMBLE_ROLE_BROADCASTER +# endif // #if MYNEWT_VAL(BLE_ROLE_BROADCASTER) /* -------------------------------------------------------------------------- */ /* SCAN FUNCTIONS */ @@ -243,7 +243,7 @@ bool NimBLEDevice::stopAdvertising() { * @return The scanning object reference. This is a singleton object. The caller should not * try and release/delete it. */ -# if CONFIG_BT_NIMBLE_ROLE_OBSERVER +# if MYNEWT_VAL(BLE_ROLE_OBSERVER) NimBLEScan* NimBLEDevice::getScan() { if (m_pScan == nullptr) { m_pScan = new NimBLEScan(); @@ -321,13 +321,13 @@ void NimBLEDevice::setScanDuplicateCacheResetTime(uint16_t time) { } # endif // CONFIG_BTDM_BLE_SCAN_DUPL || CONFIG_BT_LE_SCAN_DUPL # endif // ESP_PLATFORM -# endif // CONFIG_BT_NIMBLE_ROLE_OBSERVER +# endif // MYNEWT_VAL(BLE_ROLE_OBSERVER) /* -------------------------------------------------------------------------- */ /* CLIENT FUNCTIONS */ /* -------------------------------------------------------------------------- */ -# if CONFIG_BT_NIMBLE_ROLE_CENTRAL +# if MYNEWT_VAL(BLE_ROLE_CENTRAL) /** * @brief Creates a new client object, each client can connect to 1 peripheral device. * @return A pointer to the new client object, or nullptr on error. @@ -350,7 +350,7 @@ NimBLEClient* NimBLEDevice::createClient(const NimBLEAddress& peerAddress) { } } - NIMBLE_LOGE(LOG_TAG, "Unable to create client; already at max: %d", NIMBLE_MAX_CONNECTIONS); + NIMBLE_LOGE(LOG_TAG, "Unable to create client; already at max: %d", MYNEWT_VAL(BLE_MAX_CONNECTIONS)); return nullptr; } // createClient @@ -462,7 +462,7 @@ std::vector NimBLEDevice::getConnectedClients() { return clients; } // getConnectedClients -# endif // CONFIG_BT_NIMBLE_ROLE_CENTRAL +# endif // MYNEWT_VAL(BLE_ROLE_CENTRAL) /* -------------------------------------------------------------------------- */ /* TRANSMIT POWER */ @@ -613,7 +613,7 @@ uint16_t NimBLEDevice::getMTU() { /* BOND MANAGEMENT */ /* -------------------------------------------------------------------------- */ -# if CONFIG_BT_NIMBLE_ROLE_CENTRAL || CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +# if MYNEWT_VAL(BLE_ROLE_CENTRAL) || MYNEWT_VAL(BLE_ROLE_PERIPHERAL) /** * @brief Gets the number of bonded peers stored */ @@ -850,13 +850,13 @@ void NimBLEDevice::onSync(void) { m_synced = true; if (m_initialized) { -# if CONFIG_BT_NIMBLE_ROLE_OBSERVER +# if MYNEWT_VAL(BLE_ROLE_OBSERVER) if (m_pScan != nullptr) { m_pScan->onHostSync(); } # endif -# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER +# if MYNEWT_VAL(BLE_ROLE_BROADCASTER) if (m_bleAdvertising != nullptr) { m_bleAdvertising->onHostSync(); } @@ -907,11 +907,11 @@ bool NimBLEDevice::init(const std::string& deviceName) { esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); # if defined(CONFIG_IDF_TARGET_ESP32) bt_cfg.mode = ESP_BT_MODE_BLE; - bt_cfg.ble_max_conn = CONFIG_BT_NIMBLE_MAX_CONNECTIONS; + bt_cfg.ble_max_conn = MYNEWT_VAL(BLE_MAX_CONNECTIONS); # elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3) - bt_cfg.ble_max_act = CONFIG_BT_NIMBLE_MAX_CONNECTIONS; + bt_cfg.ble_max_act = MYNEWT_VAL(BLE_MAX_CONNECTIONS); # else - bt_cfg.nimble_max_connections = CONFIG_BT_NIMBLE_MAX_CONNECTIONS; + bt_cfg.nimble_max_connections = MYNEWT_VAL(BLE_MAX_CONNECTIONS); # endif # if CONFIG_BTDM_BLE_SCAN_DUPL @@ -1026,12 +1026,12 @@ bool NimBLEDevice::deinit(bool clearAll) { } if (clearAll) { -# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +# if MYNEWT_VAL(BLE_ROLE_PERIPHERAL) if (NimBLEDevice::m_pServer != nullptr) { delete NimBLEDevice::m_pServer; NimBLEDevice::m_pServer = nullptr; } -# if CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM +# if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) if (NimBLEDevice::m_pL2CAPServer != nullptr) { delete NimBLEDevice::m_pL2CAPServer; NimBLEDevice::m_pL2CAPServer = nullptr; @@ -1039,21 +1039,21 @@ bool NimBLEDevice::deinit(bool clearAll) { # endif # endif -# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER +# if MYNEWT_VAL(BLE_ROLE_BROADCASTER) if (NimBLEDevice::m_bleAdvertising != nullptr) { delete NimBLEDevice::m_bleAdvertising; NimBLEDevice::m_bleAdvertising = nullptr; } # endif -# if CONFIG_BT_NIMBLE_ROLE_OBSERVER +# if MYNEWT_VAL(BLE_ROLE_OBSERVER) if (NimBLEDevice::m_pScan != nullptr) { delete NimBLEDevice::m_pScan; NimBLEDevice::m_pScan = nullptr; } # endif -# if CONFIG_BT_NIMBLE_ROLE_CENTRAL +# if MYNEWT_VAL(BLE_ROLE_CENTRAL) for (auto clt : m_pClients) { deleteClient(clt); } @@ -1254,7 +1254,7 @@ bool NimBLEDevice::startSecurity(uint16_t connHandle, int* rcPtr) { return rc == 0 || rc == BLE_HS_EALREADY; } // startSecurity -# if CONFIG_BT_NIMBLE_ROLE_CENTRAL || CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +# if MYNEWT_VAL(BLE_ROLE_CENTRAL) || MYNEWT_VAL(BLE_ROLE_PERIPHERAL) /** * @brief Inject the provided passkey into the Security Manager. * @param [in] peerInfo Connection information for the peer. @@ -1279,7 +1279,7 @@ bool NimBLEDevice::injectConfirmPasskey(const NimBLEConnInfo& peerInfo, bool acc NIMBLE_LOGD(LOG_TAG, "BLE_SM_IOACT_NUMCMP; ble_sm_inject_io result: %d", rc); return rc == 0; } -# endif // CONFIG_BT_NIMBLE_ROLE_CENTRAL || CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +# endif // MYNEWT_VAL(BLE_ROLE_CENTRAL) || MYNEWT_VAL(BLE_ROLE_PERIPHERAL) /* -------------------------------------------------------------------------- */ /* UTILITIES */ @@ -1346,4 +1346,4 @@ int NimBLEDeviceCallbacks::onStoreStatus(struct ble_store_status_event* event, v return ble_store_util_status_rr(event, arg); } -#endif // CONFIG_BT_ENABLED +#endif // CONFIG_BT_NIMBLE_ENABLED diff --git a/src/NimBLEDevice.h b/src/NimBLEDevice.h index df89852c..37075009 100644 --- a/src/NimBLEDevice.h +++ b/src/NimBLEDevice.h @@ -18,8 +18,8 @@ #ifndef NIMBLE_CPP_DEVICE_H_ #define NIMBLE_CPP_DEVICE_H_ -#include "nimconfig.h" -#if CONFIG_BT_ENABLED +#include "syscfg/syscfg.h" +#if CONFIG_BT_NIMBLE_ENABLED # ifdef ESP_PLATFORM # ifndef CONFIG_IDF_TARGET_ESP32P4 # include @@ -40,31 +40,31 @@ # include # include -# if CONFIG_BT_NIMBLE_ROLE_CENTRAL +# if MYNEWT_VAL(BLE_ROLE_CENTRAL) # include class NimBLEClient; # endif -# if CONFIG_BT_NIMBLE_ROLE_OBSERVER +# if MYNEWT_VAL(BLE_ROLE_OBSERVER) class NimBLEScan; # endif -# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_ROLE_BROADCASTER) +# if MYNEWT_VAL(BLE_EXT_ADV) class NimBLEExtAdvertising; # else class NimBLEAdvertising; # endif # endif -# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +# if MYNEWT_VAL(BLE_ROLE_PERIPHERAL) class NimBLEServer; -# if CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM > 0 +# if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) class NimBLEL2CAPServer; # endif # endif -# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL || CONFIG_BT_NIMBLE_ROLE_CENTRAL +# if MYNEWT_VAL(BLE_ROLE_PERIPHERAL) || MYNEWT_VAL(BLE_ROLE_CENTRAL) class NimBLEConnInfo; # endif @@ -106,12 +106,6 @@ class NimBLEDeviceCallbacks; # define BLEL2CAPChannel NimBLEL2CAPChannel # define BLEL2CAPChannelCallbacks NimBLEL2CAPChannelCallbacks -# ifdef CONFIG_BT_NIMBLE_MAX_CONNECTIONS -# define NIMBLE_MAX_CONNECTIONS CONFIG_BT_NIMBLE_MAX_CONNECTIONS -# else -# define NIMBLE_MAX_CONNECTIONS CONFIG_NIMBLE_MAX_CONNECTIONS -# endif - enum class NimBLETxPowerType { All = 0, Advertise = 1, Scan = 2, Connection = 3 }; typedef int (*gap_event_handler)(ble_gap_event* event, void* arg); @@ -164,39 +158,39 @@ class NimBLEDevice { # endif # endif -# if CONFIG_BT_NIMBLE_ROLE_OBSERVER +# if MYNEWT_VAL(BLE_ROLE_OBSERVER) static NimBLEScan* getScan(); # endif -# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +# if MYNEWT_VAL(BLE_ROLE_PERIPHERAL) static NimBLEServer* createServer(); static NimBLEServer* getServer(); -# if CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM > 0 +# if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) static NimBLEL2CAPServer* createL2CAPServer(); static NimBLEL2CAPServer* getL2CAPServer(); # endif # endif -# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL || CONFIG_BT_NIMBLE_ROLE_CENTRAL +# if MYNEWT_VAL(BLE_ROLE_PERIPHERAL) || MYNEWT_VAL(BLE_ROLE_CENTRAL) static bool injectConfirmPasskey(const NimBLEConnInfo& peerInfo, bool accept); static bool injectPassKey(const NimBLEConnInfo& peerInfo, uint32_t pin); # endif -# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_ROLE_BROADCASTER) +# if MYNEWT_VAL(BLE_EXT_ADV) static NimBLEExtAdvertising* getAdvertising(); static bool startAdvertising(uint8_t instId, int duration = 0, int maxEvents = 0); static bool stopAdvertising(uint8_t instId); static bool stopAdvertising(); # endif -# if !CONFIG_BT_NIMBLE_EXT_ADV || defined(_DOXYGEN_) +# if !MYNEWT_VAL(BLE_EXT_ADV) || defined(_DOXYGEN_) static NimBLEAdvertising* getAdvertising(); static bool startAdvertising(uint32_t duration = 0); static bool stopAdvertising(); # endif # endif -# if CONFIG_BT_NIMBLE_ROLE_CENTRAL +# if MYNEWT_VAL(BLE_ROLE_CENTRAL) static NimBLEClient* createClient(); static NimBLEClient* createClient(const NimBLEAddress& peerAddress); static bool deleteClient(NimBLEClient* pClient); @@ -207,7 +201,7 @@ class NimBLEDevice { static std::vector getConnectedClients(); # endif -# if CONFIG_BT_NIMBLE_ROLE_CENTRAL || CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +# if MYNEWT_VAL(BLE_ROLE_CENTRAL) || MYNEWT_VAL(BLE_ROLE_PERIPHERAL) static bool deleteBond(const NimBLEAddress& address); static int getNumBonds(); static bool isBonded(const NimBLEAddress& address); @@ -225,27 +219,27 @@ class NimBLEDevice { static NimBLEDeviceCallbacks* m_pDeviceCallbacks; static NimBLEDeviceCallbacks defaultDeviceCallbacks; -# if CONFIG_BT_NIMBLE_ROLE_OBSERVER +# if MYNEWT_VAL(BLE_ROLE_OBSERVER) static NimBLEScan* m_pScan; # endif -# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +# if MYNEWT_VAL(BLE_ROLE_PERIPHERAL) static NimBLEServer* m_pServer; -# if CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM > 0 +# if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) static NimBLEL2CAPServer* m_pL2CAPServer; # endif # endif -# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_ROLE_BROADCASTER) +# if MYNEWT_VAL(BLE_EXT_ADV) static NimBLEExtAdvertising* m_bleAdvertising; # else static NimBLEAdvertising* m_bleAdvertising; # endif # endif -# if CONFIG_BT_NIMBLE_ROLE_CENTRAL - static std::array m_pClients; +# if MYNEWT_VAL(BLE_ROLE_CENTRAL) + static std::array m_pClients; # endif # ifdef ESP_PLATFORM @@ -256,59 +250,59 @@ class NimBLEDevice { # endif # endif -# if CONFIG_BT_NIMBLE_ROLE_CENTRAL +# if MYNEWT_VAL(BLE_ROLE_CENTRAL) friend class NimBLEClient; # endif -# if CONFIG_BT_NIMBLE_ROLE_OBSERVER +# if MYNEWT_VAL(BLE_ROLE_OBSERVER) friend class NimBLEScan; # endif -# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +# if MYNEWT_VAL(BLE_ROLE_PERIPHERAL) friend class NimBLEServer; friend class NimBLECharacteristic; # endif -# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER +# if MYNEWT_VAL(BLE_ROLE_BROADCASTER) friend class NimBLEAdvertising; -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_EXT_ADV) friend class NimBLEExtAdvertising; friend class NimBLEExtAdvertisement; # endif # endif }; -# if CONFIG_BT_NIMBLE_ROLE_CENTRAL +# if MYNEWT_VAL(BLE_ROLE_CENTRAL) # include "NimBLEClient.h" # include "NimBLERemoteService.h" # include "NimBLERemoteCharacteristic.h" # include "NimBLERemoteDescriptor.h" # endif -# if CONFIG_BT_NIMBLE_ROLE_OBSERVER +# if MYNEWT_VAL(BLE_ROLE_OBSERVER) # include "NimBLEScan.h" # endif -# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +# if MYNEWT_VAL(BLE_ROLE_PERIPHERAL) # include "NimBLEServer.h" # include "NimBLEService.h" # include "NimBLECharacteristic.h" # include "NimBLEDescriptor.h" -# if CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM +# if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) # include "NimBLEL2CAPServer.h" # include "NimBLEL2CAPChannel.h" # endif # endif -# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_ROLE_BROADCASTER) +# if MYNEWT_VAL(BLE_EXT_ADV) # include "NimBLEExtAdvertising.h" # else # include "NimBLEAdvertising.h" # endif # endif -# if CONFIG_BT_NIMBLE_ROLE_CENTRAL || CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +# if MYNEWT_VAL(BLE_ROLE_CENTRAL) || MYNEWT_VAL(BLE_ROLE_PERIPHERAL) # include "NimBLEConnInfo.h" # endif @@ -337,5 +331,5 @@ class NimBLEDeviceCallbacks { virtual int onStoreStatus(struct ble_store_status_event* event, void* arg); }; -#endif // CONFIG_BT_ENABLED +#endif // CONFIG_BT_NIMBLE_ENABLED #endif // NIMBLE_CPP_DEVICE_H_ diff --git a/src/NimBLEEddystoneTLM.cpp b/src/NimBLEEddystoneTLM.cpp index b374d3ac..8ee405b5 100644 --- a/src/NimBLEEddystoneTLM.cpp +++ b/src/NimBLEEddystoneTLM.cpp @@ -16,7 +16,7 @@ */ #include "NimBLEEddystoneTLM.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER) # include "NimBLEUUID.h" # include "NimBLELog.h" @@ -215,4 +215,4 @@ void NimBLEEddystoneTLM::setTime(uint32_t tmil) { m_eddystoneData.tmil = tmil; } // setTime -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER) diff --git a/src/NimBLEEddystoneTLM.h b/src/NimBLEEddystoneTLM.h index 2c1e52e3..f48cf94c 100644 --- a/src/NimBLEEddystoneTLM.h +++ b/src/NimBLEEddystoneTLM.h @@ -18,8 +18,8 @@ #ifndef NIMBLE_CPP_EDDYSTONETLM_H_ #define NIMBLE_CPP_EDDYSTONETLM_H_ -#include "nimconfig.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER +#include "syscfg/syscfg.h" +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER) class NimBLEUUID; @@ -66,5 +66,5 @@ class NimBLEEddystoneTLM { }; // NimBLEEddystoneTLM -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER) #endif // NIMBLE_CPP_EDDYSTONETLM_H_ diff --git a/src/NimBLEExtAdvertising.cpp b/src/NimBLEExtAdvertising.cpp index d3a02061..3e0062a7 100644 --- a/src/NimBLEExtAdvertising.cpp +++ b/src/NimBLEExtAdvertising.cpp @@ -16,7 +16,7 @@ */ #include "NimBLEExtAdvertising.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && CONFIG_BT_NIMBLE_EXT_ADV +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER) && MYNEWT_VAL(BLE_EXT_ADV) # if defined(CONFIG_NIMBLE_CPP_IDF) # include "services/gap/ble_svc_gap.h" @@ -38,7 +38,7 @@ static const char* LOG_TAG = "NimBLEExtAdvertising"; NimBLEExtAdvertising::NimBLEExtAdvertising() : m_deleteCallbacks{false}, m_pCallbacks{&defaultCallbacks}, - m_advStatus(CONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES + 1, false) {} + m_advStatus(MYNEWT_VAL(BLE_MULTI_ADV_INSTANCES) + 1, false) {} /** * @brief Destructor: deletes callback instances if requested. @@ -68,7 +68,7 @@ bool NimBLEExtAdvertising::setInstanceData(uint8_t instId, NimBLEExtAdvertisemen adv.m_params.scan_req_notif = false; } -# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +# if MYNEWT_VAL(BLE_ROLE_PERIPHERAL) NimBLEServer* pServer = NimBLEDevice::getServer(); if (pServer != nullptr) { pServer->start(); // make sure the GATT server is ready before advertising @@ -391,7 +391,7 @@ void NimBLEExtAdvertisement::setTxPower(int8_t dbm) { * @param [in] enable True = connectable. */ void NimBLEExtAdvertisement::setConnectable(bool enable) { -# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +# if MYNEWT_VAL(BLE_ROLE_PERIPHERAL) m_params.connectable = enable; # endif } // setConnectable @@ -531,7 +531,7 @@ void NimBLEExtAdvertisement::clearData() { * @details This will completely replace any data that was previously set. */ bool NimBLEExtAdvertisement::setData(const uint8_t* data, size_t length) { - if (length > CONFIG_BT_NIMBLE_MAX_EXT_ADV_DATA_LEN) { + if (length > MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE)) { return false; } @@ -546,7 +546,7 @@ bool NimBLEExtAdvertisement::setData(const uint8_t* data, size_t length) { * @return True if successful, false if the data is too large. */ bool NimBLEExtAdvertisement::addData(const uint8_t* data, size_t length) { - if (m_payload.size() + length > CONFIG_BT_NIMBLE_MAX_EXT_ADV_DATA_LEN) { + if (m_payload.size() + length > MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE)) { return false; } @@ -560,7 +560,7 @@ bool NimBLEExtAdvertisement::addData(const uint8_t* data, size_t length) { * @return True if successful, false if the data is too large. */ bool NimBLEExtAdvertisement::addData(const std::string& data) { - if (m_payload.size() + data.length() > CONFIG_BT_NIMBLE_MAX_EXT_ADV_DATA_LEN) { + if (m_payload.size() + data.length() > MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE)) { return false; } @@ -710,7 +710,7 @@ bool NimBLEExtAdvertisement::addServiceUUID(const NimBLEUUID& serviceUUID) { length += 2; } - if (length + getDataSize() > CONFIG_BT_NIMBLE_MAX_EXT_ADV_DATA_LEN) { + if (length + getDataSize() > MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE)) { NIMBLE_LOGE(LOG_TAG, "Cannot add UUID, data length exceeded!"); return false; } @@ -919,7 +919,7 @@ bool NimBLEExtAdvertisement::setServiceData(const NimBLEUUID& uuid, const uint8_ uint8_t uuidBytes = uuid.bitSize() / 8; uint8_t sDataLen = 2 + uuidBytes + length; - if (m_payload.size() + sDataLen > CONFIG_BT_NIMBLE_MAX_EXT_ADV_DATA_LEN) { + if (m_payload.size() + sDataLen > MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE)) { return false; } @@ -1090,4 +1090,4 @@ std::string NimBLEExtAdvertisement::toString() const { return str; } // toString -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && CONFIG_BT_NIMBLE_EXT_ADV +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER) && MYNEWT_VAL(BLE_EXT_ADV) diff --git a/src/NimBLEExtAdvertising.h b/src/NimBLEExtAdvertising.h index 9824ad19..4591ce46 100644 --- a/src/NimBLEExtAdvertising.h +++ b/src/NimBLEExtAdvertising.h @@ -18,8 +18,8 @@ #ifndef NIMBLE_CPP_EXTADVERTISING_H_ #define NIMBLE_CPP_EXTADVERTISING_H_ -#include "nimconfig.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && CONFIG_BT_NIMBLE_EXT_ADV +#include "syscfg/syscfg.h" +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER) && MYNEWT_VAL(BLE_EXT_ADV) # if defined(CONFIG_NIMBLE_CPP_IDF) # include "host/ble_gap.h" @@ -159,5 +159,5 @@ class NimBLEExtAdvertisingCallbacks { virtual void onScanRequest(NimBLEExtAdvertising* pAdv, uint8_t instId, NimBLEAddress addr); }; // NimBLEExtAdvertisingCallbacks -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && CONFIG_BT_NIMBLE_EXT_ADV +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER) && MYNEWT_VAL(BLE_EXT_ADV) #endif // NIMBLE_CPP_EXTADVERTISING_H_ diff --git a/src/NimBLEHIDDevice.cpp b/src/NimBLEHIDDevice.cpp index 73393930..105ef11b 100644 --- a/src/NimBLEHIDDevice.cpp +++ b/src/NimBLEHIDDevice.cpp @@ -16,7 +16,7 @@ */ #include "NimBLEHIDDevice.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER) && MYNEWT_VAL(BLE_ROLE_PERIPHERAL) # include "NimBLEServer.h" # include "NimBLEService.h" @@ -340,4 +340,4 @@ NimBLEService* NimBLEHIDDevice::getBatteryService() { return m_batterySvc; } // getBatteryService -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL) diff --git a/src/NimBLEHIDDevice.h b/src/NimBLEHIDDevice.h index cbc9839d..1d82fd12 100644 --- a/src/NimBLEHIDDevice.h +++ b/src/NimBLEHIDDevice.h @@ -18,8 +18,8 @@ #ifndef NIMBLE_CPP_HIDDEVICE_H_ #define NIMBLE_CPP_HIDDEVICE_H_ -#include "nimconfig.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +#include "syscfg/syscfg.h" +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER) && MYNEWT_VAL(BLE_ROLE_PERIPHERAL) # include # include @@ -85,5 +85,5 @@ class NimBLEHIDDevice { NimBLECharacteristic* locateReportCharacteristicByIdAndType(uint8_t reportId, uint8_t reportType); }; -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER) && MYNEWT_VAL(BLE_ROLE_PERIPHERAL) #endif // NIMBLE_CPP_HIDDEVICE_H_ diff --git a/src/NimBLEL2CAPChannel.cpp b/src/NimBLEL2CAPChannel.cpp index ef290d1a..4a155860 100644 --- a/src/NimBLEL2CAPChannel.cpp +++ b/src/NimBLEL2CAPChannel.cpp @@ -3,7 +3,7 @@ // #include "NimBLEL2CAPChannel.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) # include "NimBLEClient.h" # include "NimBLELog.h" @@ -149,7 +149,7 @@ int NimBLEL2CAPChannel::writeFragment(std::vector::const_iterator begin return -BLE_HS_EREJECT; } -# if CONFIG_BT_NIMBLE_ROLE_CENTRAL +# if MYNEWT_VAL(BLE_ROLE_CENTRAL) NimBLEL2CAPChannel* NimBLEL2CAPChannel::connect(NimBLEClient* client, uint16_t psm, uint16_t mtu, @@ -174,7 +174,7 @@ NimBLEL2CAPChannel* NimBLEL2CAPChannel::connect(NimBLEClient* cli } return channel; } -# endif // CONFIG_BT_NIMBLE_ROLE_CENTRAL +# endif // MYNEWT_VAL(BLE_ROLE_CENTRAL) bool NimBLEL2CAPChannel::write(const std::vector& bytes) { if (!this->channel) { @@ -311,4 +311,4 @@ int NimBLEL2CAPChannel::handleL2capEvent(struct ble_l2cap_event* event, void* ar return returnValue; } -#endif // #if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM +#endif // #if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) diff --git a/src/NimBLEL2CAPChannel.h b/src/NimBLEL2CAPChannel.h index 41cd5a96..b7fafa4a 100644 --- a/src/NimBLEL2CAPChannel.h +++ b/src/NimBLEL2CAPChannel.h @@ -5,8 +5,8 @@ #ifndef NIMBLE_CPP_L2CAPCHANNEL_H_ #define NIMBLE_CPP_L2CAPCHANNEL_H_ -#include "nimconfig.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM +#include "syscfg/syscfg.h" +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) # include "inttypes.h" # if defined(CONFIG_NIMBLE_CPP_IDF) @@ -122,5 +122,5 @@ class NimBLEL2CAPChannelCallbacks { virtual void onDisconnect(NimBLEL2CAPChannel* channel) {}; }; -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) #endif // NIMBLE_CPP_L2CAPCHANNEL_H_ diff --git a/src/NimBLEL2CAPServer.cpp b/src/NimBLEL2CAPServer.cpp index c719694b..207a72f5 100644 --- a/src/NimBLEL2CAPServer.cpp +++ b/src/NimBLEL2CAPServer.cpp @@ -3,7 +3,7 @@ // #include "NimBLEL2CAPServer.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) # include "NimBLEL2CAPChannel.h" # include "NimBLEDevice.h" @@ -37,4 +37,4 @@ NimBLEL2CAPChannel* NimBLEL2CAPServer::createService(const uint16_t return service; } -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) diff --git a/src/NimBLEL2CAPServer.h b/src/NimBLEL2CAPServer.h index 405009a2..c1a84b3c 100644 --- a/src/NimBLEL2CAPServer.h +++ b/src/NimBLEL2CAPServer.h @@ -4,8 +4,8 @@ #ifndef NIMBLE_CPP_L2CAPSERVER_H_ #define NIMBLE_CPP_L2CAPSERVER_H_ -#include "nimconfig.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM +#include "syscfg/syscfg.h" +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) # include "inttypes.h" # include @@ -37,5 +37,5 @@ class NimBLEL2CAPServer { friend class NimBLEDevice; }; -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) #endif // NIMBLE_CPP_L2CAPSERVER_H_ diff --git a/src/NimBLELocalAttribute.h b/src/NimBLELocalAttribute.h index 5427a9ea..4e00305c 100644 --- a/src/NimBLELocalAttribute.h +++ b/src/NimBLELocalAttribute.h @@ -18,8 +18,8 @@ #ifndef NIMBLE_CPP_LOCAL_ATTRIBUTE_H_ #define NIMBLE_CPP_LOCAL_ATTRIBUTE_H_ -#include "nimconfig.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +#include "syscfg/syscfg.h" +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL) # include "NimBLEAttribute.h" @@ -54,5 +54,5 @@ class NimBLELocalAttribute : public NimBLEAttribute { uint8_t m_removed{0}; }; -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL) #endif // NIMBLE_CPP_LOCAL_ATTRIBUTE_H_ diff --git a/src/NimBLELocalValueAttribute.h b/src/NimBLELocalValueAttribute.h index c9f9d8de..ebed3399 100644 --- a/src/NimBLELocalValueAttribute.h +++ b/src/NimBLELocalValueAttribute.h @@ -18,8 +18,8 @@ #ifndef NIMBLE_LOCAL_VALUE_ATTRIBUTE_H_ #define NIMBLE_LOCAL_VALUE_ATTRIBUTE_H_ -#include "nimconfig.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +#include "syscfg/syscfg.h" +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL) # if defined(CONFIG_NIMBLE_CPP_IDF) # include "host/ble_hs.h" @@ -140,5 +140,5 @@ class NimBLELocalValueAttribute : public NimBLELocalAttribute, public NimBLEValu uint16_t m_properties{0}; }; -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL) #endif // NIMBLE_LOCAL_VALUE_ATTRIBUTE_H_ diff --git a/src/NimBLELog.h b/src/NimBLELog.h index 32d863a1..0d4dd877 100644 --- a/src/NimBLELog.h +++ b/src/NimBLELog.h @@ -18,8 +18,8 @@ #ifndef NIMBLE_CPP_LOG_H_ #define NIMBLE_CPP_LOG_H_ -#include "nimconfig.h" -#if CONFIG_BT_ENABLED +#include "syscfg/syscfg.h" +#if CONFIG_BT_NIMBLE_ENABLED # if defined(CONFIG_NIMBLE_CPP_IDF) # include "esp_log.h" @@ -179,5 +179,5 @@ # define NIMBLE_LOGE_IF(cond, tag, format, ...) { if (cond) { NIMBLE_LOGE(tag, format, ##__VA_ARGS__); }} # define NIMBLE_LOGE_RC(rc, tag, format, ...) { if (rc) { NIMBLE_LOGE(tag, format "; rc=%d %s", ##__VA_ARGS__, rc, NimBLEUtils::returnCodeToString(rc)); }} -#endif /* CONFIG_BT_ENABLED */ +#endif /* CONFIG_BT_NIMBLE_ENABLED */ #endif /* NIMBLE_CPP_LOG_H_ */ \ No newline at end of file diff --git a/src/NimBLERemoteCharacteristic.cpp b/src/NimBLERemoteCharacteristic.cpp index 41029cbf..2c23ccbf 100644 --- a/src/NimBLERemoteCharacteristic.cpp +++ b/src/NimBLERemoteCharacteristic.cpp @@ -16,7 +16,7 @@ */ #include "NimBLERemoteCharacteristic.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL) # include "NimBLERemoteDescriptor.h" # include "NimBLERemoteService.h" @@ -387,4 +387,4 @@ NimBLEClient* NimBLERemoteCharacteristic::getClient() const { return getRemoteService()->getClient(); } // getClient -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL) diff --git a/src/NimBLERemoteCharacteristic.h b/src/NimBLERemoteCharacteristic.h index f2d3d6b2..c1a6ecac 100644 --- a/src/NimBLERemoteCharacteristic.h +++ b/src/NimBLERemoteCharacteristic.h @@ -18,8 +18,8 @@ #ifndef NIMBLE_CPP_REMOTE_CHARACTERISTIC_H_ #define NIMBLE_CPP_REMOTE_CHARACTERISTIC_H_ -#include "nimconfig.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL +#include "syscfg/syscfg.h" +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL) # include "NimBLERemoteValueAttribute.h" # include @@ -79,5 +79,5 @@ class NimBLERemoteCharacteristic : public NimBLERemoteValueAttribute { }; // NimBLERemoteCharacteristic -#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL */ +#endif /* CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL) */ #endif /* NIMBLE_CPP_REMOTE_CHARACTERISTIC_H_ */ diff --git a/src/NimBLERemoteDescriptor.cpp b/src/NimBLERemoteDescriptor.cpp index cdb54dc0..c3de20fd 100644 --- a/src/NimBLERemoteDescriptor.cpp +++ b/src/NimBLERemoteDescriptor.cpp @@ -16,7 +16,7 @@ */ #include "NimBLERemoteDescriptor.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL) # include "NimBLERemoteCharacteristic.h" @@ -56,4 +56,4 @@ NimBLEClient* NimBLERemoteDescriptor::getClient() const { return m_pRemoteCharacteristic->getClient(); } -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL) diff --git a/src/NimBLERemoteDescriptor.h b/src/NimBLERemoteDescriptor.h index 349988c2..b16f3de7 100644 --- a/src/NimBLERemoteDescriptor.h +++ b/src/NimBLERemoteDescriptor.h @@ -18,8 +18,8 @@ #ifndef NIMBLE_CPP_REMOTE_DESCRIPTOR_H_ #define NIMBLE_CPP_REMOTE_DESCRIPTOR_H_ -#include "nimconfig.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL +#include "syscfg/syscfg.h" +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL) # include "NimBLERemoteValueAttribute.h" @@ -44,5 +44,5 @@ class NimBLERemoteDescriptor : public NimBLERemoteValueAttribute { const NimBLERemoteCharacteristic* m_pRemoteCharacteristic; }; -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL) #endif // NIMBLE_CPP_REMOTE_DESCRIPTOR_H_ diff --git a/src/NimBLERemoteService.cpp b/src/NimBLERemoteService.cpp index fd9aeec2..f07e64b4 100644 --- a/src/NimBLERemoteService.cpp +++ b/src/NimBLERemoteService.cpp @@ -16,7 +16,7 @@ */ #include "NimBLERemoteService.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL) # include "NimBLERemoteCharacteristic.h" # include "NimBLEClient.h" @@ -302,4 +302,4 @@ std::string NimBLERemoteService::toString() const { return res; } // toString -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL) diff --git a/src/NimBLERemoteService.h b/src/NimBLERemoteService.h index 6aebbaba..c2aa445d 100644 --- a/src/NimBLERemoteService.h +++ b/src/NimBLERemoteService.h @@ -18,8 +18,8 @@ #ifndef NIMBLE_CPP_REMOTE_SERVICE_H_ #define NIMBLE_CPP_REMOTE_SERVICE_H_ -#include "nimconfig.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL +#include "syscfg/syscfg.h" +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL) # include "NimBLEAttribute.h" # include @@ -64,5 +64,5 @@ class NimBLERemoteService : public NimBLEAttribute { uint16_t m_endHandle{0}; }; // NimBLERemoteService -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL) #endif // NIMBLE_CPP_REMOTE_SERVICE_H_ diff --git a/src/NimBLERemoteValueAttribute.cpp b/src/NimBLERemoteValueAttribute.cpp index e5e5611f..c2ef17dd 100644 --- a/src/NimBLERemoteValueAttribute.cpp +++ b/src/NimBLERemoteValueAttribute.cpp @@ -16,7 +16,7 @@ */ #include "NimBLERemoteValueAttribute.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL) # include "NimBLEClient.h" # include "NimBLEUtils.h" @@ -217,4 +217,4 @@ int NimBLERemoteValueAttribute::onReadCB(uint16_t conn_handle, const ble_gatt_er return rc; } // onReadCB -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL) diff --git a/src/NimBLERemoteValueAttribute.h b/src/NimBLERemoteValueAttribute.h index 89df172e..7a92479a 100644 --- a/src/NimBLERemoteValueAttribute.h +++ b/src/NimBLERemoteValueAttribute.h @@ -18,8 +18,8 @@ #ifndef NIMBLE_CPP_REMOTE_VALUE_ATTRIBUTE_H_ #define NIMBLE_CPP_REMOTE_VALUE_ATTRIBUTE_H_ -#include "nimconfig.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL +#include "syscfg/syscfg.h" +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL) # if defined(CONFIG_NIMBLE_CPP_IDF) # include @@ -170,5 +170,5 @@ class NimBLERemoteValueAttribute : public NimBLEValueAttribute, public NimBLEAtt static int onWriteCB(uint16_t conn_handle, const ble_gatt_error* error, ble_gatt_attr* attr, void* arg); }; -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL) #endif // NIMBLE_CPP_REMOTE_VALUE_ATTRIBUTE_H_ diff --git a/src/NimBLEScan.cpp b/src/NimBLEScan.cpp index 713c84a1..72fb3c59 100644 --- a/src/NimBLEScan.cpp +++ b/src/NimBLEScan.cpp @@ -16,7 +16,7 @@ */ #include "NimBLEScan.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_OBSERVER +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_OBSERVER) # include "NimBLEDevice.h" # include "NimBLELog.h" @@ -63,7 +63,7 @@ int NimBLEScan::handleGapEvent(ble_gap_event* event, void* arg) { return 0; } -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_EXT_ADV) const auto& disc = event->ext_disc; const bool isLegacyAdv = disc.props & BLE_HCI_ADV_LEGACY_MASK; const auto event_type = isLegacyAdv ? disc.legacy_event_type : disc.props; @@ -74,7 +74,7 @@ int NimBLEScan::handleGapEvent(ble_gap_event* event, void* arg) { # endif NimBLEAddress advertisedAddress(disc.addr); -# if CONFIG_BT_NIMBLE_ROLE_CENTRAL +# if MYNEWT_VAL(BLE_ROLE_CENTRAL) // stop processing if already connected NimBLEClient* pClient = NimBLEDevice::getClientByPeerAddress(advertisedAddress); if (pClient != nullptr && pClient->isConnected()) { @@ -86,7 +86,7 @@ int NimBLEScan::handleGapEvent(ble_gap_event* event, void* arg) { // If we've seen this device before get a pointer to it from the vector for (const auto& dev : pScan->m_scanResults.m_deviceVec) { -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_EXT_ADV) // Same address but different set ID should create a new advertised device. if (dev->getAddress() == advertisedAddress && dev->getSetId() == disc.sid) # else @@ -272,7 +272,7 @@ bool NimBLEScan::isScanning() { return ble_gap_disc_active(); } -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_EXT_ADV) /** * @brief Set the PHYs to scan. * @param [in] phyMask The PHYs to scan, a bit mask of: @@ -324,7 +324,7 @@ bool NimBLEScan::start(uint32_t duration, bool isContinue, bool restart) { // If scanning is already active, call the functions anyway as the parameters can be changed. -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_EXT_ADV) ble_gap_ext_disc_params scan_params; scan_params.passive = m_scanParams.passive; scan_params.itvl = m_scanParams.itvl; @@ -560,4 +560,4 @@ void NimBLEScanCallbacks::onScanEnd(const NimBLEScanResults& results, int reason NIMBLE_LOGD(CB_TAG, "Scan ended; reason %d, num results: %d", reason, results.getCount()); } -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_OBSERVER +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_OBSERVER) diff --git a/src/NimBLEScan.h b/src/NimBLEScan.h index 7884d190..68f8def8 100644 --- a/src/NimBLEScan.h +++ b/src/NimBLEScan.h @@ -18,8 +18,8 @@ #ifndef NIMBLE_CPP_SCAN_H_ #define NIMBLE_CPP_SCAN_H_ -#include "nimconfig.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_OBSERVER +#include "syscfg/syscfg.h" +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_OBSERVER) # include "NimBLEAdvertisedDevice.h" # include "NimBLEUtils.h" @@ -83,7 +83,7 @@ class NimBLEScan { void erase(const NimBLEAddress& address); void erase(const NimBLEAdvertisedDevice* device); -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_EXT_ADV) enum Phy { SCAN_1M = 0x01, SCAN_CODED = 0x02, SCAN_ALL = 0x03 }; void setPhy(Phy phyMask); void setPeriod(uint32_t periodMs); @@ -103,7 +103,7 @@ class NimBLEScan { NimBLETaskData* m_pTaskData; uint8_t m_maxResults; -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_EXT_ADV) uint8_t m_phy{SCAN_ALL}; uint16_t m_period{0}; # endif @@ -136,5 +136,5 @@ class NimBLEScanCallbacks { virtual void onScanEnd(const NimBLEScanResults& scanResults, int reason); }; -#endif // CONFIG_BT_ENABLED CONFIG_BT_NIMBLE_ROLE_OBSERVER +#endif // CONFIG_BT_NIMBLE_ENABLED MYNEWT_VAL(BLE_ROLE_OBSERVER) #endif // NIMBLE_CPP_SCAN_H_ diff --git a/src/NimBLEServer.cpp b/src/NimBLEServer.cpp index 8694d850..a15f0927 100644 --- a/src/NimBLEServer.cpp +++ b/src/NimBLEServer.cpp @@ -16,12 +16,12 @@ */ #include "NimBLEServer.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL) # include "NimBLEDevice.h" # include "NimBLELog.h" -# if CONFIG_BT_NIMBLE_ROLE_CENTRAL +# if MYNEWT_VAL(BLE_ROLE_CENTRAL) # include "NimBLEClient.h" # endif @@ -49,7 +49,7 @@ NimBLEServer::NimBLEServer() : m_gattsStarted{false}, m_svcChanged{false}, m_deleteCallbacks{false}, -# if !CONFIG_BT_NIMBLE_EXT_ADV +# if !MYNEWT_VAL(BLE_EXT_ADV) m_advertiseOnDisconnect{false}, # endif m_pServerCallbacks{&defaultCallbacks}, @@ -69,7 +69,7 @@ NimBLEServer::~NimBLEServer() { delete m_pServerCallbacks; } -# if CONFIG_BT_NIMBLE_ROLE_CENTRAL +# if MYNEWT_VAL(BLE_ROLE_CENTRAL) if (m_pClient != nullptr) { delete m_pClient; } @@ -143,7 +143,7 @@ NimBLEService* NimBLEServer::getServiceByHandle(uint16_t handle) const { return nullptr; } -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_EXT_ADV) /** * @brief Retrieve the advertising object that can be used to advertise the existence of the server. * @return A pinter to an advertising object. @@ -153,7 +153,7 @@ NimBLEExtAdvertising* NimBLEServer::getAdvertising() const { } // getAdvertising # endif -# if (!CONFIG_BT_NIMBLE_EXT_ADV && CONFIG_BT_NIMBLE_ROLE_BROADCASTER) || defined(_DOXYGEN_) +# if (!MYNEWT_VAL(BLE_EXT_ADV) && MYNEWT_VAL(BLE_ROLE_BROADCASTER)) || defined(_DOXYGEN_) /** * @brief Retrieve the advertising object that can be used to advertise the existence of the server. * @return A pointer to an advertising object. @@ -250,7 +250,7 @@ bool NimBLEServer::disconnect(const NimBLEConnInfo& connInfo, uint8_t reason) co return disconnect(connInfo.getConnHandle(), reason); } // disconnect -# if !CONFIG_BT_NIMBLE_EXT_ADV || defined(_DOXYGEN_) +# if !MYNEWT_VAL(BLE_EXT_ADV) || defined(_DOXYGEN_) /** * @brief Set the server to automatically start advertising when a client disconnects. * @param [in] enable true == advertise, false == don't advertise. @@ -363,7 +363,7 @@ int NimBLEServer::handleGapEvent(ble_gap_event* event, void* arg) { NIMBLE_LOGE(LOG_TAG, "Connection failed rc = %d %s", rc, NimBLEUtils::returnCodeToString(rc)); -# if !CONFIG_BT_NIMBLE_EXT_ADV && CONFIG_BT_NIMBLE_ROLE_BROADCASTER +# if !MYNEWT_VAL(BLE_EXT_ADV) && MYNEWT_VAL(BLE_ROLE_BROADCASTER) NimBLEDevice::startAdvertising(); # endif } else { @@ -407,7 +407,7 @@ int NimBLEServer::handleGapEvent(ble_gap_event* event, void* arg) { } } -# if CONFIG_BT_NIMBLE_ROLE_CENTRAL +# if MYNEWT_VAL(BLE_ROLE_CENTRAL) if (pServer->m_pClient && pServer->m_pClient->m_connHandle == event->disconnect.conn.conn_handle) { // If this was also the client make sure it's flagged as disconnected. pServer->m_pClient->m_connHandle = BLE_HS_CONN_HANDLE_NONE; @@ -420,7 +420,7 @@ int NimBLEServer::handleGapEvent(ble_gap_event* event, void* arg) { peerInfo.m_desc = event->disconnect.conn; pServer->m_pServerCallbacks->onDisconnect(pServer, peerInfo, event->disconnect.reason); -# if !CONFIG_BT_NIMBLE_EXT_ADV +# if !MYNEWT_VAL(BLE_EXT_ADV) if (pServer->m_advertiseOnDisconnect) { pServer->startAdvertising(); } @@ -494,10 +494,10 @@ int NimBLEServer::handleGapEvent(ble_gap_event* event, void* arg) { } // BLE_GAP_EVENT_NOTIFY_TX case BLE_GAP_EVENT_ADV_COMPLETE: { -# if CONFIG_BT_NIMBLE_EXT_ADV && CONFIG_BT_NIMBLE_ROLE_BROADCASTER +# if MYNEWT_VAL(BLE_EXT_ADV) && MYNEWT_VAL(BLE_ROLE_BROADCASTER) case BLE_GAP_EVENT_SCAN_REQ_RCVD: return NimBLEExtAdvertising::handleGapEvent(event, arg); -# elif CONFIG_BT_NIMBLE_ROLE_BROADCASTER +# elif MYNEWT_VAL(BLE_ROLE_BROADCASTER) return NimBLEAdvertising::handleGapEvent(event, arg); # endif } // BLE_GAP_EVENT_ADV_COMPLETE | BLE_GAP_EVENT_SCAN_REQ_RCVD @@ -537,7 +537,7 @@ int NimBLEServer::handleGapEvent(ble_gap_event* event, void* arg) { } pServer->m_pServerCallbacks->onAuthenticationComplete(peerInfo); -# if CONFIG_BT_NIMBLE_ROLE_CENTRAL +# if MYNEWT_VAL(BLE_ROLE_CENTRAL) if (pServer->m_pClient && pServer->m_pClient->m_connHandle == event->enc_change.conn_handle) { NimBLEClient::handleGapEvent(event, pServer->m_pClient); } @@ -737,7 +737,7 @@ void NimBLEServer::removeService(NimBLEService* service, bool deleteSvc) { service->setRemoved(deleteSvc ? NIMBLE_ATT_REMOVE_DELETE : NIMBLE_ATT_REMOVE_HIDE); serviceChanged(); -# if !CONFIG_BT_NIMBLE_EXT_ADV && CONFIG_BT_NIMBLE_ROLE_BROADCASTER +# if !MYNEWT_VAL(BLE_EXT_ADV) && MYNEWT_VAL(BLE_ROLE_BROADCASTER) NimBLEDevice::getAdvertising()->removeServiceUUID(service->getUUID()); # endif } // removeService @@ -774,7 +774,7 @@ void NimBLEServer::resetGATT() { return; } -# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER +# if MYNEWT_VAL(BLE_ROLE_BROADCASTER) NimBLEDevice::stopAdvertising(); # endif ble_gatts_reset(); @@ -843,7 +843,7 @@ bool NimBLEServer::getPhy(uint16_t connHandle, uint8_t* txPhy, uint8_t* rxPhy) { return rc == 0; } // getPhy -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_EXT_ADV) /** * @brief Start advertising. * @param [in] instId The extended advertisement instance ID to start. @@ -868,7 +868,7 @@ bool NimBLEServer::stopAdvertising(uint8_t instId) const { # endif -# if (!CONFIG_BT_NIMBLE_EXT_ADV && CONFIG_BT_NIMBLE_ROLE_BROADCASTER) || defined(_DOXYGEN_) +# if (!MYNEWT_VAL(BLE_EXT_ADV) && MYNEWT_VAL(BLE_ROLE_BROADCASTER)) || defined(_DOXYGEN_) /** * @brief Start advertising. * @param [in] duration The duration in milliseconds to advertise for, default = forever. @@ -945,7 +945,7 @@ void NimBLEServer::setDataLen(uint16_t connHandle, uint16_t octets) const { # endif } // setDataLen -# if CONFIG_BT_NIMBLE_ROLE_CENTRAL +# if MYNEWT_VAL(BLE_ROLE_CENTRAL) /** * @brief Create a client instance from the connection handle. * @param [in] connHandle The connection handle to create a client instance from. @@ -1032,4 +1032,4 @@ void NimBLEServerCallbacks::onPhyUpdate(NimBLEConnInfo& connInfo, uint8_t txPhy, NIMBLE_LOGD("NimBLEServerCallbacks", "onPhyUpdate: default, txPhy: %d, rxPhy: %d", txPhy, rxPhy); } // onPhyUpdate -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL) diff --git a/src/NimBLEServer.h b/src/NimBLEServer.h index f8b6423b..214578ab 100644 --- a/src/NimBLEServer.h +++ b/src/NimBLEServer.h @@ -18,8 +18,8 @@ #ifndef NIMBLE_CPP_SERVER_H_ #define NIMBLE_CPP_SERVER_H_ -#include "nimconfig.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +#include "syscfg/syscfg.h" +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL) # if defined(CONFIG_NIMBLE_CPP_IDF) # include "host/ble_gap.h" @@ -45,14 +45,14 @@ class NimBLEConnInfo; class NimBLEAddress; class NimBLEService; class NimBLECharacteristic; -# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_ROLE_BROADCASTER) +# if MYNEWT_VAL(BLE_EXT_ADV) class NimBLEExtAdvertising; # else class NimBLEAdvertising; # endif # endif -# if CONFIG_BT_NIMBLE_ROLE_CENTRAL +# if MYNEWT_VAL(BLE_ROLE_CENTRAL) class NimBLEClient; # endif @@ -84,20 +84,20 @@ class NimBLEServer { bool updatePhy(uint16_t connHandle, uint8_t txPhysMask, uint8_t rxPhysMask, uint16_t phyOptions); bool getPhy(uint16_t connHandle, uint8_t* txPhy, uint8_t* rxPhy); -# if CONFIG_BT_NIMBLE_ROLE_CENTRAL +# if MYNEWT_VAL(BLE_ROLE_CENTRAL) NimBLEClient* getClient(uint16_t connHandle); NimBLEClient* getClient(const NimBLEConnInfo& connInfo); void deleteClient(); # endif -# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_ROLE_BROADCASTER) +# if MYNEWT_VAL(BLE_EXT_ADV) NimBLEExtAdvertising* getAdvertising() const; bool startAdvertising(uint8_t instanceId, int duration = 0, int maxEvents = 0) const; bool stopAdvertising(uint8_t instanceId) const; # endif -# if !CONFIG_BT_NIMBLE_EXT_ADV || defined(_DOXYGEN_) +# if !MYNEWT_VAL(BLE_EXT_ADV) || defined(_DOXYGEN_) NimBLEAdvertising* getAdvertising() const; bool startAdvertising(uint32_t duration = 0) const; bool stopAdvertising() const; @@ -108,8 +108,8 @@ class NimBLEServer { friend class NimBLEDevice; friend class NimBLEService; friend class NimBLECharacteristic; -# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_ROLE_BROADCASTER) +# if MYNEWT_VAL(BLE_EXT_ADV) friend class NimBLEExtAdvertising; # else friend class NimBLEAdvertising; @@ -122,14 +122,14 @@ class NimBLEServer { bool m_gattsStarted : 1; bool m_svcChanged : 1; bool m_deleteCallbacks : 1; -# if !CONFIG_BT_NIMBLE_EXT_ADV +# if !MYNEWT_VAL(BLE_EXT_ADV) bool m_advertiseOnDisconnect : 1; # endif NimBLEServerCallbacks* m_pServerCallbacks; std::vector m_svcVec; - std::array m_connectedPeers; + std::array m_connectedPeers; -# if CONFIG_BT_NIMBLE_ROLE_CENTRAL +# if MYNEWT_VAL(BLE_ROLE_CENTRAL) NimBLEClient* m_pClient{nullptr}; # endif @@ -223,5 +223,5 @@ class NimBLEServerCallbacks { virtual void onPhyUpdate(NimBLEConnInfo& connInfo, uint8_t txPhy, uint8_t rxPhy); }; // NimBLEServerCallbacks -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL) #endif // NIMBLE_CPP_SERVER_H_ diff --git a/src/NimBLEService.cpp b/src/NimBLEService.cpp index db6c75fe..6a086966 100644 --- a/src/NimBLEService.cpp +++ b/src/NimBLEService.cpp @@ -16,9 +16,9 @@ */ #include "NimBLEService.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL) -# if CONFIG_BT_NIMBLE_EXT_ADV +# if MYNEWT_VAL(BLE_EXT_ADV) # include "NimBLEExtAdvertising.h" # else # include "NimBLEAdvertising.h" @@ -375,4 +375,4 @@ bool NimBLEService::isStarted() const { return m_pSvcDef->type > 0; } // isStarted -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL) diff --git a/src/NimBLEService.h b/src/NimBLEService.h index 357f32cd..11d7c59c 100644 --- a/src/NimBLEService.h +++ b/src/NimBLEService.h @@ -18,8 +18,8 @@ #ifndef NIMBLE_CPP_SERVICE_H_ #define NIMBLE_CPP_SERVICE_H_ -#include "nimconfig.h" -#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +#include "syscfg/syscfg.h" +#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL) class NimBLEService; @@ -69,5 +69,5 @@ class NimBLEService : public NimBLELocalAttribute { ble_gatt_svc_def m_pSvcDef[2]{}; }; // NimBLEService -#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL +#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL) #endif // NIMBLE_CPP_SERVICE_H_ diff --git a/src/NimBLEUUID.cpp b/src/NimBLEUUID.cpp index d2604633..25954895 100644 --- a/src/NimBLEUUID.cpp +++ b/src/NimBLEUUID.cpp @@ -16,7 +16,7 @@ */ #include "NimBLEUUID.h" -#if CONFIG_BT_ENABLED +#if CONFIG_BT_NIMBLE_ENABLED # include "NimBLEUtils.h" # include "NimBLELog.h" @@ -336,4 +336,4 @@ NimBLEUUID::operator std::string() const { return ble_uuid_to_str(&m_uuid.u, buf); } // operator std::string -#endif /* CONFIG_BT_ENABLED */ +#endif /* CONFIG_BT_NIMBLE_ENABLED */ diff --git a/src/NimBLEUUID.h b/src/NimBLEUUID.h index 39b58b97..cadd6fdc 100644 --- a/src/NimBLEUUID.h +++ b/src/NimBLEUUID.h @@ -18,8 +18,8 @@ #ifndef NIMBLE_CPP_UUID_H_ #define NIMBLE_CPP_UUID_H_ -#include "nimconfig.h" -#if CONFIG_BT_ENABLED +#include "syscfg/syscfg.h" +#if CONFIG_BT_NIMBLE_ENABLED # if defined(CONFIG_NIMBLE_CPP_IDF) # include "host/ble_uuid.h" @@ -70,5 +70,5 @@ class NimBLEUUID { ble_uuid_any_t m_uuid{}; }; // NimBLEUUID -#endif // CONFIG_BT_ENABLED +#endif // CONFIG_BT_NIMBLE_ENABLED #endif // NIMBLE_CPP_UUID_H_ diff --git a/src/NimBLEUtils.cpp b/src/NimBLEUtils.cpp index f51d6823..e34255d0 100644 --- a/src/NimBLEUtils.cpp +++ b/src/NimBLEUtils.cpp @@ -16,7 +16,7 @@ */ #include "NimBLEUtils.h" -#if CONFIG_BT_ENABLED +#if CONFIG_BT_NIMBLE_ENABLED # include "NimBLEAddress.h" # include "NimBLELog.h" @@ -576,4 +576,4 @@ NimBLEAddress NimBLEUtils::generateAddr(bool nrpa) { return NimBLEAddress{addr}; } // generateAddr -#endif // CONFIG_BT_ENABLED +#endif // CONFIG_BT_NIMBLE_ENABLED diff --git a/src/NimBLEUtils.h b/src/NimBLEUtils.h index e70cf8fe..ca8e7d23 100644 --- a/src/NimBLEUtils.h +++ b/src/NimBLEUtils.h @@ -18,8 +18,20 @@ #ifndef NIMBLE_CPP_UTILS_H_ #define NIMBLE_CPP_UTILS_H_ -#include "nimconfig.h" -#if CONFIG_BT_ENABLED +#include "syscfg/syscfg.h" +#if CONFIG_BT_NIMBLE_ENABLED + +#if CONFIG_NIMBLE_CPP_DEBUG_ASSERT_ENABLED && !defined NDEBUG +void nimble_cpp_assert(const char *file, unsigned line) __attribute((weak, noreturn)); +# define NIMBLE_ATT_VAL_FILE (__builtin_strrchr(__FILE__, '/') ? \ + __builtin_strrchr (__FILE__, '/') + 1 : __FILE__) +# define NIMBLE_CPP_DEBUG_ASSERT(cond) \ + if (!(cond)) { \ + nimble_cpp_assert(NIMBLE_ATT_VAL_FILE, __LINE__); \ + } +#else +# define NIMBLE_CPP_DEBUG_ASSERT(cond) (void(0)) +#endif # include @@ -56,5 +68,5 @@ class NimBLEUtils { static void taskRelease(const NimBLETaskData& taskData, int rc = 0); }; -#endif // CONFIG_BT_ENABLED +#endif // CONFIG_BT_NIMBLE_ENABLED #endif // NIMBLE_CPP_UTILS_H_ diff --git a/src/NimBLEValueAttribute.h b/src/NimBLEValueAttribute.h index a03535a3..cd08650f 100644 --- a/src/NimBLEValueAttribute.h +++ b/src/NimBLEValueAttribute.h @@ -18,8 +18,8 @@ #ifndef NIMBLE_CPP_VALUE_ATTRIBUTE_H_ #define NIMBLE_CPP_VALUE_ATTRIBUTE_H_ -#include "nimconfig.h" -#if CONFIG_BT_ENABLED && (CONFIG_BT_NIMBLE_ROLE_PERIPHERAL || CONFIG_BT_NIMBLE_ROLE_CENTRAL) +#include "syscfg/syscfg.h" +#if CONFIG_BT_NIMBLE_ENABLED && (MYNEWT_VAL(BLE_ROLE_PERIPHERAL) || MYNEWT_VAL(BLE_ROLE_CENTRAL)) # include "NimBLEAttribute.h" # include "NimBLEAttValue.h" @@ -82,5 +82,5 @@ class NimBLEValueAttribute { NimBLEAttValue m_value{}; }; -#endif // CONFIG_BT_ENABLED && (CONFIG_BT_NIMBLE_ROLE_PERIPHERAL || CONFIG_BT_NIMBLE_ROLE_CENTRAL) +#endif // CONFIG_BT_NIMBLE_ENABLED && (MYNEWT_VAL(BLE_ROLE_PERIPHERAL) || MYNEWT_VAL(BLE_ROLE_CENTRAL)) #endif // NIMBLE_CPP_ATTRIBUTE_H_ diff --git a/src/nimble/esp_port/port/include/esp_nimble_cfg.h b/src/nimble/esp_port/port/include/esp_nimble_cfg.h index 4f9d1a15..b04ed780 100644 --- a/src/nimble/esp_port/port/include/esp_nimble_cfg.h +++ b/src/nimble/esp_port/port/include/esp_nimble_cfg.h @@ -87,17 +87,17 @@ #endif #endif -#ifndef CONFIG_BT_NIMBLE_EXT_ADV -#define MYNEWT_VAL_BLE_EXT_ADV (0) -#else -#define MYNEWT_VAL_BLE_EXT_ADV (CONFIG_BT_NIMBLE_EXT_ADV) -#endif +// #ifndef CONFIG_BT_NIMBLE_EXT_ADV +// #define MYNEWT_VAL_BLE_EXT_ADV (0) +// #else +// #define MYNEWT_VAL_BLE_EXT_ADV (CONFIG_BT_NIMBLE_EXT_ADV) +// #endif -#ifndef CONFIG_BT_NIMBLE_EXT_ADV_MAX_SIZE -#define MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE (31) -#else -#define MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE (CONFIG_BT_NIMBLE_EXT_ADV_MAX_SIZE) -#endif +// #ifndef CONFIG_BT_NIMBLE_EXT_ADV_MAX_SIZE +// #define MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE (31) +// #else +// #define MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE (CONFIG_BT_NIMBLE_EXT_ADV_MAX_SIZE) +// #endif #ifndef CONFIG_BT_NIMBLE_ENC_ADV_DATA #define MYNEWT_VAL_ENC_ADV_DATA (0) @@ -177,35 +177,35 @@ #define MYNEWT_VAL_BLE_PERIODIC_ADV (CONFIG_BT_NIMBLE_ENABLE_PERIODIC_ADV) #endif -#ifndef CONFIG_NIMBLE_MAX_CONNECTIONS -#define MYNEWT_VAL_BLE_MAX_CONNECTIONS (4) -#else -#define MYNEWT_VAL_BLE_MAX_CONNECTIONS (CONFIG_NIMBLE_MAX_CONNECTIONS) -#endif +// #ifndef CONFIG_NIMBLE_MAX_CONNECTIONS +// #define MYNEWT_VAL_BLE_MAX_CONNECTIONS (4) +// #else +// #define MYNEWT_VAL_BLE_MAX_CONNECTIONS (CONFIG_NIMBLE_MAX_CONNECTIONS) +// #endif -#ifndef CONFIG_BT_NIMBLE_ROLE_BROADCASTER -#define MYNEWT_VAL_BLE_ROLE_BROADCASTER (0) -#else -#define MYNEWT_VAL_BLE_ROLE_BROADCASTER (CONFIG_BT_NIMBLE_ROLE_BROADCASTER) -#endif +// #ifndef CONFIG_BT_NIMBLE_ROLE_BROADCASTER +// #define MYNEWT_VAL_BLE_ROLE_BROADCASTER (0) +// #else +// #define MYNEWT_VAL_BLE_ROLE_BROADCASTER (CONFIG_BT_NIMBLE_ROLE_BROADCASTER) +// #endif -#ifndef CONFIG_BT_NIMBLE_ROLE_CENTRAL -#define MYNEWT_VAL_BLE_ROLE_CENTRAL (0) -#else -#define MYNEWT_VAL_BLE_ROLE_CENTRAL (CONFIG_BT_NIMBLE_ROLE_CENTRAL) -#endif +// #ifndef CONFIG_BT_NIMBLE_ROLE_CENTRAL +// #define MYNEWT_VAL_BLE_ROLE_CENTRAL (0) +// #else +// #define MYNEWT_VAL_BLE_ROLE_CENTRAL (CONFIG_BT_NIMBLE_ROLE_CENTRAL) +// #endif -#ifndef CONFIG_BT_NIMBLE_ROLE_OBSERVER -#define MYNEWT_VAL_BLE_ROLE_OBSERVER (0) -#else -#define MYNEWT_VAL_BLE_ROLE_OBSERVER (CONFIG_BT_NIMBLE_ROLE_OBSERVER) -#endif +// #ifndef CONFIG_BT_NIMBLE_ROLE_OBSERVER +// #define MYNEWT_VAL_BLE_ROLE_OBSERVER (0) +// #else +// #define MYNEWT_VAL_BLE_ROLE_OBSERVER (CONFIG_BT_NIMBLE_ROLE_OBSERVER) +// #endif -#ifndef CONFIG_BT_NIMBLE_ROLE_PERIPHERAL -#define MYNEWT_VAL_BLE_ROLE_PERIPHERAL (0) -#else -#define MYNEWT_VAL_BLE_ROLE_PERIPHERAL (CONFIG_BT_NIMBLE_ROLE_PERIPHERAL) -#endif +// #ifndef MYNEWT_VAL(BLE_ROLE_PERIPHERAL) +// #define MYNEWT_VAL_BLE_ROLE_PERIPHERAL (0) +// #else +// #define MYNEWT_VAL_BLE_ROLE_PERIPHERAL (MYNEWT_VAL(BLE_ROLE_PERIPHERAL)) +// #endif #ifndef MYNEWT_VAL_BLE_WHITELIST #define MYNEWT_VAL_BLE_WHITELIST (1) @@ -834,7 +834,7 @@ #endif #ifndef MYNEWT_VAL_BLE_L2CAP_MAX_CHANS -#define MYNEWT_VAL_BLE_L2CAP_MAX_CHANS (3*CONFIG_BT_NIMBLE_MAX_CONNECTIONS) +#define MYNEWT_VAL_BLE_L2CAP_MAX_CHANS (3*MYNEWT_VAL_BLE_MAX_CONNECTIONS) #endif #ifndef MYNEWT_VAL_BLE_L2CAP_RX_FRAG_TIMEOUT @@ -991,7 +991,7 @@ #endif #ifndef MYNEWT_VAL_BLE_STORE_MAX_CSFCS -#define MYNEWT_VAL_BLE_STORE_MAX_CSFCS (CONFIG_BT_NIMBLE_MAX_CONNECTIONS) +#define MYNEWT_VAL_BLE_STORE_MAX_CSFCS (MYNEWT_VAL_BLE_MAX_CONNECTIONS) #endif #ifdef CONFIG_BT_NIMBLE_MAX_EADS @@ -1767,11 +1767,11 @@ CONFIG_BT_NIMBLE_SVC_GAP_CENT_ADDR_RESOLUTION #endif -#ifndef CONFIG_BT_NIMBLE_SVC_GAP_DEVICE_NAME -#define MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME "nimble" -#else -#define MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME CONFIG_BT_NIMBLE_SVC_GAP_DEVICE_NAME -#endif +// #ifndef CONFIG_BT_NIMBLE_SVC_GAP_DEVICE_NAME +// #define MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME "nimble" +// #else +// #define MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME CONFIG_BT_NIMBLE_SVC_GAP_DEVICE_NAME +// #endif #ifndef MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME_MAX_LENGTH #define MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME_MAX_LENGTH CONFIG_BT_NIMBLE_GAP_DEVICE_NAME_MAX_LEN // According to the specification, the maximum length should be 248 diff --git a/src/nimble/esp_port/port/src/exp_nimble_mem.c b/src/nimble/esp_port/port/src/exp_nimble_mem.c index 633a4209..9bef0e1a 100644 --- a/src/nimble/esp_port/port/src/exp_nimble_mem.c +++ b/src/nimble/esp_port/port/src/exp_nimble_mem.c @@ -8,16 +8,16 @@ #include "esp_attr.h" #include "esp_heap_caps.h" - #include "nimconfig.h" + #include "syscfg/syscfg.h" #include "../include/esp_nimble_mem.h" void *nimble_platform_mem_malloc(size_t size) { - #ifdef CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_INTERNAL + #if MYNEWT_VAL(NIMBLE_MEM_ALLOC_MODE_INTERNAL) return heap_caps_malloc(size, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT); - #elif CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_EXTERNAL + #elif MYNEWT_VAL(NIMBLE_MEM_ALLOC_MODE_EXTERNAL) return heap_caps_malloc(size, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT); - #elif CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_IRAM_8BIT + #elif MYNEWT_VAL(NIMBLE_MEM_ALLOC_MODE_IRAM_8BIT) return heap_caps_malloc_prefer(size, 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT); #else return malloc(size); @@ -26,11 +26,11 @@ void *nimble_platform_mem_calloc(size_t n, size_t size) { - #ifdef CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_INTERNAL + #if MYNEWT_VAL(NIMBLE_MEM_ALLOC_MODE_INTERNAL) return heap_caps_calloc(n, size, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT); - #elif CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_EXTERNAL + #elif MYNEWT_VAL(NIMBLE_MEM_ALLOC_MODE_EXTERNAL) return heap_caps_calloc(n, size, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT); - #elif CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_IRAM_8BIT + #elif MYNEWT_VAL(NIMBLE_MEM_ALLOC_MODE_IRAM_8BIT) return heap_caps_calloc_prefer(n, size, 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT); #else return calloc(n, size); diff --git a/src/nimble/nimble/host/mesh/src/mesh.c b/src/nimble/nimble/host/mesh/src/mesh.c index 8257805a..3a25fbde 100644 --- a/src/nimble/nimble/host/mesh/src/mesh.c +++ b/src/nimble/nimble/host/mesh/src/mesh.c @@ -311,7 +311,7 @@ int bt_mesh_init(uint8_t own_addr_type, const struct bt_mesh_prov *prov, g_mesh_addr_type = own_addr_type; /* initialize SM alg ECC subsystem (it is used directly from mesh code) */ - ble_sm_alg_ecc_init(); + na_ble_sm_alg_ecc_init(); err = bt_mesh_comp_register(comp); if (err) { diff --git a/src/nimble/nimble/host/src/ble_att_clt.c b/src/nimble/nimble/host/src/ble_att_clt.c index b1baa627..72769cdc 100644 --- a/src/nimble/nimble/host/src/ble_att_clt.c +++ b/src/nimble/nimble/host/src/ble_att_clt.c @@ -829,7 +829,7 @@ ble_att_clt_tx_signed_write_cmd(uint16_t conn_handle, uint16_t cid, uint16_t han /** Copying sign counter */ memcpy(&message[BLE_ATT_SIGNED_WRITE_DATA_OFFSET + OS_MBUF_PKTLEN(txom)], &counter, sizeof(counter)); - /* ble_sm_alg_aes_cmac takes data in little-endian format, + /* na_ble_sm_alg_aes_cmac takes data in little-endian format, * so converting it to LE. */ swap_in_place(message, len); @@ -838,7 +838,7 @@ ble_att_clt_tx_signed_write_cmd(uint16_t conn_handle, uint16_t cid, uint16_t han * for the message using our CSRK for this connection. */ memset(cmac, 0, sizeof cmac); - rc = ble_sm_alg_aes_cmac(csrk, message, len, cmac); + rc = na_ble_sm_alg_aes_cmac(csrk, message, len, cmac); if (rc != 0) { goto err; } diff --git a/src/nimble/nimble/host/src/ble_att_svr.c b/src/nimble/nimble/host/src/ble_att_svr.c index 3d2ece37..4e7b212b 100644 --- a/src/nimble/nimble/host/src/ble_att_svr.c +++ b/src/nimble/nimble/host/src/ble_att_svr.c @@ -2467,7 +2467,7 @@ ble_att_svr_rx_signed_write(uint16_t conn_handle, uint16_t cid, struct os_mbuf * /* Using AES-CMAC to get the CMAC from the message and CSRK of this device */ memset(cmac, 0, sizeof cmac); - rc = ble_sm_alg_aes_cmac(csrk, message, len, cmac); + rc = na_ble_sm_alg_aes_cmac(csrk, message, len, cmac); if (rc != 0) { goto err; } diff --git a/src/nimble/nimble/host/src/ble_gatts.c b/src/nimble/nimble/host/src/ble_gatts.c index e0441ad0..31f9b00c 100644 --- a/src/nimble/nimble/host/src/ble_gatts.c +++ b/src/nimble/nimble/host/src/ble_gatts.c @@ -619,7 +619,7 @@ ble_gatts_calculate_hash(uint8_t *out_hash_key) goto done; } - rc = ble_sm_alg_aes_cmac(key, buf, size, out_hash_key); + rc = na_ble_sm_alg_aes_cmac(key, buf, size, out_hash_key); if(rc != 0) { goto done; } diff --git a/src/nimble/nimble/host/src/ble_hs_resolv.c b/src/nimble/nimble/host/src/ble_hs_resolv.c index 3dfa93dd..7dd09d89 100644 --- a/src/nimble/nimble/host/src/ble_hs_resolv.c +++ b/src/nimble/nimble/host/src/ble_hs_resolv.c @@ -410,7 +410,7 @@ ble_hs_resolv_gen_priv_addr(struct ble_hs_resolv_entry *rl, int local) swap_in_place(ecb.plain_text, 16); /* Calculate hash */ - if (ble_sm_alg_encrypt(ecb.key, ecb.plain_text, ecb.cipher_text) != 0) { + if (na_ble_sm_alg_encrypt(ecb.key, ecb.plain_text, ecb.cipher_text) != 0) { /* We can't do much here if the encryption fails */ return; } @@ -768,8 +768,8 @@ ble_hs_resolv_rpa(uint8_t *rpa, uint8_t *irk) swap_in_place(ecb.plain_text, 16); - /* Send the data to ble_sm_alg_encrypt in little-endian style */ - rc = ble_sm_alg_encrypt(ecb.key, ecb.plain_text, ecb.cipher_text); + /* Send the data to na_ble_sm_alg_encrypt in little-endian style */ + rc = na_ble_sm_alg_encrypt(ecb.key, ecb.plain_text, ecb.cipher_text); if (rc != 0) { return rc; } diff --git a/src/nimble/nimble/host/src/ble_sm_alg.c b/src/nimble/nimble/host/src/ble_sm_alg.c index 95748810..ef4d58a2 100644 --- a/src/nimble/nimble/host/src/ble_sm_alg.c +++ b/src/nimble/nimble/host/src/ble_sm_alg.c @@ -91,7 +91,7 @@ ble_sm_alg_xor_128(const uint8_t *p, const uint8_t *q, uint8_t *r) } int -ble_sm_alg_encrypt(const uint8_t *key, const uint8_t *plaintext, +na_ble_sm_alg_encrypt(const uint8_t *key, const uint8_t *plaintext, uint8_t *enc_data) { uint8_t tmp[16]; @@ -135,7 +135,7 @@ ble_sm_alg_encrypt(const uint8_t *key, const uint8_t *plaintext, } int -ble_sm_alg_s1(const uint8_t *k, const uint8_t *r1, const uint8_t *r2, +na_ble_sm_alg_s1(const uint8_t *k, const uint8_t *r1, const uint8_t *r2, uint8_t *out) { int rc; @@ -152,12 +152,12 @@ ble_sm_alg_s1(const uint8_t *k, const uint8_t *r1, const uint8_t *r2, memcpy(out + 8, r1, 8); /* s1(k, r1 , r2) = e(k, r') */ - rc = ble_sm_alg_encrypt(k, out, out); + rc = na_ble_sm_alg_encrypt(k, out, out); if (rc != 0) { return rc; } - BLE_HS_LOG(DEBUG, "ble_sm_alg_s1()\n k="); + BLE_HS_LOG(DEBUG, "na_ble_sm_alg_s1()\n k="); ble_hs_log_flat_buf(k, 16); BLE_HS_LOG(DEBUG, "\n r1="); ble_hs_log_flat_buf(r1, 16); @@ -171,7 +171,7 @@ ble_sm_alg_s1(const uint8_t *k, const uint8_t *r1, const uint8_t *r2, } int -ble_sm_alg_c1(const uint8_t *k, const uint8_t *r, +na_ble_sm_alg_c1(const uint8_t *k, const uint8_t *r, const uint8_t *preq, const uint8_t *pres, uint8_t iat, uint8_t rat, const uint8_t *ia, const uint8_t *ra, @@ -180,7 +180,7 @@ ble_sm_alg_c1(const uint8_t *k, const uint8_t *r, uint8_t p1[16], p2[16]; int rc; - BLE_HS_LOG(DEBUG, "ble_sm_alg_c1()\n k="); + BLE_HS_LOG(DEBUG, "na_ble_sm_alg_c1()\n k="); ble_hs_log_flat_buf(k, 16); BLE_HS_LOG(DEBUG, "\n r="); ble_hs_log_flat_buf(r, 16); @@ -208,7 +208,7 @@ ble_sm_alg_c1(const uint8_t *k, const uint8_t *r, /* Using out_enc_data as temporary output buffer */ ble_sm_alg_xor_128(r, p1, out_enc_data); - rc = ble_sm_alg_encrypt(k, out_enc_data, out_enc_data); + rc = na_ble_sm_alg_encrypt(k, out_enc_data, out_enc_data); if (rc != 0) { rc = BLE_HS_EUNKNOWN; goto done; @@ -224,7 +224,7 @@ ble_sm_alg_c1(const uint8_t *k, const uint8_t *r, ble_sm_alg_xor_128(out_enc_data, p2, out_enc_data); - rc = ble_sm_alg_encrypt(k, out_enc_data, out_enc_data); + rc = na_ble_sm_alg_encrypt(k, out_enc_data, out_enc_data); if (rc != 0) { rc = BLE_HS_EUNKNOWN; goto done; @@ -251,7 +251,7 @@ ble_sm_alg_c1(const uint8_t *k, const uint8_t *r, #if MYNEWT_VAL(BLE_CRYPTO_STACK_MBEDTLS) int -ble_sm_alg_aes_cmac(const uint8_t *key, const uint8_t *in, size_t len, +na_ble_sm_alg_aes_cmac(const uint8_t *key, const uint8_t *in, size_t len, uint8_t *out) { int rc = BLE_HS_EUNKNOWN; @@ -289,7 +289,7 @@ ble_sm_alg_aes_cmac(const uint8_t *key, const uint8_t *in, size_t len, #else int -ble_sm_alg_aes_cmac(const uint8_t *key, const uint8_t *in, size_t len, +na_ble_sm_alg_aes_cmac(const uint8_t *key, const uint8_t *in, size_t len, uint8_t *out) { struct tc_aes_key_sched_struct sched; @@ -322,14 +322,14 @@ ble_sm_alg_log_buf(const char *name, const uint8_t *buf, int len) } int -ble_sm_alg_f4(const uint8_t *u, const uint8_t *v, const uint8_t *x, +na_ble_sm_alg_f4(const uint8_t *u, const uint8_t *v, const uint8_t *x, uint8_t z, uint8_t *out_enc_data) { uint8_t xs[16]; uint8_t m[65]; int rc; - BLE_HS_LOG(DEBUG, "ble_sm_alg_f4()\n u="); + BLE_HS_LOG(DEBUG, "na_ble_sm_alg_f4()\n u="); ble_hs_log_flat_buf(u, 32); BLE_HS_LOG(DEBUG, "\n v="); ble_hs_log_flat_buf(v, 32); @@ -344,7 +344,7 @@ ble_sm_alg_f4(const uint8_t *u, const uint8_t *v, const uint8_t *x, * Core Spec 4.2 Vol 3 Part H 2.2.5 * * note: - * ble_sm_alg_aes_cmac uses BE data; ble_sm_alg_f4 accepts LE so we swap. + * na_ble_sm_alg_aes_cmac uses BE data; na_ble_sm_alg_f4 accepts LE so we swap. */ swap_buf(m, u, 32); swap_buf(m + 32, v, 32); @@ -352,7 +352,7 @@ ble_sm_alg_f4(const uint8_t *u, const uint8_t *v, const uint8_t *x, swap_buf(xs, x, 16); - rc = ble_sm_alg_aes_cmac(xs, m, sizeof(m), out_enc_data); + rc = na_ble_sm_alg_aes_cmac(xs, m, sizeof(m), out_enc_data); if (rc != 0) { return BLE_HS_EUNKNOWN; } @@ -367,7 +367,7 @@ ble_sm_alg_f4(const uint8_t *u, const uint8_t *v, const uint8_t *x, } int -ble_sm_alg_f5(const uint8_t *w, const uint8_t *n1, const uint8_t *n2, +na_ble_sm_alg_f5(const uint8_t *w, const uint8_t *n1, const uint8_t *n2, uint8_t a1t, const uint8_t *a1, uint8_t a2t, const uint8_t *a2, uint8_t *mackey, uint8_t *ltk) { @@ -389,14 +389,14 @@ ble_sm_alg_f5(const uint8_t *w, const uint8_t *n1, const uint8_t *n2, uint8_t t[16]; int rc; - BLE_HS_LOG(DEBUG, "ble_sm_alg_f5()\n"); + BLE_HS_LOG(DEBUG, "na_ble_sm_alg_f5()\n"); ble_sm_alg_log_buf("w", w, 32); ble_sm_alg_log_buf("n1", n1, 16); ble_sm_alg_log_buf("n2", n2, 16); swap_buf(ws, w, 32); - rc = ble_sm_alg_aes_cmac(salt, ws, 32, t); + rc = na_ble_sm_alg_aes_cmac(salt, ws, 32, t); if (rc != 0) { return BLE_HS_EUNKNOWN; } @@ -410,7 +410,7 @@ ble_sm_alg_f5(const uint8_t *w, const uint8_t *n1, const uint8_t *n2, m[44] = a2t; swap_buf(m + 45, a2, 6); - rc = ble_sm_alg_aes_cmac(t, m, sizeof(m), mackey); + rc = na_ble_sm_alg_aes_cmac(t, m, sizeof(m), mackey); if (rc != 0) { return BLE_HS_EUNKNOWN; } @@ -422,7 +422,7 @@ ble_sm_alg_f5(const uint8_t *w, const uint8_t *n1, const uint8_t *n2, /* Counter for ltk is 1. */ m[0] = 0x01; - rc = ble_sm_alg_aes_cmac(t, m, sizeof(m), ltk); + rc = na_ble_sm_alg_aes_cmac(t, m, sizeof(m), ltk); if (rc != 0) { return BLE_HS_EUNKNOWN; } @@ -435,7 +435,7 @@ ble_sm_alg_f5(const uint8_t *w, const uint8_t *n1, const uint8_t *n2, } int -ble_sm_alg_f6(const uint8_t *w, const uint8_t *n1, const uint8_t *n2, +na_ble_sm_alg_f6(const uint8_t *w, const uint8_t *n1, const uint8_t *n2, const uint8_t *r, const uint8_t *iocap, uint8_t a1t, const uint8_t *a1, uint8_t a2t, const uint8_t *a2, uint8_t *check) @@ -444,7 +444,7 @@ ble_sm_alg_f6(const uint8_t *w, const uint8_t *n1, const uint8_t *n2, uint8_t m[65]; int rc; - BLE_HS_LOG(DEBUG, "ble_sm_alg_f6()\n"); + BLE_HS_LOG(DEBUG, "na_ble_sm_alg_f6()\n"); ble_sm_alg_log_buf("w", w, 16); ble_sm_alg_log_buf("n1", n1, 16); ble_sm_alg_log_buf("n2", n2, 16); @@ -470,7 +470,7 @@ ble_sm_alg_f6(const uint8_t *w, const uint8_t *n1, const uint8_t *n2, swap_buf(ws, w, 16); - rc = ble_sm_alg_aes_cmac(ws, m, sizeof(m), check); + rc = na_ble_sm_alg_aes_cmac(ws, m, sizeof(m), check); if (rc != 0) { return BLE_HS_EUNKNOWN; } @@ -483,13 +483,13 @@ ble_sm_alg_f6(const uint8_t *w, const uint8_t *n1, const uint8_t *n2, } int -ble_sm_alg_g2(const uint8_t *u, const uint8_t *v, const uint8_t *x, +na_ble_sm_alg_g2(const uint8_t *u, const uint8_t *v, const uint8_t *x, const uint8_t *y, uint32_t *passkey) { uint8_t m[80], xs[16]; int rc; - BLE_HS_LOG(DEBUG, "ble_sm_alg_g2()\n"); + BLE_HS_LOG(DEBUG, "na_ble_sm_alg_g2()\n"); ble_sm_alg_log_buf("u", u, 32); ble_sm_alg_log_buf("v", v, 32); ble_sm_alg_log_buf("x", x, 16); @@ -502,7 +502,7 @@ ble_sm_alg_g2(const uint8_t *u, const uint8_t *v, const uint8_t *x, swap_buf(xs, x, 16); /* reuse xs (key) as buffer for result */ - rc = ble_sm_alg_aes_cmac(xs, m, sizeof(m), xs); + rc = na_ble_sm_alg_aes_cmac(xs, m, sizeof(m), xs); if (rc != 0) { return BLE_HS_EUNKNOWN; } @@ -688,7 +688,7 @@ mbedtls_gen_keypair(uint8_t *public_key, uint8_t *private_key) return 0; } -void mbedtls_free_keypair(void) +void na_mbedtls_free_keypair(void) { mbedtls_ecp_keypair_free(&keypair); } @@ -765,7 +765,7 @@ ble_sm_alg_rand(uint8_t *dst, unsigned int size) #endif void -ble_sm_alg_ecc_init(void) +na_ble_sm_alg_ecc_init(void) { #if (!MYNEWT_VAL(BLE_CRYPTO_STACK_MBEDTLS)) uECC_set_rng(ble_sm_alg_rand); diff --git a/src/nimble/nimble/host/src/ble_sm_lgcy.c b/src/nimble/nimble/host/src/ble_sm_lgcy.c index 1a53aa82..3c7ce9ca 100644 --- a/src/nimble/nimble/host/src/ble_sm_lgcy.c +++ b/src/nimble/nimble/host/src/ble_sm_lgcy.c @@ -127,7 +127,7 @@ ble_sm_lgcy_confirm_exec(struct ble_sm_proc *proc, struct ble_sm_result *res) ble_sm_ia_ra(proc, &iat, ia, &rat, ra); - rc = ble_sm_alg_c1(proc->tk, ble_sm_our_pair_rand(proc), proc->pair_req, + rc = na_ble_sm_alg_c1(proc->tk, ble_sm_our_pair_rand(proc), proc->pair_req, proc->pair_rsp, iat, rat, ia, ra, cmd->value); if (rc != 0) { goto err; @@ -160,7 +160,7 @@ ble_sm_gen_stk(struct ble_sm_proc *proc) uint8_t key[16]; int rc; - rc = ble_sm_alg_s1(proc->tk, proc->rands, proc->randm, key); + rc = na_ble_sm_alg_s1(proc->tk, proc->rands, proc->randm, key); if (rc != 0) { return rc; } @@ -215,7 +215,7 @@ ble_sm_lgcy_random_rx(struct ble_sm_proc *proc, struct ble_sm_result *res) ble_sm_ia_ra(proc, &iat, ia, &rat, ra); - rc = ble_sm_alg_c1(proc->tk, ble_sm_peer_pair_rand(proc), proc->pair_req, + rc = na_ble_sm_alg_c1(proc->tk, ble_sm_peer_pair_rand(proc), proc->pair_req, proc->pair_rsp, iat, rat, ia, ra, confirm_val); if (rc != 0) { res->app_status = rc; diff --git a/src/nimble/nimble/host/src/ble_sm_priv.h b/src/nimble/nimble/host/src/ble_sm_priv.h index 59fcc1e0..1b238184 100644 --- a/src/nimble/nimble/host/src/ble_sm_priv.h +++ b/src/nimble/nimble/host/src/ble_sm_priv.h @@ -301,21 +301,21 @@ void ble_sm_dbg_set_sc_keys(uint8_t *pubkey, uint8_t *privkey); int ble_sm_num_procs(void); -int ble_sm_alg_s1(const uint8_t *k, const uint8_t *r1, const uint8_t *r2, +int na_ble_sm_alg_s1(const uint8_t *k, const uint8_t *r1, const uint8_t *r2, uint8_t *out); -int ble_sm_alg_c1(const uint8_t *k, const uint8_t *r, +int na_ble_sm_alg_c1(const uint8_t *k, const uint8_t *r, const uint8_t *preq, const uint8_t *pres, uint8_t iat, uint8_t rat, const uint8_t *ia, const uint8_t *ra, uint8_t *out_enc_data); -int ble_sm_alg_f4(const uint8_t *u, const uint8_t *v, const uint8_t *x, +int na_ble_sm_alg_f4(const uint8_t *u, const uint8_t *v, const uint8_t *x, uint8_t z, uint8_t *out_enc_data); -int ble_sm_alg_g2(const uint8_t *u, const uint8_t *v, const uint8_t *x, +int na_ble_sm_alg_g2(const uint8_t *u, const uint8_t *v, const uint8_t *x, const uint8_t *y, uint32_t *passkey); -int ble_sm_alg_f5(const uint8_t *w, const uint8_t *n1, const uint8_t *n2, +int na_ble_sm_alg_f5(const uint8_t *w, const uint8_t *n1, const uint8_t *n2, uint8_t a1t, const uint8_t *a1, uint8_t a2t, const uint8_t *a2, uint8_t *mackey, uint8_t *ltk); -int ble_sm_alg_f6(const uint8_t *w, const uint8_t *n1, const uint8_t *n2, +int na_ble_sm_alg_f6(const uint8_t *w, const uint8_t *n1, const uint8_t *n2, const uint8_t *r, const uint8_t *iocap, uint8_t a1t, const uint8_t *a1, uint8_t a2t, const uint8_t *a2, uint8_t *check); @@ -323,7 +323,7 @@ int ble_sm_alg_gen_dhkey(const uint8_t *peer_pub_key_x, const uint8_t *peer_pub_key_y, const uint8_t *our_priv_key, uint8_t *out_dhkey); int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv); -void ble_sm_alg_ecc_init(void); +void na_ble_sm_alg_ecc_init(void); void ble_sm_enc_change_rx(const struct ble_hci_ev_enrypt_chg *ev); void ble_sm_enc_key_refresh_rx(const struct ble_hci_ev_enc_key_refresh *ev); @@ -395,7 +395,7 @@ void ble_sm_ia_ra(struct ble_sm_proc *proc, int ble_sm_incr_our_sign_counter(uint16_t conn_handle); int ble_sm_incr_peer_sign_counter(uint16_t conn_handle); -int ble_sm_alg_aes_cmac(const uint8_t *key, const uint8_t *in, size_t len, +int na_ble_sm_alg_aes_cmac(const uint8_t *key, const uint8_t *in, size_t len, uint8_t *out); int32_t ble_sm_timer(void); void ble_sm_connection_broken(uint16_t conn_handle); @@ -404,14 +404,14 @@ int ble_sm_slave_initiate(uint16_t conn_handle); int ble_sm_enc_initiate(uint16_t conn_handle, uint8_t key_size, const uint8_t *ltk, uint16_t ediv, uint64_t rand_val, int auth); -int ble_sm_alg_encrypt(const uint8_t *key, const uint8_t *plaintext, +int na_ble_sm_alg_encrypt(const uint8_t *key, const uint8_t *plaintext, uint8_t *enc_data); int ble_sm_init(void); #else #define ble_sm_incr_our_sign_counter(conn_handle) BLE_HS_ENOTSUP #define ble_sm_incr_peer_sign_counter(conn_handle) BLE_HS_ENOTSUP -#define ble_sm_alg_aes_cmac(key, in, len, out) BLE_HS_ENOTSUP +#define na_ble_sm_alg_aes_cmac(key, in, len, out) BLE_HS_ENOTSUP #define ble_sm_enc_change_rx(evt) ((void)(evt)) #define ble_sm_ltk_req_rx(evt) ((void)(evt)) #define ble_sm_enc_key_refresh_rx(evt) ((void)(evt)) @@ -425,7 +425,7 @@ int ble_sm_init(void); #define ble_sm_init() 0 -#define ble_sm_alg_encrypt(key, plaintext, enc_data) \ +#define na_ble_sm_alg_encrypt(key, plaintext, enc_data) \ BLE_HS_ENOTSUP #endif diff --git a/src/nimble/nimble/host/src/ble_sm_sc.c b/src/nimble/nimble/host/src/ble_sm_sc.c index 9e3cedca..d2b517b3 100644 --- a/src/nimble/nimble/host/src/ble_sm_sc.c +++ b/src/nimble/nimble/host/src/ble_sm_sc.c @@ -269,7 +269,7 @@ ble_sm_sc_oob_confirm(struct ble_sm_proc *proc, struct ble_sm_result *res) /* Authentication stage 1: Step 5 */ if (proc->oob_data_remote) { - err = ble_sm_alg_f4(proc->pub_key_peer.x, proc->pub_key_peer.x, + err = na_ble_sm_alg_f4(proc->pub_key_peer.x, proc->pub_key_peer.x, proc->oob_data_remote->r, 0, c); if (err) { res->sm_err = BLE_SM_ERR_UNSPECIFIED; @@ -321,7 +321,7 @@ ble_sm_sc_confirm_exec(struct ble_sm_proc *proc, struct ble_sm_result *res) return; } - rc = ble_sm_alg_f4(ble_sm_sc_pub_key, proc->pub_key_peer.x, + rc = na_ble_sm_alg_f4(ble_sm_sc_pub_key, proc->pub_key_peer.x, ble_sm_our_pair_rand(proc), proc->ri, cmd->value); if (rc != 0) { os_mbuf_free_chain(txom); @@ -357,7 +357,7 @@ ble_sm_sc_gen_numcmp(struct ble_sm_proc *proc, struct ble_sm_result *res) pka = proc->pub_key_peer.x; pkb = ble_sm_sc_pub_key; } - res->app_status = ble_sm_alg_g2(pka, pkb, proc->randm, proc->rands, + res->app_status = na_ble_sm_alg_g2(pka, pkb, proc->randm, proc->rands, &res->passkey_params.numcmp); if (res->app_status != 0) { res->sm_err = BLE_SM_ERR_UNSPECIFIED; @@ -456,7 +456,7 @@ ble_sm_sc_random_rx(struct ble_sm_proc *proc, struct ble_sm_result *res) ble_hs_log_flat_buf(proc->tk, 16); BLE_HS_LOG(DEBUG, "\n"); - rc = ble_sm_alg_f4(proc->pub_key_peer.x, ble_sm_sc_pub_key, + rc = na_ble_sm_alg_f4(proc->pub_key_peer.x, ble_sm_sc_pub_key, ble_sm_peer_pair_rand(proc), proc->ri, confirm_val); if (rc != 0) { @@ -477,7 +477,7 @@ ble_sm_sc_random_rx(struct ble_sm_proc *proc, struct ble_sm_result *res) /* Calculate the mac key and ltk. */ ble_sm_ia_ra(proc, &iat, ia, &rat, ra); - rc = ble_sm_alg_f5(proc->dhkey, proc->randm, proc->rands, + rc = na_ble_sm_alg_f5(proc->dhkey, proc->randm, proc->rands, iat, ia, rat, ra, proc->mackey, proc->ltk); if (rc != 0) { res->app_status = rc; @@ -725,7 +725,7 @@ ble_sm_sc_dhkey_check_exec(struct ble_sm_proc *proc, struct ble_sm_result *res, goto err; } - rc = ble_sm_alg_f6(proc->mackey, ble_sm_our_pair_rand(proc), + rc = na_ble_sm_alg_f6(proc->mackey, ble_sm_our_pair_rand(proc), ble_sm_peer_pair_rand(proc), proc->tk, iocap, our_addr.type, our_addr.val, peer_addr.type, peer_addr.val, cmd->value); @@ -796,7 +796,7 @@ ble_sm_dhkey_check_process(struct ble_sm_proc *proc, ble_hs_log_flat_buf(proc->tk, 16); BLE_HS_LOG(DEBUG, "\n"); - res->app_status = ble_sm_alg_f6(proc->mackey, + res->app_status = na_ble_sm_alg_f6(proc->mackey, ble_sm_peer_pair_rand(proc), ble_sm_our_pair_rand(proc), proc->tk, iocap, @@ -908,7 +908,7 @@ ble_sm_sc_oob_generate_data(struct ble_sm_sc_oob_data *oob_data) return rc; } - rc = ble_sm_alg_f4(ble_sm_sc_pub_key, ble_sm_sc_pub_key, oob_data->r, 0, + rc = na_ble_sm_alg_f4(ble_sm_sc_pub_key, ble_sm_sc_pub_key, oob_data->r, 0, oob_data->c); if (rc) { return rc; @@ -920,7 +920,7 @@ ble_sm_sc_oob_generate_data(struct ble_sm_sc_oob_data *oob_data) void ble_sm_sc_init(void) { - ble_sm_alg_ecc_init(); + na_ble_sm_alg_ecc_init(); ble_sm_sc_keys_generated = 0; } diff --git a/src/nimble/porting/nimble/include/nimble/nimble_port.h b/src/nimble/porting/nimble/include/nimble/nimble_port.h index 6d77f6ea..695b8c8a 100644 --- a/src/nimble/porting/nimble/include/nimble/nimble_port.h +++ b/src/nimble/porting/nimble/include/nimble/nimble_port.h @@ -21,20 +21,14 @@ #define _NIMBLE_PORT_H #include "nimble/nimble/include/nimble/nimble_npl.h" -#include "nimble/porting/nimble/include/syscfg/syscfg.h" +#include "syscfg/syscfg.h" #ifdef ESP_PLATFORM #include "esp_err.h" -#include "nimconfig.h" -#define NIMBLE_CORE (CONFIG_BT_NIMBLE_PINNED_TO_CORE < portNUM_PROCESSORS ? CONFIG_BT_NIMBLE_PINNED_TO_CORE : tskNO_AFFINITY) - -#define NIMBLE_HS_STACK_SIZE CONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE +#define NIMBLE_CORE (MYNEWT_VAL(NIMBLE_PINNED_TO_CORE) < portNUM_PROCESSORS ? MYNEWT_VAL(NIMBLE_PINNED_TO_CORE) : tskNO_AFFINITY) +#define NIMBLE_HS_STACK_SIZE (MYNEWT_VAL(NIMBLE_HOST_TASK_STACK_SIZE)) #else -#define NIMBLE_HS_STACK_SIZE (CONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE / 4) -#endif - -#if SOC_ESP_NIMBLE_CONTROLLER && CONFIG_BT_CONTROLLER_ENABLED -#define NIMBLE_LL_STACK_SIZE CONFIG_BT_LE_CONTROLLER_TASK_STACK_SIZE +#define NIMBLE_HS_STACK_SIZE (MYNEWT_VAL(NIMBLE_HOST_TASK_STACK_SIZE) / 4) #endif #ifdef __cplusplus diff --git a/src/nimble/porting/nimble/include/syscfg/syscfg.h b/src/nimble/porting/nimble/include/syscfg/syscfg.h index 6614a4b1..e04d22a5 100644 --- a/src/nimble/porting/nimble/include/syscfg/syscfg.h +++ b/src/nimble/porting/nimble/include/syscfg/syscfg.h @@ -23,35 +23,19 @@ #endif #ifndef MYNEWT_VAL_BLE_LL_ROLE_BROADCASTER -#ifndef CONFIG_BT_NIMBLE_ROLE_BROADCASTER_DISABLED #define MYNEWT_VAL_BLE_LL_ROLE_BROADCASTER (1) -#else -#define MYNEWT_VAL_BLE_LL_ROLE_BROADCASTER (0) -#endif #endif #ifndef MYNEWT_VAL_BLE_LL_ROLE_CENTRAL -#ifndef CONFIG_BT_NIMBLE_ROLE_CENTRAL_DISABLED #define MYNEWT_VAL_BLE_LL_ROLE_CENTRAL (1) -#else -#define MYNEWT_VAL_BLE_LL_ROLE_CENTRAL (0) -#endif #endif #ifndef MYNEWT_VAL_BLE_LL_ROLE_OBSERVER -#ifndef CONFIG_BT_NIMBLE_ROLE_OBSERVER_DISABLED #define MYNEWT_VAL_BLE_LL_ROLE_OBSERVER (1) -#else -#define MYNEWT_VAL_BLE_LL_ROLE_OBSERVER (0) -#endif #endif #ifndef MYNEWT_VAL_BLE_LL_ROLE_PERIPHERAL -#ifndef CONFIG_BT_NIMBLE_ROLE_PERIPHERAL_DISABLED #define MYNEWT_VAL_BLE_LL_ROLE_PERIPHERAL (1) -#else -#define MYNEWT_VAL_BLE_LL_ROLE_PERIPHERAL (0) -#endif #endif #ifndef MYNEWT_VAL_BLE_TRANSPORT_ACL_SIZE @@ -249,13 +233,18 @@ #endif #ifndef MYNEWT_VAL_BLE_STORE_MAX_CSFCS -#define MYNEWT_VAL_BLE_STORE_MAX_CSFCS (CONFIG_BT_NIMBLE_MAX_CONNECTIONS) +#define MYNEWT_VAL_BLE_STORE_MAX_CSFCS (MYNEWT_VAL_BLE_MAX_CONNECTIONS) #endif #ifndef MYNEWT_VAL_BLE_SM_LVL #define MYNEWT_VAL_BLE_SM_LVL (0) #endif +// THESE NEED TO BE REMOVED WHEN CORE IS UPDATED +#define MYNEWT_VAL_NIMBLE_HOST_TASK_STACK_SIZE CONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE +//#define MYNEWT_VAL_NIMBLE_CONTROLLER_TASK_STACK_SIZE CONFIG_BT_NIMBLE_CONTROLLER_TASK_STACK_SIZE + + #endif /* !ESP_PLATFORM */ #if 0 diff --git a/src/nimble/porting/npl/freertos/src/nimble_port_freertos.c b/src/nimble/porting/npl/freertos/src/nimble_port_freertos.c index 6d5be4a2..dd6015e9 100644 --- a/src/nimble/porting/npl/freertos/src/nimble_port_freertos.c +++ b/src/nimble/porting/npl/freertos/src/nimble_port_freertos.c @@ -34,8 +34,8 @@ UBaseType_t nimble_port_freertos_get_hs_hwm(void) { #ifdef ESP_PLATFORM #include "esp_bt.h" -#ifdef CONFIG_BT_NIMBLE_HOST_TASK_PRIORITY -# define NIMBLE_HOST_TASK_PRIORITY (CONFIG_BT_NIMBLE_HOST_TASK_PRIORITY) +#ifdef MYNEWT_VAL_NIMBLE_HOST_TASK_PRIORITY +# define NIMBLE_HOST_TASK_PRIORITY (MYNEWT_VAL(NIMBLE_HOST_TASK_PRIORITY)) #else # define NIMBLE_HOST_TASK_PRIORITY (configMAX_PRIORITIES - 4) #endif @@ -98,8 +98,8 @@ nimble_port_freertos_deinit(void) #else // ESP_PLATFORM #if NIMBLE_CFG_CONTROLLER -# ifdef CONFIG_BT_NIMBLE_LL_TASK_STACK_SIZE -# define NIMBLE_LL_STACK_SIZE (CONFIG_BT_NIMBLE_LL_TASK_STACK_SIZE / 4) +# ifdef MYNEWT_VAL_NIMBLE_CONTROLLER_TASK_STACK_SIZE +# define NIMBLE_LL_STACK_SIZE (MYNEWT_VAL(NIMBLE_CONTROLLER_TASK_STACK_SIZE) / 4) # else # if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV) # define NIMBLE_LL_STACK_SIZE (130) @@ -109,8 +109,8 @@ nimble_port_freertos_deinit(void) # endif // configMAX_PRIORITIES - 1 is Tmr builtin task -#ifdef CONFIG_BT_NIMBLE_LL_TASK_PRIORITY -# define NIMBLE_LL_TASK_PRIORITY (CONFIG_BT_NIMBLE_LL_TASK_PRIORITY) +#ifdef MYNEWT_VAL_BLE_LL_TASK_PRIORITY +# define NIMBLE_LL_TASK_PRIORITY MYNEWT_VAL_BLE_LL_TASK_PRIORITY #else # define NIMBLE_LL_TASK_PRIORITY (configMAX_PRIORITIES - 1) #endif @@ -120,8 +120,8 @@ static StaticTask_t ll_task_buffer; static TaskHandle_t ll_task_h; #endif // NIMBLE_CFG_CONTROLLER -#ifdef CONFIG_BT_NIMBLE_HOST_TASK_PRIORITY -# define NIMBLE_HOST_TASK_PRIORITY (CONFIG_BT_NIMBLE_HOST_TASK_PRIORITY) +#ifdef MYNEWT_VAL_NIMBLE_HOST_TASK_PRIORITY +# define NIMBLE_HOST_TASK_PRIORITY (MYNEWT_VAL(NIMBLE_HOST_TASK_PRIORITY)) #else # define NIMBLE_HOST_TASK_PRIORITY (configMAX_PRIORITIES - 2) #endif diff --git a/src/nimconfig.h b/src/nimconfig.h index 8e2fb5ae..49dfbf46 100644 --- a/src/nimconfig.h +++ b/src/nimconfig.h @@ -1,16 +1,9 @@ - #pragma once +#pragma once #ifdef ESP_PLATFORM #include "sdkconfig.h" #else #include "ext_nimble_config.h" -/* Clear redefinition warnings */ -#undef CONFIG_BT_NIMBLE_ROLE_CENTRAL -#undef CONFIG_BT_NIMBLE_ROLE_PERIPHERAL -#undef CONFIG_BT_NIMBLE_ROLE_BROADCASTER -#undef CONFIG_BT_NIMBLE_ROLE_OBSERVER -#undef CONFIG_BT_ENABLED -#define CONFIG_BT_ENABLED 1 #endif #include "nimconfig_rename.h" @@ -20,117 +13,51 @@ **********************************************/ /** @brief Un-comment to change the number of simultaneous connections (esp controller max is 9) */ -// #define CONFIG_BT_NIMBLE_MAX_CONNECTIONS 3 - -/** @brief Un-comment to enable storing the timestamp when an attribute value is updated\n - * This allows for checking the last update time using getTimeStamp() or getValue(time_t*)\n - * If disabled, the timestamp returned from these functions will be 0.\n - * Disabling timestamps will reduce the memory used for each value.\n - * 1 = Enabled, 0 = Disabled; Default = Disabled - */ -// #define CONFIG_NIMBLE_CPP_ATT_VALUE_TIMESTAMP_ENABLED 0 - -/** @brief Uncomment to set the default allocation size (bytes) for each attribute if\n - * not specified when the constructor is called. This is also the size used when a remote\n - * characteristic or descriptor is constructed before a value is read/notified.\n - * Increasing this will reduce reallocations but increase memory footprint.\n - * Default value is 20. Range: 1 : 512 (BLE_ATT_ATTR_MAX_LEN) - */ -// #define CONFIG_NIMBLE_CPP_ATT_VALUE_INIT_LENGTH 20 - - -/**************************************************** - * Extended advertising settings * - * NOT FOR USE WITH ORIGINAL ESP32 * - ***************************************************/ - -/** @brief Un-comment to enable extended advertising */ -// #define CONFIG_BT_NIMBLE_EXT_ADV 1 - -/** @brief Un-comment to set the max number of extended advertising instances (Range: 0 - 4) */ -// #define CONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES 1 - -/** @brief Un-comment to set the max extended advertising data size (Range: 31 - 1650) */ -// #define CONFIG_BT_NIMBLE_MAX_EXT_ADV_DATA_LEN 251 - -/** @brief Un-comment to enable periodic advertising */ -// #define CONFIG_BT_NIMBLE_ENABLE_PERIODIC_ADV 1 - -/** @brief Un-comment to change the maximum number of periodically synced devices */ -// #define CONFIG_BT_NIMBLE_MAX_PERIODIC_SYNCS 1 - -/**************************************************** - * END Extended advertising settings * - ***************************************************/ - +// #define MYNEWT_VAL_BLE_MAX_CONNECTIONS 3 /** @brief Un-comment to change the default MTU size */ -// #define CONFIG_BT_NIMBLE_ATT_PREFERRED_MTU 255 +// #define MYNEWT_VAL_BLE_ATT_PREFERRED_MTU 517 /** @brief Un-comment to change default device name */ -// #define CONFIG_BT_NIMBLE_SVC_GAP_DEVICE_NAME "nimble" +// #define MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME "nimble" /** @brief Un-comment to set the debug log messages level from the NimBLE host stack.\n * Values: 0 = DEBUG, 1 = INFO, 2 = WARNING, 3 = ERROR, 4 = CRITICAL, 5+ = NONE\n * Uses approx. 32kB of flash memory. */ - // #define CONFIG_BT_NIMBLE_LOG_LEVEL 5 - - /** @brief Un-comment to set the debug log messages level from the NimBLE CPP Wrapper.\n - * Values: 0 = NONE, 1 = ERROR, 2 = WARNING, 3 = INFO, 4+ = DEBUG\n - * Uses approx. 32kB of flash memory. - */ - // #define CONFIG_NIMBLE_CPP_LOG_LEVEL 0 - -/** @brief Un-comment to enable the debug asserts in NimBLE CPP wrapper.*/ -// #define CONFIG_NIMBLE_CPP_DEBUG_ASSERT_ENABLED 1 - -/** @brief Un-comment to see NimBLE host return codes as text debug log messages. - * Uses approx. 7kB of flash memory. - */ -// #define CONFIG_NIMBLE_CPP_ENABLE_RETURN_CODE_TEXT - -/** @brief Un-comment to see GAP event codes as text in debug log messages. - * Uses approx. 1kB of flash memory. - */ -// #define CONFIG_NIMBLE_CPP_ENABLE_GAP_EVENT_CODE_TEXT - -/** @brief Un-comment to see advertisement types as text while scanning in debug log messages. - * Uses approx. 250 bytes of flash memory. - */ -// #define CONFIG_NIMBLE_CPP_ENABLE_ADVERTISEMENT_TYPE_TEXT + // #define MYNEWT_VAL_BLE_HS_LOG_LVL 5 /** @brief Un-comment to change the default GAP appearance */ -// #define CONFIG_BT_NIMBLE_SVC_GAP_APPEARANCE 0x0 +// #define MYNEWT_VAL_BLE_SVC_GAP_APPEARANCE 0x0 /** @brief Un-comment if not using NimBLE Client functions \n * Reduces flash size by approx. 7kB. */ -// #define CONFIG_BT_NIMBLE_ROLE_CENTRAL 0 +// #define MYNEWT_VAL_BLE_ROLE_CENTRAL 0 /** @brief Un-comment if not using NimBLE Scan functions \n * Reduces flash size by approx. 26kB. */ -// #define CONFIG_BT_NIMBLE_ROLE_OBSERVER 0 +// #define MYNEWT_VAL_BLE_ROLE_OBSERVER 0 /** @brief Un-comment if not using NimBLE Server functions \n * Reduces flash size by approx. 16kB. */ -// #define CONFIG_BT_NIMBLE_ROLE_PERIPHERAL 0 +// #define MYNEWT_VAL_BLE_ROLE_PERIPHERAL 0 /** @brief Un-comment if not using NimBLE Advertising functions \n * Reduces flash size by approx. 5kB. */ -// #define CONFIG_BT_NIMBLE_ROLE_BROADCASTER 0 +// #define MYNEWT_VAL_BLE_ROLE_BROADCASTER 0 /** @brief Un-comment to change the number of devices allowed to store/bond with */ -// #define CONFIG_BT_NIMBLE_MAX_BONDS 3 +// #define MYNEWT_VAL_BLE_STORE_MAX_BONDS 3 /** @brief Un-comment to change the maximum number of CCCD subscriptions to store */ -// #define CONFIG_BT_NIMBLE_MAX_CCCDS 8 +// #define MYNEWT_VAL_BLE_STORE_MAX_CCCDS 8 /** @brief Un-comment to change the random address refresh time (in seconds) */ -// #define CONFIG_BT_NIMBLE_RPA_TIMEOUT 900 +// #define MYNEWT_VAL_BLE_RPA_TIMEOUT 900 /** * @brief Un-comment to change the number of MSYS buffers available. @@ -138,16 +65,40 @@ * responses MBUFs are allocated out of msys_1 pool. This may need to be increased if\n * you are sending large blocks of data with a low MTU. E.g: 512 bytes with 23 MTU will fail. */ -// #define CONFIG_BT_NIMBLE_MSYS1_BLOCK_COUNT 12 +// #define MYNEWT_VAL_MSYS_1_BLOCK_COUNT 12 /** @brief Un-comment to use external PSRAM for the NimBLE host */ -// #define CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_EXTERNAL 1 +// #define MYNEWT_VAL_NIMBLE_MEM_ALLOC_MODE_EXTERNAL 1 /** @brief Un-comment to change the core NimBLE host runs on */ -// #define CONFIG_BT_NIMBLE_PINNED_TO_CORE 0 +// #define MYNEWT_VAL_NIMBLE_PINNED_TO_CORE 0 /** @brief Un-comment to change the stack size for the NimBLE host task */ -// #define CONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE 4096 +// #define MYNEWT_VAL_NIMBLE_HOST_TASK_STACK_SIZE 4096 + +/** + * @brief Un-comment to use mbedtls instead of tinycrypt. + * @details This could save approximately 8k of flash if already using mbedtls for other functionality. + */ +// #define MYNEWT_VAL_BLE_CRYPTO_STACK_MBEDTLS 1 + +/**************************************************** + * Extended advertising settings * + * NOT FOR USE WITH ORIGINAL ESP32 * + ***************************************************/ + +/** @brief Un-comment to enable extended advertising */ +// #define MYNEWT_VAL_BLE_EXT_ADV 1 + +/** @brief Un-comment to set the max number of extended advertising instances (Range: 0 - 4) */ +// #define MYNEWT_VAL_BLE_MULTI_ADV_INSTANCES 1 + +/** @brief Un-comment to set the max extended advertising data size (Range: 31 - 1650) */ +// #define MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE 251 + +/**************************************************** + * END Extended advertising settings * + ***************************************************/ /** * @brief Un-comment to change the bit used to block tasks during BLE operations @@ -166,261 +117,242 @@ */ // #define CONFIG_NIMBLE_CPP_ADDR_FMT_UPPERCASE 1 -/** - * @brief Un-comment to use mbedtls instead of tinycrypt. - * @details This could save approximately 8k of flash if already using mbedtls for other functionality. +/** @brief Un-comment to enable storing the timestamp when an attribute value is updated\n + * This allows for checking the last update time using getTimeStamp() or getValue(time_t*)\n + * If disabled, the timestamp returned from these functions will be 0.\n + * Disabling timestamps will reduce the memory used for each value.\n + * 1 = Enabled, 0 = Disabled; Default = Disabled + */ +// #define CONFIG_NIMBLE_CPP_ATT_VALUE_TIMESTAMP_ENABLED 0 + +/** @brief Uncomment to set the default allocation size (bytes) for each attribute if\n + * not specified when the constructor is called. This is also the size used when a remote\n + * characteristic or descriptor is constructed before a value is read/notified.\n + * Increasing this will reduce reallocations but increase memory footprint.\n + * Default value is 20. Range: 1 : 512 (BLE_ATT_ATTR_MAX_LEN) + */ +// #define CONFIG_NIMBLE_CPP_ATT_VALUE_INIT_LENGTH 20 + + /** @brief Un-comment to set the debug log messages level from the NimBLE CPP Wrapper.\n + * Values: 0 = NONE, 1 = ERROR, 2 = WARNING, 3 = INFO, 4+ = DEBUG\n + * Uses approx. 32kB of flash memory. */ -// #define CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS 1 + // #define CONFIG_NIMBLE_CPP_LOG_LEVEL 0 + +/** @brief Un-comment to enable the debug asserts in NimBLE CPP wrapper.*/ +// #define CONFIG_NIMBLE_CPP_DEBUG_ASSERT_ENABLED 1 + +/** @brief Un-comment to see NimBLE host return codes as text debug log messages. + * Uses approx. 7kB of flash memory. + */ +// #define CONFIG_NIMBLE_CPP_ENABLE_RETURN_CODE_TEXT + +/** @brief Un-comment to see GAP event codes as text in debug log messages. + * Uses approx. 1kB of flash memory. + */ +// #define CONFIG_NIMBLE_CPP_ENABLE_GAP_EVENT_CODE_TEXT + +/** @brief Un-comment to see advertisement types as text while scanning in debug log messages. + * Uses approx. 250 bytes of flash memory. + */ +// #define CONFIG_NIMBLE_CPP_ENABLE_ADVERTISEMENT_TYPE_TEXT /********************************** End Arduino user-config **********************************/ /* This section should not be altered */ -#ifndef CONFIG_BT_NIMBLE_ROLE_CENTRAL -#ifndef CONFIG_BT_NIMBLE_ROLE_CENTRAL_DISABLED -#define CONFIG_BT_NIMBLE_ROLE_CENTRAL 1 -#else -#define CONFIG_BT_NIMBLE_ROLE_CENTRAL 0 -#endif +#ifndef MYNEWT_VAL_BLE_ROLE_BROADCASTER +#define MYNEWT_VAL_BLE_ROLE_BROADCASTER (1) #endif -#ifndef CONFIG_BT_NIMBLE_ROLE_OBSERVER -#ifndef CONFIG_BT_NIMBLE_ROLE_OBSERVER_DISABLED -#define CONFIG_BT_NIMBLE_ROLE_OBSERVER 1 -#else -#define CONFIG_BT_NIMBLE_ROLE_OBSERVER 0 +#ifndef MYNEWT_VAL_BLE_ROLE_CENTRAL +#define MYNEWT_VAL_BLE_ROLE_CENTRAL (1) #endif + +#ifndef MYNEWT_VAL_BLE_ROLE_OBSERVER +#define MYNEWT_VAL_BLE_ROLE_OBSERVER (1) #endif -#ifndef CONFIG_BT_NIMBLE_ROLE_PERIPHERAL -#ifndef CONFIG_BT_NIMBLE_ROLE_PERIPHERAL_DISABLED -#define CONFIG_BT_NIMBLE_ROLE_PERIPHERAL 1 -#else -#define CONFIG_BT_NIMBLE_ROLE_PERIPHERAL 0 +#ifndef MYNEWT_VAL_BLE_ROLE_PERIPHERAL +#define MYNEWT_VAL_BLE_ROLE_PERIPHERAL (1) #endif + +#ifndef MYNEWT_VAL_NIMBLE_PINNED_TO_CORE +#define MYNEWT_VAL_NIMBLE_PINNED_TO_CORE (0) #endif -#ifndef CONFIG_BT_NIMBLE_ROLE_BROADCASTER -#ifndef CONFIG_BT_NIMBLE_ROLE_BROADCASTER_DISABLED -#define CONFIG_BT_NIMBLE_ROLE_BROADCASTER 1 -#else -#define CONFIG_BT_NIMBLE_ROLE_BROADCASTER 0 +#ifndef MYNEWT_VAL_NIMBLE_HOST_TASK_STACK_SIZE +#define MYNEWT_VAL_NIMBLE_HOST_TASK_STACK_SIZE (4096) #endif + +#ifndef MYNEWT_VAL_NIMBLE_CONTROLLER_TASK_STACK_SIZE +#define MYNEWT_VAL_NIMBLE_CONTROLLER_TASK_STACK_SIZE (4096) #endif -#ifndef CONFIG_BT_NIMBLE_PINNED_TO_CORE -#define CONFIG_BT_NIMBLE_PINNED_TO_CORE 0 +#ifndef MYNEWT_VAL_NIMBLE_MEM_ALLOC_MODE_EXTERNAL +#define MYNEWT_VAL_NIMBLE_MEM_ALLOC_MODE_INTERNAL (1) #endif -#ifndef CONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE -#define CONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE 4096 +#ifndef MYNEWT_VAL_BLE_MAX_CONNECTIONS +#define MYNEWT_VAL_BLE_MAX_CONNECTIONS (3) #endif -#ifndef CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_EXTERNAL -#define CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_INTERNAL 1 +#ifndef MYNEWT_VAL_BLE_STORE_MAX_BONDS +#define MYNEWT_VAL_BLE_STORE_MAX_BONDS (3) #endif -#ifndef CONFIG_BT_NIMBLE_MAX_CONNECTIONS -#define CONFIG_BT_NIMBLE_MAX_CONNECTIONS 3 +#ifndef MYNEWT_VAL_BLE_STORE_MAX_CCCDS +#define MYNEWT_VAL_BLE_STORE_MAX_CCCDS (8) #endif -// bugfix: max connections macro renamed upstream -#ifndef CONFIG_NIMBLE_MAX_CONNECTIONS -#define CONFIG_NIMBLE_MAX_CONNECTIONS CONFIG_BT_NIMBLE_MAX_CONNECTIONS +#ifndef MYNEWT_VAL_BLE_ATT_PREFERRED_MTU +#define MYNEWT_VAL_BLE_ATT_PREFERRED_MTU (255) #endif -#ifndef CONFIG_BT_NIMBLE_MAX_BONDS -#define CONFIG_BT_NIMBLE_MAX_BONDS 3 +#ifndef MYNEWT_VAL_BLE_SVC_GAP_APPEARANCE +#define MYNEWT_VAL_BLE_SVC_GAP_APPEARANCE (0x0) #endif -#ifndef CONFIG_BT_NIMBLE_MAX_CCCDS -#define CONFIG_BT_NIMBLE_MAX_CCCDS 8 +#ifndef MYNEWT_VAL_MSYS_1_BLOCK_COUNT +#define MYNEWT_VAL_MSYS_1_BLOCK_COUNT (12) #endif -#ifndef CONFIG_BT_NIMBLE_SVC_GAP_DEVICE_NAME -#define CONFIG_BT_NIMBLE_SVC_GAP_DEVICE_NAME "nimble" +#ifndef MYNEWT_VAL_MSYS_1_BLOCK_SIZE +#define MYNEWT_VAL_MSYS_1_BLOCK_SIZE (256) #endif -#ifndef CONFIG_BT_NIMBLE_ATT_PREFERRED_MTU -#define CONFIG_BT_NIMBLE_ATT_PREFERRED_MTU 255 +#ifndef MYNEWT_VAL_MSYS_2_BLOCK_COUNT +#define MYNEWT_VAL_MSYS_2_BLOCK_COUNT (0) #endif -#ifndef CONFIG_BT_NIMBLE_SVC_GAP_APPEARANCE -#define CONFIG_BT_NIMBLE_SVC_GAP_APPEARANCE 0x0 +#ifndef MYNEWT_VAL_MSYS_2_BLOCK_SIZE +#define MYNEWT_VAL_MSYS_2_BLOCK_SIZE (0) #endif -#ifdef CONFIG_BT_NIMBLE_MSYS1_BLOCK_COUNT // backward compatibility -#define CONFIG_BT_NIMBLE_MSYS_1_BLOCK_COUNT CONFIG_BT_NIMBLE_MSYS1_BLOCK_COUNT -#elif !defined(CONFIG_BT_NIMBLE_MSYS_1_BLOCK_COUNT) -#define CONFIG_BT_NIMBLE_MSYS_1_BLOCK_COUNT 12 +#ifndef MYNEWT_VAL_BLE_TRANSPORT_EVT_DISCARDABLE_COUNT +#define MYNEWT_VAL_BLE_TRANSPORT_EVT_DISCARDABLE_COUNT (16) #endif -#ifndef CONFIG_BT_NIMBLE_MSYS_1_BLOCK_SIZE -#define CONFIG_BT_NIMBLE_MSYS_1_BLOCK_SIZE 256 +#ifndef MYNEWT_VAL_BLE_RPA_TIMEOUT +#define MYNEWT_VAL_BLE_RPA_TIMEOUT (900) #endif -#ifndef CONFIG_BT_NIMBLE_RPA_TIMEOUT -#define CONFIG_BT_NIMBLE_RPA_TIMEOUT 900 +#ifndef MYNEWT_VAL_BLE_HS_LOG_LVL +#define MYNEWT_VAL_BLE_HS_LOG_LVL (5) #endif -#ifndef CONFIG_BT_NIMBLE_LOG_LEVEL -#define CONFIG_BT_NIMBLE_LOG_LEVEL 5 +#ifndef MYNEWT_VAL_BLE_MESH_DEVICE_NAME +#define MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME "nimble" #endif -/** @brief Maximum number of connection oriented channels */ -#ifndef CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM -#define CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM 0 +#ifndef MYNEWT_VAL_BLE_LL_WHITELIST_SIZE +#define MYNEWT_VAL_BLE_LL_WHITELIST_SIZE (12) #endif /** @brief Set if CCCD's and bond data should be stored in NVS */ -#define CONFIG_BT_NIMBLE_NVS_PERSIST 1 +#define MYNEWT_VAL_BLE_STORE_CONFIG_PERSIST (1) /** @brief Allow legacy paring */ -#define CONFIG_BT_NIMBLE_SM_LEGACY 1 +#define MYNEWT_VAL_BLE_SM_LEGACY (1) /** @brief Allow BLE secure connections */ -#define CONFIG_BT_NIMBLE_SM_SC 1 +#define MYNEWT_VAL_BLE_SM_SC (1) /** @brief Max device name length (bytes) */ -#define CONFIG_BT_NIMBLE_GAP_DEVICE_NAME_MAX_LEN 31 +#define MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME_MAX_LENGTH (31) /** @brief ACL Buffer count */ -#define CONFIG_BT_NIMBLE_TRANSPORT_ACL_FROM_LL_COUNT 12 +#define MYNEWT_VAL_BLE_TRANSPORT_ACL_FROM_LL_COUNT (12) /** @brief ACL Buffer size */ -#define CONFIG_BT_NIMBLE_TRANSPORT_ACL_SIZE 255 +#define MYNEWT_VAL_BLE_TRANSPORT_ACL_SIZE (255) /** @brief Transport (HCI) Event Buffer size */ -#if CONFIG_BT_NIMBLE_EXT_ADV -# define CONFIG_BT_NIMBLE_TRANSPORT_EVT_SIZE 257 +#if MYNEWT_VAL_BLE_EXT_ADV +# define MYNEWT_VAL_BLE_TRANSPORT_EVT_SIZE (257) #else -# define CONFIG_BT_NIMBLE_TRANSPORT_EVT_SIZE 70 +# define MYNEWT_VAL_BLE_TRANSPORT_EVT_SIZE (70) #endif /** @brief Number of high priority HCI event buffers */ -#define CONFIG_BT_NIMBLE_TRANSPORT_EVT_COUNT 30 - -/** @brief Number of low priority HCI event buffers */ -#define CONFIG_BT_NIMBLE_TRANSPORT_EVT_DISCARD_COUNT 8 +#define MYNEWT_VAL_BLE_TRANSPORT_EVT_COUNT (30) -#define CONFIG_BT_NIMBLE_L2CAP_COC_SDU_BUFF_COUNT 1 -#define CONFIG_BT_NIMBLE_EATT_CHAN_NUM 0 -#define CONFIG_BT_NIMBLE_SVC_GAP_CENT_ADDR_RESOLUTION -1 -#define CONFIG_BT_NIMBLE_GATT_MAX_PROCS 4 -#define CONFIG_BT_NIMBLE_HS_STOP_TIMEOUT_MS 2000 - -#ifndef CONFIG_BT_ENABLED -#define CONFIG_BT_ENABLED -#endif +#define MYNEWT_VAL_BLE_L2CAP_COC_SDU_BUFF_COUNT (1) +#define MYNEWT_VAL_BLE_EATT_CHAN_NUM (0) +#define MYNEWT_VAL_BLE_SVC_GAP_CENTRAL_ADDRESS_RESOLUTION (-1) +#define MYNEWT_VAL_BLE_GATT_MAX_PROCS (4) +#define MYNEWT_VAL_BLE_HS_STOP_ON_SHUTDOWN_TIMEOUT (2000) #ifndef CONFIG_BT_NIMBLE_ENABLED -#define CONFIG_BT_NIMBLE_ENABLED 1 +#define CONFIG_BT_NIMBLE_ENABLED (1) #endif #ifndef CONFIG_BT_CONTROLLER_ENABLED -#define CONFIG_BT_CONTROLLER_ENABLED 1 -#endif - -#ifndef CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS -#define CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS 0 +#define CONFIG_BT_CONTROLLER_ENABLED (1) #endif #ifndef MYNEWT_VAL_BLE_CRYPTO_STACK_MBEDTLS -#define MYNEWT_VAL_BLE_CRYPTO_STACK_MBEDTLS (CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS) +#define MYNEWT_VAL_BLE_CRYPTO_STACK_MBEDTLS (0) #endif #ifdef ESP_PLATFORM -#ifndef CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY -#define CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY -#endif - #ifndef CONFIG_BTDM_SCAN_DUPL_TYPE_DEVICE -#define CONFIG_BTDM_SCAN_DUPL_TYPE_DEVICE 0 +#define CONFIG_BTDM_SCAN_DUPL_TYPE_DEVICE (0) #endif #ifndef CONFIG_BTDM_SCAN_DUPL_TYPE_DATA -#define CONFIG_BTDM_SCAN_DUPL_TYPE_DATA 1 +#define CONFIG_BTDM_SCAN_DUPL_TYPE_DATA (1) #endif #ifndef CONFIG_BTDM_SCAN_DUPL_TYPE_DATA_DEVICE -#define CONFIG_BTDM_SCAN_DUPL_TYPE_DATA_DEVICE 2 +#define CONFIG_BTDM_SCAN_DUPL_TYPE_DATA_DEVICE (2) #endif -#if !defined(CONFIG_BT_NIMBLE_LEGACY_VHCI_ENABLE) && defined(CONFIG_IDF_TARGET_ESP32) || \ -defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3) -#define CONFIG_BT_NIMBLE_LEGACY_VHCI_ENABLE 1 +#if !defined(CONFIG_BT_NIMBLE_LEGACY_VHCI_ENABLE) && (defined(CONFIG_IDF_TARGET_ESP32) || \ +defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3)) +#define CONFIG_BT_NIMBLE_LEGACY_VHCI_ENABLE (1) #endif #ifdef CONFIG_IDF_TARGET_ESP32 -#define CONFIG_BT_NIMBLE_HS_FLOW_CTRL 1 -#define CONFIG_BT_NIMBLE_HS_FLOW_CTRL_ITVL 1000 -#define CONFIG_BT_NIMBLE_HS_FLOW_CTRL_THRESH 2 -#define CONFIG_BT_NIMBLE_HS_FLOW_CTRL_TX_ON_DISCONNECT 1 +#define MYNEWT_VAL_BLE_HS_FLOW_CTRL_TX_ON_DISCONNECT (1) #endif #if !defined(CONFIG_BT_CONTROLLER_DISABLED) -#define CONFIG_BT_CONTROLLER_DISABLED 0 +#define CONFIG_BT_CONTROLLER_DISABLED (0) #endif -#if CONFIG_BT_NIMBLE_EXT_ADV || CONFIG_BT_NIMBLE_ENABLE_PERIODIC_ADV +#if MYNEWT_VAL_BLE_EXT_ADV # if defined(CONFIG_IDF_TARGET_ESP32) # error Extended advertising is not supported on ESP32. # endif #endif #ifndef CONFIG_BT_NIMBLE_USE_ESP_TIMER -#define CONFIG_BT_NIMBLE_USE_ESP_TIMER 1 -#endif - -#ifndef CONFIG_BT_NIMBLE_WHITELIST_SIZE -#define CONFIG_BT_NIMBLE_WHITELIST_SIZE 12 +#define CONFIG_BT_NIMBLE_USE_ESP_TIMER (1) #endif #endif // ESP_PLATFORM -#if CONFIG_BT_NIMBLE_ENABLE_PERIODIC_ADV && !CONFIG_BT_NIMBLE_EXT_ADV -# error Extended advertising must be enabled to use periodic advertising. -#endif - -/* Must have max instances and data length set if extended advertising is enabled */ -#if CONFIG_BT_NIMBLE_EXT_ADV -# if !defined(CONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES) -# define CONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES 1 -# endif -# if !defined(CONFIG_BT_NIMBLE_MAX_EXT_ADV_DATA_LEN) -# define CONFIG_BT_NIMBLE_MAX_EXT_ADV_DATA_LEN 251 -# endif +#if !defined(MYNEWT_VAL_BLE_MULTI_ADV_INSTANCES) +# define MYNEWT_VAL_BLE_MULTI_ADV_INSTANCES (1) #endif -/* Must set max number of syncs if periodic advertising is enabled */ -#if CONFIG_BT_NIMBLE_ENABLE_PERIODIC_ADV && !defined(CONFIG_BT_NIMBLE_MAX_PERIODIC_SYNCS) -# define CONFIG_BT_NIMBLE_MAX_PERIODIC_SYNCS 1 +#if !defined(MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE) +# define MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE (251) #endif /* Enables the use of Arduino String class for attribute values */ #if defined __has_include # if __has_include () -# define NIMBLE_CPP_ARDUINO_STRING_AVAILABLE +# define NIMBLE_CPP_ARDUINO_STRING_AVAILABLE (1) # endif #endif #ifndef CONFIG_NIMBLE_CPP_DEBUG_ASSERT_ENABLED -#define CONFIG_NIMBLE_CPP_DEBUG_ASSERT_ENABLED 0 +#define CONFIG_NIMBLE_CPP_DEBUG_ASSERT_ENABLED (0) #endif #ifndef CONFIG_NIMBLE_CPP_FREERTOS_TASK_BLOCK_BIT -#define CONFIG_NIMBLE_CPP_FREERTOS_TASK_BLOCK_BIT 31 +#define CONFIG_NIMBLE_CPP_FREERTOS_TASK_BLOCK_BIT (31) #endif - -#if CONFIG_NIMBLE_CPP_DEBUG_ASSERT_ENABLED && !defined NDEBUG -void nimble_cpp_assert(const char *file, unsigned line) __attribute((weak, noreturn)); -# define NIMBLE_ATT_VAL_FILE (__builtin_strrchr(__FILE__, '/') ? \ - __builtin_strrchr (__FILE__, '/') + 1 : __FILE__) -# define NIMBLE_CPP_DEBUG_ASSERT(cond) \ - if (!(cond)) { \ - nimble_cpp_assert(NIMBLE_ATT_VAL_FILE, __LINE__); \ - } -#else -# define NIMBLE_CPP_DEBUG_ASSERT(cond) (void(0)) -#endif \ No newline at end of file diff --git a/src/nimconfig_rename.h b/src/nimconfig_rename.h index 24e05060..7844e93a 100644 --- a/src/nimconfig_rename.h +++ b/src/nimconfig_rename.h @@ -8,26 +8,6 @@ #define CONFIG_BT_NIMBLE_ENABLED #endif -#if defined(CONFIG_NIMBLE_ROLE_OBSERVER) && !CONFIG_BT_NIMBLE_ROLE_OBSERVER -#define CONFIG_BT_NIMBLE_ROLE_OBSERVER -#endif - -#if defined(CONFIG_NIMBLE_ROLE_BROADCASTER) && !CONFIG_BT_NIMBLE_ROLE_BROADCASTER -#define CONFIG_BT_NIMBLE_ROLE_BROADCASTER -#endif - -#if defined(CONFIG_NIMBLE_ROLE_CENTRAL) && !CONFIG_BT_NIMBLE_ROLE_CENTRAL -#define CONFIG_BT_NIMBLE_ROLE_CENTRAL -#endif - -#if defined(CONFIG_NIMBLE_ROLE_PERIPHERAL) && !CONFIG_BT_NIMBLE_ROLE_PERIPHERAL -#define CONFIG_BT_NIMBLE_ROLE_PERIPHERAL -#endif - -#if defined(CONFIG_NIMBLE_DEBUG) && !defined(CONFIG_BT_NIMBLE_DEBUG) -#define CONFIG_BT_NIMBLE_DEBUG -#endif - #if defined(CONFIG_SCAN_DUPLICATE_BY_DEVICE_ADDR) && !defined(CONFIG_BTDM_SCAN_DUPL_TYPE_DEVICE) #define CONFIG_BTDM_SCAN_DUPL_TYPE_DEVICE CONFIG_SCAN_DUPLICATE_BY_DEVICE_ADDR #endif