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.
Fork of BLE_API by
Revision 684:448cdd97e926, committed 2015-06-19
- Comitter:
- rgrover1
- Date:
- Fri Jun 19 15:53:03 2015 +0100
- Parent:
- 683:a8e31b13d359
- Child:
- 685:676b116f7be2
- Commit message:
- Synchronized with git rev 61eae6c0
Author: Rohit Grover
fix Gap::onTimeout().
Introduce Gap::TimeoutSource_t. Update TimeoutEventCallback_t
Changed in this revision
| public/BLE.h | Show annotated file Show diff for this revision Revisions of this file |
| public/Gap.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/public/BLE.h Fri Jun 19 15:53:03 2015 +0100
+++ b/public/BLE.h Fri Jun 19 15:53:03 2015 +0100
@@ -1053,7 +1053,18 @@
return gattServer().write(connectionHandle, attributeHandle, value, size, localOnly);
}
- void onTimeout(Gap::EventCallback_t timeoutCallback);
+ /**
+ * Setup a callback for timeout events. Refer to Gap::TimeoutSource_t for
+ * possible event types.
+ *
+ * @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
+ * to ble.onTimeout(callback) should be replaced with
+ * ble.gap().onTimeout(callback).
+ */
+ void onTimeout(Gap::TimeoutEventCallback_t timeoutCallback) {
+ gap().onTimeout(timeoutCallback);
+ }
void onConnection(Gap::ConnectionEventCallback_t connectionCallback);
/**
@@ -1157,12 +1168,6 @@
* transport.*/
inline void
-BLE::onTimeout(Gap::EventCallback_t timeoutCallback)
-{
- gap().setOnTimeout(timeoutCallback);
-}
-
-inline void
BLE::onConnection(Gap::ConnectionEventCallback_t connectionCallback)
{
gap().setOnConnection(connectionCallback);
--- a/public/Gap.h Fri Jun 19 15:53:03 2015 +0100
+++ b/public/Gap.h Fri Jun 19 15:53:03 2015 +0100
@@ -45,6 +45,13 @@
typedef uint8_t Address_t[ADDR_LEN]; /* 48-bit address, LSB format. */
typedef Address_t address_t; /* @Note: deprecated. Use Address_t instead. */
+ enum TimeoutSource_t {
+ TIMEOUT_SRC_ADVERTISING = 0x00, /**< Advertising timeout. */
+ TIMEOUT_SRC_SECURITY_REQUEST = 0x01, /**< Security request timeout. */
+ TIMEOUT_SRC_SCAN = 0x02, /**< Scanning timeout. */
+ TIMEOUT_SRC_CONN = 0x03, /**< Connection timeout. */
+ };
+
/**
* Enumeration for disconnection reasons. The values for these reasons are
* derived from Nordic's implementation; but the reasons are meant to be
@@ -183,7 +190,7 @@
return (gapUnits * UNIT_0_625_MS) / 1000;
}
- typedef void (*EventCallback_t)(void);
+ typedef void (*TimeoutEventCallback_t)(TimeoutSource_t source);
typedef void (*ConnectionEventCallback_t)(const ConnectionCallbackParams_t *params);
typedef void (*HandleSpecificEvent_t)(Handle_t handle);
typedef void (*DisconnectionEventCallback_t)(Handle_t, DisconnectionReason_t);
@@ -742,11 +749,16 @@
_advParams = newParams;
}
+ /* Event callback handlers */
public:
virtual ble_error_t startRadioScan(const GapScanningParams &scanningParams) = 0;
- /* Event callback handlers */
- void setOnTimeout(EventCallback_t callback) {onTimeout = callback;}
+ /**
+ * Setup a callback for timeout events. Refer to TimeoutSource_t for
+ * possible event types.
+ */
+ void onTimeout(TimeoutEventCallback_t callback) {timeoutCallback = callback;}
+
void setOnConnection(ConnectionEventCallback_t callback) {onConnection = callback;}
/**
@@ -813,7 +825,7 @@
_scanningParams(),
_scanResponse(),
state(),
- onTimeout(NULL),
+ timeoutCallback(NULL),
onConnection(NULL),
onDisconnection(NULL),
onRadioNotification(),
@@ -897,16 +909,9 @@
onAdvertisementReport.call(¶ms);
}
- void processEvent(GapEvents::gapEvent_e type) {
- switch (type) {
- case GapEvents::GAP_EVENT_TIMEOUT:
- state.advertising = 0;
- if (onTimeout) {
- onTimeout();
- }
- break;
- default:
- break;
+ void processTimeoutEvent(TimeoutSource_t source) {
+ if (timeoutCallback) {
+ timeoutCallback(source);
}
}
@@ -919,7 +924,7 @@
GapState_t state;
protected:
- EventCallback_t onTimeout;
+ TimeoutEventCallback_t timeoutCallback;
ConnectionEventCallback_t onConnection;
DisconnectionEventCallback_t onDisconnection;
RadioNotificationEventCallback_t onRadioNotification;
