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