Improve readability with getHandle inline
Fork of BLE_API by
public/GapAdvertisingParams.h@124:acf0d0c49867, 2014-11-21 (annotated)
- Committer:
- rgrover1
- Date:
- Fri Nov 21 09:23:21 2014 +0000
- Revision:
- 124:acf0d0c49867
- Parent:
- 116:ca826083980e
- Child:
- 125:aae3f50670c9
Synchronized with git rev 252d056d
Author: Rohit Grover
increasing GAP_ADV_PARAMS_INTERVAL_MAX to 0x4000
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Rohit Grover |
106:a20be740075d | 1 | /* mbed Microcontroller Library |
Rohit Grover |
106:a20be740075d | 2 | * Copyright (c) 2006-2013 ARM Limited |
Rohit Grover |
106:a20be740075d | 3 | * |
Rohit Grover |
106:a20be740075d | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
Rohit Grover |
106:a20be740075d | 5 | * you may not use this file except in compliance with the License. |
Rohit Grover |
106:a20be740075d | 6 | * You may obtain a copy of the License at |
Rohit Grover |
106:a20be740075d | 7 | * |
Rohit Grover |
106:a20be740075d | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Rohit Grover |
106:a20be740075d | 9 | * |
Rohit Grover |
106:a20be740075d | 10 | * Unless required by applicable law or agreed to in writing, software |
Rohit Grover |
106:a20be740075d | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
Rohit Grover |
106:a20be740075d | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Rohit Grover |
106:a20be740075d | 13 | * See the License for the specific language governing permissions and |
Rohit Grover |
106:a20be740075d | 14 | * limitations under the License. |
Rohit Grover |
106:a20be740075d | 15 | */ |
Rohit Grover |
106:a20be740075d | 16 | |
Rohit Grover |
106:a20be740075d | 17 | #ifndef __GAP_ADVERTISING_PARAMS_H__ |
Rohit Grover |
106:a20be740075d | 18 | #define __GAP_ADVERTISING_PARAMS_H__ |
Rohit Grover |
106:a20be740075d | 19 | |
Rohit Grover |
106:a20be740075d | 20 | #include "blecommon.h" |
Rohit Grover |
106:a20be740075d | 21 | |
Rohit Grover |
106:a20be740075d | 22 | /**************************************************************************/ |
Rohit Grover |
106:a20be740075d | 23 | /*! |
Rohit Grover |
106:a20be740075d | 24 | \brief |
Rohit Grover |
106:a20be740075d | 25 | This class provides a wrapper for the core advertising parameters, |
Rohit Grover |
106:a20be740075d | 26 | including the advertising type (Connectable Undirected, |
Rohit Grover |
106:a20be740075d | 27 | Non Connectable Undirected, etc.), as well as the advertising and |
Rohit Grover |
106:a20be740075d | 28 | timeout intervals. |
Rohit Grover |
106:a20be740075d | 29 | |
Rohit Grover |
106:a20be740075d | 30 | \par |
Rohit Grover |
106:a20be740075d | 31 | See the following for more information on advertising types: |
Rohit Grover |
106:a20be740075d | 32 | |
Rohit Grover |
106:a20be740075d | 33 | \li \c Bluetooth Core Specification 4.0 (Vol. 6), Part B, Section 2.3.1 |
Rohit Grover |
106:a20be740075d | 34 | \li \c Bluetooth Core Specification 4.0 (Vol. 3), Part C, Section 9.3 |
Rohit Grover |
106:a20be740075d | 35 | |
Rohit Grover |
106:a20be740075d | 36 | \par EXAMPLE |
Rohit Grover |
106:a20be740075d | 37 | |
Rohit Grover |
106:a20be740075d | 38 | \code |
Rohit Grover |
106:a20be740075d | 39 | |
Rohit Grover |
106:a20be740075d | 40 | // ToDo |
Rohit Grover |
106:a20be740075d | 41 | |
Rohit Grover |
106:a20be740075d | 42 | \endcode |
Rohit Grover |
106:a20be740075d | 43 | */ |
Rohit Grover |
106:a20be740075d | 44 | /**************************************************************************/ |
Rohit Grover |
106:a20be740075d | 45 | class GapAdvertisingParams |
Rohit Grover |
106:a20be740075d | 46 | { |
Rohit Grover |
106:a20be740075d | 47 | public: |
rgrover1 | 124:acf0d0c49867 | 48 | static const unsigned GAP_ADV_PARAMS_INTERVAL_MIN = 0x0020; |
rgrover1 | 124:acf0d0c49867 | 49 | static const unsigned GAP_ADV_PARAMS_INTERVAL_MIN_NONCON = 0x00A0; |
rgrover1 | 124:acf0d0c49867 | 50 | static const unsigned GAP_ADV_PARAMS_INTERVAL_MAX = 0x4000; |
rgrover1 | 124:acf0d0c49867 | 51 | static const unsigned GAP_ADV_PARAMS_TIMEOUT_MAX = 0x3FFF; |
rgrover1 | 124:acf0d0c49867 | 52 | |
Rohit Grover |
106:a20be740075d | 53 | /**************************************************************************/ |
Rohit Grover |
106:a20be740075d | 54 | /*! |
Rohit Grover |
106:a20be740075d | 55 | \brief |
Rohit Grover |
106:a20be740075d | 56 | Encapsulates the peripheral advertising modes, which determine how |
Rohit Grover |
106:a20be740075d | 57 | the device appears to other central devices in hearing range |
Rohit Grover |
106:a20be740075d | 58 | |
Rohit Grover |
106:a20be740075d | 59 | \par |
Rohit Grover |
106:a20be740075d | 60 | See the following for more information on advertising types: |
Rohit Grover |
106:a20be740075d | 61 | |
Rohit Grover |
106:a20be740075d | 62 | \li \c Bluetooth Core Specification 4.0 (Vol. 6), Part B, Section 2.3.1 |
Rohit Grover |
106:a20be740075d | 63 | \li \c Bluetooth Core Specification 4.0 (Vol. 3), Part C, Section 9.3 |
Rohit Grover |
106:a20be740075d | 64 | */ |
Rohit Grover |
106:a20be740075d | 65 | /**************************************************************************/ |
Rohit Grover |
116:ca826083980e | 66 | enum AdvertisingType { |
Rohit Grover |
116:ca826083980e | 67 | ADV_CONNECTABLE_UNDIRECTED, /**< Vol 3, Part C, Section 9.3.4 and Vol 6, Part B, Section 2.3.1.1 */ |
Rohit Grover |
116:ca826083980e | 68 | ADV_CONNECTABLE_DIRECTED, /**< Vol 3, Part C, Section 9.3.3 and Vol 6, Part B, Section 2.3.1.2 */ |
Rohit Grover |
116:ca826083980e | 69 | ADV_SCANNABLE_UNDIRECTED, /**< Include support for Scan Response payloads, see Vol 6, Part B, Section 2.3.1.4 */ |
Rohit Grover |
116:ca826083980e | 70 | ADV_NON_CONNECTABLE_UNDIRECTED /**< Vol 3, Part C, Section 9.3.2 and Vol 6, Part B, Section 2.3.1.3 */ |
Rohit Grover |
106:a20be740075d | 71 | }; |
Rohit Grover |
106:a20be740075d | 72 | |
rgrover1 | 124:acf0d0c49867 | 73 | public: |
Rohit Grover |
116:ca826083980e | 74 | GapAdvertisingParams(AdvertisingType advType = GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED, |
Rohit Grover |
116:ca826083980e | 75 | uint16_t interval = GAP_ADV_PARAMS_INTERVAL_MIN_NONCON, |
Rohit Grover |
106:a20be740075d | 76 | uint16_t timeout = 0); |
Rohit Grover |
106:a20be740075d | 77 | virtual ~GapAdvertisingParams(void); |
Rohit Grover |
106:a20be740075d | 78 | |
Rohit Grover |
106:a20be740075d | 79 | void setAdvertisingType(AdvertisingType newAdvType); |
Rohit Grover |
106:a20be740075d | 80 | void setInterval(uint16_t newInterval); |
Rohit Grover |
106:a20be740075d | 81 | void setTimeout(uint16_t newTimeout); |
Rohit Grover |
106:a20be740075d | 82 | |
Rohit Grover |
106:a20be740075d | 83 | virtual AdvertisingType getAdvertisingType(void) const; |
Rohit Grover |
106:a20be740075d | 84 | virtual uint16_t getInterval(void) const; |
Rohit Grover |
106:a20be740075d | 85 | virtual uint16_t getTimeout(void) const; |
Rohit Grover |
106:a20be740075d | 86 | |
Rohit Grover |
106:a20be740075d | 87 | private: |
Rohit Grover |
106:a20be740075d | 88 | AdvertisingType _advType; |
Rohit Grover |
106:a20be740075d | 89 | uint16_t _interval; |
Rohit Grover |
106:a20be740075d | 90 | uint16_t _timeout; |
Rohit Grover |
106:a20be740075d | 91 | }; |
Rohit Grover |
106:a20be740075d | 92 | |
Rohit Grover |
106:a20be740075d | 93 | inline void |
Rohit Grover |
106:a20be740075d | 94 | GapAdvertisingParams::setAdvertisingType(AdvertisingType newAdvType) { |
Rohit Grover |
106:a20be740075d | 95 | _advType = newAdvType; |
Rohit Grover |
106:a20be740075d | 96 | } |
Rohit Grover |
106:a20be740075d | 97 | |
Rohit Grover |
106:a20be740075d | 98 | inline void |
Rohit Grover |
106:a20be740075d | 99 | GapAdvertisingParams::setInterval(uint16_t newInterval) { |
Rohit Grover |
106:a20be740075d | 100 | _interval = newInterval; |
Rohit Grover |
106:a20be740075d | 101 | } |
Rohit Grover |
106:a20be740075d | 102 | |
Rohit Grover |
106:a20be740075d | 103 | inline void |
Rohit Grover |
106:a20be740075d | 104 | GapAdvertisingParams::setTimeout(uint16_t newTimeout) { |
Rohit Grover |
106:a20be740075d | 105 | _timeout = newTimeout; |
Rohit Grover |
106:a20be740075d | 106 | } |
Rohit Grover |
106:a20be740075d | 107 | |
Rohit Grover |
106:a20be740075d | 108 | |
Rohit Grover |
106:a20be740075d | 109 | /**************************************************************************/ |
Rohit Grover |
106:a20be740075d | 110 | /*! |
Rohit Grover |
106:a20be740075d | 111 | \brief returns the current Advertising Type value |
Rohit Grover |
106:a20be740075d | 112 | */ |
Rohit Grover |
106:a20be740075d | 113 | /**************************************************************************/ |
Rohit Grover |
106:a20be740075d | 114 | inline GapAdvertisingParams::AdvertisingType |
Rohit Grover |
106:a20be740075d | 115 | GapAdvertisingParams::getAdvertisingType(void) const |
Rohit Grover |
106:a20be740075d | 116 | { |
Rohit Grover |
106:a20be740075d | 117 | return _advType; |
Rohit Grover |
106:a20be740075d | 118 | } |
Rohit Grover |
106:a20be740075d | 119 | |
Rohit Grover |
106:a20be740075d | 120 | /**************************************************************************/ |
Rohit Grover |
106:a20be740075d | 121 | /*! |
Rohit Grover |
106:a20be740075d | 122 | \brief returns the current Advertising Delay (in units of 0.625ms) |
Rohit Grover |
106:a20be740075d | 123 | */ |
Rohit Grover |
106:a20be740075d | 124 | /**************************************************************************/ |
Rohit Grover |
106:a20be740075d | 125 | inline uint16_t |
Rohit Grover |
106:a20be740075d | 126 | GapAdvertisingParams::getInterval(void) const |
Rohit Grover |
106:a20be740075d | 127 | { |
Rohit Grover |
106:a20be740075d | 128 | return _interval; |
Rohit Grover |
106:a20be740075d | 129 | } |
Rohit Grover |
106:a20be740075d | 130 | |
Rohit Grover |
106:a20be740075d | 131 | /**************************************************************************/ |
Rohit Grover |
106:a20be740075d | 132 | /*! |
Rohit Grover |
106:a20be740075d | 133 | \brief returns the current Advertising Timeout (in seconds) |
Rohit Grover |
106:a20be740075d | 134 | */ |
Rohit Grover |
106:a20be740075d | 135 | /**************************************************************************/ |
Rohit Grover |
106:a20be740075d | 136 | inline uint16_t |
Rohit Grover |
106:a20be740075d | 137 | GapAdvertisingParams::getTimeout(void) const |
Rohit Grover |
106:a20be740075d | 138 | { |
Rohit Grover |
106:a20be740075d | 139 | return _timeout; |
Rohit Grover |
106:a20be740075d | 140 | } |
Rohit Grover |
106:a20be740075d | 141 | |
rgrover1 | 124:acf0d0c49867 | 142 | #endif // ifndef __GAP_ADVERTISING_PARAMS_H__ |