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