mirror of
https://github.com/h2zero/esp-nimble-cpp.git
synced 2025-07-30 10:27:14 +02:00
Fix builds when exluding roles
This commit is contained in:
@ -15,10 +15,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "NimBLE2904.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
|
|
||||||
# include "NimBLE2904.h"
|
|
||||||
|
|
||||||
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) {
|
||||||
@ -71,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_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define NIMBLE_CPP_2904_H_
|
#define NIMBLE_CPP_2904_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "nimconfig.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
|
|
||||||
# include "NimBLEDescriptor.h"
|
# include "NimBLEDescriptor.h"
|
||||||
|
|
||||||
|
@ -15,10 +15,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "NimBLEAddress.h"
|
||||||
#if defined(CONFIG_BT_ENABLED)
|
#if CONFIG_BT_ENABLED
|
||||||
|
|
||||||
# include "NimBLEAddress.h"
|
|
||||||
# include "NimBLELog.h"
|
# include "NimBLELog.h"
|
||||||
|
|
||||||
# include <algorithm>
|
# include <algorithm>
|
||||||
@ -224,11 +223,16 @@ NimBLEAddress::operator std::string() const {
|
|||||||
snprintf(buffer,
|
snprintf(buffer,
|
||||||
sizeof(buffer),
|
sizeof(buffer),
|
||||||
NIMBLE_CPP_ADDR_FMT,
|
NIMBLE_CPP_ADDR_FMT,
|
||||||
this->val[5], NIMBLE_CPP_ADDR_DELIMITER,
|
this->val[5],
|
||||||
this->val[4], NIMBLE_CPP_ADDR_DELIMITER,
|
NIMBLE_CPP_ADDR_DELIMITER,
|
||||||
this->val[3], NIMBLE_CPP_ADDR_DELIMITER,
|
this->val[4],
|
||||||
this->val[2], NIMBLE_CPP_ADDR_DELIMITER,
|
NIMBLE_CPP_ADDR_DELIMITER,
|
||||||
this->val[1], NIMBLE_CPP_ADDR_DELIMITER,
|
this->val[3],
|
||||||
|
NIMBLE_CPP_ADDR_DELIMITER,
|
||||||
|
this->val[2],
|
||||||
|
NIMBLE_CPP_ADDR_DELIMITER,
|
||||||
|
this->val[1],
|
||||||
|
NIMBLE_CPP_ADDR_DELIMITER,
|
||||||
this->val[0]);
|
this->val[0]);
|
||||||
return std::string{buffer};
|
return std::string{buffer};
|
||||||
} // operator std::string
|
} // operator std::string
|
||||||
|
@ -17,8 +17,9 @@
|
|||||||
|
|
||||||
#ifndef NIMBLE_CPP_ADDRESS_H_
|
#ifndef NIMBLE_CPP_ADDRESS_H_
|
||||||
#define NIMBLE_CPP_ADDRESS_H_
|
#define NIMBLE_CPP_ADDRESS_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "nimconfig.h"
|
||||||
#if defined(CONFIG_BT_ENABLED)
|
#if CONFIG_BT_ENABLED
|
||||||
|
|
||||||
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
||||||
# include "nimble/ble.h"
|
# include "nimble/ble.h"
|
||||||
@ -66,5 +67,5 @@ class NimBLEAddress : private ble_addr_t {
|
|||||||
operator uint64_t() const;
|
operator uint64_t() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* CONFIG_BT_ENABLED */
|
#endif // CONFIG_BT_ENABLED
|
||||||
#endif /* NIMBLE_CPP_ADDRESS_H_ */
|
#endif // NIMBLE_CPP_ADDRESS_H_
|
||||||
|
@ -15,11 +15,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "NimBLEAdvertisedDevice.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
||||||
|
|
||||||
# include "NimBLEDevice.h"
|
# include "NimBLEDevice.h"
|
||||||
# include "NimBLEAdvertisedDevice.h"
|
|
||||||
# include "NimBLEUtils.h"
|
# include "NimBLEUtils.h"
|
||||||
# include "NimBLELog.h"
|
# include "NimBLELog.h"
|
||||||
|
|
||||||
@ -814,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_CENTRAL */
|
#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define NIMBLE_CPP_ADVERTISED_DEVICE_H_
|
#define NIMBLE_CPP_ADVERTISED_DEVICE_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "nimconfig.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
||||||
|
|
||||||
# include "NimBLEAddress.h"
|
# include "NimBLEAddress.h"
|
||||||
# include "NimBLEScan.h"
|
# include "NimBLEScan.h"
|
||||||
|
@ -15,11 +15,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "NimBLEAdvertisementData.h"
|
||||||
#if (defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER) && !CONFIG_BT_NIMBLE_EXT_ADV) || \
|
#if (CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && !CONFIG_BT_NIMBLE_EXT_ADV) || defined(_DOXYGEN_)
|
||||||
defined(_DOXYGEN_)
|
|
||||||
|
|
||||||
# include "NimBLEAdvertisementData.h"
|
|
||||||
# include "NimBLEDevice.h"
|
# include "NimBLEDevice.h"
|
||||||
# include "NimBLEUtils.h"
|
# include "NimBLEUtils.h"
|
||||||
# include "NimBLEUUID.h"
|
# include "NimBLEUUID.h"
|
||||||
@ -585,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
|
#endif // (CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && !CONFIG_BT_NIMBLE_EXT_ADV) || defined(_DOXYGEN_)
|
||||||
|
@ -19,8 +19,7 @@
|
|||||||
#define NIMBLE_CPP_ADVERTISEMENT_DATA_H_
|
#define NIMBLE_CPP_ADVERTISEMENT_DATA_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "nimconfig.h"
|
||||||
#if (defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER) && !CONFIG_BT_NIMBLE_EXT_ADV) || \
|
#if (CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && !CONFIG_BT_NIMBLE_EXT_ADV) || defined(_DOXYGEN_)
|
||||||
defined(_DOXYGEN_)
|
|
||||||
|
|
||||||
# include <cstdint>
|
# include <cstdint>
|
||||||
# include <string>
|
# include <string>
|
||||||
@ -75,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
|
#endif // (CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && !CONFIG_BT_NIMBLE_EXT_ADV) || defined(_DOXYGEN_)
|
||||||
#endif // NIMBLE_CPP_ADVERTISEMENT_DATA_H_
|
#endif // NIMBLE_CPP_ADVERTISEMENT_DATA_H_
|
||||||
|
@ -15,16 +15,14 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "NimBLEAdvertising.h"
|
||||||
#if (defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER) && !CONFIG_BT_NIMBLE_EXT_ADV) || \
|
#if (CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && !CONFIG_BT_NIMBLE_EXT_ADV) || defined(_DOXYGEN_)
|
||||||
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"
|
||||||
# else
|
# else
|
||||||
# include "nimble/nimble/host/services/gap/include/services/gap/ble_svc_gap.h"
|
# include "nimble/nimble/host/services/gap/include/services/gap/ble_svc_gap.h"
|
||||||
# endif
|
# endif
|
||||||
# include "NimBLEAdvertising.h"
|
|
||||||
# include "NimBLEDevice.h"
|
# include "NimBLEDevice.h"
|
||||||
# include "NimBLEServer.h"
|
# include "NimBLEServer.h"
|
||||||
# include "NimBLEUtils.h"
|
# include "NimBLEUtils.h"
|
||||||
@ -44,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 !defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
# if !CONFIG_BT_NIMBLE_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;
|
||||||
@ -197,7 +195,7 @@ bool NimBLEAdvertising::start(uint32_t duration, const NimBLEAddress* dirAddr) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
# if CONFIG_BT_NIMBLE_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
|
||||||
@ -222,7 +220,7 @@ bool NimBLEAdvertising::start(uint32_t duration, const NimBLEAddress* dirAddr) {
|
|||||||
duration = BLE_HS_FOREVER;
|
duration = BLE_HS_FOREVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
# if CONFIG_BT_NIMBLE_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,
|
||||||
@ -622,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 */
|
#endif // (CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && !CONFIG_BT_NIMBLE_EXT_ADV) || defined(_DOXYGEN_)
|
||||||
|
@ -19,8 +19,7 @@
|
|||||||
#define NIMBLE_CPP_ADVERTISING_H_
|
#define NIMBLE_CPP_ADVERTISING_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "nimconfig.h"
|
||||||
#if (defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER) && !CONFIG_BT_NIMBLE_EXT_ADV) || \
|
#if (CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && !CONFIG_BT_NIMBLE_EXT_ADV) || defined(_DOXYGEN_)
|
||||||
defined(_DOXYGEN_)
|
|
||||||
|
|
||||||
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
||||||
# include "host/ble_gap.h"
|
# include "host/ble_gap.h"
|
||||||
@ -106,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 */
|
#endif // (CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && !CONFIG_BT_NIMBLE_EXT_ADV) || defined(_DOXYGEN_)
|
||||||
#endif /* NIMBLE_CPP_ADVERTISING_H_ */
|
#endif // NIMBLE_CPP_ADVERTISING_H_
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "NimBLEAttValue.h"
|
||||||
#if defined(CONFIG_BT_ENABLED)
|
#if CONFIG_BT_ENABLED
|
||||||
|
|
||||||
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
||||||
# include "nimble/nimble_npl.h"
|
# include "nimble/nimble_npl.h"
|
||||||
@ -24,7 +24,6 @@
|
|||||||
# include "nimble/nimble/include/nimble/nimble_npl.h"
|
# include "nimble/nimble/include/nimble/nimble_npl.h"
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# include "NimBLEAttValue.h"
|
|
||||||
# include "NimBLELog.h"
|
# include "NimBLELog.h"
|
||||||
|
|
||||||
static const char* LOG_TAG = "NimBLEAttValue";
|
static const char* LOG_TAG = "NimBLEAttValue";
|
||||||
@ -105,7 +104,7 @@ void NimBLEAttValue::deepCopy(const NimBLEAttValue& source) {
|
|||||||
|
|
||||||
// Set the value of the attribute.
|
// Set the value of the attribute.
|
||||||
bool NimBLEAttValue::setValue(const uint8_t* value, uint16_t len) {
|
bool NimBLEAttValue::setValue(const uint8_t* value, uint16_t len) {
|
||||||
m_attr_len = 0; // Just set the value length to 0 and append instead of repeating code.
|
m_attr_len = 0; // Just set the value length to 0 and append instead of repeating code.
|
||||||
m_attr_value[0] = '\0'; // Set the first byte to 0 incase the len of the new value is 0.
|
m_attr_value[0] = '\0'; // Set the first byte to 0 incase the len of the new value is 0.
|
||||||
append(value, len);
|
append(value, len);
|
||||||
return memcmp(m_attr_value, value, len) == 0 && m_attr_len == len;
|
return memcmp(m_attr_value, value, len) == 0 && m_attr_len == len;
|
||||||
|
@ -17,8 +17,9 @@
|
|||||||
|
|
||||||
#ifndef NIMBLE_CPP_ATTVALUE_H
|
#ifndef NIMBLE_CPP_ATTVALUE_H
|
||||||
#define NIMBLE_CPP_ATTVALUE_H
|
#define NIMBLE_CPP_ATTVALUE_H
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "nimconfig.h"
|
||||||
#if defined(CONFIG_BT_ENABLED)
|
#if CONFIG_BT_ENABLED
|
||||||
|
|
||||||
# ifdef NIMBLE_CPP_ARDUINO_STRING_AVAILABLE
|
# ifdef NIMBLE_CPP_ARDUINO_STRING_AVAILABLE
|
||||||
# include <Arduino.h>
|
# include <Arduino.h>
|
||||||
@ -362,5 +363,5 @@ class NimBLEAttValue {
|
|||||||
# endif
|
# endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*(CONFIG_BT_ENABLED) */
|
#endif // CONFIG_BT_ENABLED
|
||||||
#endif /* NIMBLE_CPP_ATTVALUE_H_ */
|
#endif // NIMBLE_CPP_ATTVALUE_H_
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define NIMBLE_CPP_ATTRIBUTE_H_
|
#define NIMBLE_CPP_ATTRIBUTE_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "nimconfig.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && (defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL) || defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL))
|
#if CONFIG_BT_ENABLED && (CONFIG_BT_NIMBLE_ROLE_PERIPHERAL || CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
||||||
|
|
||||||
# include "NimBLEUUID.h"
|
# include "NimBLEUUID.h"
|
||||||
|
|
||||||
|
@ -15,10 +15,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "NimBLEBeacon.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
||||||
|
|
||||||
# include "NimBLEBeacon.h"
|
|
||||||
# include "NimBLEUUID.h"
|
# include "NimBLEUUID.h"
|
||||||
# include "NimBLELog.h"
|
# include "NimBLELog.h"
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define NIMBLE_CPP_BEACON_H_
|
#define NIMBLE_CPP_BEACON_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "nimconfig.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
||||||
|
|
||||||
class NimBLEUUID;
|
class NimBLEUUID;
|
||||||
|
|
||||||
@ -60,5 +60,5 @@ class NimBLEBeacon {
|
|||||||
BeaconData m_beaconData;
|
BeaconData m_beaconData;
|
||||||
}; // NimBLEBeacon
|
}; // NimBLEBeacon
|
||||||
|
|
||||||
#endif // NIMBLE_CPP_BEACON_H_
|
|
||||||
#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
|
#endif // NIMBLE_CPP_BEACON_H_
|
||||||
|
@ -15,10 +15,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nimconfig.h"
|
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
|
||||||
|
|
||||||
# include "NimBLECharacteristic.h"
|
# include "NimBLECharacteristic.h"
|
||||||
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
|
|
||||||
# include "NimBLE2904.h"
|
# include "NimBLE2904.h"
|
||||||
# include "NimBLEDevice.h"
|
# include "NimBLEDevice.h"
|
||||||
# include "NimBLELog.h"
|
# include "NimBLELog.h"
|
||||||
@ -415,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_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
|
@ -17,8 +17,9 @@
|
|||||||
|
|
||||||
#ifndef NIMBLE_CPP_CHARACTERISTIC_H_
|
#ifndef NIMBLE_CPP_CHARACTERISTIC_H_
|
||||||
#define NIMBLE_CPP_CHARACTERISTIC_H_
|
#define NIMBLE_CPP_CHARACTERISTIC_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "nimconfig.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
|
|
||||||
class NimBLECharacteristicCallbacks;
|
class NimBLECharacteristicCallbacks;
|
||||||
class NimBLEService;
|
class NimBLEService;
|
||||||
@ -253,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_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
#endif /*NIMBLE_CPP_CHARACTERISTIC_H_*/
|
#endif // NIMBLE_CPP_CHARACTERISTIC_H_
|
||||||
|
@ -15,10 +15,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "NimBLEClient.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||||
|
|
||||||
# include "NimBLEClient.h"
|
|
||||||
# include "NimBLERemoteService.h"
|
# include "NimBLERemoteService.h"
|
||||||
# include "NimBLERemoteCharacteristic.h"
|
# include "NimBLERemoteCharacteristic.h"
|
||||||
# include "NimBLEDevice.h"
|
# include "NimBLEDevice.h"
|
||||||
@ -126,6 +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
|
||||||
/**
|
/**
|
||||||
* @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.
|
||||||
@ -141,6 +141,7 @@ bool NimBLEClient::connect(const NimBLEAdvertisedDevice* pDevice, bool deleteAtt
|
|||||||
NimBLEAddress address(pDevice->getAddress());
|
NimBLEAddress address(pDevice->getAddress());
|
||||||
return connect(address, deleteAttributes, asyncConnect, exchangeMTU);
|
return connect(address, deleteAttributes, asyncConnect, exchangeMTU);
|
||||||
} // connect
|
} // connect
|
||||||
|
# endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Connect to the BLE Server using the address of the last connected device, or the address\n
|
* @brief Connect to the BLE Server using the address of the last connected device, or the address\n
|
||||||
@ -227,10 +228,15 @@ bool NimBLEClient::connect(const NimBLEAddress& address, bool deleteAttributes,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BLE_HS_EBUSY:
|
case BLE_HS_EBUSY:
|
||||||
|
# if CONFIG_BT_NIMBLE_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()) {
|
||||||
rc = BLE_HS_EUNKNOWN;
|
rc = BLE_HS_EUNKNOWN;
|
||||||
}
|
}
|
||||||
|
# else
|
||||||
|
rc = BLE_HS_EUNKNOWN;
|
||||||
|
# endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BLE_HS_EDONE:
|
case BLE_HS_EDONE:
|
||||||
@ -1301,4 +1307,4 @@ void NimBLEClientCallbacks::onPhyUpdate(NimBLEClient* pClient, uint8_t txPhy, ui
|
|||||||
} // onPhyUpdate
|
} // onPhyUpdate
|
||||||
#
|
#
|
||||||
|
|
||||||
#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL */
|
#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define NIMBLE_CPP_CLIENT_H_
|
#define NIMBLE_CPP_CLIENT_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "nimconfig.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_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,10 +48,12 @@ struct NimBLETaskData;
|
|||||||
*/
|
*/
|
||||||
class NimBLEClient {
|
class NimBLEClient {
|
||||||
public:
|
public:
|
||||||
|
# if CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
||||||
bool connect(const NimBLEAdvertisedDevice* device,
|
bool connect(const NimBLEAdvertisedDevice* device,
|
||||||
bool deleteAttributes = true,
|
bool deleteAttributes = true,
|
||||||
bool asyncConnect = false,
|
bool asyncConnect = false,
|
||||||
bool exchangeMTU = true);
|
bool exchangeMTU = true);
|
||||||
|
# endif
|
||||||
bool connect(const NimBLEAddress& address, bool deleteAttributes = true, bool asyncConnect = false, bool exchangeMTU = true);
|
bool connect(const NimBLEAddress& address, bool deleteAttributes = true, bool asyncConnect = false, bool exchangeMTU = true);
|
||||||
bool connect(bool deleteAttributes = true, bool asyncConnect = false, bool exchangeMTU = true);
|
bool connect(bool deleteAttributes = true, bool asyncConnect = false, bool exchangeMTU = true);
|
||||||
bool disconnect(uint8_t reason = BLE_ERR_REM_USER_CONN_TERM);
|
bool disconnect(uint8_t reason = BLE_ERR_REM_USER_CONN_TERM);
|
||||||
@ -227,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_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||||
#endif /* NIMBLE_CPP_CLIENT_H_ */
|
#endif // NIMBLE_CPP_CLIENT_H_
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NIMBLECONNINFO_H_
|
#ifndef NIMBLE_CPP_CONNINFO_H_
|
||||||
#define NIMBLECONNINFO_H_
|
#define NIMBLE_CPP_CONNINFO_H_
|
||||||
|
|
||||||
#if defined(CONFIG_NIMBLE_CPP_IDF)
|
#if defined(CONFIG_NIMBLE_CPP_IDF)
|
||||||
# include "host/ble_gap.h"
|
# include "host/ble_gap.h"
|
||||||
@ -80,4 +80,5 @@ class NimBLEConnInfo {
|
|||||||
NimBLEConnInfo() {};
|
NimBLEConnInfo() {};
|
||||||
NimBLEConnInfo(ble_gap_conn_desc desc) { m_desc = desc; }
|
NimBLEConnInfo(ble_gap_conn_desc desc) { m_desc = desc; }
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
#endif // NIMBLE_CPP_CONNINFO_H_
|
||||||
|
@ -15,11 +15,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "NimBLEDescriptor.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
|
|
||||||
# include "NimBLEService.h"
|
# include "NimBLEService.h"
|
||||||
# include "NimBLEDescriptor.h"
|
|
||||||
# include "NimBLELog.h"
|
# include "NimBLELog.h"
|
||||||
|
|
||||||
# include <string>
|
# include <string>
|
||||||
@ -148,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_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define NIMBLE_CPP_DESCRIPTOR_H_
|
#define NIMBLE_CPP_DESCRIPTOR_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "nimconfig.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_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_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
#endif /* NIMBLE_CPP_DESCRIPTOR_H_ */
|
#endif // NIMBLE_CPP_DESCRIPTOR_H_
|
||||||
|
@ -15,11 +15,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "NimBLEDevice.h"
|
||||||
#if defined(CONFIG_BT_ENABLED)
|
#if CONFIG_BT_ENABLED
|
||||||
|
|
||||||
# include "NimBLEDevice.h"
|
|
||||||
# include "NimBLEUtils.h"
|
|
||||||
|
|
||||||
# ifdef ESP_PLATFORM
|
# ifdef ESP_PLATFORM
|
||||||
# include "esp_err.h"
|
# include "esp_err.h"
|
||||||
@ -59,17 +56,6 @@
|
|||||||
# include "esp32-hal-bt.h"
|
# include "esp32-hal-bt.h"
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
|
||||||
# include "NimBLEClient.h"
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
|
||||||
# include "NimBLEServer.h"
|
|
||||||
# if CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM > 0
|
|
||||||
# include "NimBLEL2CAPServer.h"
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# include "NimBLELog.h"
|
# include "NimBLELog.h"
|
||||||
|
|
||||||
static const char* LOG_TAG = "NimBLEDevice";
|
static const char* LOG_TAG = "NimBLEDevice";
|
||||||
@ -82,18 +68,18 @@ 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 defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
|
# if CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
||||||
NimBLEScan* NimBLEDevice::m_pScan = nullptr;
|
NimBLEScan* NimBLEDevice::m_pScan = nullptr;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
NimBLEServer* NimBLEDevice::m_pServer = nullptr;
|
NimBLEServer* NimBLEDevice::m_pServer = nullptr;
|
||||||
# if CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM > 0
|
# if CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM > 0
|
||||||
NimBLEL2CAPServer* NimBLEDevice::m_pL2CAPServer = nullptr;
|
NimBLEL2CAPServer* NimBLEDevice::m_pL2CAPServer = nullptr;
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER)
|
# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if CONFIG_BT_NIMBLE_EXT_ADV
|
||||||
NimBLEExtAdvertising* NimBLEDevice::m_bleAdvertising = nullptr;
|
NimBLEExtAdvertising* NimBLEDevice::m_bleAdvertising = nullptr;
|
||||||
# else
|
# else
|
||||||
@ -101,7 +87,7 @@ NimBLEAdvertising* NimBLEDevice::m_bleAdvertising = nullptr;
|
|||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
# if CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||||
std::array<NimBLEClient*, NIMBLE_MAX_CONNECTIONS> NimBLEDevice::m_pClients{};
|
std::array<NimBLEClient*, NIMBLE_MAX_CONNECTIONS> NimBLEDevice::m_pClients{};
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
@ -132,7 +118,7 @@ extern "C" int ble_vhci_disc_duplicate_mode_enable(int mode);
|
|||||||
/* SERVER FUNCTIONS */
|
/* SERVER FUNCTIONS */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
# if CONFIG_BT_NIMBLE_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.
|
||||||
@ -156,7 +142,7 @@ NimBLEServer* NimBLEDevice::getServer() {
|
|||||||
return m_pServer;
|
return m_pServer;
|
||||||
} // getServer
|
} // getServer
|
||||||
|
|
||||||
# if CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM > 0
|
# if CONFIG_BT_NIMBLE_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.
|
||||||
@ -175,14 +161,14 @@ NimBLEL2CAPServer* NimBLEDevice::createL2CAPServer() {
|
|||||||
NimBLEL2CAPServer* NimBLEDevice::getL2CAPServer() {
|
NimBLEL2CAPServer* NimBLEDevice::getL2CAPServer() {
|
||||||
return m_pL2CAPServer;
|
return m_pL2CAPServer;
|
||||||
} // getL2CAPServer
|
} // getL2CAPServer
|
||||||
# endif
|
# endif // #if CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM
|
||||||
# endif // #if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
# endif // #if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* ADVERTISING FUNCTIONS */
|
/* ADVERTISING FUNCTIONS */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER)
|
# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if CONFIG_BT_NIMBLE_EXT_ADV
|
||||||
/**
|
/**
|
||||||
* @brief Get the instance of the extended advertising object.
|
* @brief Get the instance of the extended advertising object.
|
||||||
@ -246,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 defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER)
|
# endif // #if CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* SCAN FUNCTIONS */
|
/* SCAN FUNCTIONS */
|
||||||
@ -257,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 defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
|
# if CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
||||||
NimBLEScan* NimBLEDevice::getScan() {
|
NimBLEScan* NimBLEDevice::getScan() {
|
||||||
if (m_pScan == nullptr) {
|
if (m_pScan == nullptr) {
|
||||||
m_pScan = new NimBLEScan();
|
m_pScan = new NimBLEScan();
|
||||||
@ -335,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 // #if defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
|
# endif // CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* CLIENT FUNCTIONS */
|
/* CLIENT FUNCTIONS */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
# if CONFIG_BT_NIMBLE_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.
|
||||||
@ -476,7 +462,7 @@ std::vector<NimBLEClient*> NimBLEDevice::getConnectedClients() {
|
|||||||
return clients;
|
return clients;
|
||||||
} // getConnectedClients
|
} // getConnectedClients
|
||||||
|
|
||||||
# endif // #if defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
# endif // CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* TRANSMIT POWER */
|
/* TRANSMIT POWER */
|
||||||
@ -627,7 +613,7 @@ uint16_t NimBLEDevice::getMTU() {
|
|||||||
/* BOND MANAGEMENT */
|
/* BOND MANAGEMENT */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL) || defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
# if CONFIG_BT_NIMBLE_ROLE_CENTRAL || CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
/**
|
/**
|
||||||
* @brief Gets the number of bonded peers stored
|
* @brief Gets the number of bonded peers stored
|
||||||
*/
|
*/
|
||||||
@ -864,13 +850,13 @@ void NimBLEDevice::onSync(void) {
|
|||||||
m_synced = true;
|
m_synced = true;
|
||||||
|
|
||||||
if (m_initialized) {
|
if (m_initialized) {
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
|
# if CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
||||||
if (m_pScan != nullptr) {
|
if (m_pScan != nullptr) {
|
||||||
m_pScan->onHostSync();
|
m_pScan->onHostSync();
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER)
|
# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
||||||
if (m_bleAdvertising != nullptr) {
|
if (m_bleAdvertising != nullptr) {
|
||||||
m_bleAdvertising->onHostSync();
|
m_bleAdvertising->onHostSync();
|
||||||
}
|
}
|
||||||
@ -1038,12 +1024,12 @@ bool NimBLEDevice::deinit(bool clearAll) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (clearAll) {
|
if (clearAll) {
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
# if CONFIG_BT_NIMBLE_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 > 0
|
# if CONFIG_BT_NIMBLE_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;
|
||||||
@ -1051,21 +1037,21 @@ bool NimBLEDevice::deinit(bool clearAll) {
|
|||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER)
|
# if CONFIG_BT_NIMBLE_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 defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
|
# if CONFIG_BT_NIMBLE_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 defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
# if CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||||
for (auto clt : m_pClients) {
|
for (auto clt : m_pClients) {
|
||||||
deleteClient(clt);
|
deleteClient(clt);
|
||||||
}
|
}
|
||||||
@ -1266,7 +1252,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 defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL) || defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
# if CONFIG_BT_NIMBLE_ROLE_CENTRAL || CONFIG_BT_NIMBLE_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.
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define NIMBLE_CPP_DEVICE_H_
|
#define NIMBLE_CPP_DEVICE_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "nimconfig.h"
|
||||||
#if defined(CONFIG_BT_ENABLED)
|
#if CONFIG_BT_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,16 +40,16 @@
|
|||||||
# include <string>
|
# include <string>
|
||||||
# include <vector>
|
# include <vector>
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
# if CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||||
# include <array>
|
# include <array>
|
||||||
class NimBLEClient;
|
class NimBLEClient;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
|
# if CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
||||||
class NimBLEScan;
|
class NimBLEScan;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER)
|
# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if CONFIG_BT_NIMBLE_EXT_ADV
|
||||||
class NimBLEExtAdvertising;
|
class NimBLEExtAdvertising;
|
||||||
# else
|
# else
|
||||||
@ -57,14 +57,14 @@ class NimBLEAdvertising;
|
|||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
class NimBLEServer;
|
class NimBLEServer;
|
||||||
# if CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM > 0
|
# if CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM > 0
|
||||||
class NimBLEL2CAPServer;
|
class NimBLEL2CAPServer;
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL) || defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL || CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||||
class NimBLEConnInfo;
|
class NimBLEConnInfo;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
@ -164,11 +164,11 @@ class NimBLEDevice {
|
|||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
|
# if CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
||||||
static NimBLEScan* getScan();
|
static NimBLEScan* getScan();
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
static NimBLEServer* createServer();
|
static NimBLEServer* createServer();
|
||||||
static NimBLEServer* getServer();
|
static NimBLEServer* getServer();
|
||||||
# if CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM > 0
|
# if CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM > 0
|
||||||
@ -177,12 +177,12 @@ class NimBLEDevice {
|
|||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL) || defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL || CONFIG_BT_NIMBLE_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 defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER)
|
# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if CONFIG_BT_NIMBLE_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);
|
||||||
@ -196,7 +196,7 @@ class NimBLEDevice {
|
|||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
# if CONFIG_BT_NIMBLE_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 +207,7 @@ class NimBLEDevice {
|
|||||||
static std::vector<NimBLEClient*> getConnectedClients();
|
static std::vector<NimBLEClient*> getConnectedClients();
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL) || defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
# if CONFIG_BT_NIMBLE_ROLE_CENTRAL || CONFIG_BT_NIMBLE_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,18 +225,18 @@ class NimBLEDevice {
|
|||||||
static NimBLEDeviceCallbacks* m_pDeviceCallbacks;
|
static NimBLEDeviceCallbacks* m_pDeviceCallbacks;
|
||||||
static NimBLEDeviceCallbacks defaultDeviceCallbacks;
|
static NimBLEDeviceCallbacks defaultDeviceCallbacks;
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
|
# if CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
||||||
static NimBLEScan* m_pScan;
|
static NimBLEScan* m_pScan;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
static NimBLEServer* m_pServer;
|
static NimBLEServer* m_pServer;
|
||||||
# if CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM > 0
|
# if CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM > 0
|
||||||
static NimBLEL2CAPServer* m_pL2CAPServer;
|
static NimBLEL2CAPServer* m_pL2CAPServer;
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER)
|
# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if CONFIG_BT_NIMBLE_EXT_ADV
|
||||||
static NimBLEExtAdvertising* m_bleAdvertising;
|
static NimBLEExtAdvertising* m_bleAdvertising;
|
||||||
# else
|
# else
|
||||||
@ -244,7 +244,7 @@ class NimBLEDevice {
|
|||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
# if CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||||
static std::array<NimBLEClient*, NIMBLE_MAX_CONNECTIONS> m_pClients;
|
static std::array<NimBLEClient*, NIMBLE_MAX_CONNECTIONS> m_pClients;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
@ -256,20 +256,20 @@ class NimBLEDevice {
|
|||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
# if CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||||
friend class NimBLEClient;
|
friend class NimBLEClient;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
|
# if CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
||||||
friend class NimBLEScan;
|
friend class NimBLEScan;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
friend class NimBLEServer;
|
friend class NimBLEServer;
|
||||||
friend class NimBLECharacteristic;
|
friend class NimBLECharacteristic;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER)
|
# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
||||||
friend class NimBLEAdvertising;
|
friend class NimBLEAdvertising;
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if CONFIG_BT_NIMBLE_EXT_ADV
|
||||||
friend class NimBLEExtAdvertising;
|
friend class NimBLEExtAdvertising;
|
||||||
@ -278,29 +278,29 @@ class NimBLEDevice {
|
|||||||
# endif
|
# endif
|
||||||
};
|
};
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
# if CONFIG_BT_NIMBLE_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 defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
|
# if CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
||||||
# include "NimBLEScan.h"
|
# include "NimBLEScan.h"
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
# if CONFIG_BT_NIMBLE_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 > 0
|
# if CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM
|
||||||
# include "NimBLEL2CAPServer.h"
|
# include "NimBLEL2CAPServer.h"
|
||||||
# include "NimBLEL2CAPChannel.h"
|
# include "NimBLEL2CAPChannel.h"
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER)
|
# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if CONFIG_BT_NIMBLE_EXT_ADV
|
||||||
# include "NimBLEExtAdvertising.h"
|
# include "NimBLEExtAdvertising.h"
|
||||||
# else
|
# else
|
||||||
@ -308,10 +308,11 @@ class NimBLEDevice {
|
|||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL) || defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
# if CONFIG_BT_NIMBLE_ROLE_CENTRAL || CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
# include "NimBLEConnInfo.h"
|
# include "NimBLEConnInfo.h"
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
# include "NimBLEAddress.h"
|
||||||
# include "NimBLEUtils.h"
|
# include "NimBLEUtils.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,10 +15,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "NimBLEEddystoneTLM.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
||||||
|
|
||||||
# include "NimBLEEddystoneTLM.h"
|
|
||||||
# include "NimBLEUUID.h"
|
# include "NimBLEUUID.h"
|
||||||
# include "NimBLELog.h"
|
# include "NimBLELog.h"
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define NIMBLE_CPP_EDDYSTONETLM_H_
|
#define NIMBLE_CPP_EDDYSTONETLM_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "nimconfig.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
||||||
|
|
||||||
class NimBLEUUID;
|
class NimBLEUUID;
|
||||||
|
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "NimBLEExtAdvertising.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER) && CONFIG_BT_NIMBLE_EXT_ADV
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && CONFIG_BT_NIMBLE_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"
|
||||||
@ -24,7 +24,6 @@
|
|||||||
# include "nimble/nimble/host/services/gap/include/services/gap/ble_svc_gap.h"
|
# include "nimble/nimble/host/services/gap/include/services/gap/ble_svc_gap.h"
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# include "NimBLEExtAdvertising.h"
|
|
||||||
# include "NimBLEDevice.h"
|
# include "NimBLEDevice.h"
|
||||||
# include "NimBLEServer.h"
|
# include "NimBLEServer.h"
|
||||||
# include "NimBLEUtils.h"
|
# include "NimBLEUtils.h"
|
||||||
@ -69,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 defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
# if CONFIG_BT_NIMBLE_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
|
||||||
@ -392,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 defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
# if CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
m_params.connectable = enable;
|
m_params.connectable = enable;
|
||||||
# endif
|
# endif
|
||||||
} // setConnectable
|
} // setConnectable
|
||||||
@ -1091,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_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && CONFIG_BT_NIMBLE_EXT_ADV
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define NIMBLE_CPP_EXTADVERTISING_H_
|
#define NIMBLE_CPP_EXTADVERTISING_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "nimconfig.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER) && CONFIG_BT_NIMBLE_EXT_ADV
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && CONFIG_BT_NIMBLE_EXT_ADV
|
||||||
|
|
||||||
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
||||||
# include "host/ble_gap.h"
|
# include "host/ble_gap.h"
|
||||||
|
@ -15,10 +15,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "NimBLEHIDDevice.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
|
|
||||||
# include "NimBLEHIDDevice.h"
|
|
||||||
# include "NimBLEServer.h"
|
# include "NimBLEServer.h"
|
||||||
# include "NimBLEService.h"
|
# include "NimBLEService.h"
|
||||||
# include "NimBLE2904.h"
|
# include "NimBLE2904.h"
|
||||||
@ -341,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_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define NIMBLE_CPP_HIDDEVICE_H_
|
#define NIMBLE_CPP_HIDDEVICE_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "nimconfig.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER) && defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && CONFIG_BT_NIMBLE_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 && defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
#endif // NIMBLE_CPP_HIDDEVICE_H_
|
#endif // NIMBLE_CPP_HIDDEVICE_H_
|
||||||
|
@ -1,21 +1,29 @@
|
|||||||
//
|
//
|
||||||
// (C) Dr. Michael 'Mickey' Lauer <mickey@vanille-media.de>
|
// (C) Dr. Michael 'Mickey' Lauer <mickey@vanille-media.de>
|
||||||
//
|
//
|
||||||
#include "NimBLEL2CAPChannel.h"
|
|
||||||
|
|
||||||
#include "NimBLEClient.h"
|
#include "NimBLEL2CAPChannel.h"
|
||||||
#include "NimBLELog.h"
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM
|
||||||
#include "NimBLEUtils.h"
|
|
||||||
|
# include "NimBLEClient.h"
|
||||||
|
# include "NimBLELog.h"
|
||||||
|
# include "NimBLEUtils.h"
|
||||||
|
|
||||||
|
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
||||||
|
# include "host/ble_gap.h"
|
||||||
|
# else
|
||||||
|
# include "nimble/nimble/host/include/host/ble_gap.h"
|
||||||
|
# endif
|
||||||
|
|
||||||
// L2CAP buffer block size
|
// L2CAP buffer block size
|
||||||
#define L2CAP_BUF_BLOCK_SIZE (250)
|
# define L2CAP_BUF_BLOCK_SIZE (250)
|
||||||
#define L2CAP_BUF_SIZE_MTUS_PER_CHANNEL (3)
|
# define L2CAP_BUF_SIZE_MTUS_PER_CHANNEL (3)
|
||||||
// Round-up integer division
|
// Round-up integer division
|
||||||
#define CEIL_DIVIDE(a, b) (((a) + (b) - 1) / (b))
|
# define CEIL_DIVIDE(a, b) (((a) + (b) - 1) / (b))
|
||||||
#define ROUND_DIVIDE(a, b) (((a) + (b) / 2) / (b))
|
# define ROUND_DIVIDE(a, b) (((a) + (b) / 2) / (b))
|
||||||
// Retry
|
// Retry
|
||||||
constexpr uint32_t RetryTimeout = 50;
|
constexpr uint32_t RetryTimeout = 50;
|
||||||
constexpr int RetryCounter = 3;
|
constexpr int RetryCounter = 3;
|
||||||
|
|
||||||
NimBLEL2CAPChannel::NimBLEL2CAPChannel(uint16_t psm, uint16_t mtu, NimBLEL2CAPChannelCallbacks* callbacks)
|
NimBLEL2CAPChannel::NimBLEL2CAPChannel(uint16_t psm, uint16_t mtu, NimBLEL2CAPChannelCallbacks* callbacks)
|
||||||
: psm(psm), mtu(mtu), callbacks(callbacks) {
|
: psm(psm), mtu(mtu), callbacks(callbacks) {
|
||||||
@ -84,7 +92,7 @@ int NimBLEL2CAPChannel::writeFragment(std::vector<uint8_t>::const_iterator begin
|
|||||||
m_pTaskData = &taskData;
|
m_pTaskData = &taskData;
|
||||||
NimBLEUtils::taskWait(taskData, BLE_NPL_TIME_FOREVER);
|
NimBLEUtils::taskWait(taskData, BLE_NPL_TIME_FOREVER);
|
||||||
m_pTaskData = nullptr;
|
m_pTaskData = nullptr;
|
||||||
stalled = false;
|
stalled = false;
|
||||||
NIMBLE_LOGD(LOG_TAG, "L2CAP Channel unstalled!");
|
NIMBLE_LOGD(LOG_TAG, "L2CAP Channel unstalled!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +149,7 @@ int NimBLEL2CAPChannel::writeFragment(std::vector<uint8_t>::const_iterator begin
|
|||||||
return -BLE_HS_EREJECT;
|
return -BLE_HS_EREJECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
# if CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||||
NimBLEL2CAPChannel* NimBLEL2CAPChannel::connect(NimBLEClient* client,
|
NimBLEL2CAPChannel* NimBLEL2CAPChannel::connect(NimBLEClient* client,
|
||||||
uint16_t psm,
|
uint16_t psm,
|
||||||
uint16_t mtu,
|
uint16_t mtu,
|
||||||
@ -166,7 +174,7 @@ NimBLEL2CAPChannel* NimBLEL2CAPChannel::connect(NimBLEClient* cli
|
|||||||
}
|
}
|
||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
# endif // CONFIG_BT_NIMBLE_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) {
|
||||||
@ -302,3 +310,5 @@ 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
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
//
|
//
|
||||||
// (C) Dr. Michael 'Mickey' Lauer <mickey@vanille-media.de>
|
// (C) Dr. Michael 'Mickey' Lauer <mickey@vanille-media.de>
|
||||||
//
|
//
|
||||||
#pragma once
|
|
||||||
#ifndef NIMBLEL2CAPCHANNEL_H
|
|
||||||
# define NIMBLEL2CAPCHANNEL_H
|
|
||||||
|
|
||||||
# include "nimconfig.h"
|
#ifndef NIMBLE_CPP_L2CAPCHANNEL_H_
|
||||||
|
#define NIMBLE_CPP_L2CAPCHANNEL_H_
|
||||||
|
|
||||||
|
#include "nimconfig.h"
|
||||||
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM
|
||||||
|
|
||||||
# include "inttypes.h"
|
# include "inttypes.h"
|
||||||
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
||||||
@ -85,7 +86,7 @@ class NimBLEL2CAPChannel {
|
|||||||
|
|
||||||
// Runtime handling
|
// Runtime handling
|
||||||
std::atomic<bool> stalled{false};
|
std::atomic<bool> stalled{false};
|
||||||
NimBLETaskData* m_pTaskData{nullptr};
|
NimBLETaskData* m_pTaskData{nullptr};
|
||||||
|
|
||||||
// Allocate / deallocate NimBLE memory pool
|
// Allocate / deallocate NimBLE memory pool
|
||||||
bool setupMemPool();
|
bool setupMemPool();
|
||||||
@ -121,4 +122,5 @@ class NimBLEL2CAPChannelCallbacks {
|
|||||||
virtual void onDisconnect(NimBLEL2CAPChannel* channel) {};
|
virtual void onDisconnect(NimBLEL2CAPChannel* channel) {};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM
|
||||||
|
#endif // NIMBLE_CPP_L2CAPCHANNEL_H_
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
//
|
//
|
||||||
// (C) Dr. Michael 'Mickey' Lauer <mickey@vanille-media.de>
|
// (C) Dr. Michael 'Mickey' Lauer <mickey@vanille-media.de>
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "NimBLEL2CAPServer.h"
|
#include "NimBLEL2CAPServer.h"
|
||||||
#include "NimBLEL2CAPChannel.h"
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM
|
||||||
#include "NimBLEDevice.h"
|
|
||||||
#include "NimBLELog.h"
|
# include "NimBLEL2CAPChannel.h"
|
||||||
|
# include "NimBLEDevice.h"
|
||||||
|
# include "NimBLELog.h"
|
||||||
|
|
||||||
static const char* LOG_TAG = "NimBLEL2CAPServer";
|
static const char* LOG_TAG = "NimBLEL2CAPServer";
|
||||||
|
|
||||||
@ -33,3 +36,5 @@ NimBLEL2CAPChannel* NimBLEL2CAPServer::createService(const uint16_t
|
|||||||
this->services.push_back(service);
|
this->services.push_back(service);
|
||||||
return service;
|
return service;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
//
|
//
|
||||||
// (C) Dr. Michael 'Mickey' Lauer <mickey@vanille-media.de>
|
// (C) Dr. Michael 'Mickey' Lauer <mickey@vanille-media.de>
|
||||||
//
|
//
|
||||||
#ifndef NIMBLEL2CAPSERVER_H
|
|
||||||
#define NIMBLEL2CAPSERVER_H
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "inttypes.h"
|
#ifndef NIMBLE_CPP_L2CAPSERVER_H_
|
||||||
#include <vector>
|
#define NIMBLE_CPP_L2CAPSERVER_H_
|
||||||
|
#include "nimconfig.h"
|
||||||
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM
|
||||||
|
|
||||||
|
# include "inttypes.h"
|
||||||
|
# include <vector>
|
||||||
|
|
||||||
class NimBLEL2CAPChannel;
|
class NimBLEL2CAPChannel;
|
||||||
class NimBLEL2CAPChannelCallbacks;
|
class NimBLEL2CAPChannelCallbacks;
|
||||||
@ -35,4 +37,5 @@ class NimBLEL2CAPServer {
|
|||||||
friend class NimBLEDevice;
|
friend class NimBLEDevice;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM
|
||||||
|
#endif // NIMBLE_CPP_L2CAPSERVER_H_
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define NIMBLE_CPP_LOCAL_ATTRIBUTE_H_
|
#define NIMBLE_CPP_LOCAL_ATTRIBUTE_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "nimconfig.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
|
|
||||||
# include "NimBLEAttribute.h"
|
# include "NimBLEAttribute.h"
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define NIMBLE_LOCAL_VALUE_ATTRIBUTE_H_
|
#define NIMBLE_LOCAL_VALUE_ATTRIBUTE_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "nimconfig.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
|
|
||||||
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
||||||
# include "host/ble_hs.h"
|
# include "host/ble_hs.h"
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define NIMBLE_CPP_LOG_H_
|
#define NIMBLE_CPP_LOG_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "nimconfig.h"
|
||||||
#if defined(CONFIG_BT_ENABLED)
|
#if CONFIG_BT_ENABLED
|
||||||
|
|
||||||
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
||||||
# include "esp_log.h"
|
# include "esp_log.h"
|
||||||
|
@ -15,10 +15,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "NimBLERemoteCharacteristic.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||||
|
|
||||||
# include "NimBLERemoteCharacteristic.h"
|
|
||||||
# include "NimBLERemoteDescriptor.h"
|
# include "NimBLERemoteDescriptor.h"
|
||||||
# include "NimBLERemoteService.h"
|
# include "NimBLERemoteService.h"
|
||||||
# include "NimBLEClient.h"
|
# include "NimBLEClient.h"
|
||||||
@ -388,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_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define NIMBLE_CPP_REMOTE_CHARACTERISTIC_H_
|
#define NIMBLE_CPP_REMOTE_CHARACTERISTIC_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "nimconfig.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||||
|
|
||||||
# include "NimBLERemoteValueAttribute.h"
|
# include "NimBLERemoteValueAttribute.h"
|
||||||
# include <vector>
|
# include <vector>
|
||||||
|
@ -15,10 +15,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "NimBLERemoteDescriptor.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||||
|
|
||||||
# include "NimBLERemoteDescriptor.h"
|
|
||||||
# include "NimBLERemoteCharacteristic.h"
|
# include "NimBLERemoteCharacteristic.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,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_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define NIMBLE_CPP_REMOTE_DESCRIPTOR_H_
|
#define NIMBLE_CPP_REMOTE_DESCRIPTOR_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "nimconfig.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_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_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||||
#endif /* NIMBLE_CPP_REMOTE_DESCRIPTOR_H_ */
|
#endif // NIMBLE_CPP_REMOTE_DESCRIPTOR_H_
|
||||||
|
@ -15,10 +15,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "NimBLERemoteService.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||||
|
|
||||||
# include "NimBLERemoteService.h"
|
|
||||||
# include "NimBLERemoteCharacteristic.h"
|
# include "NimBLERemoteCharacteristic.h"
|
||||||
# include "NimBLEClient.h"
|
# include "NimBLEClient.h"
|
||||||
# include "NimBLEAttValue.h"
|
# include "NimBLEAttValue.h"
|
||||||
@ -303,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_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define NIMBLE_CPP_REMOTE_SERVICE_H_
|
#define NIMBLE_CPP_REMOTE_SERVICE_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "nimconfig.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_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_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||||
#endif /* NIMBLE_CPP_REMOTE_SERVICE_H_*/
|
#endif // NIMBLE_CPP_REMOTE_SERVICE_H_
|
||||||
|
@ -15,10 +15,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "NimBLERemoteValueAttribute.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||||
|
|
||||||
# include "NimBLERemoteValueAttribute.h"
|
|
||||||
# include "NimBLEClient.h"
|
# include "NimBLEClient.h"
|
||||||
# include "NimBLEUtils.h"
|
# include "NimBLEUtils.h"
|
||||||
# include "NimBLELog.h"
|
# include "NimBLELog.h"
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define NIMBLE_CPP_REMOTE_VALUE_ATTRIBUTE_H_
|
#define NIMBLE_CPP_REMOTE_VALUE_ATTRIBUTE_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "nimconfig.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_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_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||||
#endif // NIMBLE_CPP_REMOTE_VALUE_ATTRIBUTE_H_
|
#endif // NIMBLE_CPP_REMOTE_VALUE_ATTRIBUTE_H_
|
||||||
|
@ -15,10 +15,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "NimBLEScan.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
||||||
|
|
||||||
# include "NimBLEScan.h"
|
|
||||||
# include "NimBLEDevice.h"
|
# include "NimBLEDevice.h"
|
||||||
# include "NimBLELog.h"
|
# include "NimBLELog.h"
|
||||||
|
|
||||||
@ -73,7 +72,7 @@ int NimBLEScan::handleGapEvent(ble_gap_event* event, void* arg) {
|
|||||||
# endif
|
# endif
|
||||||
NimBLEAddress advertisedAddress(disc.addr);
|
NimBLEAddress advertisedAddress(disc.addr);
|
||||||
|
|
||||||
# ifdef CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
# if CONFIG_BT_NIMBLE_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()) {
|
||||||
@ -559,4 +558,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_ENABLED && CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define NIMBLE_CPP_SCAN_H_
|
#define NIMBLE_CPP_SCAN_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "nimconfig.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
||||||
|
|
||||||
# include "NimBLEAdvertisedDevice.h"
|
# include "NimBLEAdvertisedDevice.h"
|
||||||
# include "NimBLEUtils.h"
|
# include "NimBLEUtils.h"
|
||||||
|
@ -15,14 +15,13 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "NimBLEServer.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
|
|
||||||
# include "NimBLEServer.h"
|
|
||||||
# include "NimBLEDevice.h"
|
# include "NimBLEDevice.h"
|
||||||
# include "NimBLELog.h"
|
# include "NimBLELog.h"
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
# if CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||||
# include "NimBLEClient.h"
|
# include "NimBLEClient.h"
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
@ -70,7 +69,7 @@ NimBLEServer::~NimBLEServer() {
|
|||||||
delete m_pServerCallbacks;
|
delete m_pServerCallbacks;
|
||||||
}
|
}
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
# if CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||||
if (m_pClient != nullptr) {
|
if (m_pClient != nullptr) {
|
||||||
delete m_pClient;
|
delete m_pClient;
|
||||||
}
|
}
|
||||||
@ -154,7 +153,7 @@ NimBLEExtAdvertising* NimBLEServer::getAdvertising() const {
|
|||||||
} // getAdvertising
|
} // getAdvertising
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if !CONFIG_BT_NIMBLE_EXT_ADV || defined(_DOXYGEN_)
|
# if (!CONFIG_BT_NIMBLE_EXT_ADV && CONFIG_BT_NIMBLE_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.
|
||||||
@ -357,7 +356,7 @@ int NimBLEServer::handleGapEvent(ble_gap_event* event, void* arg) {
|
|||||||
case BLE_GAP_EVENT_CONNECT: {
|
case BLE_GAP_EVENT_CONNECT: {
|
||||||
if (event->connect.status != 0) {
|
if (event->connect.status != 0) {
|
||||||
NIMBLE_LOGE(LOG_TAG, "Connection failed");
|
NIMBLE_LOGE(LOG_TAG, "Connection failed");
|
||||||
# if !CONFIG_BT_NIMBLE_EXT_ADV
|
# if !CONFIG_BT_NIMBLE_EXT_ADV && CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
||||||
NimBLEDevice::startAdvertising();
|
NimBLEDevice::startAdvertising();
|
||||||
# endif
|
# endif
|
||||||
} else {
|
} else {
|
||||||
@ -401,7 +400,7 @@ int NimBLEServer::handleGapEvent(ble_gap_event* event, void* arg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
# if CONFIG_BT_NIMBLE_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;
|
||||||
@ -488,10 +487,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
|
# if CONFIG_BT_NIMBLE_EXT_ADV && CONFIG_BT_NIMBLE_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);
|
||||||
# else
|
# elif CONFIG_BT_NIMBLE_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
|
||||||
@ -726,7 +725,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
|
# if !CONFIG_BT_NIMBLE_EXT_ADV && CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
||||||
NimBLEDevice::getAdvertising()->removeServiceUUID(service->getUUID());
|
NimBLEDevice::getAdvertising()->removeServiceUUID(service->getUUID());
|
||||||
# endif
|
# endif
|
||||||
} // removeService
|
} // removeService
|
||||||
@ -763,7 +762,9 @@ void NimBLEServer::resetGATT() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
||||||
NimBLEDevice::stopAdvertising();
|
NimBLEDevice::stopAdvertising();
|
||||||
|
# endif
|
||||||
ble_gatts_reset();
|
ble_gatts_reset();
|
||||||
ble_svc_gap_init();
|
ble_svc_gap_init();
|
||||||
ble_svc_gatt_init();
|
ble_svc_gatt_init();
|
||||||
@ -855,7 +856,7 @@ bool NimBLEServer::stopAdvertising(uint8_t instId) const {
|
|||||||
|
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if !CONFIG_BT_NIMBLE_EXT_ADV || defined(_DOXYGEN_)
|
# if (!CONFIG_BT_NIMBLE_EXT_ADV && CONFIG_BT_NIMBLE_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.
|
||||||
@ -932,7 +933,7 @@ void NimBLEServer::setDataLen(uint16_t connHandle, uint16_t octets) const {
|
|||||||
# endif
|
# endif
|
||||||
} // setDataLen
|
} // setDataLen
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
# if CONFIG_BT_NIMBLE_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.
|
||||||
@ -1019,4 +1020,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_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define NIMBLE_CPP_SERVER_H_
|
#define NIMBLE_CPP_SERVER_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "nimconfig.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_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,12 +45,14 @@ class NimBLEConnInfo;
|
|||||||
class NimBLEAddress;
|
class NimBLEAddress;
|
||||||
class NimBLEService;
|
class NimBLEService;
|
||||||
class NimBLECharacteristic;
|
class NimBLECharacteristic;
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
||||||
|
# if CONFIG_BT_NIMBLE_EXT_ADV
|
||||||
class NimBLEExtAdvertising;
|
class NimBLEExtAdvertising;
|
||||||
# else
|
# else
|
||||||
class NimBLEAdvertising;
|
class NimBLEAdvertising;
|
||||||
|
# endif
|
||||||
# endif
|
# endif
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
# if CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||||
class NimBLEClient;
|
class NimBLEClient;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
@ -82,32 +84,36 @@ 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 defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
# if CONFIG_BT_NIMBLE_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_EXT_ADV
|
# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
||||||
|
# if CONFIG_BT_NIMBLE_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 !CONFIG_BT_NIMBLE_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;
|
||||||
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class NimBLEDevice;
|
friend class NimBLEDevice;
|
||||||
friend class NimBLEService;
|
friend class NimBLEService;
|
||||||
friend class NimBLECharacteristic;
|
friend class NimBLECharacteristic;
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
||||||
|
# if CONFIG_BT_NIMBLE_EXT_ADV
|
||||||
friend class NimBLEExtAdvertising;
|
friend class NimBLEExtAdvertising;
|
||||||
# else
|
# else
|
||||||
friend class NimBLEAdvertising;
|
friend class NimBLEAdvertising;
|
||||||
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
NimBLEServer();
|
NimBLEServer();
|
||||||
@ -123,7 +129,7 @@ class NimBLEServer {
|
|||||||
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, CONFIG_BT_NIMBLE_MAX_CONNECTIONS> m_connectedPeers;
|
||||||
|
|
||||||
# if defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
# if CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||||
NimBLEClient* m_pClient{nullptr};
|
NimBLEClient* m_pClient{nullptr};
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
@ -15,10 +15,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "NimBLEService.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
|
|
||||||
# include "NimBLEService.h"
|
|
||||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
# if CONFIG_BT_NIMBLE_EXT_ADV
|
||||||
# include "NimBLEExtAdvertising.h"
|
# include "NimBLEExtAdvertising.h"
|
||||||
# else
|
# else
|
||||||
@ -376,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_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define NIMBLE_CPP_SERVICE_H_
|
#define NIMBLE_CPP_SERVICE_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "nimconfig.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
#if CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_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_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
#endif /* NIMBLE_CPP_SERVICE_H_ */
|
#endif // NIMBLE_CPP_SERVICE_H_
|
||||||
|
@ -15,11 +15,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "NimBLEUUID.h"
|
||||||
#if defined(CONFIG_BT_ENABLED)
|
#if CONFIG_BT_ENABLED
|
||||||
|
|
||||||
# include "NimBLEUtils.h"
|
# include "NimBLEUtils.h"
|
||||||
# include "NimBLEUUID.h"
|
|
||||||
# include "NimBLELog.h"
|
# include "NimBLELog.h"
|
||||||
|
|
||||||
/**** FIX COMPILATION ****/
|
/**** FIX COMPILATION ****/
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define NIMBLE_CPP_UUID_H_
|
#define NIMBLE_CPP_UUID_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "nimconfig.h"
|
||||||
#if defined(CONFIG_BT_ENABLED)
|
#if CONFIG_BT_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_ENABLED
|
||||||
#endif /* NIMBLE_CPP_UUID_H_ */
|
#endif // NIMBLE_CPP_UUID_H_
|
||||||
|
@ -15,10 +15,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "NimBLEUtils.h"
|
||||||
#if defined(CONFIG_BT_ENABLED)
|
#if CONFIG_BT_ENABLED
|
||||||
|
|
||||||
# include "NimBLEUtils.h"
|
|
||||||
# include "NimBLEAddress.h"
|
# include "NimBLEAddress.h"
|
||||||
# include "NimBLELog.h"
|
# include "NimBLELog.h"
|
||||||
|
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
#define NIMBLE_CPP_UTILS_H_
|
#define NIMBLE_CPP_UTILS_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "nimconfig.h"
|
||||||
#if defined(CONFIG_BT_ENABLED)
|
#if CONFIG_BT_ENABLED
|
||||||
|
|
||||||
# include <string>
|
# include <string>
|
||||||
|
|
||||||
class NimBLEAddress;
|
class NimBLEAddress;
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define NIMBLE_CPP_VALUE_ATTRIBUTE_H_
|
#define NIMBLE_CPP_VALUE_ATTRIBUTE_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "nimconfig.h"
|
||||||
#if defined(CONFIG_BT_ENABLED) && (defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL) || defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL))
|
#if CONFIG_BT_ENABLED && (CONFIG_BT_NIMBLE_ROLE_PERIPHERAL || CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
||||||
|
|
||||||
# include "NimBLEAttribute.h"
|
# include "NimBLEAttribute.h"
|
||||||
# include "NimBLEAttValue.h"
|
# include "NimBLEAttValue.h"
|
||||||
|
@ -8,19 +8,19 @@
|
|||||||
#define CONFIG_BT_NIMBLE_ENABLED
|
#define CONFIG_BT_NIMBLE_ENABLED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_NIMBLE_ROLE_OBSERVER) && !defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
|
#if defined(CONFIG_NIMBLE_ROLE_OBSERVER) && !CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
||||||
#define CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
#define CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_NIMBLE_ROLE_BROADCASTER) && !defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER)
|
#if defined(CONFIG_NIMBLE_ROLE_BROADCASTER) && !CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
||||||
#define CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
#define CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_NIMBLE_ROLE_CENTRAL) && !defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
#if defined(CONFIG_NIMBLE_ROLE_CENTRAL) && !CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||||
#define CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
#define CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_NIMBLE_ROLE_PERIPHERAL) && !defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
#if defined(CONFIG_NIMBLE_ROLE_PERIPHERAL) && !CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
#define CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
#define CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user