Release 0.4.2
============= This is a minor release. Enhancements ~~~~~~~~~~~~ * fix #53: add GattClient API for handling HVX Events (notifications and indications). Refer to GattClient::onHVX(HVXCallback_t ...) and GattHVXCallbackParams. * Add empty (void) declarations for unused variables in the default implementations for several API (in Gap, GattServer, GattClient, etc). This avoids compiler warnings. Bugfixes ~~~~~~~~ none.
This commit is contained in:
commit
0586bdf264
9 changed files with 174 additions and 14 deletions
|
@ -916,7 +916,7 @@ public:
|
|||
*
|
||||
* @note This API is a version of above with an additional connection handle
|
||||
* parameter to allow fetches for connection-specific multivalued
|
||||
* attribtues (such as the CCCDs).
|
||||
* attributes (such as the CCCDs).
|
||||
*
|
||||
* @note: This API is now *deprecated* and will be dropped in the future.
|
||||
* You should use the parallel API from GattServer directly. A former call
|
||||
|
@ -960,7 +960,7 @@ public:
|
|||
/**
|
||||
* Update the value of a characteristic on the local GattServer. A version
|
||||
* of the same as above with connection handle parameter to allow updates
|
||||
* for connection-specific multivalued attribtues (such as the CCCDs).
|
||||
* for connection-specific multivalued attributes (such as the CCCDs).
|
||||
*
|
||||
* @param[in] connectionHandle
|
||||
* Connection Handle.
|
||||
|
|
51
ble/Gap.h
51
ble/Gap.h
|
@ -154,6 +154,10 @@ public:
|
|||
* @return BLE_ERROR_NONE on success.
|
||||
*/
|
||||
virtual ble_error_t setAddress(AddressType_t type, const Address_t address) {
|
||||
/* avoid compiler warnings about unused variables */
|
||||
(void)type;
|
||||
(void)address;
|
||||
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
|
||||
}
|
||||
|
||||
|
@ -163,6 +167,10 @@ public:
|
|||
* @return BLE_ERROR_NONE on success.
|
||||
*/
|
||||
virtual ble_error_t getAddress(AddressType_t *typeP, Address_t address) {
|
||||
/* avoid compiler warnings about unused variables */
|
||||
(void)typeP;
|
||||
(void)address;
|
||||
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
|
||||
}
|
||||
|
||||
|
@ -219,6 +227,12 @@ public:
|
|||
Gap::AddressType_t peerAddrType,
|
||||
const ConnectionParams_t *connectionParams,
|
||||
const GapScanningParams *scanParams) {
|
||||
/* avoid compiler warnings about unused variables */
|
||||
(void)peerAddr;
|
||||
(void)peerAddrType;
|
||||
(void)connectionParams;
|
||||
(void)scanParams;
|
||||
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
|
||||
}
|
||||
|
||||
|
@ -231,6 +245,10 @@ public:
|
|||
* The reason for disconnection to be sent back to the peer.
|
||||
*/
|
||||
virtual ble_error_t disconnect(Handle_t connectionHandle, DisconnectionReason_t reason) {
|
||||
/* avoid compiler warnings about unused variables */
|
||||
(void)connectionHandle;
|
||||
(void)reason;
|
||||
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
|
||||
}
|
||||
|
||||
|
@ -248,6 +266,9 @@ public:
|
|||
* altertive which takes a connection handle. It will be dropped in the future.
|
||||
*/
|
||||
virtual ble_error_t disconnect(DisconnectionReason_t reason) {
|
||||
/* avoid compiler warnings about unused variables */
|
||||
(void)reason;
|
||||
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
|
||||
}
|
||||
|
||||
|
@ -264,6 +285,9 @@ public:
|
|||
* the given structure pointed to by params.
|
||||
*/
|
||||
virtual ble_error_t getPreferredConnectionParams(ConnectionParams_t *params) {
|
||||
/* avoid compiler warnings about unused variables */
|
||||
(void)params;
|
||||
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
|
||||
}
|
||||
|
||||
|
@ -276,6 +300,9 @@ public:
|
|||
* The structure containing the desired parameters.
|
||||
*/
|
||||
virtual ble_error_t setPreferredConnectionParams(const ConnectionParams_t *params) {
|
||||
/* avoid compiler warnings about unused variables */
|
||||
(void)params;
|
||||
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
|
||||
}
|
||||
|
||||
|
@ -290,6 +317,10 @@ public:
|
|||
* the parameters in the PPCP characteristic of the GAP service will be used instead.
|
||||
*/
|
||||
virtual ble_error_t updateConnectionParams(Handle_t handle, const ConnectionParams_t *params) {
|
||||
/* avoid compiler warnings about unused variables */
|
||||
(void)handle;
|
||||
(void)params;
|
||||
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
|
||||
}
|
||||
|
||||
|
@ -299,6 +330,9 @@ public:
|
|||
* The new value for the device-name. This is a UTF-8 encoded, <b>NULL-terminated</b> string.
|
||||
*/
|
||||
virtual ble_error_t setDeviceName(const uint8_t *deviceName) {
|
||||
/* avoid compiler warnings about unused variables */
|
||||
(void)deviceName;
|
||||
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
|
||||
}
|
||||
|
||||
|
@ -321,6 +355,10 @@ public:
|
|||
* use this information to retry with a suitable buffer size.
|
||||
*/
|
||||
virtual ble_error_t getDeviceName(uint8_t *deviceName, unsigned *lengthP) {
|
||||
/* avoid compiler warnings about unused variables */
|
||||
(void)deviceName;
|
||||
(void)lengthP;
|
||||
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
|
||||
}
|
||||
|
||||
|
@ -330,6 +368,9 @@ public:
|
|||
* The new value for the device-appearance.
|
||||
*/
|
||||
virtual ble_error_t setAppearance(GapAdvertisingData::Appearance appearance) {
|
||||
/* avoid compiler warnings about unused variables */
|
||||
(void)appearance;
|
||||
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
|
||||
}
|
||||
|
||||
|
@ -339,6 +380,9 @@ public:
|
|||
* The new value for the device-appearance.
|
||||
*/
|
||||
virtual ble_error_t getAppearance(GapAdvertisingData::Appearance *appearanceP) {
|
||||
/* avoid compiler warnings about unused variables */
|
||||
(void)appearanceP;
|
||||
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
|
||||
}
|
||||
|
||||
|
@ -347,6 +391,9 @@ public:
|
|||
* @param[in] txPower Radio transmit power in dBm.
|
||||
*/
|
||||
virtual ble_error_t setTxPower(int8_t txPower) {
|
||||
/* avoid compiler warnings about unused variables */
|
||||
(void)txPower;
|
||||
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
|
||||
}
|
||||
|
||||
|
@ -359,6 +406,10 @@ public:
|
|||
* Out parameter to receive the array's size.
|
||||
*/
|
||||
virtual void getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *countP) {
|
||||
/* avoid compiler warnings about unused variables */
|
||||
(void)valueArrayPP;
|
||||
(void)countP;
|
||||
|
||||
*countP = 0; /* default implementation; override this API if this capability is supported. */
|
||||
}
|
||||
|
||||
|
|
|
@ -75,4 +75,12 @@ struct GattReadAuthCallbackParams {
|
|||
* request is to proceed; false otherwise. */
|
||||
};
|
||||
|
||||
/* For encapsulating handle-value update events (notifications or indications) generated at the remote server. */
|
||||
struct GattHVXCallbackParams {
|
||||
GattAttribute::Handle_t handle; /**< Attribute Handle to which the HVx operation applies. */
|
||||
HVXType_t type; /**< Indication or Notification, see @ref HVXType_t. */
|
||||
uint16_t len; /**< Attribute data length. */
|
||||
const uint8_t *data; /**< Attribute data, variable length. */
|
||||
};
|
||||
|
||||
#endif /*__GATT_CALLBACK_PARAM_TYPES_H__*/
|
||||
|
|
|
@ -34,6 +34,8 @@ public:
|
|||
|
||||
typedef void (*WriteCallback_t)(const GattWriteCallbackParams *params);
|
||||
|
||||
typedef void (*HVXCallback_t)(const GattHVXCallbackParams *params);
|
||||
|
||||
/*
|
||||
* The following functions are meant to be overridden in the platform-specific sub-class.
|
||||
*/
|
||||
|
@ -97,6 +99,13 @@ public:
|
|||
ServiceDiscovery::CharacteristicCallback_t cc = NULL,
|
||||
const UUID &matchingServiceUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN),
|
||||
const UUID &matchingCharacteristicUUIDIn = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)) {
|
||||
/* avoid compiler warnings about unused variables */
|
||||
(void)connectionHandle;
|
||||
(void)sc;
|
||||
(void)cc;
|
||||
(void)matchingServiceUUID;
|
||||
(void)matchingCharacteristicUUIDIn;
|
||||
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
|
||||
}
|
||||
|
||||
|
@ -129,6 +138,11 @@ public:
|
|||
virtual ble_error_t discoverServices(Gap::Handle_t connectionHandle,
|
||||
ServiceDiscovery::ServiceCallback_t callback,
|
||||
const UUID &matchingServiceUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)) {
|
||||
/* avoid compiler warnings about unused variables */
|
||||
(void)connectionHandle;
|
||||
(void)callback;
|
||||
(void)matchingServiceUUID;
|
||||
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
|
||||
}
|
||||
|
||||
|
@ -160,6 +174,12 @@ public:
|
|||
ServiceDiscovery::ServiceCallback_t callback,
|
||||
GattAttribute::Handle_t startHandle,
|
||||
GattAttribute::Handle_t endHandle) {
|
||||
/* avoid compiler warnings about unused variables */
|
||||
(void)connectionHandle;
|
||||
(void)callback;
|
||||
(void)startHandle;
|
||||
(void)endHandle;
|
||||
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
|
||||
}
|
||||
|
||||
|
@ -180,6 +200,11 @@ public:
|
|||
|
||||
/* Initiate a Gatt Client read procedure by attribute-handle. */
|
||||
virtual ble_error_t read(Gap::Handle_t connHandle, GattAttribute::Handle_t attributeHandle, uint16_t offset) const {
|
||||
/* avoid compiler warnings about unused variables */
|
||||
(void)connHandle;
|
||||
(void)attributeHandle;
|
||||
(void)offset;
|
||||
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
|
||||
}
|
||||
|
||||
|
@ -204,6 +229,13 @@ public:
|
|||
GattAttribute::Handle_t attributeHandle,
|
||||
size_t length,
|
||||
const uint8_t *value) const {
|
||||
/* avoid compiler warnings about unused variables */
|
||||
(void)cmd;
|
||||
(void)connHandle;
|
||||
(void)attributeHandle;
|
||||
(void)length;
|
||||
(void)value;
|
||||
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
|
||||
}
|
||||
|
||||
|
@ -228,9 +260,20 @@ public:
|
|||
* Setup callback for when serviceDiscovery terminates.
|
||||
*/
|
||||
virtual void onServiceDiscoveryTermination(ServiceDiscovery::TerminationCallback_t callback) {
|
||||
(void)callback; /* avoid compiler warnings about ununsed variables */
|
||||
|
||||
/* default implementation; override this API if this capability is supported. */
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup a callback for when GattClient receives an update event
|
||||
* corresponding to a change in value of a characteristic on the remote
|
||||
* GattServer.
|
||||
*/
|
||||
void onHVX(HVXCallback_t callback) {
|
||||
onHVXCallback = callback;
|
||||
}
|
||||
|
||||
protected:
|
||||
GattClient() {
|
||||
/* empty */
|
||||
|
@ -250,9 +293,16 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void processHVXEvent(const GattHVXCallbackParams *params) {
|
||||
if (onHVXCallback) {
|
||||
onHVXCallback(params);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
ReadCallback_t onDataReadCallback;
|
||||
WriteCallback_t onDataWriteCallback;
|
||||
HVXCallback_t onHVXCallback;
|
||||
|
||||
private:
|
||||
/* disallow copy and assignment */
|
||||
|
|
|
@ -52,7 +52,10 @@ public:
|
|||
* Add a service declaration to the local server ATT table. Also add the
|
||||
* characteristics contained within.
|
||||
*/
|
||||
virtual ble_error_t addService(GattService &) {
|
||||
virtual ble_error_t addService(GattService &service) {
|
||||
/* avoid compiler warnings about unused variables */
|
||||
(void)service;
|
||||
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
|
||||
}
|
||||
|
||||
|
@ -72,6 +75,11 @@ public:
|
|||
* @return BLE_ERROR_NONE if a value was read successfully into the buffer.
|
||||
*/
|
||||
virtual ble_error_t read(GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP) {
|
||||
/* avoid compiler warnings about unused variables */
|
||||
(void)attributeHandle;
|
||||
(void)buffer;
|
||||
(void)lengthP;
|
||||
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
|
||||
}
|
||||
|
||||
|
@ -94,9 +102,15 @@ public:
|
|||
*
|
||||
* @note This API is a version of above with an additional connection handle
|
||||
* parameter to allow fetches for connection-specific multivalued
|
||||
* attribtues (such as the CCCDs).
|
||||
* attributes (such as the CCCDs).
|
||||
*/
|
||||
virtual ble_error_t read(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t *buffer, uint16_t *lengthP) {
|
||||
/* avoid compiler warnings about unused variables */
|
||||
(void)connectionHandle;
|
||||
(void)attributeHandle;
|
||||
(void)buffer;
|
||||
(void)lengthP;
|
||||
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
|
||||
}
|
||||
|
||||
|
@ -118,14 +132,20 @@ public:
|
|||
*
|
||||
* @return BLE_ERROR_NONE if we have successfully set the value of the attribute.
|
||||
*/
|
||||
virtual ble_error_t write(GattAttribute::Handle_t, const uint8_t *, uint16_t, bool localOnly = false) {
|
||||
virtual ble_error_t write(GattAttribute::Handle_t attributeHandle, const uint8_t *value, uint16_t size, bool localOnly = false) {
|
||||
/* avoid compiler warnings about unused variables */
|
||||
(void)attributeHandle;
|
||||
(void)value;
|
||||
(void)size;
|
||||
(void)localOnly;
|
||||
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the value of a characteristic on the local GattServer. A version
|
||||
* of the same as above with connection handle parameter to allow updates
|
||||
* for connection-specific multivalued attribtues (such as the CCCDs).
|
||||
* for connection-specific multivalued attributes (such as the CCCDs).
|
||||
*
|
||||
* @param[in] connectionHandle
|
||||
* Connection Handle.
|
||||
|
@ -144,7 +164,14 @@ public:
|
|||
*
|
||||
* @return BLE_ERROR_NONE if we have successfully set the value of the attribute.
|
||||
*/
|
||||
virtual ble_error_t write(Gap::Handle_t connectionHandle, GattAttribute::Handle_t, const uint8_t *, uint16_t, bool localOnly = false) {
|
||||
virtual ble_error_t write(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, const uint8_t *value, uint16_t size, bool localOnly = false) {
|
||||
/* avoid compiler warnings about unused variables */
|
||||
(void)connectionHandle;
|
||||
(void)attributeHandle;
|
||||
(void)value;
|
||||
(void)size;
|
||||
(void)localOnly;
|
||||
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
|
||||
}
|
||||
|
||||
|
@ -159,6 +186,10 @@ public:
|
|||
* @return BLE_ERROR_NONE if the connection and handle are found. false otherwise.
|
||||
*/
|
||||
virtual ble_error_t areUpdatesEnabled(const GattCharacteristic &characteristic, bool *enabledP) {
|
||||
/* avoid compiler warnings about unused variables */
|
||||
(void)characteristic;
|
||||
(void)enabledP;
|
||||
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
|
||||
}
|
||||
|
||||
|
@ -176,6 +207,11 @@ public:
|
|||
* @return BLE_ERROR_NONE if the connection and handle are found. false otherwise.
|
||||
*/
|
||||
virtual ble_error_t areUpdatesEnabled(Gap::Handle_t connectionHandle, const GattCharacteristic &characteristic, bool *enabledP) {
|
||||
/* avoid compiler warnings about unused variables */
|
||||
(void)connectionHandle;
|
||||
(void)characteristic;
|
||||
(void)enabledP;
|
||||
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
|
||||
}
|
||||
|
||||
|
|
|
@ -105,7 +105,13 @@ public:
|
|||
bool requireMITM = true,
|
||||
SecurityIOCapabilities_t iocaps = IO_CAPS_NONE,
|
||||
const Passkey_t passkey = NULL) {
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* default implementation; override this if security is supported. */
|
||||
/* avoid compiler warnings about unused variables */
|
||||
(void)enableBonding;
|
||||
(void)requireMITM;
|
||||
(void)iocaps;
|
||||
(void)passkey;
|
||||
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if security is supported. */
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -117,7 +123,11 @@ public:
|
|||
* @return BLE_SUCCESS Or appropriate error code indicating reason for failure.
|
||||
*/
|
||||
virtual ble_error_t getLinkSecurity(Gap::Handle_t connectionHandle, LinkSecurityStatus_t *securityStatusP) {
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* default implementation; override this if security is supported. */
|
||||
/* avoid compiler warnings about unused variables */
|
||||
(void)connectionHandle;
|
||||
(void)securityStatusP;
|
||||
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if security is supported. */
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -129,7 +139,7 @@ public:
|
|||
* application registration.
|
||||
*/
|
||||
virtual ble_error_t purgeAllBondingState(void) {
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* default implementation; override this if security is supported. */
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if security is supported. */
|
||||
}
|
||||
|
||||
/* Event callback handlers. */
|
||||
|
|
|
@ -129,6 +129,11 @@ enum ble_error_t {
|
|||
/** @brief Default MTU size. */
|
||||
static const unsigned BLE_GATT_MTU_SIZE_DEFAULT = 23;
|
||||
|
||||
enum HVXType_t {
|
||||
BLE_HVX_NOTIFICATION = 0x01, /**< Handle Value Notification. */
|
||||
BLE_HVX_INDICATION = 0x02, /**< Handle Value Indication. */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "ble",
|
||||
"version": "0.0.0",
|
||||
"version": "0.4.2",
|
||||
"description": "The BLE module offers a high level abstraction for using Bluetooth Low Energy on multiple platforms.",
|
||||
"keywords": [
|
||||
"Bluetooth",
|
||||
|
@ -19,11 +19,11 @@
|
|||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"mbed": "^3.0.2"
|
||||
"mbed-classic":"~0.0.1"
|
||||
},
|
||||
"targetDependencies": {
|
||||
"nrf51822": {
|
||||
"ble-nrf51822":"~0.0.1"
|
||||
"ble-nrf51822":"~0.4.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "ble/BLE.h"
|
||||
|
||||
#if defined(TARGET_OTA_ENABLED)
|
||||
#include "DFUService.h"
|
||||
#include "ble/services/DFUService.h"
|
||||
#endif
|
||||
|
||||
ble_error_t
|
||||
|
|
Loading…
Reference in a new issue