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
Diff: public/GapAdvertisingParams.h
- Revision:
- 329:2e082a9c7c13
- Parent:
- 260:ea7f9f14cc15
- Child:
- 408:388570b048a7
diff -r 1fd12f67ed7a -r 2e082a9c7c13 public/GapAdvertisingParams.h
--- a/public/GapAdvertisingParams.h Wed Apr 15 09:05:09 2015 +0100
+++ b/public/GapAdvertisingParams.h Wed Apr 15 09:05:10 2015 +0100
@@ -62,8 +62,37 @@
public:
GapAdvertisingParams(AdvertisingType advType = GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED,
uint16_t interval = GAP_ADV_PARAMS_INTERVAL_MIN_NONCON,
- uint16_t timeout = 0);
- virtual ~GapAdvertisingParams(void);
+ uint16_t timeout = 0) : _advType(advType), _interval(interval), _timeout(timeout) {
+ /* Interval checks */
+ if (_advType == ADV_CONNECTABLE_DIRECTED) {
+ /* Interval must be 0 in directed connectable mode */
+ _interval = 0;
+ } else if (_advType == ADV_NON_CONNECTABLE_UNDIRECTED) {
+ /* Min interval is slightly larger than in other modes */
+ if (_interval < GAP_ADV_PARAMS_INTERVAL_MIN_NONCON) {
+ _interval = GAP_ADV_PARAMS_INTERVAL_MIN_NONCON;
+ }
+ if (_interval > GAP_ADV_PARAMS_INTERVAL_MAX) {
+ _interval = GAP_ADV_PARAMS_INTERVAL_MAX;
+ }
+ } else {
+ /* Stay within interval limits */
+ if (_interval < GAP_ADV_PARAMS_INTERVAL_MIN) {
+ _interval = GAP_ADV_PARAMS_INTERVAL_MIN;
+ }
+ if (_interval > GAP_ADV_PARAMS_INTERVAL_MAX) {
+ _interval = GAP_ADV_PARAMS_INTERVAL_MAX;
+ }
+ }
+
+ /* Timeout checks */
+ if (timeout) {
+ /* Stay within timeout limits */
+ if (_timeout > GAP_ADV_PARAMS_TIMEOUT_MAX) {
+ _timeout = GAP_ADV_PARAMS_TIMEOUT_MAX;
+ }
+ }
+ }
AdvertisingType getAdvertisingType(void) const {return _advType; }
uint16_t getInterval(void) const {return _interval;}
