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: microbit-dal microbit-dal microbit-ble-open microbit-dal ... more
Fork of BLE_API by
Revision 770:079b714e9c1a, committed 2015-08-07
- Comitter:
- rgrover1
- Date:
- Fri Aug 07 15:55:21 2015 +0100
- Parent:
- 769:2d236d9afa9e
- Child:
- 771:26b809199308
- Commit message:
- Synchronized with git rev 45813579
Author: Rohit Grover
fix #60: if scanning parameters are changed while scanning is active, their new values are propagate
Changed in this revision
| ble/Gap.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/ble/Gap.h Fri Aug 07 15:55:21 2015 +0100
+++ b/ble/Gap.h Fri Aug 07 15:55:21 2015 +0100
@@ -725,9 +725,22 @@
*
* Once the scanning parameters have been configured, scanning can be
* enabled by using startScan().
+ *
+ * If scanning is already active, the updated value of scanWindow will be
+ * propagated to the underlying BLE stack.
*/
ble_error_t setScanWindow(uint16_t window) {
- return _scanningParams.setWindow(window);
+ ble_error_t rc;
+ if ((rc = _scanningParams.setWindow(window)) != BLE_ERROR_NONE) {
+ return rc;
+ }
+
+ /* If scanning is already active, propagate the new setting to the stack. */
+ if (scanningActive) {
+ return startRadioScan(_scanningParams);
+ }
+
+ return BLE_ERROR_NONE;
}
/**
@@ -737,9 +750,22 @@
*
* Once the scanning parameters have been configured, scanning can be
* enabled by using startScan().
+ *
+ * If scanning is already active, the updated value of scanTimeout will be
+ * propagated to the underlying BLE stack.
*/
ble_error_t setScanTimeout(uint16_t timeout) {
- return _scanningParams.setTimeout(timeout);
+ ble_error_t rc;
+ if ((rc = _scanningParams.setTimeout(timeout)) != BLE_ERROR_NONE) {
+ return rc;
+ }
+
+ /* If scanning is already active, propagate the new settings to the stack. */
+ if (scanningActive) {
+ return startRadioScan(_scanningParams);
+ }
+
+ return BLE_ERROR_NONE;
}
/**
@@ -750,9 +776,19 @@
*
* Once the scanning parameters have been configured, scanning can be
* enabled by using startScan().
+ *
+ * If scanning is already in progress, then active-scanning will be enabled
+ * for the underlying BLE stack.
*/
- void setActiveScanning(bool activeScanning) {
+ ble_error_t setActiveScanning(bool activeScanning) {
_scanningParams.setActiveScanning(activeScanning);
+
+ /* If scanning is already active, propagate the new settings to the stack. */
+ if (scanningActive) {
+ return startRadioScan(_scanningParams);
+ }
+
+ return BLE_ERROR_NONE;
}
/**
@@ -768,6 +804,7 @@
ble_error_t err = BLE_ERROR_NONE;
if (callback) {
if ((err = startRadioScan(_scanningParams)) == BLE_ERROR_NONE) {
+ scanningActive = true;
onAdvertisementReport.attach(callback);
}
}
@@ -783,6 +820,7 @@
ble_error_t err = BLE_ERROR_NONE;
if (object && callbackMember) {
if ((err = startRadioScan(_scanningParams)) == BLE_ERROR_NONE) {
+ scanningActive = true;
onAdvertisementReport.attach(object, callbackMember);
}
}
@@ -915,6 +953,7 @@
_scanningParams(),
_scanResponse(),
state(),
+ scanningActive(false),
timeoutCallback(NULL),
connectionCallback(NULL),
disconnectionCallback(NULL),
@@ -978,6 +1017,7 @@
GapAdvertisingData _scanResponse;
GapState_t state;
+ bool scanningActive;
protected:
TimeoutEventCallback_t timeoutCallback;
