Improve readability with getHandle inline
Fork of BLE_API by
public/GapAdvertisingParams.h@139:baaf1c5f0db2, 2014-11-21 (annotated)
- Committer:
- rgrover1
- Date:
- Fri Nov 21 09:23:24 2014 +0000
- Revision:
- 139:baaf1c5f0db2
- Parent:
- 135:6cf6e7bd21c9
- Child:
- 140:407d134c179d
Synchronized with git rev d93ad344
Author: Rohit Grover
Merge pull request #5 from xiongyihui/master
make the library less dependent on the mbed.h header
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 | |
rgrover1 | 139:baaf1c5f0db2 | 22 | #define GAP_ADV_PARAMS_INTERVAL_MIN (0x0020) |
rgrover1 | 139:baaf1c5f0db2 | 23 | #define GAP_ADV_PARAMS_INTERVAL_MIN_NONCON (0x00A0) |
rgrover1 | 139:baaf1c5f0db2 | 24 | #define GAP_ADV_PARAMS_INTERVAL_MAX (0x1000) |
rgrover1 | 139:baaf1c5f0db2 | 25 | #define GAP_ADV_PARAMS_TIMEOUT_MAX (0x3FFF) |
rgrover1 | 139:baaf1c5f0db2 | 26 | |
Rohit Grover |
106:a20be740075d | 27 | /**************************************************************************/ |
Rohit Grover |
106:a20be740075d | 28 | /*! |
Rohit Grover |
106:a20be740075d | 29 | \brief |
Rohit Grover |
106:a20be740075d | 30 | This class provides a wrapper for the core advertising parameters, |
Rohit Grover |
106:a20be740075d | 31 | including the advertising type (Connectable Undirected, |
Rohit Grover |
106:a20be740075d | 32 | Non Connectable Undirected, etc.), as well as the advertising and |
Rohit Grover |
106:a20be740075d | 33 | timeout intervals. |
Rohit Grover |
106:a20be740075d | 34 | |
Rohit Grover |
106:a20be740075d | 35 | \par |
Rohit Grover |
106:a20be740075d | 36 | See the following for more information on advertising types: |
Rohit Grover |
106:a20be740075d | 37 | |
Rohit Grover |
106:a20be740075d | 38 | \li \c Bluetooth Core Specification 4.0 (Vol. 6), Part B, Section 2.3.1 |
Rohit Grover |
106:a20be740075d | 39 | \li \c Bluetooth Core Specification 4.0 (Vol. 3), Part C, Section 9.3 |
Rohit Grover |
106:a20be740075d | 40 | |
Rohit Grover |
106:a20be740075d | 41 | \par EXAMPLE |
Rohit Grover |
106:a20be740075d | 42 | |
Rohit Grover |
106:a20be740075d | 43 | \code |
Rohit Grover |
106:a20be740075d | 44 | |
Rohit Grover |
106:a20be740075d | 45 | // ToDo |
Rohit Grover |
106:a20be740075d | 46 | |
Rohit Grover |
106:a20be740075d | 47 | \endcode |
Rohit Grover |
106:a20be740075d | 48 | */ |
Rohit Grover |
106:a20be740075d | 49 | /**************************************************************************/ |
Rohit Grover |
106:a20be740075d | 50 | class GapAdvertisingParams |
Rohit Grover |
106:a20be740075d | 51 | { |
Rohit Grover |
106:a20be740075d | 52 | public: |
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 | |
Rohit Grover |
116:ca826083980e | 73 | GapAdvertisingParams(AdvertisingType advType = GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED, |
Rohit Grover |
116:ca826083980e | 74 | uint16_t interval = GAP_ADV_PARAMS_INTERVAL_MIN_NONCON, |
Rohit Grover |
106:a20be740075d | 75 | uint16_t timeout = 0); |
Rohit Grover |
106:a20be740075d | 76 | virtual ~GapAdvertisingParams(void); |
Rohit Grover |
106:a20be740075d | 77 | |
Rohit Grover |
106:a20be740075d | 78 | void setAdvertisingType(AdvertisingType newAdvType); |
Rohit Grover |
106:a20be740075d | 79 | void setInterval(uint16_t newInterval); |
Rohit Grover |
106:a20be740075d | 80 | void setTimeout(uint16_t newTimeout); |
Rohit Grover |
106:a20be740075d | 81 | |
Rohit Grover |
106:a20be740075d | 82 | virtual AdvertisingType getAdvertisingType(void) const; |
Rohit Grover |
106:a20be740075d | 83 | virtual uint16_t getInterval(void) const; |
Rohit Grover |
106:a20be740075d | 84 | virtual uint16_t getTimeout(void) const; |
Rohit Grover |
106:a20be740075d | 85 | |
Rohit Grover |
106:a20be740075d | 86 | private: |
Rohit Grover |
106:a20be740075d | 87 | AdvertisingType _advType; |
Rohit Grover |
106:a20be740075d | 88 | uint16_t _interval; |
Rohit Grover |
106:a20be740075d | 89 | uint16_t _timeout; |
Rohit Grover |
106:a20be740075d | 90 | }; |
Rohit Grover |
106:a20be740075d | 91 | |
Rohit Grover |
106:a20be740075d | 92 | inline void |
Rohit Grover |
106:a20be740075d | 93 | GapAdvertisingParams::setAdvertisingType(AdvertisingType newAdvType) { |
Rohit Grover |
106:a20be740075d | 94 | _advType = newAdvType; |
Rohit Grover |
106:a20be740075d | 95 | } |
Rohit Grover |
106:a20be740075d | 96 | |
Rohit Grover |
106:a20be740075d | 97 | inline void |
Rohit Grover |
106:a20be740075d | 98 | GapAdvertisingParams::setInterval(uint16_t newInterval) { |
Rohit Grover |
106:a20be740075d | 99 | _interval = newInterval; |
Rohit Grover |
106:a20be740075d | 100 | } |
Rohit Grover |
106:a20be740075d | 101 | |
Rohit Grover |
106:a20be740075d | 102 | inline void |
Rohit Grover |
106:a20be740075d | 103 | GapAdvertisingParams::setTimeout(uint16_t newTimeout) { |
Rohit Grover |
106:a20be740075d | 104 | _timeout = newTimeout; |
Rohit Grover |
106:a20be740075d | 105 | } |
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 | \brief returns the current Advertising Type value |
Rohit Grover |
106:a20be740075d | 111 | */ |
Rohit Grover |
106:a20be740075d | 112 | /**************************************************************************/ |
Rohit Grover |
106:a20be740075d | 113 | inline GapAdvertisingParams::AdvertisingType |
Rohit Grover |
106:a20be740075d | 114 | GapAdvertisingParams::getAdvertisingType(void) const |
Rohit Grover |
106:a20be740075d | 115 | { |
Rohit Grover |
106:a20be740075d | 116 | return _advType; |
Rohit Grover |
106:a20be740075d | 117 | } |
Rohit Grover |
106:a20be740075d | 118 | |
Rohit Grover |
106:a20be740075d | 119 | /**************************************************************************/ |
Rohit Grover |
106:a20be740075d | 120 | /*! |
Rohit Grover |
106:a20be740075d | 121 | \brief returns the current Advertising Delay (in units of 0.625ms) |
Rohit Grover |
106:a20be740075d | 122 | */ |
Rohit Grover |
106:a20be740075d | 123 | /**************************************************************************/ |
Rohit Grover |
106:a20be740075d | 124 | inline uint16_t |
Rohit Grover |
106:a20be740075d | 125 | GapAdvertisingParams::getInterval(void) const |
Rohit Grover |
106:a20be740075d | 126 | { |
Rohit Grover |
106:a20be740075d | 127 | return _interval; |
Rohit Grover |
106:a20be740075d | 128 | } |
Rohit Grover |
106:a20be740075d | 129 | |
Rohit Grover |
106:a20be740075d | 130 | /**************************************************************************/ |
Rohit Grover |
106:a20be740075d | 131 | /*! |
Rohit Grover |
106:a20be740075d | 132 | \brief returns the current Advertising Timeout (in seconds) |
Rohit Grover |
106:a20be740075d | 133 | */ |
Rohit Grover |
106:a20be740075d | 134 | /**************************************************************************/ |
Rohit Grover |
106:a20be740075d | 135 | inline uint16_t |
Rohit Grover |
106:a20be740075d | 136 | GapAdvertisingParams::getTimeout(void) const |
Rohit Grover |
106:a20be740075d | 137 | { |
Rohit Grover |
106:a20be740075d | 138 | return _timeout; |
Rohit Grover |
106:a20be740075d | 139 | } |
Rohit Grover |
106:a20be740075d | 140 | |
rgrover1 | 124:acf0d0c49867 | 141 | #endif // ifndef __GAP_ADVERTISING_PARAMS_H__ |