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