Lightly modified version of the BLE stack, that doesn't bring up a DFUService by default... as we have our own.

Fork of BLE_API by Bluetooth Low Energy

Committer:
Rohit Grover
Date:
Wed Jul 23 15:09:23 2014 +0100
Revision:
106:a20be740075d
Child:
116:ca826083980e
initial re-organization of BLE_API directory structure

Who changed what in which revision?

UserRevisionLine numberNew 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 #define GAP_ADV_PARAMS_INTERVAL_MIN (0x0020)
Rohit Grover 106:a20be740075d 23 #define GAP_ADV_PARAMS_INTERVAL_MIN_NONCON (0x00A0)
Rohit Grover 106:a20be740075d 24 #define GAP_ADV_PARAMS_INTERVAL_MAX (0x1000)
Rohit Grover 106:a20be740075d 25 #define GAP_ADV_PARAMS_TIMEOUT_MAX (0x3FFF)
Rohit Grover 106:a20be740075d 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 106:a20be740075d 66 enum AdvertisingType
Rohit Grover 106:a20be740075d 67 {
Rohit Grover 106:a20be740075d 68 ADV_CONNECTABLE_UNDIRECTED, /**< Vol 3, Part C, Section 9.3.4 and
Rohit Grover 106:a20be740075d 69 *Vol 6, Part B, Section 2.3.1.1 */
Rohit Grover 106:a20be740075d 70 ADV_CONNECTABLE_DIRECTED, /**< Vol 3, Part C, Section 9.3.3 and
Rohit Grover 106:a20be740075d 71 *Vol 6, Part B, Section 2.3.1.2 */
Rohit Grover 106:a20be740075d 72 ADV_SCANNABLE_UNDIRECTED, /**< Include support for Scan Response
Rohit Grover 106:a20be740075d 73 *payloads, see Vol 6, Part B, Section
Rohit Grover 106:a20be740075d 74 *2.3.1.4 */
Rohit Grover 106:a20be740075d 75 ADV_NON_CONNECTABLE_UNDIRECTED /**< Vol 3, Part C, Section 9.3.2 and
Rohit Grover 106:a20be740075d 76 *Vol 6, Part B, Section 2.3.1.3 */
Rohit Grover 106:a20be740075d 77 };
Rohit Grover 106:a20be740075d 78
Rohit Grover 106:a20be740075d 79 GapAdvertisingParams(AdvertisingType advType =
Rohit Grover 106:a20be740075d 80 GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED,
Rohit Grover 106:a20be740075d 81 uint16_t interval =
Rohit Grover 106:a20be740075d 82 GAP_ADV_PARAMS_INTERVAL_MIN_NONCON,
Rohit Grover 106:a20be740075d 83 uint16_t timeout = 0);
Rohit Grover 106:a20be740075d 84 virtual ~GapAdvertisingParams(void);
Rohit Grover 106:a20be740075d 85
Rohit Grover 106:a20be740075d 86 void setAdvertisingType(AdvertisingType newAdvType);
Rohit Grover 106:a20be740075d 87 void setInterval(uint16_t newInterval);
Rohit Grover 106:a20be740075d 88 void setTimeout(uint16_t newTimeout);
Rohit Grover 106:a20be740075d 89
Rohit Grover 106:a20be740075d 90 virtual AdvertisingType getAdvertisingType(void) const;
Rohit Grover 106:a20be740075d 91 virtual uint16_t getInterval(void) const;
Rohit Grover 106:a20be740075d 92 virtual uint16_t getTimeout(void) const;
Rohit Grover 106:a20be740075d 93
Rohit Grover 106:a20be740075d 94 private:
Rohit Grover 106:a20be740075d 95 AdvertisingType _advType;
Rohit Grover 106:a20be740075d 96 uint16_t _interval;
Rohit Grover 106:a20be740075d 97 uint16_t _timeout;
Rohit Grover 106:a20be740075d 98 };
Rohit Grover 106:a20be740075d 99
Rohit Grover 106:a20be740075d 100 inline void
Rohit Grover 106:a20be740075d 101 GapAdvertisingParams::setAdvertisingType(AdvertisingType newAdvType) {
Rohit Grover 106:a20be740075d 102 _advType = newAdvType;
Rohit Grover 106:a20be740075d 103 }
Rohit Grover 106:a20be740075d 104
Rohit Grover 106:a20be740075d 105 inline void
Rohit Grover 106:a20be740075d 106 GapAdvertisingParams::setInterval(uint16_t newInterval) {
Rohit Grover 106:a20be740075d 107 _interval = newInterval;
Rohit Grover 106:a20be740075d 108 }
Rohit Grover 106:a20be740075d 109
Rohit Grover 106:a20be740075d 110 inline void
Rohit Grover 106:a20be740075d 111 GapAdvertisingParams::setTimeout(uint16_t newTimeout) {
Rohit Grover 106:a20be740075d 112 _timeout = newTimeout;
Rohit Grover 106:a20be740075d 113 }
Rohit Grover 106:a20be740075d 114
Rohit Grover 106:a20be740075d 115
Rohit Grover 106:a20be740075d 116 /**************************************************************************/
Rohit Grover 106:a20be740075d 117 /*!
Rohit Grover 106:a20be740075d 118 \brief returns the current Advertising Type value
Rohit Grover 106:a20be740075d 119 */
Rohit Grover 106:a20be740075d 120 /**************************************************************************/
Rohit Grover 106:a20be740075d 121 inline GapAdvertisingParams::AdvertisingType
Rohit Grover 106:a20be740075d 122 GapAdvertisingParams::getAdvertisingType(void) const
Rohit Grover 106:a20be740075d 123 {
Rohit Grover 106:a20be740075d 124 return _advType;
Rohit Grover 106:a20be740075d 125 }
Rohit Grover 106:a20be740075d 126
Rohit Grover 106:a20be740075d 127 /**************************************************************************/
Rohit Grover 106:a20be740075d 128 /*!
Rohit Grover 106:a20be740075d 129 \brief returns the current Advertising Delay (in units of 0.625ms)
Rohit Grover 106:a20be740075d 130 */
Rohit Grover 106:a20be740075d 131 /**************************************************************************/
Rohit Grover 106:a20be740075d 132 inline uint16_t
Rohit Grover 106:a20be740075d 133 GapAdvertisingParams::getInterval(void) const
Rohit Grover 106:a20be740075d 134 {
Rohit Grover 106:a20be740075d 135 return _interval;
Rohit Grover 106:a20be740075d 136 }
Rohit Grover 106:a20be740075d 137
Rohit Grover 106:a20be740075d 138 /**************************************************************************/
Rohit Grover 106:a20be740075d 139 /*!
Rohit Grover 106:a20be740075d 140 \brief returns the current Advertising Timeout (in seconds)
Rohit Grover 106:a20be740075d 141 */
Rohit Grover 106:a20be740075d 142 /**************************************************************************/
Rohit Grover 106:a20be740075d 143 inline uint16_t
Rohit Grover 106:a20be740075d 144 GapAdvertisingParams::getTimeout(void) const
Rohit Grover 106:a20be740075d 145 {
Rohit Grover 106:a20be740075d 146 return _timeout;
Rohit Grover 106:a20be740075d 147 }
Rohit Grover 106:a20be740075d 148
Rohit Grover 106:a20be740075d 149
Rohit Grover 106:a20be740075d 150 #endif // ifndef __GAP_ADVERTISING_PARAMS_H__