Rename BLEDevice as BLE. Retain an alias to BLEDevice for the sake of compatibility with old code.

This commit is contained in:
Rohit Grover 2015-06-16 09:45:57 +01:00
parent bfc5480375
commit 9bcd743330

View file

@ -27,7 +27,7 @@
* The base class used to abstract away BLE capable radio transceivers or SOCs,
* to enable this BLE API to work with any radio transparently.
*/
class BLEDevice
class BLE
{
public:
/**
@ -39,7 +39,7 @@ public:
* setup (such as clocks or power-modes) which happens early on during
* system startup. It may not be safe to call init() from global static
* context where ordering is compiler specific and can't be guaranteed--it
* is safe to call BLEDevice::init() from within main().
* is safe to call BLE::init() from within main().
*/
ble_error_t init();
@ -612,7 +612,7 @@ public:
ble_error_t purgeAllBondingState(void);
public:
BLEDevice() : transport(createBLEDeviceInstance()), advParams(), advPayload(), scanResponse(), needToSetAdvPayload(true), scanningParams() {
BLE() : transport(createBLEDeviceInstance()), advParams(), advPayload(), scanResponse(), needToSetAdvPayload(true), scanningParams() {
advPayload.clear();
scanResponse.clear();
}
@ -632,42 +632,45 @@ private:
GapScanningParams scanningParams;
};
typedef BLE BLEDevice; /* DEPRECATED. This type alias is retained for the sake of compatibilty with older
* code. Will be dropped at some point soon.*/
/* BLEDevice methods. Most of these simply forward the calls to the underlying
* transport.*/
inline ble_error_t
BLEDevice::reset(void)
BLE::reset(void)
{
return transport->reset();
}
inline ble_error_t
BLEDevice::shutdown(void)
BLE::shutdown(void)
{
clearAdvertisingPayload();
return transport->shutdown();
}
inline ble_error_t
BLEDevice::setAddress(Gap::AddressType_t type, const Gap::Address_t address)
BLE::setAddress(Gap::AddressType_t type, const Gap::Address_t address)
{
return transport->getGap().setAddress(type, address);
}
inline ble_error_t
BLEDevice::getAddress(Gap::AddressType_t *typeP, Gap::Address_t address)
BLE::getAddress(Gap::AddressType_t *typeP, Gap::Address_t address)
{
return transport->getGap().getAddress(typeP, address);
}
inline void
BLEDevice::setAdvertisingType(GapAdvertisingParams::AdvertisingType advType)
BLE::setAdvertisingType(GapAdvertisingParams::AdvertisingType advType)
{
advParams.setAdvertisingType(advType);
}
inline void
BLEDevice::setAdvertisingInterval(uint16_t interval)
BLE::setAdvertisingInterval(uint16_t interval)
{
if (interval == 0) {
stopAdvertising();
@ -678,54 +681,54 @@ BLEDevice::setAdvertisingInterval(uint16_t interval)
}
inline uint16_t
BLEDevice::getMinAdvertisingInterval(void) const {
BLE::getMinAdvertisingInterval(void) const {
return transport->getGap().getMinAdvertisingInterval();
}
inline uint16_t
BLEDevice::getMinNonConnectableAdvertisingInterval(void) const {
BLE::getMinNonConnectableAdvertisingInterval(void) const {
return transport->getGap().getMinNonConnectableAdvertisingInterval();
}
inline uint16_t
BLEDevice::getMaxAdvertisingInterval(void) const {
BLE::getMaxAdvertisingInterval(void) const {
return transport->getGap().getMaxAdvertisingInterval();
}
inline void
BLEDevice::setAdvertisingTimeout(uint16_t timeout)
BLE::setAdvertisingTimeout(uint16_t timeout)
{
advParams.setTimeout(timeout);
}
inline void
BLEDevice::setAdvertisingParams(const GapAdvertisingParams &newAdvParams)
BLE::setAdvertisingParams(const GapAdvertisingParams &newAdvParams)
{
advParams = newAdvParams;
}
inline const GapAdvertisingParams &
BLEDevice::getAdvertisingParams(void) const
BLE::getAdvertisingParams(void) const
{
return advParams;
}
inline void
BLEDevice::clearAdvertisingPayload(void)
BLE::clearAdvertisingPayload(void)
{
needToSetAdvPayload = true;
advPayload.clear();
}
inline ble_error_t
BLEDevice::accumulateAdvertisingPayload(uint8_t flags)
BLE::accumulateAdvertisingPayload(uint8_t flags)
{
needToSetAdvPayload = true;
return advPayload.addFlags(flags);
}
inline ble_error_t
BLEDevice::accumulateAdvertisingPayload(GapAdvertisingData::Appearance app)
BLE::accumulateAdvertisingPayload(GapAdvertisingData::Appearance app)
{
needToSetAdvPayload = true;
transport->getGap().setAppearance(app);
@ -733,14 +736,14 @@ BLEDevice::accumulateAdvertisingPayload(GapAdvertisingData::Appearance app)
}
inline ble_error_t
BLEDevice::accumulateAdvertisingPayloadTxPower(int8_t txPower)
BLE::accumulateAdvertisingPayloadTxPower(int8_t txPower)
{
needToSetAdvPayload = true;
return advPayload.addTxPower(txPower);
}
inline ble_error_t
BLEDevice::accumulateAdvertisingPayload(GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len)
BLE::accumulateAdvertisingPayload(GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len)
{
needToSetAdvPayload = true;
if (type == GapAdvertisingData::COMPLETE_LOCAL_NAME) {
@ -750,27 +753,27 @@ BLEDevice::accumulateAdvertisingPayload(GapAdvertisingData::DataType type, const
}
inline ble_error_t
BLEDevice::accumulateScanResponse(GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len)
BLE::accumulateScanResponse(GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len)
{
needToSetAdvPayload = true;
return scanResponse.addData(type, data, len);
}
inline void
BLEDevice::clearScanResponse(void)
BLE::clearScanResponse(void)
{
needToSetAdvPayload = true;
scanResponse.clear();
}
inline ble_error_t
BLEDevice::setAdvertisingPayload(void) {
BLE::setAdvertisingPayload(void) {
needToSetAdvPayload = false;
return transport->getGap().setAdvertisingData(advPayload, scanResponse);
}
inline ble_error_t
BLEDevice::setAdvertisingData(const GapAdvertisingData& newPayload)
BLE::setAdvertisingData(const GapAdvertisingData& newPayload)
{
advPayload = newPayload;
@ -778,12 +781,12 @@ BLEDevice::setAdvertisingData(const GapAdvertisingData& newPayload)
}
inline const GapAdvertisingData &
BLEDevice::getAdvertisingData(void) const {
BLE::getAdvertisingData(void) const {
return advPayload;
}
inline ble_error_t
BLEDevice::startAdvertising(void)
BLE::startAdvertising(void)
{
ble_error_t rc;
if ((rc = transport->getGattServer().initializeGATTDatabase()) != BLE_ERROR_NONE) {
@ -799,13 +802,13 @@ BLEDevice::startAdvertising(void)
}
inline ble_error_t
BLEDevice::stopAdvertising(void)
BLE::stopAdvertising(void)
{
return transport->getGap().stopAdvertising();
}
inline ble_error_t
BLEDevice::setScanParams(uint16_t interval, uint16_t window, uint16_t timeout, bool activeScanning) {
BLE::setScanParams(uint16_t interval, uint16_t window, uint16_t timeout, bool activeScanning) {
ble_error_t rc;
if (((rc = scanningParams.setInterval(interval)) == BLE_ERROR_NONE) &&
((rc = scanningParams.setWindow(window)) == BLE_ERROR_NONE) &&
@ -818,271 +821,273 @@ BLEDevice::setScanParams(uint16_t interval, uint16_t window, uint16_t timeout, b
}
inline ble_error_t
BLEDevice::setScanInterval(uint16_t interval) {
BLE::setScanInterval(uint16_t interval) {
return scanningParams.setInterval(interval);
}
inline ble_error_t
BLEDevice::setScanWindow(uint16_t window) {
BLE::setScanWindow(uint16_t window) {
return scanningParams.setWindow(window);
}
inline ble_error_t
BLEDevice::setScanTimeout(uint16_t timeout) {
BLE::setScanTimeout(uint16_t timeout) {
return scanningParams.setTimeout(timeout);
}
inline void
BLEDevice::setActiveScan(bool activeScanning) {
BLE::setActiveScan(bool activeScanning) {
return scanningParams.setActiveScanning(activeScanning);
}
inline ble_error_t
BLEDevice::startScan(void (*callback)(const Gap::AdvertisementCallbackParams_t *params)) {
BLE::startScan(void (*callback)(const Gap::AdvertisementCallbackParams_t *params)) {
return transport->getGap().startScan(scanningParams, callback);
}
template<typename T>
inline ble_error_t
BLEDevice::startScan(T *object, void (T::*memberCallback)(const Gap::AdvertisementCallbackParams_t *params)) {
BLE::startScan(T *object, void (T::*memberCallback)(const Gap::AdvertisementCallbackParams_t *params)) {
return transport->getGap().startScan(scanningParams, object, memberCallback);
}
inline ble_error_t
BLEDevice::stopScan(void) {
BLE::stopScan(void) {
return transport->getGap().stopScan();
}
inline ble_error_t
BLEDevice::disconnect(Gap::DisconnectionReason_t reason)
BLE::disconnect(Gap::DisconnectionReason_t reason)
{
return transport->getGap().disconnect(reason);
}
inline void
BLEDevice::onTimeout(Gap::EventCallback_t timeoutCallback)
BLE::onTimeout(Gap::EventCallback_t timeoutCallback)
{
transport->getGap().setOnTimeout(timeoutCallback);
}
inline void
BLEDevice::onConnection(Gap::ConnectionEventCallback_t connectionCallback)
BLE::onConnection(Gap::ConnectionEventCallback_t connectionCallback)
{
transport->getGap().setOnConnection(connectionCallback);
}
inline void
BLEDevice::onDisconnection(Gap::DisconnectionEventCallback_t disconnectionCallback)
BLE::onDisconnection(Gap::DisconnectionEventCallback_t disconnectionCallback)
{
transport->getGap().setOnDisconnection(disconnectionCallback);
}
template<typename T>
inline void
BLEDevice::addToDisconnectionCallChain(T *tptr, void (T::*mptr)(void)) {
BLE::addToDisconnectionCallChain(T *tptr, void (T::*mptr)(void)) {
transport->getGap().addToDisconnectionCallChain(tptr, mptr);
}
inline void
BLEDevice::onDataSent(void (*callback)(unsigned count)) {
BLE::onDataSent(void (*callback)(unsigned count)) {
transport->getGattServer().setOnDataSent(callback);
}
template <typename T> inline void
BLEDevice::onDataSent(T *objPtr, void (T::*memberPtr)(unsigned count)) {
BLE::onDataSent(T *objPtr, void (T::*memberPtr)(unsigned count)) {
transport->getGattServer().setOnDataSent(objPtr, memberPtr);
}
inline void
BLEDevice::onDataWritten(void (*callback)(const GattCharacteristicWriteCBParams *eventDataP)) {
BLE::onDataWritten(void (*callback)(const GattCharacteristicWriteCBParams *eventDataP)) {
transport->getGattServer().setOnDataWritten(callback);
}
template <typename T> inline void
BLEDevice::onDataWritten(T *objPtr, void (T::*memberPtr)(const GattCharacteristicWriteCBParams *context)) {
BLE::onDataWritten(T *objPtr, void (T::*memberPtr)(const GattCharacteristicWriteCBParams *context)) {
transport->getGattServer().setOnDataWritten(objPtr, memberPtr);
}
inline ble_error_t
BLEDevice::onDataRead(void (*callback)(const GattCharacteristicReadCBParams *eventDataP)) {
BLE::onDataRead(void (*callback)(const GattCharacteristicReadCBParams *eventDataP)) {
return transport->getGattServer().setOnDataRead(callback);
}
template <typename T> inline ble_error_t
BLEDevice::onDataRead(T *objPtr, void (T::*memberPtr)(const GattCharacteristicReadCBParams *context)) {
BLE::onDataRead(T *objPtr, void (T::*memberPtr)(const GattCharacteristicReadCBParams *context)) {
return transport->getGattServer().setOnDataRead(objPtr, memberPtr);
}
inline void
BLEDevice::onUpdatesEnabled(GattServer::EventCallback_t callback)
BLE::onUpdatesEnabled(GattServer::EventCallback_t callback)
{
transport->getGattServer().setOnUpdatesEnabled(callback);
}
inline void
BLEDevice::onUpdatesDisabled(GattServer::EventCallback_t callback)
BLE::onUpdatesDisabled(GattServer::EventCallback_t callback)
{
transport->getGattServer().setOnUpdatesDisabled(callback);
}
inline void
BLEDevice::onConfirmationReceived(GattServer::EventCallback_t callback)
BLE::onConfirmationReceived(GattServer::EventCallback_t callback)
{
transport->getGattServer().setOnConfirmationReceived(callback);
}
inline void
BLEDevice::onRadioNotification(Gap::RadioNotificationEventCallback_t callback)
BLE::onRadioNotification(Gap::RadioNotificationEventCallback_t callback)
{
transport->getGap().setOnRadioNotification(callback);
}
inline ble_error_t
BLEDevice::addService(GattService &service)
BLE::addService(GattService &service)
{
return transport->getGattServer().addService(service);
}
inline Gap::GapState_t
BLEDevice::getGapState(void) const
BLE::getGapState(void) const
{
return transport->getGap().getState();
}
inline ble_error_t BLEDevice::readCharacteristicValue(GattAttribute::Handle_t attributeHandle, uint8_t *buffer, uint16_t *lengthP)
inline ble_error_t
BLE::readCharacteristicValue(GattAttribute::Handle_t attributeHandle, uint8_t *buffer, uint16_t *lengthP)
{
return transport->getGattServer().readValue(attributeHandle, buffer, lengthP);
}
inline ble_error_t BLEDevice::readCharacteristicValue(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t *buffer, uint16_t *lengthP)
inline ble_error_t
BLE::readCharacteristicValue(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t *buffer, uint16_t *lengthP)
{
return transport->getGattServer().readValue(connectionHandle, attributeHandle, buffer, lengthP);
}
inline ble_error_t
BLEDevice::updateCharacteristicValue(GattAttribute::Handle_t attributeHandle, const uint8_t *value, uint16_t size, bool localOnly)
BLE::updateCharacteristicValue(GattAttribute::Handle_t attributeHandle, const uint8_t *value, uint16_t size, bool localOnly)
{
return transport->getGattServer().updateValue(attributeHandle, const_cast<uint8_t *>(value), size, localOnly);
}
inline ble_error_t
BLEDevice::updateCharacteristicValue(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, const uint8_t *value, uint16_t size, bool localOnly)
BLE::updateCharacteristicValue(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, const uint8_t *value, uint16_t size, bool localOnly)
{
return transport->getGattServer().updateValue(connectionHandle, attributeHandle, const_cast<uint8_t *>(value), size, localOnly);
}
inline void
BLEDevice::waitForEvent(void)
BLE::waitForEvent(void)
{
transport->waitForEvent();
}
inline ble_error_t
BLEDevice::getPreferredConnectionParams(Gap::ConnectionParams_t *params)
BLE::getPreferredConnectionParams(Gap::ConnectionParams_t *params)
{
return transport->getGap().getPreferredConnectionParams(params);
}
inline ble_error_t
BLEDevice::setPreferredConnectionParams(const Gap::ConnectionParams_t *params)
BLE::setPreferredConnectionParams(const Gap::ConnectionParams_t *params)
{
return transport->getGap().setPreferredConnectionParams(params);
}
inline ble_error_t
BLEDevice::updateConnectionParams(Gap::Handle_t handle, const Gap::ConnectionParams_t *params) {
BLE::updateConnectionParams(Gap::Handle_t handle, const Gap::ConnectionParams_t *params) {
return transport->getGap().updateConnectionParams(handle, params);
}
inline const char *
BLEDevice::getVersion(void)
BLE::getVersion(void)
{
return transport->getVersion();
}
inline ble_error_t
BLEDevice::setDeviceName(const uint8_t *deviceName)
BLE::setDeviceName(const uint8_t *deviceName)
{
return transport->getGap().setDeviceName(deviceName);
}
inline ble_error_t
BLEDevice::getDeviceName(uint8_t *deviceName, unsigned *lengthP)
BLE::getDeviceName(uint8_t *deviceName, unsigned *lengthP)
{
return transport->getGap().getDeviceName(deviceName, lengthP);
}
inline ble_error_t
BLEDevice::setAppearance(uint16_t appearance)
BLE::setAppearance(uint16_t appearance)
{
return transport->getGap().setAppearance(appearance);
}
inline ble_error_t
BLEDevice::getAppearance(uint16_t *appearanceP)
BLE::getAppearance(uint16_t *appearanceP)
{
return transport->getGap().getAppearance(appearanceP);
}
inline ble_error_t
BLEDevice::setTxPower(int8_t txPower)
BLE::setTxPower(int8_t txPower)
{
return transport->getGap().setTxPower(txPower);
}
inline void
BLEDevice::getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *countP)
BLE::getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *countP)
{
transport->getGap().getPermittedTxPowerValues(valueArrayPP, countP);
}
inline ble_error_t
BLEDevice::initializeSecurity(bool enableBonding,
bool requireMITM,
Gap::SecurityIOCapabilities_t iocaps,
const Gap::Passkey_t passkey)
BLE::initializeSecurity(bool enableBonding,
bool requireMITM,
Gap::SecurityIOCapabilities_t iocaps,
const Gap::Passkey_t passkey)
{
return transport->initializeSecurity(enableBonding, requireMITM, iocaps, passkey);
}
inline void
BLEDevice::onSecuritySetupInitiated(Gap::SecuritySetupInitiatedCallback_t callback)
BLE::onSecuritySetupInitiated(Gap::SecuritySetupInitiatedCallback_t callback)
{
transport->getGap().setOnSecuritySetupInitiated(callback);
}
inline void
BLEDevice::onSecuritySetupCompleted(Gap::SecuritySetupCompletedCallback_t callback)
BLE::onSecuritySetupCompleted(Gap::SecuritySetupCompletedCallback_t callback)
{
transport->getGap().setOnSecuritySetupCompleted(callback);
}
inline void
BLEDevice::onLinkSecured(Gap::LinkSecuredCallback_t callback)
BLE::onLinkSecured(Gap::LinkSecuredCallback_t callback)
{
transport->getGap().setOnLinkSecured(callback);
}
inline void
BLEDevice::onSecurityContextStored(Gap::HandleSpecificEvent_t callback)
BLE::onSecurityContextStored(Gap::HandleSpecificEvent_t callback)
{
transport->getGap().setOnSecurityContextStored(callback);
}
inline void
BLEDevice::onPasskeyDisplay(Gap::PasskeyDisplayCallback_t callback)
BLE::onPasskeyDisplay(Gap::PasskeyDisplayCallback_t callback)
{
return transport->getGap().setOnPasskeyDisplay(callback);
}
inline ble_error_t
BLEDevice::getLinkSecurity(Gap::Handle_t connectionHandle, Gap::LinkSecurityStatus_t *securityStatusP)
BLE::getLinkSecurity(Gap::Handle_t connectionHandle, Gap::LinkSecurityStatus_t *securityStatusP)
{
return transport->getGap().getLinkSecurity(connectionHandle, securityStatusP);
}
inline ble_error_t
BLEDevice::purgeAllBondingState(void)
BLE::purgeAllBondingState(void)
{
return transport->getGap().purgeAllBondingState();
}