WallbotBLE default code

Dependencies:   mbed

Fork of BLE_WallbotBLE_Challenge by Wallbot BLE Developer

Committer:
jksoft
Date:
Fri Feb 20 00:07:48 2015 +0000
Revision:
2:3c406d25860e
Parent:
0:76dfa9657d9d
Wallbot BLE??????????

Who changed what in which revision?

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