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 386:d30591c3d39c, committed 2015-05-13
- Comitter:
- rgrover1
- Date:
- Wed May 13 08:51:08 2015 +0100
- Parent:
- 385:6e66d1c6de00
- Child:
- 387:7faa54079669
- Commit message:
- Synchronized with git rev 4c6fb079
Author: Rohit Grover
add error checking for APIs for ScanningParameters.
Changed in this revision
| public/GapScanningParams.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/public/GapScanningParams.h Wed May 13 08:51:08 2015 +0100
+++ b/public/GapScanningParams.h Wed May 13 08:51:08 2015 +0100
@@ -39,14 +39,43 @@
if (_interval > SCAN_INTERVAL_MAX) {
_interval = SCAN_INTERVAL_MAX;
}
+ if (_window < SCAN_WINDOW_MIN) {
+ _window = SCAN_WINDOW_MIN;
+ }
+ if (_window > SCAN_WINDOW_MAX) {
+ _window = SCAN_WINDOW_MAX;
+ }
if (_timeout > SCAN_TIMEOUT_MAX) {
_timeout = SCAN_TIMEOUT_MAX;
}
}
- void setInterval(uint16_t newInterval) {_interval = newInterval;}
- void setWindow(uint16_t newWindow) {_window = newWindow; }
- void setTimeout(uint16_t newTimeout) {_timeout = newTimeout; }
+ ble_error_t setInterval(uint16_t newInterval) {
+ if ((newInterval >= SCAN_INTERVAL_MIN) && (newInterval < SCAN_INTERVAL_MAX)) {
+ _interval = newInterval;
+ return BLE_ERROR_NONE;
+ }
+
+ return BLE_ERROR_PARAM_OUT_OF_RANGE;
+ }
+
+ ble_error_t setWindow(uint16_t newWindow) {
+ if ((newWindow >= SCAN_WINDOW_MIN) && (newWindow < SCAN_WINDOW_MAX)) {
+ _window = newWindow;
+ return BLE_ERROR_NONE;
+ }
+
+ return BLE_ERROR_PARAM_OUT_OF_RANGE;
+ }
+
+ ble_error_t setTimeout(uint16_t newTimeout) {
+ if (newTimeout <= SCAN_TIMEOUT_MAX) {
+ _timeout = newTimeout;
+ return BLE_ERROR_NONE;
+ }
+
+ return BLE_ERROR_PARAM_OUT_OF_RANGE;
+ }
uint16_t getInterval(void) const {return _interval;}
uint16_t getWindow(void) const {return _window; }
