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: LinkNode_SimpleChatwithSerial
Fork of BLE_API by
Diff: ble/Gap.h
- Revision:
- 770:079b714e9c1a
- Parent:
- 767:d6a79c77d1c3
- Child:
- 772:b6d27ab66c94
--- 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;
