mirror of
https://github.com/h2zero/esp-nimble-cpp.git
synced 2025-09-25 05:21:13 +02:00
Refactor to use MYNEWT_VAL macros.
This replaces the previously prefixed CONFIG_BT_X config macros with the underlying MYNEWT_VAL_X config macros that they affected.
This commit is contained in:
4
Kconfig
4
Kconfig
@@ -204,6 +204,10 @@ config NIMBLE_CPP_FREERTOS_TASK_BLOCK_BIT
|
|||||||
Configure the bit to set in the task notification value when a task is blocked waiting for an event.
|
Configure the bit to set in the task notification value when a task is blocked waiting for an event.
|
||||||
This should be set to a bit that is not used by other notifications in the system.
|
This should be set to a bit that is not used by other notifications in the system.
|
||||||
|
|
||||||
|
config NIMBLE_CPP_IDF
|
||||||
|
bool
|
||||||
|
default BT_NIMBLE_ENABLED
|
||||||
|
|
||||||
#
|
#
|
||||||
# BT config
|
# BT config
|
||||||
#
|
#
|
||||||
|
@@ -112,7 +112,7 @@ bool connectToServer() {
|
|||||||
|
|
||||||
/** No client to reuse? Create a new one. */
|
/** No client to reuse? Create a new one. */
|
||||||
if (!pClient) {
|
if (!pClient) {
|
||||||
if (NimBLEDevice::getCreatedClientCount() >= NIMBLE_MAX_CONNECTIONS) {
|
if (NimBLEDevice::getCreatedClientCount() >= MYNEWT_VAL(BLE_MAX_CONNECTIONS)) {
|
||||||
printf("Max clients reached - no more connections available\n");
|
printf("Max clients reached - no more connections available\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "NimBLE2904.h"
|
#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)
|
NimBLE2904::NimBLE2904(NimBLECharacteristic* pChr)
|
||||||
: NimBLEDescriptor(NimBLEUUID((uint16_t)0x2904), BLE_GATT_CHR_F_READ, sizeof(NimBLE2904Data), 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);
|
setValue(m_data);
|
||||||
} // setUnit
|
} // setUnit
|
||||||
|
|
||||||
#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
#ifndef NIMBLE_CPP_2904_H_
|
#ifndef NIMBLE_CPP_2904_H_
|
||||||
#define NIMBLE_CPP_2904_H_
|
#define NIMBLE_CPP_2904_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "syscfg/syscfg.h"
|
||||||
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
|
||||||
|
|
||||||
# include "NimBLEDescriptor.h"
|
# include "NimBLEDescriptor.h"
|
||||||
|
|
||||||
@@ -79,5 +79,5 @@ class NimBLE2904 : public NimBLEDescriptor {
|
|||||||
NimBLE2904Data m_data{};
|
NimBLE2904Data m_data{};
|
||||||
}; // NimBLE2904
|
}; // 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_
|
#endif // NIMBLE_CPP_2904_H_
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "NimBLEAddress.h"
|
#include "NimBLEAddress.h"
|
||||||
#if CONFIG_BT_ENABLED
|
#if CONFIG_BT_NIMBLE_ENABLED
|
||||||
|
|
||||||
# include "NimBLELog.h"
|
# include "NimBLELog.h"
|
||||||
|
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
#ifndef NIMBLE_CPP_ADDRESS_H_
|
#ifndef NIMBLE_CPP_ADDRESS_H_
|
||||||
#define NIMBLE_CPP_ADDRESS_H_
|
#define NIMBLE_CPP_ADDRESS_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "syscfg/syscfg.h"
|
||||||
#if CONFIG_BT_ENABLED
|
#if CONFIG_BT_NIMBLE_ENABLED
|
||||||
|
|
||||||
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
||||||
# include "nimble/ble.h"
|
# include "nimble/ble.h"
|
||||||
@@ -67,5 +67,5 @@ class NimBLEAddress : private ble_addr_t {
|
|||||||
operator uint64_t() const;
|
operator uint64_t() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONFIG_BT_ENABLED
|
#endif // CONFIG_BT_NIMBLE_ENABLED
|
||||||
#endif // NIMBLE_CPP_ADDRESS_H_
|
#endif // NIMBLE_CPP_ADDRESS_H_
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "NimBLEAdvertisedDevice.h"
|
#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 "NimBLEDevice.h"
|
||||||
# include "NimBLEUtils.h"
|
# include "NimBLEUtils.h"
|
||||||
@@ -31,7 +31,7 @@ static const char* LOG_TAG = "NimBLEAdvertisedDevice";
|
|||||||
* @param [in] event The advertisement event data.
|
* @param [in] event The advertisement event data.
|
||||||
*/
|
*/
|
||||||
NimBLEAdvertisedDevice::NimBLEAdvertisedDevice(const ble_gap_event* event, uint8_t eventType)
|
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_address{event->ext_disc.addr},
|
||||||
m_advType{eventType},
|
m_advType{eventType},
|
||||||
m_rssi{event->ext_disc.rssi},
|
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.
|
* @param [in] event The advertisement event data.
|
||||||
*/
|
*/
|
||||||
void NimBLEAdvertisedDevice::update(const ble_gap_event* event, uint8_t eventType) {
|
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;
|
const auto& disc = event->ext_disc;
|
||||||
m_isLegacyAdv = disc.props & BLE_HCI_ADV_LEGACY_MASK;
|
m_isLegacyAdv = disc.props & BLE_HCI_ADV_LEGACY_MASK;
|
||||||
# else
|
# else
|
||||||
@@ -580,7 +580,7 @@ bool NimBLEAdvertisedDevice::haveTXPower() const {
|
|||||||
return findAdvField(BLE_HS_ADV_TYPE_TX_PWR_LVL) > 0;
|
return findAdvField(BLE_HS_ADV_TYPE_TX_PWR_LVL) > 0;
|
||||||
} // haveTXPower
|
} // haveTXPower
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if MYNEWT_VAL(BLE_EXT_ADV)
|
||||||
/**
|
/**
|
||||||
* @brief Get the set ID of the extended advertisement.
|
* @brief Get the set ID of the extended advertisement.
|
||||||
* @return The set ID.
|
* @return The set ID.
|
||||||
@@ -751,7 +751,7 @@ uint8_t NimBLEAdvertisedDevice::getAddressType() const {
|
|||||||
* @return True if the device is connectable.
|
* @return True if the device is connectable.
|
||||||
*/
|
*/
|
||||||
bool NimBLEAdvertisedDevice::isConnectable() const {
|
bool NimBLEAdvertisedDevice::isConnectable() const {
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if MYNEWT_VAL(BLE_EXT_ADV)
|
||||||
if (m_isLegacyAdv) {
|
if (m_isLegacyAdv) {
|
||||||
return m_advType == BLE_HCI_ADV_RPT_EVTYPE_ADV_IND || m_advType == BLE_HCI_ADV_RPT_EVTYPE_DIR_IND;
|
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).
|
* @return True if legacy (Bluetooth 4.x), false if extended (bluetooth 5.x).
|
||||||
*/
|
*/
|
||||||
bool NimBLEAdvertisedDevice::isLegacyAdvertisement() const {
|
bool NimBLEAdvertisedDevice::isLegacyAdvertisement() const {
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if MYNEWT_VAL(BLE_EXT_ADV)
|
||||||
return m_isLegacyAdv;
|
return m_isLegacyAdv;
|
||||||
# else
|
# else
|
||||||
return true;
|
return true;
|
||||||
@@ -813,4 +813,4 @@ const std::vector<uint8_t>::const_iterator NimBLEAdvertisedDevice::end() const {
|
|||||||
return m_payload.cend();
|
return m_payload.cend();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_OBSERVER)
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
#ifndef NIMBLE_CPP_ADVERTISED_DEVICE_H_
|
#ifndef NIMBLE_CPP_ADVERTISED_DEVICE_H_
|
||||||
#define NIMBLE_CPP_ADVERTISED_DEVICE_H_
|
#define NIMBLE_CPP_ADVERTISED_DEVICE_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "syscfg/syscfg.h"
|
||||||
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_OBSERVER)
|
||||||
|
|
||||||
# include "NimBLEAddress.h"
|
# include "NimBLEAddress.h"
|
||||||
# include "NimBLEScan.h"
|
# include "NimBLEScan.h"
|
||||||
@@ -87,7 +87,7 @@ class NimBLEAdvertisedDevice {
|
|||||||
bool isConnectable() const;
|
bool isConnectable() const;
|
||||||
bool isScannable() const;
|
bool isScannable() const;
|
||||||
bool isLegacyAdvertisement() const;
|
bool isLegacyAdvertisement() const;
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if MYNEWT_VAL(BLE_EXT_ADV)
|
||||||
uint8_t getSetId() const;
|
uint8_t getSetId() const;
|
||||||
uint8_t getPrimaryPhy() const;
|
uint8_t getPrimaryPhy() const;
|
||||||
uint8_t getSecondaryPhy() const;
|
uint8_t getSecondaryPhy() const;
|
||||||
@@ -163,7 +163,7 @@ class NimBLEAdvertisedDevice {
|
|||||||
uint8_t m_callbackSent{};
|
uint8_t m_callbackSent{};
|
||||||
uint8_t m_advLength{};
|
uint8_t m_advLength{};
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if MYNEWT_VAL(BLE_EXT_ADV)
|
||||||
bool m_isLegacyAdv{};
|
bool m_isLegacyAdv{};
|
||||||
uint8_t m_sid{};
|
uint8_t m_sid{};
|
||||||
uint8_t m_primPhy{};
|
uint8_t m_primPhy{};
|
||||||
@@ -174,5 +174,5 @@ class NimBLEAdvertisedDevice {
|
|||||||
std::vector<uint8_t> m_payload;
|
std::vector<uint8_t> 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_ */
|
#endif /* NIMBLE_CPP_ADVERTISED_DEVICE_H_ */
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "NimBLEAdvertisementData.h"
|
#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 "NimBLEDevice.h"
|
||||||
# include "NimBLEUtils.h"
|
# include "NimBLEUtils.h"
|
||||||
@@ -583,4 +583,4 @@ std::string NimBLEAdvertisementData::toString() const {
|
|||||||
return str;
|
return str;
|
||||||
} // toString
|
} // 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_)
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
#ifndef NIMBLE_CPP_ADVERTISEMENT_DATA_H_
|
#ifndef NIMBLE_CPP_ADVERTISEMENT_DATA_H_
|
||||||
#define NIMBLE_CPP_ADVERTISEMENT_DATA_H_
|
#define NIMBLE_CPP_ADVERTISEMENT_DATA_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "syscfg/syscfg.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 <cstdint>
|
# include <cstdint>
|
||||||
# include <string>
|
# include <string>
|
||||||
@@ -74,5 +74,5 @@ class NimBLEAdvertisementData {
|
|||||||
std::vector<uint8_t> m_payload{};
|
std::vector<uint8_t> m_payload{};
|
||||||
}; // NimBLEAdvertisementData
|
}; // 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_
|
#endif // NIMBLE_CPP_ADVERTISEMENT_DATA_H_
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "NimBLEAdvertising.h"
|
#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)
|
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
||||||
# include "services/gap/ble_svc_gap.h"
|
# include "services/gap/ble_svc_gap.h"
|
||||||
@@ -42,7 +42,7 @@ NimBLEAdvertising::NimBLEAdvertising()
|
|||||||
m_duration{BLE_HS_FOREVER},
|
m_duration{BLE_HS_FOREVER},
|
||||||
m_scanResp{false},
|
m_scanResp{false},
|
||||||
m_advDataSet{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;
|
m_advParams.conn_mode = BLE_GAP_CONN_MODE_NON;
|
||||||
# else
|
# else
|
||||||
m_advParams.conn_mode = BLE_GAP_CONN_MODE_UND;
|
m_advParams.conn_mode = BLE_GAP_CONN_MODE_UND;
|
||||||
@@ -195,7 +195,7 @@ bool NimBLEAdvertising::start(uint32_t duration, const NimBLEAddress* dirAddr) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
# if MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
|
||||||
NimBLEServer* pServer = NimBLEDevice::getServer();
|
NimBLEServer* pServer = NimBLEDevice::getServer();
|
||||||
if (pServer != nullptr) {
|
if (pServer != nullptr) {
|
||||||
pServer->start(); // make sure the GATT server is ready before advertising
|
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;
|
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,
|
int rc = ble_gap_adv_start(NimBLEDevice::m_ownAddrType,
|
||||||
(dirAddr != nullptr) ? dirAddr->getBase() : NULL,
|
(dirAddr != nullptr) ? dirAddr->getBase() : NULL,
|
||||||
duration,
|
duration,
|
||||||
@@ -620,4 +620,4 @@ bool NimBLEAdvertising::setServiceData(const NimBLEUUID& uuid, const std::string
|
|||||||
return setServiceData(uuid, reinterpret_cast<const uint8_t*>(data.data()), data.length());
|
return setServiceData(uuid, reinterpret_cast<const uint8_t*>(data.data()), data.length());
|
||||||
} // setServiceData
|
} // 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_)
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
#ifndef NIMBLE_CPP_ADVERTISING_H_
|
#ifndef NIMBLE_CPP_ADVERTISING_H_
|
||||||
#define NIMBLE_CPP_ADVERTISING_H_
|
#define NIMBLE_CPP_ADVERTISING_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "syscfg/syscfg.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)
|
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
||||||
# include "host/ble_gap.h"
|
# include "host/ble_gap.h"
|
||||||
@@ -105,5 +105,5 @@ class NimBLEAdvertising {
|
|||||||
bool m_advDataSet : 1;
|
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_
|
#endif // NIMBLE_CPP_ADVERTISING_H_
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "NimBLEAttValue.h"
|
#include "NimBLEAttValue.h"
|
||||||
#if CONFIG_BT_ENABLED
|
#if CONFIG_BT_NIMBLE_ENABLED
|
||||||
|
|
||||||
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
||||||
# include "nimble/nimble_npl.h"
|
# include "nimble/nimble_npl.h"
|
||||||
@@ -24,6 +24,7 @@
|
|||||||
# include "nimble/nimble/include/nimble/nimble_npl.h"
|
# include "nimble/nimble/include/nimble/nimble_npl.h"
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
# include "NimBLEUtils.h"
|
||||||
# include "NimBLELog.h"
|
# include "NimBLELog.h"
|
||||||
|
|
||||||
static const char* LOG_TAG = "NimBLEAttValue";
|
static const char* LOG_TAG = "NimBLEAttValue";
|
||||||
@@ -159,4 +160,4 @@ uint8_t NimBLEAttValue::operator[](int pos) const {
|
|||||||
return m_attr_value[pos];
|
return m_attr_value[pos];
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // CONFIG_BT_ENABLED
|
#endif // CONFIG_BT_NIMBLE_ENABLED
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
#ifndef NIMBLE_CPP_ATTVALUE_H
|
#ifndef NIMBLE_CPP_ATTVALUE_H
|
||||||
#define NIMBLE_CPP_ATTVALUE_H
|
#define NIMBLE_CPP_ATTVALUE_H
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "syscfg/syscfg.h"
|
||||||
#if CONFIG_BT_ENABLED
|
#if CONFIG_BT_NIMBLE_ENABLED
|
||||||
|
|
||||||
# ifdef NIMBLE_CPP_ARDUINO_STRING_AVAILABLE
|
# ifdef NIMBLE_CPP_ARDUINO_STRING_AVAILABLE
|
||||||
# include <Arduino.h>
|
# include <Arduino.h>
|
||||||
@@ -363,5 +363,5 @@ class NimBLEAttValue {
|
|||||||
# endif
|
# endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONFIG_BT_ENABLED
|
#endif // CONFIG_BT_NIMBLE_ENABLED
|
||||||
#endif // NIMBLE_CPP_ATTVALUE_H_
|
#endif // NIMBLE_CPP_ATTVALUE_H_
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
#ifndef NIMBLE_CPP_ATTRIBUTE_H_
|
#ifndef NIMBLE_CPP_ATTRIBUTE_H_
|
||||||
#define NIMBLE_CPP_ATTRIBUTE_H_
|
#define NIMBLE_CPP_ATTRIBUTE_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "syscfg/syscfg.h"
|
||||||
#if CONFIG_BT_ENABLED && (CONFIG_BT_NIMBLE_ROLE_PERIPHERAL || CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
#if CONFIG_BT_NIMBLE_ENABLED && (MYNEWT_VAL(BLE_ROLE_PERIPHERAL) || MYNEWT_VAL(BLE_ROLE_CENTRAL))
|
||||||
|
|
||||||
# include "NimBLEUUID.h"
|
# include "NimBLEUUID.h"
|
||||||
|
|
||||||
@@ -56,5 +56,5 @@ class NimBLEAttribute {
|
|||||||
uint16_t m_handle{0};
|
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_
|
#endif // NIMBLE_CPP_ATTRIBUTE_H_
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "NimBLEBeacon.h"
|
#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 "NimBLEUUID.h"
|
||||||
# include "NimBLELog.h"
|
# include "NimBLELog.h"
|
||||||
@@ -137,4 +137,4 @@ void NimBLEBeacon::setSignalPower(int8_t signalPower) {
|
|||||||
m_beaconData.signalPower = signalPower;
|
m_beaconData.signalPower = signalPower;
|
||||||
} // setSignalPower
|
} // setSignalPower
|
||||||
|
|
||||||
#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER)
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
#ifndef NIMBLE_CPP_BEACON_H_
|
#ifndef NIMBLE_CPP_BEACON_H_
|
||||||
#define NIMBLE_CPP_BEACON_H_
|
#define NIMBLE_CPP_BEACON_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "syscfg/syscfg.h"
|
||||||
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER)
|
||||||
|
|
||||||
class NimBLEUUID;
|
class NimBLEUUID;
|
||||||
|
|
||||||
@@ -65,5 +65,5 @@ class NimBLEBeacon {
|
|||||||
BeaconData m_beaconData;
|
BeaconData m_beaconData;
|
||||||
}; // NimBLEBeacon
|
}; // 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_
|
#endif // NIMBLE_CPP_BEACON_H_
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
# include "NimBLECharacteristic.h"
|
# 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 "NimBLE2904.h"
|
||||||
# include "NimBLEDevice.h"
|
# include "NimBLEDevice.h"
|
||||||
@@ -414,4 +414,4 @@ void NimBLECharacteristicCallbacks::onSubscribe(NimBLECharacteristic* pCharacter
|
|||||||
NIMBLE_LOGD("NimBLECharacteristicCallbacks", "onSubscribe: default");
|
NIMBLE_LOGD("NimBLECharacteristicCallbacks", "onSubscribe: default");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
#ifndef NIMBLE_CPP_CHARACTERISTIC_H_
|
#ifndef NIMBLE_CPP_CHARACTERISTIC_H_
|
||||||
#define NIMBLE_CPP_CHARACTERISTIC_H_
|
#define NIMBLE_CPP_CHARACTERISTIC_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "syscfg/syscfg.h"
|
||||||
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
|
||||||
|
|
||||||
class NimBLECharacteristicCallbacks;
|
class NimBLECharacteristicCallbacks;
|
||||||
class NimBLEService;
|
class NimBLEService;
|
||||||
@@ -254,5 +254,5 @@ class NimBLECharacteristicCallbacks {
|
|||||||
virtual void onSubscribe(NimBLECharacteristic* pCharacteristic, NimBLEConnInfo& connInfo, uint16_t subValue);
|
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_
|
#endif // NIMBLE_CPP_CHARACTERISTIC_H_
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "NimBLEClient.h"
|
#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 "NimBLERemoteService.h"
|
||||||
# include "NimBLERemoteCharacteristic.h"
|
# include "NimBLERemoteCharacteristic.h"
|
||||||
@@ -68,7 +68,7 @@ NimBLEClient::NimBLEClient(const NimBLEAddress& peerAddress)
|
|||||||
m_terminateFailCount{0},
|
m_terminateFailCount{0},
|
||||||
m_asyncSecureAttempt{0},
|
m_asyncSecureAttempt{0},
|
||||||
m_config{},
|
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},
|
m_phyMask{BLE_GAP_LE_PHY_1M_MASK | BLE_GAP_LE_PHY_2M_MASK | BLE_GAP_LE_PHY_CODED_MASK},
|
||||||
# endif
|
# endif
|
||||||
m_connParams{16,
|
m_connParams{16,
|
||||||
@@ -125,7 +125,7 @@ size_t NimBLEClient::deleteService(const NimBLEUUID& uuid) {
|
|||||||
return m_svcVec.size();
|
return m_svcVec.size();
|
||||||
} // deleteService
|
} // deleteService
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
# if MYNEWT_VAL(BLE_ROLE_OBSERVER)
|
||||||
/**
|
/**
|
||||||
* @brief Connect to an advertising device.
|
* @brief Connect to an advertising device.
|
||||||
* @param [in] pDevice A pointer to the advertised device instance to connect to.
|
* @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;
|
m_config.exchangeMTU = exchangeMTU;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if MYNEWT_VAL(BLE_EXT_ADV)
|
||||||
rc = ble_gap_ext_connect(NimBLEDevice::m_ownAddrType,
|
rc = ble_gap_ext_connect(NimBLEDevice::m_ownAddrType,
|
||||||
peerAddr,
|
peerAddr,
|
||||||
m_connectTimeout,
|
m_connectTimeout,
|
||||||
@@ -228,7 +228,7 @@ bool NimBLEClient::connect(const NimBLEAddress& address, bool deleteAttributes,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BLE_HS_EBUSY:
|
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.
|
// Scan was active, stop it through the NimBLEScan API to release any tasks and call the callback.
|
||||||
if (!NimBLEDevice::getScan()->stop()) {
|
if (!NimBLEDevice::getScan()->stop()) {
|
||||||
@@ -402,7 +402,7 @@ void NimBLEClient::setConfig(NimBLEClient::Config config) {
|
|||||||
m_config = config;
|
m_config = config;
|
||||||
} // setConfig
|
} // 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.
|
* @brief Set the PHY types to use when connecting to a server.
|
||||||
* @param [in] mask A bitmask indicating what PHYS to connect with.\n
|
* @param [in] mask A bitmask indicating what PHYS to connect with.\n
|
||||||
@@ -1320,4 +1320,4 @@ void NimBLEClientCallbacks::onPhyUpdate(NimBLEClient* pClient, uint8_t txPhy, ui
|
|||||||
} // onPhyUpdate
|
} // onPhyUpdate
|
||||||
#
|
#
|
||||||
|
|
||||||
#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL)
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
#ifndef NIMBLE_CPP_CLIENT_H_
|
#ifndef NIMBLE_CPP_CLIENT_H_
|
||||||
#define NIMBLE_CPP_CLIENT_H_
|
#define NIMBLE_CPP_CLIENT_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "syscfg/syscfg.h"
|
||||||
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL)
|
||||||
|
|
||||||
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
||||||
# include "host/ble_gap.h"
|
# include "host/ble_gap.h"
|
||||||
@@ -48,7 +48,7 @@ struct NimBLETaskData;
|
|||||||
*/
|
*/
|
||||||
class NimBLEClient {
|
class NimBLEClient {
|
||||||
public:
|
public:
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
# if MYNEWT_VAL(BLE_ROLE_OBSERVER)
|
||||||
bool connect(const NimBLEAdvertisedDevice* device,
|
bool connect(const NimBLEAdvertisedDevice* device,
|
||||||
bool deleteAttributes = true,
|
bool deleteAttributes = true,
|
||||||
bool asyncConnect = false,
|
bool asyncConnect = false,
|
||||||
@@ -95,7 +95,7 @@ class NimBLEClient {
|
|||||||
const NimBLEAttValue& value,
|
const NimBLEAttValue& value,
|
||||||
bool response = false);
|
bool response = false);
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if MYNEWT_VAL(BLE_EXT_ADV)
|
||||||
void setConnectPhy(uint8_t phyMask);
|
void setConnectPhy(uint8_t phyMask);
|
||||||
# endif
|
# endif
|
||||||
bool updatePhy(uint8_t txPhysMask, uint8_t rxPhysMask, uint16_t phyOptions = 0);
|
bool updatePhy(uint8_t txPhysMask, uint8_t rxPhysMask, uint16_t phyOptions = 0);
|
||||||
@@ -137,7 +137,7 @@ class NimBLEClient {
|
|||||||
mutable uint8_t m_asyncSecureAttempt;
|
mutable uint8_t m_asyncSecureAttempt;
|
||||||
Config m_config;
|
Config m_config;
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if MYNEWT_VAL(BLE_EXT_ADV)
|
||||||
uint8_t m_phyMask;
|
uint8_t m_phyMask;
|
||||||
# endif
|
# endif
|
||||||
ble_gap_conn_params m_connParams;
|
ble_gap_conn_params m_connParams;
|
||||||
@@ -229,5 +229,5 @@ class NimBLEClientCallbacks {
|
|||||||
virtual void onPhyUpdate(NimBLEClient* pClient, uint8_t txPhy, uint8_t rxPhy);
|
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_
|
#endif // NIMBLE_CPP_CLIENT_H_
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "NimBLEDescriptor.h"
|
#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 "NimBLEService.h"
|
||||||
# include "NimBLELog.h"
|
# include "NimBLELog.h"
|
||||||
@@ -147,4 +147,4 @@ void NimBLEDescriptorCallbacks::onWrite(NimBLEDescriptor* pDescriptor, NimBLECon
|
|||||||
NIMBLE_LOGD("NimBLEDescriptorCallbacks", "onWrite: default");
|
NIMBLE_LOGD("NimBLEDescriptorCallbacks", "onWrite: default");
|
||||||
} // onWrite
|
} // onWrite
|
||||||
|
|
||||||
#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
#ifndef NIMBLE_CPP_DESCRIPTOR_H_
|
#ifndef NIMBLE_CPP_DESCRIPTOR_H_
|
||||||
#define NIMBLE_CPP_DESCRIPTOR_H_
|
#define NIMBLE_CPP_DESCRIPTOR_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "syscfg/syscfg.h"
|
||||||
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
|
||||||
|
|
||||||
# include "NimBLELocalValueAttribute.h"
|
# include "NimBLELocalValueAttribute.h"
|
||||||
# include <string>
|
# include <string>
|
||||||
@@ -72,5 +72,5 @@ class NimBLEDescriptorCallbacks {
|
|||||||
|
|
||||||
# include "NimBLE2904.h"
|
# 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_
|
#endif // NIMBLE_CPP_DESCRIPTOR_H_
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "NimBLEDevice.h"
|
#include "NimBLEDevice.h"
|
||||||
#if CONFIG_BT_ENABLED
|
#if CONFIG_BT_NIMBLE_ENABLED
|
||||||
|
|
||||||
# ifdef ESP_PLATFORM
|
# ifdef ESP_PLATFORM
|
||||||
# include "esp_err.h"
|
# include "esp_err.h"
|
||||||
@@ -68,27 +68,27 @@ extern "C" void ble_store_config_init(void);
|
|||||||
NimBLEDeviceCallbacks NimBLEDevice::defaultDeviceCallbacks{};
|
NimBLEDeviceCallbacks NimBLEDevice::defaultDeviceCallbacks{};
|
||||||
NimBLEDeviceCallbacks* NimBLEDevice::m_pDeviceCallbacks = &defaultDeviceCallbacks;
|
NimBLEDeviceCallbacks* NimBLEDevice::m_pDeviceCallbacks = &defaultDeviceCallbacks;
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
# if MYNEWT_VAL(BLE_ROLE_OBSERVER)
|
||||||
NimBLEScan* NimBLEDevice::m_pScan = nullptr;
|
NimBLEScan* NimBLEDevice::m_pScan = nullptr;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
# if MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
|
||||||
NimBLEServer* NimBLEDevice::m_pServer = nullptr;
|
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;
|
NimBLEL2CAPServer* NimBLEDevice::m_pL2CAPServer = nullptr;
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
# if MYNEWT_VAL(BLE_ROLE_BROADCASTER)
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if MYNEWT_VAL(BLE_EXT_ADV)
|
||||||
NimBLEExtAdvertising* NimBLEDevice::m_bleAdvertising = nullptr;
|
NimBLEExtAdvertising* NimBLEDevice::m_bleAdvertising = nullptr;
|
||||||
# else
|
# else
|
||||||
NimBLEAdvertising* NimBLEDevice::m_bleAdvertising = nullptr;
|
NimBLEAdvertising* NimBLEDevice::m_bleAdvertising = nullptr;
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
# if MYNEWT_VAL(BLE_ROLE_CENTRAL)
|
||||||
std::array<NimBLEClient*, NIMBLE_MAX_CONNECTIONS> NimBLEDevice::m_pClients{};
|
std::array<NimBLEClient*, MYNEWT_VAL(BLE_MAX_CONNECTIONS)> NimBLEDevice::m_pClients{};
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
bool NimBLEDevice::m_initialized{false};
|
bool NimBLEDevice::m_initialized{false};
|
||||||
@@ -118,7 +118,7 @@ extern "C" int ble_vhci_disc_duplicate_mode_enable(int mode);
|
|||||||
/* SERVER FUNCTIONS */
|
/* SERVER FUNCTIONS */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
# if MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
|
||||||
/**
|
/**
|
||||||
* @brief Create an instance of a server.
|
* @brief Create an instance of a server.
|
||||||
* @return A pointer to the instance of the server.
|
* @return A pointer to the instance of the server.
|
||||||
@@ -142,7 +142,7 @@ NimBLEServer* NimBLEDevice::getServer() {
|
|||||||
return m_pServer;
|
return m_pServer;
|
||||||
} // getServer
|
} // 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.
|
* @brief Create an instance of a L2CAP server.
|
||||||
* @return A pointer to the instance of the L2CAP server.
|
* @return A pointer to the instance of the L2CAP server.
|
||||||
@@ -161,15 +161,15 @@ NimBLEL2CAPServer* NimBLEDevice::createL2CAPServer() {
|
|||||||
NimBLEL2CAPServer* NimBLEDevice::getL2CAPServer() {
|
NimBLEL2CAPServer* NimBLEDevice::getL2CAPServer() {
|
||||||
return m_pL2CAPServer;
|
return m_pL2CAPServer;
|
||||||
} // getL2CAPServer
|
} // getL2CAPServer
|
||||||
# endif // #if CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM
|
# endif // #if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM)
|
||||||
# endif // #if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
# endif // #if MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* ADVERTISING FUNCTIONS */
|
/* ADVERTISING FUNCTIONS */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
# if MYNEWT_VAL(BLE_ROLE_BROADCASTER)
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if MYNEWT_VAL(BLE_EXT_ADV)
|
||||||
/**
|
/**
|
||||||
* @brief Get the instance of the extended advertising object.
|
* @brief Get the instance of the extended advertising object.
|
||||||
* @return A pointer to the extended advertising object.
|
* @return A pointer to the extended advertising object.
|
||||||
@@ -203,7 +203,7 @@ bool NimBLEDevice::stopAdvertising(uint8_t instId) {
|
|||||||
} // stopAdvertising
|
} // stopAdvertising
|
||||||
# endif
|
# 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.
|
* @brief Get the instance of the advertising object.
|
||||||
* @return A pointer to the advertising object.
|
* @return A pointer to the advertising object.
|
||||||
@@ -232,7 +232,7 @@ bool NimBLEDevice::startAdvertising(uint32_t duration) {
|
|||||||
bool NimBLEDevice::stopAdvertising() {
|
bool NimBLEDevice::stopAdvertising() {
|
||||||
return getAdvertising()->stop();
|
return getAdvertising()->stop();
|
||||||
} // stopAdvertising
|
} // stopAdvertising
|
||||||
# endif // #if CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
# endif // #if MYNEWT_VAL(BLE_ROLE_BROADCASTER)
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* SCAN FUNCTIONS */
|
/* SCAN FUNCTIONS */
|
||||||
@@ -243,7 +243,7 @@ bool NimBLEDevice::stopAdvertising() {
|
|||||||
* @return The scanning object reference. This is a singleton object. The caller should not
|
* @return The scanning object reference. This is a singleton object. The caller should not
|
||||||
* try and release/delete it.
|
* try and release/delete it.
|
||||||
*/
|
*/
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
# if MYNEWT_VAL(BLE_ROLE_OBSERVER)
|
||||||
NimBLEScan* NimBLEDevice::getScan() {
|
NimBLEScan* NimBLEDevice::getScan() {
|
||||||
if (m_pScan == nullptr) {
|
if (m_pScan == nullptr) {
|
||||||
m_pScan = new NimBLEScan();
|
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 // CONFIG_BTDM_BLE_SCAN_DUPL || CONFIG_BT_LE_SCAN_DUPL
|
||||||
# endif // ESP_PLATFORM
|
# endif // ESP_PLATFORM
|
||||||
# endif // CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
# endif // MYNEWT_VAL(BLE_ROLE_OBSERVER)
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* CLIENT FUNCTIONS */
|
/* 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.
|
* @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.
|
* @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;
|
return nullptr;
|
||||||
} // createClient
|
} // createClient
|
||||||
|
|
||||||
@@ -462,7 +462,7 @@ std::vector<NimBLEClient*> NimBLEDevice::getConnectedClients() {
|
|||||||
return clients;
|
return clients;
|
||||||
} // getConnectedClients
|
} // getConnectedClients
|
||||||
|
|
||||||
# endif // CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
# endif // MYNEWT_VAL(BLE_ROLE_CENTRAL)
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* TRANSMIT POWER */
|
/* TRANSMIT POWER */
|
||||||
@@ -613,7 +613,7 @@ uint16_t NimBLEDevice::getMTU() {
|
|||||||
/* BOND MANAGEMENT */
|
/* 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
|
* @brief Gets the number of bonded peers stored
|
||||||
*/
|
*/
|
||||||
@@ -850,13 +850,13 @@ void NimBLEDevice::onSync(void) {
|
|||||||
m_synced = true;
|
m_synced = true;
|
||||||
|
|
||||||
if (m_initialized) {
|
if (m_initialized) {
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
# if MYNEWT_VAL(BLE_ROLE_OBSERVER)
|
||||||
if (m_pScan != nullptr) {
|
if (m_pScan != nullptr) {
|
||||||
m_pScan->onHostSync();
|
m_pScan->onHostSync();
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
# if MYNEWT_VAL(BLE_ROLE_BROADCASTER)
|
||||||
if (m_bleAdvertising != nullptr) {
|
if (m_bleAdvertising != nullptr) {
|
||||||
m_bleAdvertising->onHostSync();
|
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();
|
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
||||||
# if defined(CONFIG_IDF_TARGET_ESP32)
|
# if defined(CONFIG_IDF_TARGET_ESP32)
|
||||||
bt_cfg.mode = ESP_BT_MODE_BLE;
|
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)
|
# 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
|
# else
|
||||||
bt_cfg.nimble_max_connections = CONFIG_BT_NIMBLE_MAX_CONNECTIONS;
|
bt_cfg.nimble_max_connections = MYNEWT_VAL(BLE_MAX_CONNECTIONS);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if CONFIG_BTDM_BLE_SCAN_DUPL
|
# if CONFIG_BTDM_BLE_SCAN_DUPL
|
||||||
@@ -1026,12 +1026,12 @@ bool NimBLEDevice::deinit(bool clearAll) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (clearAll) {
|
if (clearAll) {
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
# if MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
|
||||||
if (NimBLEDevice::m_pServer != nullptr) {
|
if (NimBLEDevice::m_pServer != nullptr) {
|
||||||
delete NimBLEDevice::m_pServer;
|
delete NimBLEDevice::m_pServer;
|
||||||
NimBLEDevice::m_pServer = nullptr;
|
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) {
|
if (NimBLEDevice::m_pL2CAPServer != nullptr) {
|
||||||
delete NimBLEDevice::m_pL2CAPServer;
|
delete NimBLEDevice::m_pL2CAPServer;
|
||||||
NimBLEDevice::m_pL2CAPServer = nullptr;
|
NimBLEDevice::m_pL2CAPServer = nullptr;
|
||||||
@@ -1039,21 +1039,21 @@ bool NimBLEDevice::deinit(bool clearAll) {
|
|||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
# if MYNEWT_VAL(BLE_ROLE_BROADCASTER)
|
||||||
if (NimBLEDevice::m_bleAdvertising != nullptr) {
|
if (NimBLEDevice::m_bleAdvertising != nullptr) {
|
||||||
delete NimBLEDevice::m_bleAdvertising;
|
delete NimBLEDevice::m_bleAdvertising;
|
||||||
NimBLEDevice::m_bleAdvertising = nullptr;
|
NimBLEDevice::m_bleAdvertising = nullptr;
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
# if MYNEWT_VAL(BLE_ROLE_OBSERVER)
|
||||||
if (NimBLEDevice::m_pScan != nullptr) {
|
if (NimBLEDevice::m_pScan != nullptr) {
|
||||||
delete NimBLEDevice::m_pScan;
|
delete NimBLEDevice::m_pScan;
|
||||||
NimBLEDevice::m_pScan = nullptr;
|
NimBLEDevice::m_pScan = nullptr;
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
# if MYNEWT_VAL(BLE_ROLE_CENTRAL)
|
||||||
for (auto clt : m_pClients) {
|
for (auto clt : m_pClients) {
|
||||||
deleteClient(clt);
|
deleteClient(clt);
|
||||||
}
|
}
|
||||||
@@ -1254,7 +1254,7 @@ bool NimBLEDevice::startSecurity(uint16_t connHandle, int* rcPtr) {
|
|||||||
return rc == 0 || rc == BLE_HS_EALREADY;
|
return rc == 0 || rc == BLE_HS_EALREADY;
|
||||||
} // startSecurity
|
} // 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.
|
* @brief Inject the provided passkey into the Security Manager.
|
||||||
* @param [in] peerInfo Connection information for the peer.
|
* @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);
|
NIMBLE_LOGD(LOG_TAG, "BLE_SM_IOACT_NUMCMP; ble_sm_inject_io result: %d", rc);
|
||||||
return rc == 0;
|
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 */
|
/* UTILITIES */
|
||||||
@@ -1347,4 +1347,4 @@ int NimBLEDeviceCallbacks::onStoreStatus(struct ble_store_status_event* event, v
|
|||||||
return ble_store_util_status_rr(event, arg);
|
return ble_store_util_status_rr(event, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // CONFIG_BT_ENABLED
|
#endif // CONFIG_BT_NIMBLE_ENABLED
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
#ifndef NIMBLE_CPP_DEVICE_H_
|
#ifndef NIMBLE_CPP_DEVICE_H_
|
||||||
#define NIMBLE_CPP_DEVICE_H_
|
#define NIMBLE_CPP_DEVICE_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "syscfg/syscfg.h"
|
||||||
#if CONFIG_BT_ENABLED
|
#if CONFIG_BT_NIMBLE_ENABLED
|
||||||
# ifdef ESP_PLATFORM
|
# ifdef ESP_PLATFORM
|
||||||
# ifndef CONFIG_IDF_TARGET_ESP32P4
|
# ifndef CONFIG_IDF_TARGET_ESP32P4
|
||||||
# include <esp_bt.h>
|
# include <esp_bt.h>
|
||||||
@@ -40,31 +40,31 @@
|
|||||||
# include <string>
|
# include <string>
|
||||||
# include <vector>
|
# include <vector>
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
# if MYNEWT_VAL(BLE_ROLE_CENTRAL)
|
||||||
# include <array>
|
# include <array>
|
||||||
class NimBLEClient;
|
class NimBLEClient;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
# if MYNEWT_VAL(BLE_ROLE_OBSERVER)
|
||||||
class NimBLEScan;
|
class NimBLEScan;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
# if MYNEWT_VAL(BLE_ROLE_BROADCASTER)
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if MYNEWT_VAL(BLE_EXT_ADV)
|
||||||
class NimBLEExtAdvertising;
|
class NimBLEExtAdvertising;
|
||||||
# else
|
# else
|
||||||
class NimBLEAdvertising;
|
class NimBLEAdvertising;
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
# if MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
|
||||||
class NimBLEServer;
|
class NimBLEServer;
|
||||||
# if CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM > 0
|
# if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM)
|
||||||
class NimBLEL2CAPServer;
|
class NimBLEL2CAPServer;
|
||||||
# endif
|
# endif
|
||||||
# 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;
|
class NimBLEConnInfo;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
@@ -106,12 +106,6 @@ class NimBLEDeviceCallbacks;
|
|||||||
# define BLEL2CAPChannel NimBLEL2CAPChannel
|
# define BLEL2CAPChannel NimBLEL2CAPChannel
|
||||||
# define BLEL2CAPChannelCallbacks NimBLEL2CAPChannelCallbacks
|
# 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 };
|
enum class NimBLETxPowerType { All = 0, Advertise = 1, Scan = 2, Connection = 3 };
|
||||||
|
|
||||||
typedef int (*gap_event_handler)(ble_gap_event* event, void* arg);
|
typedef int (*gap_event_handler)(ble_gap_event* event, void* arg);
|
||||||
@@ -164,39 +158,39 @@ class NimBLEDevice {
|
|||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
# if MYNEWT_VAL(BLE_ROLE_OBSERVER)
|
||||||
static NimBLEScan* getScan();
|
static NimBLEScan* getScan();
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
# if MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
|
||||||
static NimBLEServer* createServer();
|
static NimBLEServer* createServer();
|
||||||
static NimBLEServer* getServer();
|
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* createL2CAPServer();
|
||||||
static NimBLEL2CAPServer* getL2CAPServer();
|
static NimBLEL2CAPServer* getL2CAPServer();
|
||||||
# endif
|
# endif
|
||||||
# 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 injectConfirmPasskey(const NimBLEConnInfo& peerInfo, bool accept);
|
||||||
static bool injectPassKey(const NimBLEConnInfo& peerInfo, uint32_t pin);
|
static bool injectPassKey(const NimBLEConnInfo& peerInfo, uint32_t pin);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
# if MYNEWT_VAL(BLE_ROLE_BROADCASTER)
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if MYNEWT_VAL(BLE_EXT_ADV)
|
||||||
static NimBLEExtAdvertising* getAdvertising();
|
static NimBLEExtAdvertising* getAdvertising();
|
||||||
static bool startAdvertising(uint8_t instId, int duration = 0, int maxEvents = 0);
|
static bool startAdvertising(uint8_t instId, int duration = 0, int maxEvents = 0);
|
||||||
static bool stopAdvertising(uint8_t instId);
|
static bool stopAdvertising(uint8_t instId);
|
||||||
static bool stopAdvertising();
|
static bool stopAdvertising();
|
||||||
# endif
|
# endif
|
||||||
# if !CONFIG_BT_NIMBLE_EXT_ADV || defined(_DOXYGEN_)
|
# if !MYNEWT_VAL(BLE_EXT_ADV) || defined(_DOXYGEN_)
|
||||||
static NimBLEAdvertising* getAdvertising();
|
static NimBLEAdvertising* getAdvertising();
|
||||||
static bool startAdvertising(uint32_t duration = 0);
|
static bool startAdvertising(uint32_t duration = 0);
|
||||||
static bool stopAdvertising();
|
static bool stopAdvertising();
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
# if MYNEWT_VAL(BLE_ROLE_CENTRAL)
|
||||||
static NimBLEClient* createClient();
|
static NimBLEClient* createClient();
|
||||||
static NimBLEClient* createClient(const NimBLEAddress& peerAddress);
|
static NimBLEClient* createClient(const NimBLEAddress& peerAddress);
|
||||||
static bool deleteClient(NimBLEClient* pClient);
|
static bool deleteClient(NimBLEClient* pClient);
|
||||||
@@ -207,7 +201,7 @@ class NimBLEDevice {
|
|||||||
static std::vector<NimBLEClient*> getConnectedClients();
|
static std::vector<NimBLEClient*> getConnectedClients();
|
||||||
# endif
|
# 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 bool deleteBond(const NimBLEAddress& address);
|
||||||
static int getNumBonds();
|
static int getNumBonds();
|
||||||
static bool isBonded(const NimBLEAddress& address);
|
static bool isBonded(const NimBLEAddress& address);
|
||||||
@@ -225,27 +219,27 @@ class NimBLEDevice {
|
|||||||
static NimBLEDeviceCallbacks* m_pDeviceCallbacks;
|
static NimBLEDeviceCallbacks* m_pDeviceCallbacks;
|
||||||
static NimBLEDeviceCallbacks defaultDeviceCallbacks;
|
static NimBLEDeviceCallbacks defaultDeviceCallbacks;
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
# if MYNEWT_VAL(BLE_ROLE_OBSERVER)
|
||||||
static NimBLEScan* m_pScan;
|
static NimBLEScan* m_pScan;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
# if MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
|
||||||
static NimBLEServer* m_pServer;
|
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;
|
static NimBLEL2CAPServer* m_pL2CAPServer;
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
# if MYNEWT_VAL(BLE_ROLE_BROADCASTER)
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if MYNEWT_VAL(BLE_EXT_ADV)
|
||||||
static NimBLEExtAdvertising* m_bleAdvertising;
|
static NimBLEExtAdvertising* m_bleAdvertising;
|
||||||
# else
|
# else
|
||||||
static NimBLEAdvertising* m_bleAdvertising;
|
static NimBLEAdvertising* m_bleAdvertising;
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
# if MYNEWT_VAL(BLE_ROLE_CENTRAL)
|
||||||
static std::array<NimBLEClient*, NIMBLE_MAX_CONNECTIONS> m_pClients;
|
static std::array<NimBLEClient*, MYNEWT_VAL(BLE_MAX_CONNECTIONS)> m_pClients;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef ESP_PLATFORM
|
# ifdef ESP_PLATFORM
|
||||||
@@ -256,59 +250,59 @@ class NimBLEDevice {
|
|||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
# if MYNEWT_VAL(BLE_ROLE_CENTRAL)
|
||||||
friend class NimBLEClient;
|
friend class NimBLEClient;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
# if MYNEWT_VAL(BLE_ROLE_OBSERVER)
|
||||||
friend class NimBLEScan;
|
friend class NimBLEScan;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
# if MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
|
||||||
friend class NimBLEServer;
|
friend class NimBLEServer;
|
||||||
friend class NimBLECharacteristic;
|
friend class NimBLECharacteristic;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
# if MYNEWT_VAL(BLE_ROLE_BROADCASTER)
|
||||||
friend class NimBLEAdvertising;
|
friend class NimBLEAdvertising;
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if MYNEWT_VAL(BLE_EXT_ADV)
|
||||||
friend class NimBLEExtAdvertising;
|
friend class NimBLEExtAdvertising;
|
||||||
friend class NimBLEExtAdvertisement;
|
friend class NimBLEExtAdvertisement;
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
};
|
};
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
# if MYNEWT_VAL(BLE_ROLE_CENTRAL)
|
||||||
# include "NimBLEClient.h"
|
# include "NimBLEClient.h"
|
||||||
# include "NimBLERemoteService.h"
|
# include "NimBLERemoteService.h"
|
||||||
# include "NimBLERemoteCharacteristic.h"
|
# include "NimBLERemoteCharacteristic.h"
|
||||||
# include "NimBLERemoteDescriptor.h"
|
# include "NimBLERemoteDescriptor.h"
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
# if MYNEWT_VAL(BLE_ROLE_OBSERVER)
|
||||||
# include "NimBLEScan.h"
|
# include "NimBLEScan.h"
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
# if MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
|
||||||
# include "NimBLEServer.h"
|
# include "NimBLEServer.h"
|
||||||
# include "NimBLEService.h"
|
# include "NimBLEService.h"
|
||||||
# include "NimBLECharacteristic.h"
|
# include "NimBLECharacteristic.h"
|
||||||
# include "NimBLEDescriptor.h"
|
# include "NimBLEDescriptor.h"
|
||||||
# if CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM
|
# if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM)
|
||||||
# include "NimBLEL2CAPServer.h"
|
# include "NimBLEL2CAPServer.h"
|
||||||
# include "NimBLEL2CAPChannel.h"
|
# include "NimBLEL2CAPChannel.h"
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
# if MYNEWT_VAL(BLE_ROLE_BROADCASTER)
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if MYNEWT_VAL(BLE_EXT_ADV)
|
||||||
# include "NimBLEExtAdvertising.h"
|
# include "NimBLEExtAdvertising.h"
|
||||||
# else
|
# else
|
||||||
# include "NimBLEAdvertising.h"
|
# include "NimBLEAdvertising.h"
|
||||||
# endif
|
# endif
|
||||||
# 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"
|
# include "NimBLEConnInfo.h"
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
@@ -337,5 +331,5 @@ class NimBLEDeviceCallbacks {
|
|||||||
virtual int onStoreStatus(struct ble_store_status_event* event, void* arg);
|
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_
|
#endif // NIMBLE_CPP_DEVICE_H_
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "NimBLEEddystoneTLM.h"
|
#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 "NimBLEUUID.h"
|
||||||
# include "NimBLELog.h"
|
# include "NimBLELog.h"
|
||||||
@@ -215,4 +215,4 @@ void NimBLEEddystoneTLM::setTime(uint32_t tmil) {
|
|||||||
m_eddystoneData.tmil = tmil;
|
m_eddystoneData.tmil = tmil;
|
||||||
} // setTime
|
} // setTime
|
||||||
|
|
||||||
#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER)
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
#ifndef NIMBLE_CPP_EDDYSTONETLM_H_
|
#ifndef NIMBLE_CPP_EDDYSTONETLM_H_
|
||||||
#define NIMBLE_CPP_EDDYSTONETLM_H_
|
#define NIMBLE_CPP_EDDYSTONETLM_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "syscfg/syscfg.h"
|
||||||
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER)
|
||||||
|
|
||||||
class NimBLEUUID;
|
class NimBLEUUID;
|
||||||
|
|
||||||
@@ -66,5 +66,5 @@ class NimBLEEddystoneTLM {
|
|||||||
|
|
||||||
}; // 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_
|
#endif // NIMBLE_CPP_EDDYSTONETLM_H_
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "NimBLEExtAdvertising.h"
|
#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)
|
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
||||||
# include "services/gap/ble_svc_gap.h"
|
# include "services/gap/ble_svc_gap.h"
|
||||||
@@ -38,7 +38,7 @@ static const char* LOG_TAG = "NimBLEExtAdvertising";
|
|||||||
NimBLEExtAdvertising::NimBLEExtAdvertising()
|
NimBLEExtAdvertising::NimBLEExtAdvertising()
|
||||||
: m_deleteCallbacks{false},
|
: m_deleteCallbacks{false},
|
||||||
m_pCallbacks{&defaultCallbacks},
|
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.
|
* @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;
|
adv.m_params.scan_req_notif = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
# if MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
|
||||||
NimBLEServer* pServer = NimBLEDevice::getServer();
|
NimBLEServer* pServer = NimBLEDevice::getServer();
|
||||||
if (pServer != nullptr) {
|
if (pServer != nullptr) {
|
||||||
pServer->start(); // make sure the GATT server is ready before advertising
|
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.
|
* @param [in] enable True = connectable.
|
||||||
*/
|
*/
|
||||||
void NimBLEExtAdvertisement::setConnectable(bool enable) {
|
void NimBLEExtAdvertisement::setConnectable(bool enable) {
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
# if MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
|
||||||
m_params.connectable = enable;
|
m_params.connectable = enable;
|
||||||
# endif
|
# endif
|
||||||
} // setConnectable
|
} // setConnectable
|
||||||
@@ -531,7 +531,7 @@ void NimBLEExtAdvertisement::clearData() {
|
|||||||
* @details This will completely replace any data that was previously set.
|
* @details This will completely replace any data that was previously set.
|
||||||
*/
|
*/
|
||||||
bool NimBLEExtAdvertisement::setData(const uint8_t* data, size_t length) {
|
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;
|
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.
|
* @return True if successful, false if the data is too large.
|
||||||
*/
|
*/
|
||||||
bool NimBLEExtAdvertisement::addData(const uint8_t* data, size_t length) {
|
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;
|
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.
|
* @return True if successful, false if the data is too large.
|
||||||
*/
|
*/
|
||||||
bool NimBLEExtAdvertisement::addData(const std::string& data) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -710,7 +710,7 @@ bool NimBLEExtAdvertisement::addServiceUUID(const NimBLEUUID& serviceUUID) {
|
|||||||
length += 2;
|
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!");
|
NIMBLE_LOGE(LOG_TAG, "Cannot add UUID, data length exceeded!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -919,7 +919,7 @@ bool NimBLEExtAdvertisement::setServiceData(const NimBLEUUID& uuid, const uint8_
|
|||||||
uint8_t uuidBytes = uuid.bitSize() / 8;
|
uint8_t uuidBytes = uuid.bitSize() / 8;
|
||||||
uint8_t sDataLen = 2 + uuidBytes + length;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1090,4 +1090,4 @@ std::string NimBLEExtAdvertisement::toString() const {
|
|||||||
return str;
|
return str;
|
||||||
} // toString
|
} // 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)
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
#ifndef NIMBLE_CPP_EXTADVERTISING_H_
|
#ifndef NIMBLE_CPP_EXTADVERTISING_H_
|
||||||
#define NIMBLE_CPP_EXTADVERTISING_H_
|
#define NIMBLE_CPP_EXTADVERTISING_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "syscfg/syscfg.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)
|
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
||||||
# include "host/ble_gap.h"
|
# include "host/ble_gap.h"
|
||||||
@@ -159,5 +159,5 @@ class NimBLEExtAdvertisingCallbacks {
|
|||||||
virtual void onScanRequest(NimBLEExtAdvertising* pAdv, uint8_t instId, NimBLEAddress addr);
|
virtual void onScanRequest(NimBLEExtAdvertising* pAdv, uint8_t instId, NimBLEAddress addr);
|
||||||
}; // NimBLEExtAdvertisingCallbacks
|
}; // 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_
|
#endif // NIMBLE_CPP_EXTADVERTISING_H_
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "NimBLEHIDDevice.h"
|
#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 "NimBLEServer.h"
|
||||||
# include "NimBLEService.h"
|
# include "NimBLEService.h"
|
||||||
@@ -340,4 +340,4 @@ NimBLEService* NimBLEHIDDevice::getBatteryService() {
|
|||||||
return m_batterySvc;
|
return m_batterySvc;
|
||||||
} // getBatteryService
|
} // getBatteryService
|
||||||
|
|
||||||
#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
#ifndef NIMBLE_CPP_HIDDEVICE_H_
|
#ifndef NIMBLE_CPP_HIDDEVICE_H_
|
||||||
#define NIMBLE_CPP_HIDDEVICE_H_
|
#define NIMBLE_CPP_HIDDEVICE_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "syscfg/syscfg.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 <stdint.h>
|
# include <stdint.h>
|
||||||
# include <string>
|
# include <string>
|
||||||
@@ -85,5 +85,5 @@ class NimBLEHIDDevice {
|
|||||||
NimBLECharacteristic* locateReportCharacteristicByIdAndType(uint8_t reportId, uint8_t reportType);
|
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_
|
#endif // NIMBLE_CPP_HIDDEVICE_H_
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "NimBLEL2CAPChannel.h"
|
#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 "NimBLEClient.h"
|
||||||
# include "NimBLELog.h"
|
# include "NimBLELog.h"
|
||||||
@@ -149,7 +149,7 @@ int NimBLEL2CAPChannel::writeFragment(std::vector<uint8_t>::const_iterator begin
|
|||||||
return -BLE_HS_EREJECT;
|
return -BLE_HS_EREJECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
# if MYNEWT_VAL(BLE_ROLE_CENTRAL)
|
||||||
NimBLEL2CAPChannel* NimBLEL2CAPChannel::connect(NimBLEClient* client,
|
NimBLEL2CAPChannel* NimBLEL2CAPChannel::connect(NimBLEClient* client,
|
||||||
uint16_t psm,
|
uint16_t psm,
|
||||||
uint16_t mtu,
|
uint16_t mtu,
|
||||||
@@ -174,7 +174,7 @@ NimBLEL2CAPChannel* NimBLEL2CAPChannel::connect(NimBLEClient* cli
|
|||||||
}
|
}
|
||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
# endif // CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
# endif // MYNEWT_VAL(BLE_ROLE_CENTRAL)
|
||||||
|
|
||||||
bool NimBLEL2CAPChannel::write(const std::vector<uint8_t>& bytes) {
|
bool NimBLEL2CAPChannel::write(const std::vector<uint8_t>& bytes) {
|
||||||
if (!this->channel) {
|
if (!this->channel) {
|
||||||
@@ -311,4 +311,4 @@ int NimBLEL2CAPChannel::handleL2capEvent(struct ble_l2cap_event* event, void* ar
|
|||||||
return returnValue;
|
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)
|
||||||
|
@@ -5,8 +5,8 @@
|
|||||||
#ifndef NIMBLE_CPP_L2CAPCHANNEL_H_
|
#ifndef NIMBLE_CPP_L2CAPCHANNEL_H_
|
||||||
#define NIMBLE_CPP_L2CAPCHANNEL_H_
|
#define NIMBLE_CPP_L2CAPCHANNEL_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "syscfg/syscfg.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 "inttypes.h"
|
# include "inttypes.h"
|
||||||
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
||||||
@@ -122,5 +122,5 @@ class NimBLEL2CAPChannelCallbacks {
|
|||||||
virtual void onDisconnect(NimBLEL2CAPChannel* channel) {};
|
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_
|
#endif // NIMBLE_CPP_L2CAPCHANNEL_H_
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "NimBLEL2CAPServer.h"
|
#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 "NimBLEL2CAPChannel.h"
|
||||||
# include "NimBLEDevice.h"
|
# include "NimBLEDevice.h"
|
||||||
@@ -37,4 +37,4 @@ NimBLEL2CAPChannel* NimBLEL2CAPServer::createService(const uint16_t
|
|||||||
return service;
|
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)
|
||||||
|
@@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
#ifndef NIMBLE_CPP_L2CAPSERVER_H_
|
#ifndef NIMBLE_CPP_L2CAPSERVER_H_
|
||||||
#define NIMBLE_CPP_L2CAPSERVER_H_
|
#define NIMBLE_CPP_L2CAPSERVER_H_
|
||||||
#include "nimconfig.h"
|
#include "syscfg/syscfg.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 "inttypes.h"
|
# include "inttypes.h"
|
||||||
# include <vector>
|
# include <vector>
|
||||||
@@ -37,5 +37,5 @@ class NimBLEL2CAPServer {
|
|||||||
friend class NimBLEDevice;
|
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_
|
#endif // NIMBLE_CPP_L2CAPSERVER_H_
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
#ifndef NIMBLE_CPP_LOCAL_ATTRIBUTE_H_
|
#ifndef NIMBLE_CPP_LOCAL_ATTRIBUTE_H_
|
||||||
#define NIMBLE_CPP_LOCAL_ATTRIBUTE_H_
|
#define NIMBLE_CPP_LOCAL_ATTRIBUTE_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "syscfg/syscfg.h"
|
||||||
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
|
||||||
|
|
||||||
# include "NimBLEAttribute.h"
|
# include "NimBLEAttribute.h"
|
||||||
|
|
||||||
@@ -54,5 +54,5 @@ class NimBLELocalAttribute : public NimBLEAttribute {
|
|||||||
uint8_t m_removed{0};
|
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_
|
#endif // NIMBLE_CPP_LOCAL_ATTRIBUTE_H_
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
#ifndef NIMBLE_LOCAL_VALUE_ATTRIBUTE_H_
|
#ifndef NIMBLE_LOCAL_VALUE_ATTRIBUTE_H_
|
||||||
#define NIMBLE_LOCAL_VALUE_ATTRIBUTE_H_
|
#define NIMBLE_LOCAL_VALUE_ATTRIBUTE_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "syscfg/syscfg.h"
|
||||||
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
|
||||||
|
|
||||||
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
||||||
# include "host/ble_hs.h"
|
# include "host/ble_hs.h"
|
||||||
@@ -140,5 +140,5 @@ class NimBLELocalValueAttribute : public NimBLELocalAttribute, public NimBLEValu
|
|||||||
uint16_t m_properties{0};
|
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_
|
#endif // NIMBLE_LOCAL_VALUE_ATTRIBUTE_H_
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
#ifndef NIMBLE_CPP_LOG_H_
|
#ifndef NIMBLE_CPP_LOG_H_
|
||||||
#define NIMBLE_CPP_LOG_H_
|
#define NIMBLE_CPP_LOG_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "syscfg/syscfg.h"
|
||||||
#if CONFIG_BT_ENABLED
|
#if CONFIG_BT_NIMBLE_ENABLED
|
||||||
|
|
||||||
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
||||||
# include "esp_log.h"
|
# include "esp_log.h"
|
||||||
@@ -137,7 +137,7 @@
|
|||||||
# define NIMBLE_LOGE(tag, format, ...) NIMBLE_CPP_LOG_PRINT(ESP_LOG_ERROR, tag, format, ##__VA_ARGS__)
|
# define NIMBLE_LOGE(tag, format, ...) NIMBLE_CPP_LOG_PRINT(ESP_LOG_ERROR, tag, format, ##__VA_ARGS__)
|
||||||
|
|
||||||
# else
|
# else
|
||||||
# include "nimble/porting/nimble/include/syscfg/syscfg.h"
|
# include "syscfg/syscfg.h"
|
||||||
# include "nimble/console/console.h"
|
# include "nimble/console/console.h"
|
||||||
# ifndef CONFIG_NIMBLE_CPP_LOG_LEVEL
|
# ifndef CONFIG_NIMBLE_CPP_LOG_LEVEL
|
||||||
# if defined(ARDUINO_ARCH_ESP32) && defined(CORE_DEBUG_LEVEL)
|
# if defined(ARDUINO_ARCH_ESP32) && defined(CORE_DEBUG_LEVEL)
|
||||||
@@ -179,5 +179,5 @@
|
|||||||
# define NIMBLE_LOGE_IF(cond, tag, format, ...) { if (cond) { NIMBLE_LOGE(tag, format, ##__VA_ARGS__); }}
|
# 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)); }}
|
# 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_ */
|
#endif /* NIMBLE_CPP_LOG_H_ */
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "NimBLERemoteCharacteristic.h"
|
#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 "NimBLERemoteDescriptor.h"
|
||||||
# include "NimBLERemoteService.h"
|
# include "NimBLERemoteService.h"
|
||||||
@@ -387,4 +387,4 @@ NimBLEClient* NimBLERemoteCharacteristic::getClient() const {
|
|||||||
return getRemoteService()->getClient();
|
return getRemoteService()->getClient();
|
||||||
} // getClient
|
} // getClient
|
||||||
|
|
||||||
#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL)
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
#ifndef NIMBLE_CPP_REMOTE_CHARACTERISTIC_H_
|
#ifndef NIMBLE_CPP_REMOTE_CHARACTERISTIC_H_
|
||||||
#define NIMBLE_CPP_REMOTE_CHARACTERISTIC_H_
|
#define NIMBLE_CPP_REMOTE_CHARACTERISTIC_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "syscfg/syscfg.h"
|
||||||
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL)
|
||||||
|
|
||||||
# include "NimBLERemoteValueAttribute.h"
|
# include "NimBLERemoteValueAttribute.h"
|
||||||
# include <vector>
|
# include <vector>
|
||||||
@@ -79,5 +79,5 @@ class NimBLERemoteCharacteristic : public NimBLERemoteValueAttribute {
|
|||||||
|
|
||||||
}; // NimBLERemoteCharacteristic
|
}; // 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_ */
|
#endif /* NIMBLE_CPP_REMOTE_CHARACTERISTIC_H_ */
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "NimBLERemoteDescriptor.h"
|
#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"
|
# include "NimBLERemoteCharacteristic.h"
|
||||||
|
|
||||||
@@ -56,4 +56,4 @@ NimBLEClient* NimBLERemoteDescriptor::getClient() const {
|
|||||||
return m_pRemoteCharacteristic->getClient();
|
return m_pRemoteCharacteristic->getClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL)
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
#ifndef NIMBLE_CPP_REMOTE_DESCRIPTOR_H_
|
#ifndef NIMBLE_CPP_REMOTE_DESCRIPTOR_H_
|
||||||
#define NIMBLE_CPP_REMOTE_DESCRIPTOR_H_
|
#define NIMBLE_CPP_REMOTE_DESCRIPTOR_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "syscfg/syscfg.h"
|
||||||
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL)
|
||||||
|
|
||||||
# include "NimBLERemoteValueAttribute.h"
|
# include "NimBLERemoteValueAttribute.h"
|
||||||
|
|
||||||
@@ -44,5 +44,5 @@ class NimBLERemoteDescriptor : public NimBLERemoteValueAttribute {
|
|||||||
const NimBLERemoteCharacteristic* m_pRemoteCharacteristic;
|
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_
|
#endif // NIMBLE_CPP_REMOTE_DESCRIPTOR_H_
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "NimBLERemoteService.h"
|
#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 "NimBLERemoteCharacteristic.h"
|
||||||
# include "NimBLEClient.h"
|
# include "NimBLEClient.h"
|
||||||
@@ -302,4 +302,4 @@ std::string NimBLERemoteService::toString() const {
|
|||||||
return res;
|
return res;
|
||||||
} // toString
|
} // toString
|
||||||
|
|
||||||
#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL)
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
#ifndef NIMBLE_CPP_REMOTE_SERVICE_H_
|
#ifndef NIMBLE_CPP_REMOTE_SERVICE_H_
|
||||||
#define NIMBLE_CPP_REMOTE_SERVICE_H_
|
#define NIMBLE_CPP_REMOTE_SERVICE_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "syscfg/syscfg.h"
|
||||||
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL)
|
||||||
|
|
||||||
# include "NimBLEAttribute.h"
|
# include "NimBLEAttribute.h"
|
||||||
# include <vector>
|
# include <vector>
|
||||||
@@ -64,5 +64,5 @@ class NimBLERemoteService : public NimBLEAttribute {
|
|||||||
uint16_t m_endHandle{0};
|
uint16_t m_endHandle{0};
|
||||||
}; // NimBLERemoteService
|
}; // 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_
|
#endif // NIMBLE_CPP_REMOTE_SERVICE_H_
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "NimBLERemoteValueAttribute.h"
|
#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 "NimBLEClient.h"
|
||||||
# include "NimBLEUtils.h"
|
# include "NimBLEUtils.h"
|
||||||
@@ -217,4 +217,4 @@ int NimBLERemoteValueAttribute::onReadCB(uint16_t conn_handle, const ble_gatt_er
|
|||||||
return rc;
|
return rc;
|
||||||
} // onReadCB
|
} // onReadCB
|
||||||
|
|
||||||
#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL)
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
#ifndef NIMBLE_CPP_REMOTE_VALUE_ATTRIBUTE_H_
|
#ifndef NIMBLE_CPP_REMOTE_VALUE_ATTRIBUTE_H_
|
||||||
#define NIMBLE_CPP_REMOTE_VALUE_ATTRIBUTE_H_
|
#define NIMBLE_CPP_REMOTE_VALUE_ATTRIBUTE_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "syscfg/syscfg.h"
|
||||||
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL)
|
||||||
|
|
||||||
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
||||||
# include <host/ble_gatt.h>
|
# include <host/ble_gatt.h>
|
||||||
@@ -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);
|
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_
|
#endif // NIMBLE_CPP_REMOTE_VALUE_ATTRIBUTE_H_
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "NimBLEScan.h"
|
#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 "NimBLEDevice.h"
|
||||||
# include "NimBLELog.h"
|
# include "NimBLELog.h"
|
||||||
@@ -63,7 +63,7 @@ int NimBLEScan::handleGapEvent(ble_gap_event* event, void* arg) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if MYNEWT_VAL(BLE_EXT_ADV)
|
||||||
const auto& disc = event->ext_disc;
|
const auto& disc = event->ext_disc;
|
||||||
const bool isLegacyAdv = disc.props & BLE_HCI_ADV_LEGACY_MASK;
|
const bool isLegacyAdv = disc.props & BLE_HCI_ADV_LEGACY_MASK;
|
||||||
const auto event_type = isLegacyAdv ? disc.legacy_event_type : disc.props;
|
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
|
# endif
|
||||||
NimBLEAddress advertisedAddress(disc.addr);
|
NimBLEAddress advertisedAddress(disc.addr);
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
# if MYNEWT_VAL(BLE_ROLE_CENTRAL)
|
||||||
// stop processing if already connected
|
// stop processing if already connected
|
||||||
NimBLEClient* pClient = NimBLEDevice::getClientByPeerAddress(advertisedAddress);
|
NimBLEClient* pClient = NimBLEDevice::getClientByPeerAddress(advertisedAddress);
|
||||||
if (pClient != nullptr && pClient->isConnected()) {
|
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
|
// If we've seen this device before get a pointer to it from the vector
|
||||||
for (const auto& dev : pScan->m_scanResults.m_deviceVec) {
|
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.
|
// Same address but different set ID should create a new advertised device.
|
||||||
if (dev->getAddress() == advertisedAddress && dev->getSetId() == disc.sid)
|
if (dev->getAddress() == advertisedAddress && dev->getSetId() == disc.sid)
|
||||||
# else
|
# else
|
||||||
@@ -272,7 +272,7 @@ bool NimBLEScan::isScanning() {
|
|||||||
return ble_gap_disc_active();
|
return ble_gap_disc_active();
|
||||||
}
|
}
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if MYNEWT_VAL(BLE_EXT_ADV)
|
||||||
/**
|
/**
|
||||||
* @brief Set the PHYs to scan.
|
* @brief Set the PHYs to scan.
|
||||||
* @param [in] phyMask The PHYs to scan, a bit mask of:
|
* @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 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;
|
ble_gap_ext_disc_params scan_params;
|
||||||
scan_params.passive = m_scanParams.passive;
|
scan_params.passive = m_scanParams.passive;
|
||||||
scan_params.itvl = m_scanParams.itvl;
|
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());
|
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)
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
#ifndef NIMBLE_CPP_SCAN_H_
|
#ifndef NIMBLE_CPP_SCAN_H_
|
||||||
#define NIMBLE_CPP_SCAN_H_
|
#define NIMBLE_CPP_SCAN_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "syscfg/syscfg.h"
|
||||||
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_OBSERVER)
|
||||||
|
|
||||||
# include "NimBLEAdvertisedDevice.h"
|
# include "NimBLEAdvertisedDevice.h"
|
||||||
# include "NimBLEUtils.h"
|
# include "NimBLEUtils.h"
|
||||||
@@ -83,7 +83,7 @@ class NimBLEScan {
|
|||||||
void erase(const NimBLEAddress& address);
|
void erase(const NimBLEAddress& address);
|
||||||
void erase(const NimBLEAdvertisedDevice* device);
|
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 };
|
enum Phy { SCAN_1M = 0x01, SCAN_CODED = 0x02, SCAN_ALL = 0x03 };
|
||||||
void setPhy(Phy phyMask);
|
void setPhy(Phy phyMask);
|
||||||
void setPeriod(uint32_t periodMs);
|
void setPeriod(uint32_t periodMs);
|
||||||
@@ -103,7 +103,7 @@ class NimBLEScan {
|
|||||||
NimBLETaskData* m_pTaskData;
|
NimBLETaskData* m_pTaskData;
|
||||||
uint8_t m_maxResults;
|
uint8_t m_maxResults;
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if MYNEWT_VAL(BLE_EXT_ADV)
|
||||||
uint8_t m_phy{SCAN_ALL};
|
uint8_t m_phy{SCAN_ALL};
|
||||||
uint16_t m_period{0};
|
uint16_t m_period{0};
|
||||||
# endif
|
# endif
|
||||||
@@ -136,5 +136,5 @@ class NimBLEScanCallbacks {
|
|||||||
virtual void onScanEnd(const NimBLEScanResults& scanResults, int reason);
|
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_
|
#endif // NIMBLE_CPP_SCAN_H_
|
||||||
|
@@ -16,12 +16,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "NimBLEServer.h"
|
#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 "NimBLEDevice.h"
|
||||||
# include "NimBLELog.h"
|
# include "NimBLELog.h"
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
# if MYNEWT_VAL(BLE_ROLE_CENTRAL)
|
||||||
# include "NimBLEClient.h"
|
# include "NimBLEClient.h"
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ NimBLEServer::NimBLEServer()
|
|||||||
: m_gattsStarted{false},
|
: m_gattsStarted{false},
|
||||||
m_svcChanged{false},
|
m_svcChanged{false},
|
||||||
m_deleteCallbacks{false},
|
m_deleteCallbacks{false},
|
||||||
# if !CONFIG_BT_NIMBLE_EXT_ADV
|
# if !MYNEWT_VAL(BLE_EXT_ADV)
|
||||||
m_advertiseOnDisconnect{false},
|
m_advertiseOnDisconnect{false},
|
||||||
# endif
|
# endif
|
||||||
m_pServerCallbacks{&defaultCallbacks},
|
m_pServerCallbacks{&defaultCallbacks},
|
||||||
@@ -69,7 +69,7 @@ NimBLEServer::~NimBLEServer() {
|
|||||||
delete m_pServerCallbacks;
|
delete m_pServerCallbacks;
|
||||||
}
|
}
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
# if MYNEWT_VAL(BLE_ROLE_CENTRAL)
|
||||||
if (m_pClient != nullptr) {
|
if (m_pClient != nullptr) {
|
||||||
delete m_pClient;
|
delete m_pClient;
|
||||||
}
|
}
|
||||||
@@ -143,7 +143,7 @@ NimBLEService* NimBLEServer::getServiceByHandle(uint16_t handle) const {
|
|||||||
return nullptr;
|
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.
|
* @brief Retrieve the advertising object that can be used to advertise the existence of the server.
|
||||||
* @return A pinter to an advertising object.
|
* @return A pinter to an advertising object.
|
||||||
@@ -153,7 +153,7 @@ NimBLEExtAdvertising* NimBLEServer::getAdvertising() const {
|
|||||||
} // getAdvertising
|
} // getAdvertising
|
||||||
# endif
|
# 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.
|
* @brief Retrieve the advertising object that can be used to advertise the existence of the server.
|
||||||
* @return A pointer to an advertising object.
|
* @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);
|
return disconnect(connInfo.getConnHandle(), reason);
|
||||||
} // disconnect
|
} // 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.
|
* @brief Set the server to automatically start advertising when a client disconnects.
|
||||||
* @param [in] enable true == advertise, false == don't advertise.
|
* @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",
|
NIMBLE_LOGE(LOG_TAG, "Connection failed rc = %d %s",
|
||||||
rc,
|
rc,
|
||||||
NimBLEUtils::returnCodeToString(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();
|
NimBLEDevice::startAdvertising();
|
||||||
# endif
|
# endif
|
||||||
} else {
|
} 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 (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.
|
// If this was also the client make sure it's flagged as disconnected.
|
||||||
pServer->m_pClient->m_connHandle = BLE_HS_CONN_HANDLE_NONE;
|
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;
|
peerInfo.m_desc = event->disconnect.conn;
|
||||||
pServer->m_pServerCallbacks->onDisconnect(pServer, peerInfo, event->disconnect.reason);
|
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) {
|
if (pServer->m_advertiseOnDisconnect) {
|
||||||
pServer->startAdvertising();
|
pServer->startAdvertising();
|
||||||
}
|
}
|
||||||
@@ -494,10 +494,10 @@ int NimBLEServer::handleGapEvent(ble_gap_event* event, void* arg) {
|
|||||||
} // BLE_GAP_EVENT_NOTIFY_TX
|
} // BLE_GAP_EVENT_NOTIFY_TX
|
||||||
|
|
||||||
case BLE_GAP_EVENT_ADV_COMPLETE: {
|
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:
|
case BLE_GAP_EVENT_SCAN_REQ_RCVD:
|
||||||
return NimBLEExtAdvertising::handleGapEvent(event, arg);
|
return NimBLEExtAdvertising::handleGapEvent(event, arg);
|
||||||
# elif CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
# elif MYNEWT_VAL(BLE_ROLE_BROADCASTER)
|
||||||
return NimBLEAdvertising::handleGapEvent(event, arg);
|
return NimBLEAdvertising::handleGapEvent(event, arg);
|
||||||
# endif
|
# endif
|
||||||
} // BLE_GAP_EVENT_ADV_COMPLETE | BLE_GAP_EVENT_SCAN_REQ_RCVD
|
} // 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);
|
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) {
|
if (pServer->m_pClient && pServer->m_pClient->m_connHandle == event->enc_change.conn_handle) {
|
||||||
NimBLEClient::handleGapEvent(event, pServer->m_pClient);
|
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);
|
service->setRemoved(deleteSvc ? NIMBLE_ATT_REMOVE_DELETE : NIMBLE_ATT_REMOVE_HIDE);
|
||||||
serviceChanged();
|
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());
|
NimBLEDevice::getAdvertising()->removeServiceUUID(service->getUUID());
|
||||||
# endif
|
# endif
|
||||||
} // removeService
|
} // removeService
|
||||||
@@ -774,7 +774,7 @@ void NimBLEServer::resetGATT() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
# if MYNEWT_VAL(BLE_ROLE_BROADCASTER)
|
||||||
NimBLEDevice::stopAdvertising();
|
NimBLEDevice::stopAdvertising();
|
||||||
# endif
|
# endif
|
||||||
ble_gatts_reset();
|
ble_gatts_reset();
|
||||||
@@ -843,7 +843,7 @@ bool NimBLEServer::getPhy(uint16_t connHandle, uint8_t* txPhy, uint8_t* rxPhy) {
|
|||||||
return rc == 0;
|
return rc == 0;
|
||||||
} // getPhy
|
} // getPhy
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if MYNEWT_VAL(BLE_EXT_ADV)
|
||||||
/**
|
/**
|
||||||
* @brief Start advertising.
|
* @brief Start advertising.
|
||||||
* @param [in] instId The extended advertisement instance ID to start.
|
* @param [in] instId The extended advertisement instance ID to start.
|
||||||
@@ -868,7 +868,7 @@ bool NimBLEServer::stopAdvertising(uint8_t instId) const {
|
|||||||
|
|
||||||
# endif
|
# 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.
|
* @brief Start advertising.
|
||||||
* @param [in] duration The duration in milliseconds to advertise for, default = forever.
|
* @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
|
# endif
|
||||||
} // setDataLen
|
} // setDataLen
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
# if MYNEWT_VAL(BLE_ROLE_CENTRAL)
|
||||||
/**
|
/**
|
||||||
* @brief Create a client instance from the connection handle.
|
* @brief Create a client instance from the connection handle.
|
||||||
* @param [in] connHandle The connection handle to create a client instance from.
|
* @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);
|
NIMBLE_LOGD("NimBLEServerCallbacks", "onPhyUpdate: default, txPhy: %d, rxPhy: %d", txPhy, rxPhy);
|
||||||
} // onPhyUpdate
|
} // onPhyUpdate
|
||||||
|
|
||||||
#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
#ifndef NIMBLE_CPP_SERVER_H_
|
#ifndef NIMBLE_CPP_SERVER_H_
|
||||||
#define NIMBLE_CPP_SERVER_H_
|
#define NIMBLE_CPP_SERVER_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "syscfg/syscfg.h"
|
||||||
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
|
||||||
|
|
||||||
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
||||||
# include "host/ble_gap.h"
|
# include "host/ble_gap.h"
|
||||||
@@ -45,14 +45,14 @@ class NimBLEConnInfo;
|
|||||||
class NimBLEAddress;
|
class NimBLEAddress;
|
||||||
class NimBLEService;
|
class NimBLEService;
|
||||||
class NimBLECharacteristic;
|
class NimBLECharacteristic;
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
# if MYNEWT_VAL(BLE_ROLE_BROADCASTER)
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if MYNEWT_VAL(BLE_EXT_ADV)
|
||||||
class NimBLEExtAdvertising;
|
class NimBLEExtAdvertising;
|
||||||
# else
|
# else
|
||||||
class NimBLEAdvertising;
|
class NimBLEAdvertising;
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
# if MYNEWT_VAL(BLE_ROLE_CENTRAL)
|
||||||
class NimBLEClient;
|
class NimBLEClient;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
@@ -84,20 +84,20 @@ class NimBLEServer {
|
|||||||
bool updatePhy(uint16_t connHandle, uint8_t txPhysMask, uint8_t rxPhysMask, uint16_t phyOptions);
|
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);
|
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(uint16_t connHandle);
|
||||||
NimBLEClient* getClient(const NimBLEConnInfo& connInfo);
|
NimBLEClient* getClient(const NimBLEConnInfo& connInfo);
|
||||||
void deleteClient();
|
void deleteClient();
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
# if MYNEWT_VAL(BLE_ROLE_BROADCASTER)
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if MYNEWT_VAL(BLE_EXT_ADV)
|
||||||
NimBLEExtAdvertising* getAdvertising() const;
|
NimBLEExtAdvertising* getAdvertising() const;
|
||||||
bool startAdvertising(uint8_t instanceId, int duration = 0, int maxEvents = 0) const;
|
bool startAdvertising(uint8_t instanceId, int duration = 0, int maxEvents = 0) const;
|
||||||
bool stopAdvertising(uint8_t instanceId) const;
|
bool stopAdvertising(uint8_t instanceId) const;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if !CONFIG_BT_NIMBLE_EXT_ADV || defined(_DOXYGEN_)
|
# if !MYNEWT_VAL(BLE_EXT_ADV) || defined(_DOXYGEN_)
|
||||||
NimBLEAdvertising* getAdvertising() const;
|
NimBLEAdvertising* getAdvertising() const;
|
||||||
bool startAdvertising(uint32_t duration = 0) const;
|
bool startAdvertising(uint32_t duration = 0) const;
|
||||||
bool stopAdvertising() const;
|
bool stopAdvertising() const;
|
||||||
@@ -108,8 +108,8 @@ class NimBLEServer {
|
|||||||
friend class NimBLEDevice;
|
friend class NimBLEDevice;
|
||||||
friend class NimBLEService;
|
friend class NimBLEService;
|
||||||
friend class NimBLECharacteristic;
|
friend class NimBLECharacteristic;
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
# if MYNEWT_VAL(BLE_ROLE_BROADCASTER)
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if MYNEWT_VAL(BLE_EXT_ADV)
|
||||||
friend class NimBLEExtAdvertising;
|
friend class NimBLEExtAdvertising;
|
||||||
# else
|
# else
|
||||||
friend class NimBLEAdvertising;
|
friend class NimBLEAdvertising;
|
||||||
@@ -122,14 +122,14 @@ class NimBLEServer {
|
|||||||
bool m_gattsStarted : 1;
|
bool m_gattsStarted : 1;
|
||||||
bool m_svcChanged : 1;
|
bool m_svcChanged : 1;
|
||||||
bool m_deleteCallbacks : 1;
|
bool m_deleteCallbacks : 1;
|
||||||
# if !CONFIG_BT_NIMBLE_EXT_ADV
|
# if !MYNEWT_VAL(BLE_EXT_ADV)
|
||||||
bool m_advertiseOnDisconnect : 1;
|
bool m_advertiseOnDisconnect : 1;
|
||||||
# endif
|
# endif
|
||||||
NimBLEServerCallbacks* m_pServerCallbacks;
|
NimBLEServerCallbacks* m_pServerCallbacks;
|
||||||
std::vector<NimBLEService*> m_svcVec;
|
std::vector<NimBLEService*> m_svcVec;
|
||||||
std::array<uint16_t, CONFIG_BT_NIMBLE_MAX_CONNECTIONS> m_connectedPeers;
|
std::array<uint16_t, MYNEWT_VAL(BLE_MAX_CONNECTIONS)> m_connectedPeers;
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
# if MYNEWT_VAL(BLE_ROLE_CENTRAL)
|
||||||
NimBLEClient* m_pClient{nullptr};
|
NimBLEClient* m_pClient{nullptr};
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
@@ -223,5 +223,5 @@ class NimBLEServerCallbacks {
|
|||||||
virtual void onPhyUpdate(NimBLEConnInfo& connInfo, uint8_t txPhy, uint8_t rxPhy);
|
virtual void onPhyUpdate(NimBLEConnInfo& connInfo, uint8_t txPhy, uint8_t rxPhy);
|
||||||
}; // NimBLEServerCallbacks
|
}; // 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_
|
#endif // NIMBLE_CPP_SERVER_H_
|
||||||
|
@@ -16,9 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "NimBLEService.h"
|
#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"
|
# include "NimBLEExtAdvertising.h"
|
||||||
# else
|
# else
|
||||||
# include "NimBLEAdvertising.h"
|
# include "NimBLEAdvertising.h"
|
||||||
@@ -375,4 +375,4 @@ bool NimBLEService::isStarted() const {
|
|||||||
return m_pSvcDef->type > 0;
|
return m_pSvcDef->type > 0;
|
||||||
} // isStarted
|
} // isStarted
|
||||||
|
|
||||||
#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
#ifndef NIMBLE_CPP_SERVICE_H_
|
#ifndef NIMBLE_CPP_SERVICE_H_
|
||||||
#define NIMBLE_CPP_SERVICE_H_
|
#define NIMBLE_CPP_SERVICE_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "syscfg/syscfg.h"
|
||||||
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
|
||||||
|
|
||||||
class NimBLEService;
|
class NimBLEService;
|
||||||
|
|
||||||
@@ -69,5 +69,5 @@ class NimBLEService : public NimBLELocalAttribute {
|
|||||||
ble_gatt_svc_def m_pSvcDef[2]{};
|
ble_gatt_svc_def m_pSvcDef[2]{};
|
||||||
}; // NimBLEService
|
}; // 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_
|
#endif // NIMBLE_CPP_SERVICE_H_
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "NimBLEUUID.h"
|
#include "NimBLEUUID.h"
|
||||||
#if CONFIG_BT_ENABLED
|
#if CONFIG_BT_NIMBLE_ENABLED
|
||||||
|
|
||||||
# include "NimBLEUtils.h"
|
# include "NimBLEUtils.h"
|
||||||
# include "NimBLELog.h"
|
# include "NimBLELog.h"
|
||||||
@@ -336,4 +336,4 @@ NimBLEUUID::operator std::string() const {
|
|||||||
return ble_uuid_to_str(&m_uuid.u, buf);
|
return ble_uuid_to_str(&m_uuid.u, buf);
|
||||||
} // operator std::string
|
} // operator std::string
|
||||||
|
|
||||||
#endif /* CONFIG_BT_ENABLED */
|
#endif /* CONFIG_BT_NIMBLE_ENABLED */
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
#ifndef NIMBLE_CPP_UUID_H_
|
#ifndef NIMBLE_CPP_UUID_H_
|
||||||
#define NIMBLE_CPP_UUID_H_
|
#define NIMBLE_CPP_UUID_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "syscfg/syscfg.h"
|
||||||
#if CONFIG_BT_ENABLED
|
#if CONFIG_BT_NIMBLE_ENABLED
|
||||||
|
|
||||||
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
||||||
# include "host/ble_uuid.h"
|
# include "host/ble_uuid.h"
|
||||||
@@ -70,5 +70,5 @@ class NimBLEUUID {
|
|||||||
ble_uuid_any_t m_uuid{};
|
ble_uuid_any_t m_uuid{};
|
||||||
}; // NimBLEUUID
|
}; // NimBLEUUID
|
||||||
|
|
||||||
#endif // CONFIG_BT_ENABLED
|
#endif // CONFIG_BT_NIMBLE_ENABLED
|
||||||
#endif // NIMBLE_CPP_UUID_H_
|
#endif // NIMBLE_CPP_UUID_H_
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "NimBLEUtils.h"
|
#include "NimBLEUtils.h"
|
||||||
#if CONFIG_BT_ENABLED
|
#if CONFIG_BT_NIMBLE_ENABLED
|
||||||
|
|
||||||
# include "NimBLEAddress.h"
|
# include "NimBLEAddress.h"
|
||||||
# include "NimBLELog.h"
|
# include "NimBLELog.h"
|
||||||
@@ -576,4 +576,4 @@ NimBLEAddress NimBLEUtils::generateAddr(bool nrpa) {
|
|||||||
return NimBLEAddress{addr};
|
return NimBLEAddress{addr};
|
||||||
} // generateAddr
|
} // generateAddr
|
||||||
|
|
||||||
#endif // CONFIG_BT_ENABLED
|
#endif // CONFIG_BT_NIMBLE_ENABLED
|
||||||
|
@@ -18,8 +18,20 @@
|
|||||||
#ifndef NIMBLE_CPP_UTILS_H_
|
#ifndef NIMBLE_CPP_UTILS_H_
|
||||||
#define NIMBLE_CPP_UTILS_H_
|
#define NIMBLE_CPP_UTILS_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "syscfg/syscfg.h"
|
||||||
#if CONFIG_BT_ENABLED
|
#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 <string>
|
# include <string>
|
||||||
|
|
||||||
@@ -56,5 +68,5 @@ class NimBLEUtils {
|
|||||||
static void taskRelease(const NimBLETaskData& taskData, int rc = 0);
|
static void taskRelease(const NimBLETaskData& taskData, int rc = 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONFIG_BT_ENABLED
|
#endif // CONFIG_BT_NIMBLE_ENABLED
|
||||||
#endif // NIMBLE_CPP_UTILS_H_
|
#endif // NIMBLE_CPP_UTILS_H_
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
#ifndef NIMBLE_CPP_VALUE_ATTRIBUTE_H_
|
#ifndef NIMBLE_CPP_VALUE_ATTRIBUTE_H_
|
||||||
#define NIMBLE_CPP_VALUE_ATTRIBUTE_H_
|
#define NIMBLE_CPP_VALUE_ATTRIBUTE_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "syscfg/syscfg.h"
|
||||||
#if CONFIG_BT_ENABLED && (CONFIG_BT_NIMBLE_ROLE_PERIPHERAL || CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
#if CONFIG_BT_NIMBLE_ENABLED && (MYNEWT_VAL(BLE_ROLE_PERIPHERAL) || MYNEWT_VAL(BLE_ROLE_CENTRAL))
|
||||||
|
|
||||||
# include "NimBLEAttribute.h"
|
# include "NimBLEAttribute.h"
|
||||||
# include "NimBLEAttValue.h"
|
# include "NimBLEAttValue.h"
|
||||||
@@ -82,5 +82,5 @@ class NimBLEValueAttribute {
|
|||||||
NimBLEAttValue m_value{};
|
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_
|
#endif // NIMBLE_CPP_ATTRIBUTE_H_
|
||||||
|
142
src/nimconfig.h
142
src/nimconfig.h
@@ -1,142 +0,0 @@
|
|||||||
/** @file
|
|
||||||
*
|
|
||||||
* IGNORE THIS FILE IF USING ESP-IDF, USE MENUCONFIG TO SET NIMBLE OPTIONS.
|
|
||||||
*
|
|
||||||
* The config options here are for doxygen documentation only.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "sdkconfig.h"
|
|
||||||
#include "nimconfig_rename.h"
|
|
||||||
|
|
||||||
#if defined(CONFIG_BT_ENABLED)
|
|
||||||
|
|
||||||
// Allows cpp wrapper to select the correct include paths when using esp-idf
|
|
||||||
#define CONFIG_NIMBLE_CPP_IDF
|
|
||||||
|
|
||||||
/* Enables the use of Arduino String class for attribute values */
|
|
||||||
#if defined __has_include
|
|
||||||
# if __has_include (<Arduino.h>)
|
|
||||||
# define NIMBLE_CPP_ARDUINO_STRING_AVAILABLE
|
|
||||||
# endif
|
|
||||||
#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
|
|
||||||
|
|
||||||
#endif /* CONFIG_BT_ENABLED */
|
|
||||||
|
|
||||||
#ifdef _DOXYGEN_
|
|
||||||
|
|
||||||
/** @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/notifed.\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 change the default MTU size */
|
|
||||||
#define CONFIG_BT_NIMBLE_ATT_PREFERRED_MTU 255
|
|
||||||
|
|
||||||
/** @brief Un-comment to change default device name */
|
|
||||||
#define CONFIG_BT_NIMBLE_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 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 advertisment types as text while scanning in debug log messages.
|
|
||||||
* Uses approx. 250 bytes of flash memory.
|
|
||||||
*/
|
|
||||||
#define CONFIG_NIMBLE_CPP_ENABLE_ADVERTISMENT_TYPE_TEXT
|
|
||||||
|
|
||||||
/** @brief Un-comment to change the default GAP appearance */
|
|
||||||
#define CONFIG_BT_NIMBLE_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_DISABLED
|
|
||||||
|
|
||||||
/** @brief Un-comment if not using NimBLE Scan functions \n
|
|
||||||
* Reduces flash size by approx. 26kB.
|
|
||||||
*/
|
|
||||||
#define CONFIG_BT_NIMBLE_ROLE_OBSERVER_DISABLED
|
|
||||||
|
|
||||||
/** @brief Un-comment if not using NimBLE Server functions \n
|
|
||||||
* Reduces flash size by approx. 16kB.
|
|
||||||
*/
|
|
||||||
#define CONFIG_BT_NIMBLE_ROLE_PERIPHERAL_DISABLED
|
|
||||||
|
|
||||||
/** @brief Un-comment if not using NimBLE Advertising functions \n
|
|
||||||
* Reduces flash size by approx. 5kB.
|
|
||||||
*/
|
|
||||||
#define CONFIG_BT_NIMBLE_ROLE_BROADCASTER_DISABLED
|
|
||||||
|
|
||||||
/** @brief Un-comment to change the number of devices allowed to store/bond with */
|
|
||||||
#define CONFIG_BT_NIMBLE_MAX_BONDS 3
|
|
||||||
|
|
||||||
/** @brief Un-comment to change the maximum number of CCCD subscriptions to store */
|
|
||||||
#define CONFIG_BT_NIMBLE_MAX_CCCDS 8
|
|
||||||
|
|
||||||
/** @brief Un-comment to change the random address refresh time (in seconds) */
|
|
||||||
#define CONFIG_BT_NIMBLE_RPA_TIMEOUT 900
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Un-comment to change the number of MSYS buffers available.
|
|
||||||
* @details MSYS is a system level mbuf registry. For prepare write & prepare \n
|
|
||||||
* 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
|
|
||||||
|
|
||||||
/** @brief Un-comment to use external PSRAM for the NimBLE host */
|
|
||||||
#define CONFIG_BT_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
|
|
||||||
|
|
||||||
/** @brief Un-comment to change the stack size for the NimBLE host task */
|
|
||||||
#define CONFIG_BT_NIMBLE_TASK_STACK_SIZE 4096
|
|
||||||
|
|
||||||
#endif // _DOXYGEN_
|
|
@@ -1,93 +0,0 @@
|
|||||||
/*
|
|
||||||
* For ESP-IDF compatibility
|
|
||||||
* Some versions of ESP-IDF used the config name format "CONFIG_NIMBLE_".
|
|
||||||
* This converts them to "CONFIG_BT_NIMBLE_" format used in the latest IDF.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(CONFIG_NIMBLE_ENABLED) && !defined(CONFIG_BT_NIMBLE_ENABLED)
|
|
||||||
#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
|
|
||||||
|
|
||||||
#if defined(CONFIG_SCAN_DUPLICATE_BY_ADV_DATA ) && !defined(CONFIG_BTDM_SCAN_DUPL_TYPE_DATA)
|
|
||||||
#define CONFIG_BTDM_SCAN_DUPL_TYPE_DATA CONFIG_SCAN_DUPLICATE_BY_ADV_DATA
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR) && !defined(CONFIG_BTDM_SCAN_DUPL_TYPE_DATA_DEVICE)
|
|
||||||
#define CONFIG_BTDM_SCAN_DUPL_TYPE_DATA_DEVICE CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CONFIG_SCAN_DUPLICATE_TYPE) && !defined(CONFIG_BTDM_SCAN_DUPL_TYPE)
|
|
||||||
#define CONFIG_BTDM_SCAN_DUPL_TYPE CONFIG_SCAN_DUPLICATE_TYPE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CONFIG_BT_CTRL_SCAN_DUPL_TYPE) && !defined(CONFIG_BTDM_SCAN_DUPL_TYPE)
|
|
||||||
#define CONFIG_BTDM_SCAN_DUPL_TYPE CONFIG_BT_CTRL_SCAN_DUPL_TYPE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CONFIG_DUPLICATE_SCAN_CACHE_SIZE) && !defined(CONFIG_BTDM_SCAN_DUPL_CACHE_SIZE)
|
|
||||||
#define CONFIG_BTDM_SCAN_DUPL_CACHE_SIZE CONFIG_DUPLICATE_SCAN_CACHE_SIZE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CONFIG_BT_CTRL_SCAN_DUPL_CACHE_SIZE) && !defined(CONFIG_BTDM_SCAN_DUPL_CACHE_SIZE)
|
|
||||||
#define CONFIG_BTDM_SCAN_DUPL_CACHE_SIZE CONFIG_BT_CTRL_SCAN_DUPL_CACHE_SIZE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CONFIG_NIMBLE_MAX_CONNECTIONS ) && !defined(CONFIG_BT_NIMBLE_MAX_CONNECTIONS)
|
|
||||||
#define CONFIG_BT_NIMBLE_MAX_CONNECTIONS CONFIG_NIMBLE_MAX_CONNECTIONS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CONFIG_BT_NIMBLE_EXT_ADV_MAX_SIZE) && !defined(CONFIG_BT_NIMBLE_MAX_EXT_ADV_DATA_LEN)
|
|
||||||
#define CONFIG_BT_NIMBLE_MAX_EXT_ADV_DATA_LEN CONFIG_BT_NIMBLE_EXT_ADV_MAX_SIZE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(CONFIG_BTDM_BLE_SCAN_DUPL) && defined(CONFIG_BT_CTRL_BLE_SCAN_DUPL)
|
|
||||||
#define CONFIG_BTDM_BLE_SCAN_DUPL CONFIG_BT_CTRL_BLE_SCAN_DUPL
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(CONFIG_BTDM_SCAN_DUPL_TYPE_DEVICE) && defined(CONFIG_BT_CTRL_SCAN_DUPL_TYPE_DEVICE)
|
|
||||||
#define CONFIG_BTDM_SCAN_DUPL_TYPE_DEVICE CONFIG_BT_CTRL_SCAN_DUPL_TYPE_DEVICE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(CONFIG_BTDM_SCAN_DUPL_TYPE_DATA) && defined(CONFIG_BT_CTRL_SCAN_DUPL_TYPE_DATA)
|
|
||||||
#define CONFIG_BTDM_SCAN_DUPL_TYPE_DATA CONFIG_BT_CTRL_SCAN_DUPL_TYPE_DATA
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(CONFIG_BTDM_SCAN_DUPL_TYPE_DATA_DEVICE) && defined(CONFIG_BT_CTRL_SCAN_DUPL_TYPE_DATA_DEVICE)
|
|
||||||
#define CONFIG_BTDM_SCAN_DUPL_TYPE_DATA_DEVICE CONFIG_BT_CTRL_SCAN_DUPL_TYPE_DATA_DEVICE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_LE_LL_CFG_FEAT_LE_CODED_PHY
|
|
||||||
#define CONFIG_BT_NIMBLE_LL_CFG_FEAT_LE_CODED_PHY CONFIG_BT_LE_LL_CFG_FEAT_LE_CODED_PHY
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_LE_LL_CFG_FEAT_LE_2M_PHY
|
|
||||||
#define CONFIG_BT_NIMBLE_LL_CFG_FEAT_LE_2M_PHY CONFIG_BT_LE_LL_CFG_FEAT_LE_2M_PHY
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_LE_50_FEATURE_SUPPORT
|
|
||||||
#define CONFIG_BT_NIMBLE_50_FEATURE_SUPPORT CONFIG_BT_LE_50_FEATURE_SUPPORT
|
|
||||||
#endif
|
|
Reference in New Issue
Block a user