Lightly modified version of the BLE stack, that doesn't bring up a DFUService by default... as we have our own.
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; }