Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: BLE_ANCS_SDAPI BLE_temperature BLE_HeartRate BLE_ANCS_SDAPI_IRC ... more
Diff: public/BLEDevice.h
- Revision:
- 514:1fa338281798
- Parent:
- 513:0e6ad6ac1d9b
- Child:
- 518:54731cc463b3
--- a/public/BLEDevice.h Fri Jun 19 15:52:05 2015 +0100
+++ b/public/BLEDevice.h Fri Jun 19 15:52:05 2015 +0100
@@ -20,14 +20,9 @@
#include "blecommon.h"
#include "Gap.h"
#include "GattServer.h"
-#include "GattClient.h"
+#include "GapScanningParams.h"
#include "BLEDeviceInstanceBase.h"
-#include "GapAdvertisingData.h"
-#include "GapAdvertisingParams.h"
-#include "GapScanningParams.h"
-
-
/**
* The base class used to abstract away BLE capable radio transceivers or SOCs,
* to enable this BLE API to work with any radio transparently.
@@ -321,25 +316,6 @@
ble_error_t stopScan(void);
/**
- * Create a connection (GAP Link Establishment).
- * @param peerAddr
- * 48-bit address, LSB format.
- * @param peerAddrType
- * Address type of the peer.
- * @param connectionParams
- * Connection parameters.
- * @param scanParams
- * Paramters to be used while scanning for the peer.
- * @return BLE_ERROR_NONE if connection establishment procedure is started
- * successfully. The onConnection callback (if set) will be invoked upon
- * a connection event.
- */
- ble_error_t connect(const Gap::Address_t peerAddr,
- Gap::AddressType_t peerAddrType = Gap::ADDR_TYPE_RANDOM_STATIC,
- const Gap::ConnectionParams_t *connectionParams = NULL,
- const GapScanningParams *scanParams = NULL);
-
- /**
* This call initiates the disconnection procedure, and its completion will
* be communicated to the application with an invocation of the
* onDisconnection callback.
@@ -392,8 +368,8 @@
* @Note: it is also possible to setup a callback into a member function of
* some object.
*/
- void onDataWritten(void (*callback)(const GattWriteCallbackParams *eventDataP));
- template <typename T> void onDataWritten(T * objPtr, void (T::*memberPtr)(const GattWriteCallbackParams *context));
+ void onDataWritten(void (*callback)(const GattCharacteristicWriteCBParams *eventDataP));
+ template <typename T> void onDataWritten(T * objPtr, void (T::*memberPtr)(const GattCharacteristicWriteCBParams *context));
/**
* Setup a callback for when a characteristic is being read by a client.
@@ -413,8 +389,8 @@
* @return BLE_ERROR_NOT_IMPLEMENTED if this functionality isn't available;
* else BLE_ERROR_NONE.
*/
- ble_error_t onDataRead(void (*callback)(const GattReadCallbackParams *eventDataP));
- template <typename T> ble_error_t onDataRead(T * objPtr, void (T::*memberPtr)(const GattReadCallbackParams *context));
+ ble_error_t onDataRead(void (*callback)(const GattCharacteristicReadCBParams *eventDataP));
+ template <typename T> ble_error_t onDataRead(T * objPtr, void (T::*memberPtr)(const GattCharacteristicReadCBParams *context));
void onUpdatesEnabled(GattServer::EventCallback_t callback);
void onUpdatesDisabled(GattServer::EventCallback_t callback);
@@ -469,11 +445,7 @@
/**
* A version of the same as above with connection handle parameter to allow updates for connection-specific multivalued attribtues (such as the CCCDs).
*/
- ble_error_t updateCharacteristicValue(Gap::Handle_t connectionHandle,
- GattAttribute::Handle_t attributeHandle,
- const uint8_t *value,
- uint16_t size,
- bool localOnly = false);
+ ble_error_t updateCharacteristicValue(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, const uint8_t *value, uint16_t size, bool localOnly = false);
/**
* Yield control to the BLE stack or to other tasks waiting for events. This
@@ -639,78 +611,6 @@
*/
ble_error_t purgeAllBondingState(void);
- /**
- * Launch service discovery. Once launched, service discovery will remain
- * active with callbacks being issued back into the application for matching
- * services/characteristics. isServiceDiscoveryActive() can be used to
- * determine status; and a termination callback (if setup) will be invoked
- * at the end. Service discovery can be terminated prematurely if needed
- * using terminateServiceDiscovery().
- *
- * @param connectionHandle
- * Handle for the connection with the peer.
- * @param sc
- * This is the application callback for matching service. Taken as
- * NULL by default. Note: service discovery may still be active
- * when this callback is issued; calling asynchronous BLE-stack
- * APIs from within this application callback might cause the
- * stack to abort service discovery. If this becomes an issue, it
- * may be better to make local copy of the discoveredService and
- * wait for service discovery to terminate before operating on the
- * service.
- * @param cc
- * This is the application callback for matching characteristic.
- * Taken as NULL by default. Note: service discovery may still be
- * active when this callback is issued; calling asynchronous
- * BLE-stack APIs from within this application callback might cause
- * the stack to abort service discovery. If this becomes an issue,
- * it may be better to make local copy of the discoveredCharacteristic
- * and wait for service discovery to terminate before operating on the
- * characteristic.
- * @param matchingServiceUUID
- * UUID based filter for specifying a service in which the application is
- * interested. By default it is set as the wildcard UUID_UNKNOWN,
- * in which case it matches all services. If characteristic-UUID
- * filter (below) is set to the wildcard value, then a service
- * callback will be invoked for the matching service (or for every
- * service if the service filter is a wildcard).
- * @param matchingCharacteristicUUIDIn
- * UUID based filter for specifying characteristic in which the application
- * is interested. By default it is set as the wildcard UUID_UKNOWN
- * to match against any characteristic. If both service-UUID
- * filter and characteristic-UUID filter are used with non- wildcard
- * values, then only a single characteristic callback is
- * invoked for the matching characteristic.
- *
- * @Note Using wildcard values for both service-UUID and characteristic-
- * UUID will result in complete service discovery--callbacks being
- * called for every service and characteristic.
- *
- * @return
- * BLE_ERROR_NONE if service discovery is launched successfully; else an appropriate error.
- */
- ble_error_t launchServiceDiscovery(Gap::Handle_t connectionHandle,
- ServiceDiscovery::ServiceCallback_t sc = NULL,
- ServiceDiscovery::CharacteristicCallback_t cc = NULL,
- const UUID &matchingServiceUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN),
- const UUID &matchingCharacteristicUUIDIn = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN));
-
- /**
- * Setup callback for when serviceDiscovery terminates.
- */
- void onServiceDiscoveryTermination(ServiceDiscovery::TerminationCallback_t callback);
-
- /**
- * Is service-discovery currently active?
- */
- bool isServiceDiscoveryActive(void);
-
- /**
- * Terminate an ongoing service-discovery. This should result in an
- * invocation of the TerminationCallback if service-discovery is active.
- */
- void terminateServiceDiscovery(void);
-
public:
BLEDevice() : transport(createBLEDeviceInstance()), advParams(), advPayload(), scanResponse(), needToSetAdvPayload(true), scanningParams() {
advPayload.clear();
@@ -954,14 +854,6 @@
}
inline ble_error_t
-BLEDevice::connect(const Gap::Address_t peerAddr,
- Gap::AddressType_t peerAddrType,
- const Gap::ConnectionParams_t *connectionParams,
- const GapScanningParams *scanParams) {
- return transport->getGap().connect(peerAddr, peerAddrType, connectionParams, scanParams);
-}
-
-inline ble_error_t
BLEDevice::disconnect(Gap::DisconnectionReason_t reason)
{
return transport->getGap().disconnect(reason);
@@ -1002,22 +894,22 @@
}
inline void
-BLEDevice::onDataWritten(void (*callback)(const GattWriteCallbackParams *eventDataP)) {
+BLEDevice::onDataWritten(void (*callback)(const GattCharacteristicWriteCBParams *eventDataP)) {
transport->getGattServer().setOnDataWritten(callback);
}
template <typename T> inline void
-BLEDevice::onDataWritten(T *objPtr, void (T::*memberPtr)(const GattWriteCallbackParams *context)) {
+BLEDevice::onDataWritten(T *objPtr, void (T::*memberPtr)(const GattCharacteristicWriteCBParams *context)) {
transport->getGattServer().setOnDataWritten(objPtr, memberPtr);
}
inline ble_error_t
-BLEDevice::onDataRead(void (*callback)(const GattReadCallbackParams *eventDataP)) {
+BLEDevice::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 GattReadCallbackParams *context)) {
+BLEDevice::onDataRead(T *objPtr, void (T::*memberPtr)(const GattCharacteristicReadCBParams *context)) {
return transport->getGattServer().setOnDataRead(objPtr, memberPtr);
}
@@ -1062,10 +954,7 @@
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 BLEDevice::readCharacteristicValue(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t *buffer, uint16_t *lengthP)
{
return transport->getGattServer().readValue(connectionHandle, attributeHandle, buffer, lengthP);
}
@@ -1077,11 +966,7 @@
}
inline ble_error_t
-BLEDevice::updateCharacteristicValue(Gap::Handle_t connectionHandle,
- GattAttribute::Handle_t attributeHandle,
- const uint8_t *value,
- uint16_t size,
- bool localOnly)
+BLEDevice::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);
}
@@ -1202,40 +1087,4 @@
return transport->getGap().purgeAllBondingState();
}
-inline ble_error_t
-BLEDevice::launchServiceDiscovery(Gap::Handle_t connectionHandle,
- ServiceDiscovery::ServiceCallback_t sc,
- ServiceDiscovery::CharacteristicCallback_t cc,
- const UUID &matchingServiceUUID,
- const UUID &matchingCharacteristicUUID)
-{
- return transport->getGattClient().launchServiceDiscovery(connectionHandle, sc, cc, matchingServiceUUID, matchingCharacteristicUUID);
-}
-
-inline void
-BLEDevice::onServiceDiscoveryTermination(ServiceDiscovery::TerminationCallback_t callback)
-{
- transport->getGattClient().onServiceDiscoveryTermination(callback);
-}
-
-/**
- * Is service-discovery currently active?
- */
-inline bool
-BLEDevice::isServiceDiscoveryActive(void)
-{
- return transport->getGattClient().isServiceDiscoveryActive();
-}
-
-/**
- * Terminate an ongoing service-discovery. This should result in an
- * invocation of the TerminationCallback if service-discovery is active.
- */
-inline void
-BLEDevice::terminateServiceDiscovery(void)
-{
- transport->getGattClient().terminateServiceDiscovery();
-}
-
-
#endif // ifndef __BLE_DEVICE__
\ No newline at end of file