BLE EddystoneService example
This example is a fork of the following mbed-os example:
https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-EddystoneService/
Please read the documentation in this page.
source/EddystoneService.h@0:4c8f8bf32a99, 2016-07-26 (annotated)
- Committer:
- Vincent Coubard
- Date:
- Tue Jul 26 14:40:25 2016 +0100
- Revision:
- 0:4c8f8bf32a99
- Child:
- 1:9db4d46bb63f
Update example at tag mbed-os-5.0.1-rc1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Vincent Coubard |
0:4c8f8bf32a99 | 1 | /* mbed Microcontroller Library |
Vincent Coubard |
0:4c8f8bf32a99 | 2 | * Copyright (c) 2006-2015 ARM Limited |
Vincent Coubard |
0:4c8f8bf32a99 | 3 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
Vincent Coubard |
0:4c8f8bf32a99 | 5 | * you may not use this file except in compliance with the License. |
Vincent Coubard |
0:4c8f8bf32a99 | 6 | * You may obtain a copy of the License at |
Vincent Coubard |
0:4c8f8bf32a99 | 7 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Vincent Coubard |
0:4c8f8bf32a99 | 9 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 10 | * Unless required by applicable law or agreed to in writing, software |
Vincent Coubard |
0:4c8f8bf32a99 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
Vincent Coubard |
0:4c8f8bf32a99 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Vincent Coubard |
0:4c8f8bf32a99 | 13 | * See the License for the specific language governing permissions and |
Vincent Coubard |
0:4c8f8bf32a99 | 14 | * limitations under the License. |
Vincent Coubard |
0:4c8f8bf32a99 | 15 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 16 | |
Vincent Coubard |
0:4c8f8bf32a99 | 17 | #ifndef __EDDYSTONESERVICE_H__ |
Vincent Coubard |
0:4c8f8bf32a99 | 18 | #define __EDDYSTONESERVICE_H__ |
Vincent Coubard |
0:4c8f8bf32a99 | 19 | |
Vincent Coubard |
0:4c8f8bf32a99 | 20 | #include <mbed-events/events.h> |
Vincent Coubard |
0:4c8f8bf32a99 | 21 | #include "ble/BLE.h" |
Vincent Coubard |
0:4c8f8bf32a99 | 22 | #include "EddystoneTypes.h" |
Vincent Coubard |
0:4c8f8bf32a99 | 23 | #include "URLFrame.h" |
Vincent Coubard |
0:4c8f8bf32a99 | 24 | #include "UIDFrame.h" |
Vincent Coubard |
0:4c8f8bf32a99 | 25 | #include "TLMFrame.h" |
Vincent Coubard |
0:4c8f8bf32a99 | 26 | #include <string.h> |
Vincent Coubard |
0:4c8f8bf32a99 | 27 | #ifdef YOTTA_CFG_MBED_OS |
Vincent Coubard |
0:4c8f8bf32a99 | 28 | #include <mbed.h> |
Vincent Coubard |
0:4c8f8bf32a99 | 29 | #include "mbed-drivers/CircularBuffer.h" |
Vincent Coubard |
0:4c8f8bf32a99 | 30 | #else |
Vincent Coubard |
0:4c8f8bf32a99 | 31 | #include "mbed.h" |
Vincent Coubard |
0:4c8f8bf32a99 | 32 | #include "CircularBuffer.h" |
Vincent Coubard |
0:4c8f8bf32a99 | 33 | #endif |
Vincent Coubard |
0:4c8f8bf32a99 | 34 | |
Vincent Coubard |
0:4c8f8bf32a99 | 35 | #ifndef YOTTA_CFG_EDDYSTONE_DEFAULT_URL_FRAME_INTERVAL |
Vincent Coubard |
0:4c8f8bf32a99 | 36 | #define YOTTA_CFG_EDDYSTONE_DEFAULT_URL_FRAME_INTERVAL 700 |
Vincent Coubard |
0:4c8f8bf32a99 | 37 | #endif |
Vincent Coubard |
0:4c8f8bf32a99 | 38 | |
Vincent Coubard |
0:4c8f8bf32a99 | 39 | #ifndef YOTTA_CFG_EDDYSTONE_DEFAULT_UID_FRAME_INTERVAL |
Vincent Coubard |
0:4c8f8bf32a99 | 40 | #define YOTTA_CFG_EDDYSTONE_DEFAULT_UID_FRAME_INTERVAL 300 |
Vincent Coubard |
0:4c8f8bf32a99 | 41 | #endif |
Vincent Coubard |
0:4c8f8bf32a99 | 42 | |
Vincent Coubard |
0:4c8f8bf32a99 | 43 | #ifndef YOTTA_CFG_EDDYSTONE_DEFAULT_TLM_FRAME_INTERVAL |
Vincent Coubard |
0:4c8f8bf32a99 | 44 | #define YOTTA_CFG_EDDYSTONE_DEFAULT_TLM_FRAME_INTERVAL 2000 |
Vincent Coubard |
0:4c8f8bf32a99 | 45 | #endif |
Vincent Coubard |
0:4c8f8bf32a99 | 46 | |
Vincent Coubard |
0:4c8f8bf32a99 | 47 | #ifndef YOTTA_CFG_EDDYSTONE_DEFAULT_EDDYSTONE_URL_CONFIG_ADV_INTERVAL |
Vincent Coubard |
0:4c8f8bf32a99 | 48 | #define YOTTA_CFG_EDDYSTONE_DEFAULT_EDDYSTONE_URL_CONFIG_ADV_INTERVAL 1000 |
Vincent Coubard |
0:4c8f8bf32a99 | 49 | #endif |
Vincent Coubard |
0:4c8f8bf32a99 | 50 | |
Vincent Coubard |
0:4c8f8bf32a99 | 51 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 52 | * This class implements the Eddystone-URL Config Service and the Eddystone |
Vincent Coubard |
0:4c8f8bf32a99 | 53 | * Protocol Specification as defined in the publicly available specification at |
Vincent Coubard |
0:4c8f8bf32a99 | 54 | * https://github.com/google/eddystone/blob/master/protocol-specification.md. |
Vincent Coubard |
0:4c8f8bf32a99 | 55 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 56 | class EddystoneService |
Vincent Coubard |
0:4c8f8bf32a99 | 57 | { |
Vincent Coubard |
0:4c8f8bf32a99 | 58 | public: |
Vincent Coubard |
0:4c8f8bf32a99 | 59 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 60 | * Total number of GATT Characteristics in the Eddystonei-URL Configuration |
Vincent Coubard |
0:4c8f8bf32a99 | 61 | * Service. |
Vincent Coubard |
0:4c8f8bf32a99 | 62 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 63 | static const uint16_t TOTAL_CHARACTERISTICS = 9; |
Vincent Coubard |
0:4c8f8bf32a99 | 64 | |
Vincent Coubard |
0:4c8f8bf32a99 | 65 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 66 | * Default interval for advertising packets for the Eddystone-URL |
Vincent Coubard |
0:4c8f8bf32a99 | 67 | * Configuration Service. |
Vincent Coubard |
0:4c8f8bf32a99 | 68 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 69 | static const uint32_t DEFAULT_CONFIG_PERIOD_MSEC = YOTTA_CFG_EDDYSTONE_DEFAULT_EDDYSTONE_URL_CONFIG_ADV_INTERVAL; |
Vincent Coubard |
0:4c8f8bf32a99 | 70 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 71 | * Recommended interval for advertising packets containing Eddystone URL |
Vincent Coubard |
0:4c8f8bf32a99 | 72 | * frames. |
Vincent Coubard |
0:4c8f8bf32a99 | 73 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 74 | static const uint16_t DEFAULT_URL_FRAME_PERIOD_MSEC = YOTTA_CFG_EDDYSTONE_DEFAULT_URL_FRAME_INTERVAL; |
Vincent Coubard |
0:4c8f8bf32a99 | 75 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 76 | * Recommended interval for advertising packets containing Eddystone UID |
Vincent Coubard |
0:4c8f8bf32a99 | 77 | * frames. |
Vincent Coubard |
0:4c8f8bf32a99 | 78 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 79 | static const uint16_t DEFAULT_UID_FRAME_PERIOD_MSEC = YOTTA_CFG_EDDYSTONE_DEFAULT_UID_FRAME_INTERVAL; |
Vincent Coubard |
0:4c8f8bf32a99 | 80 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 81 | * Recommended interval for advertising packets containing Eddystone TLM |
Vincent Coubard |
0:4c8f8bf32a99 | 82 | * frames. |
Vincent Coubard |
0:4c8f8bf32a99 | 83 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 84 | static const uint16_t DEFAULT_TLM_FRAME_PERIOD_MSEC = YOTTA_CFG_EDDYSTONE_DEFAULT_TLM_FRAME_INTERVAL; |
Vincent Coubard |
0:4c8f8bf32a99 | 85 | |
Vincent Coubard |
0:4c8f8bf32a99 | 86 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 87 | * Enumeration that defines the various operation modes of the |
Vincent Coubard |
0:4c8f8bf32a99 | 88 | * EddystoneService. |
Vincent Coubard |
0:4c8f8bf32a99 | 89 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 90 | * @note The main app can change the mode of EddystoneService at any point |
Vincent Coubard |
0:4c8f8bf32a99 | 91 | * of time by calling startConfigService() or startBeaconService(). |
Vincent Coubard |
0:4c8f8bf32a99 | 92 | * Resources from the previous mode will be freed. |
Vincent Coubard |
0:4c8f8bf32a99 | 93 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 94 | * @note It is currently NOT possible to force EddystoneService back into |
Vincent Coubard |
0:4c8f8bf32a99 | 95 | * EDDYSTONE_MODE_NONE. |
Vincent Coubard |
0:4c8f8bf32a99 | 96 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 97 | enum OperationModes { |
Vincent Coubard |
0:4c8f8bf32a99 | 98 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 99 | * NONE: EddystoneService has been initialized but no memory has been |
Vincent Coubard |
0:4c8f8bf32a99 | 100 | * dynamically allocated. Additionally, no services are running |
Vincent Coubard |
0:4c8f8bf32a99 | 101 | * nothing is being advertised. |
Vincent Coubard |
0:4c8f8bf32a99 | 102 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 103 | EDDYSTONE_MODE_NONE, |
Vincent Coubard |
0:4c8f8bf32a99 | 104 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 105 | * CONFIG: EddystoneService has been initialized, the configuration |
Vincent Coubard |
0:4c8f8bf32a99 | 106 | * service started and memory has been allocated for BLE |
Vincent Coubard |
0:4c8f8bf32a99 | 107 | * characteristics. Memory consumption peaks during CONFIG |
Vincent Coubard |
0:4c8f8bf32a99 | 108 | * mode. |
Vincent Coubard |
0:4c8f8bf32a99 | 109 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 110 | EDDYSTONE_MODE_CONFIG, |
Vincent Coubard |
0:4c8f8bf32a99 | 111 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 112 | * BEACON: Eddystone service is running as a beacon advertising URL, |
Vincent Coubard |
0:4c8f8bf32a99 | 113 | * UID and/or TLM frames depending on how it is configured. |
Vincent Coubard |
0:4c8f8bf32a99 | 114 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 115 | EDDYSTONE_MODE_BEACON |
Vincent Coubard |
0:4c8f8bf32a99 | 116 | }; |
Vincent Coubard |
0:4c8f8bf32a99 | 117 | |
Vincent Coubard |
0:4c8f8bf32a99 | 118 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 119 | * Structure that encapsulates the Eddystone configuration parameters. This |
Vincent Coubard |
0:4c8f8bf32a99 | 120 | * structure is particularly useful when storing the parameters to |
Vincent Coubard |
0:4c8f8bf32a99 | 121 | * persistent storage. |
Vincent Coubard |
0:4c8f8bf32a99 | 122 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 123 | struct EddystoneParams_t { |
Vincent Coubard |
0:4c8f8bf32a99 | 124 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 125 | * The value of the Eddystone-URL Configuration Service Lock State |
Vincent Coubard |
0:4c8f8bf32a99 | 126 | * characteristic. |
Vincent Coubard |
0:4c8f8bf32a99 | 127 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 128 | bool lockState; |
Vincent Coubard |
0:4c8f8bf32a99 | 129 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 130 | * The value of the Eddystone-URL Configuration Service Lock |
Vincent Coubard |
0:4c8f8bf32a99 | 131 | * characteristic that can be used to lock the beacon and set the |
Vincent Coubard |
0:4c8f8bf32a99 | 132 | * single-use lock-code. |
Vincent Coubard |
0:4c8f8bf32a99 | 133 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 134 | Lock_t lock; |
Vincent Coubard |
0:4c8f8bf32a99 | 135 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 136 | * The value of the Eddystone-URL Configuration Service Unlock |
Vincent Coubard |
0:4c8f8bf32a99 | 137 | * characteristic that can be used to unlock the beacon and clear the |
Vincent Coubard |
0:4c8f8bf32a99 | 138 | * single-use lock-code. |
Vincent Coubard |
0:4c8f8bf32a99 | 139 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 140 | Lock_t unlock; |
Vincent Coubard |
0:4c8f8bf32a99 | 141 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 142 | * The value of the Eddystone-URL Configuration Service Flags |
Vincent Coubard |
0:4c8f8bf32a99 | 143 | * characteristic. This value is currently fixed to 0x10. |
Vincent Coubard |
0:4c8f8bf32a99 | 144 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 145 | uint8_t flags; |
Vincent Coubard |
0:4c8f8bf32a99 | 146 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 147 | * The value of the Eddystone-URL Configuration Service Advertised TX |
Vincent Coubard |
0:4c8f8bf32a99 | 148 | * Power Levels characteristic that is an array of bytes whose values |
Vincent Coubard |
0:4c8f8bf32a99 | 149 | * are put into the advertising packets when in EDDYSTONE_BEACON_MODE. |
Vincent Coubard |
0:4c8f8bf32a99 | 150 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 151 | * @note These are not the same values set internally into the radio tx |
Vincent Coubard |
0:4c8f8bf32a99 | 152 | * power. |
Vincent Coubard |
0:4c8f8bf32a99 | 153 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 154 | PowerLevels_t advPowerLevels; |
Vincent Coubard |
0:4c8f8bf32a99 | 155 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 156 | * The value of the Eddystone-URL Configuration Service TX Power Mode |
Vincent Coubard |
0:4c8f8bf32a99 | 157 | * characteristic. This value is an index into the |
Vincent Coubard |
0:4c8f8bf32a99 | 158 | * EddystoneParams_t::advPowerLevels array. |
Vincent Coubard |
0:4c8f8bf32a99 | 159 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 160 | uint8_t txPowerMode; |
Vincent Coubard |
0:4c8f8bf32a99 | 161 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 162 | * The value of the Eddystone-URL Configuration Service Beacon Period |
Vincent Coubard |
0:4c8f8bf32a99 | 163 | * characteristic that is the interval (in milliseconds) of the |
Vincent Coubard |
0:4c8f8bf32a99 | 164 | * Eddystone-URL frames. |
Vincent Coubard |
0:4c8f8bf32a99 | 165 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 166 | * @note A value of zero disables Eddystone-URL frame trasmissions. |
Vincent Coubard |
0:4c8f8bf32a99 | 167 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 168 | uint16_t urlFramePeriod; |
Vincent Coubard |
0:4c8f8bf32a99 | 169 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 170 | * The configured interval (in milliseconds) of the Eddystone-UID |
Vincent Coubard |
0:4c8f8bf32a99 | 171 | * frames. |
Vincent Coubard |
0:4c8f8bf32a99 | 172 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 173 | * @note A value of zero disables Eddystone-UID frame transmissions. |
Vincent Coubard |
0:4c8f8bf32a99 | 174 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 175 | * @note Currently it is only possible to modify this value by using |
Vincent Coubard |
0:4c8f8bf32a99 | 176 | * the setUIDFrameAdvertisingInterval() API. |
Vincent Coubard |
0:4c8f8bf32a99 | 177 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 178 | uint16_t uidFramePeriod; |
Vincent Coubard |
0:4c8f8bf32a99 | 179 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 180 | * The configured interval (in milliseconds) of the Eddystone-TLM |
Vincent Coubard |
0:4c8f8bf32a99 | 181 | * frames. |
Vincent Coubard |
0:4c8f8bf32a99 | 182 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 183 | * @note A value of zero disables Eddystone-TLM frame transmissions. |
Vincent Coubard |
0:4c8f8bf32a99 | 184 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 185 | * @note Currently it is only possible to modify this value by using |
Vincent Coubard |
0:4c8f8bf32a99 | 186 | * the setTLMFrameAdvertisingInterval() API. |
Vincent Coubard |
0:4c8f8bf32a99 | 187 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 188 | uint16_t tlmFramePeriod; |
Vincent Coubard |
0:4c8f8bf32a99 | 189 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 190 | * The configured version of the Eddystone-TLM frames. |
Vincent Coubard |
0:4c8f8bf32a99 | 191 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 192 | uint8_t tlmVersion; |
Vincent Coubard |
0:4c8f8bf32a99 | 193 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 194 | * The length of the encoded URL in EddystoneParams_t::urlData used |
Vincent Coubard |
0:4c8f8bf32a99 | 195 | * within Eddystone-URL frames. |
Vincent Coubard |
0:4c8f8bf32a99 | 196 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 197 | uint8_t urlDataLength; |
Vincent Coubard |
0:4c8f8bf32a99 | 198 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 199 | * The value of the Eddystone-URL Configuration Service URI Data |
Vincent Coubard |
0:4c8f8bf32a99 | 200 | * characteristic that contains an encoded URL as described in the |
Vincent Coubard |
0:4c8f8bf32a99 | 201 | * Eddystone Specification at |
Vincent Coubard |
0:4c8f8bf32a99 | 202 | * https://github.com/google/eddystone/blob/master/eddystone-url/README.md#eddystone-url-http-url-encoding. |
Vincent Coubard |
0:4c8f8bf32a99 | 203 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 204 | UrlData_t urlData; |
Vincent Coubard |
0:4c8f8bf32a99 | 205 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 206 | * The configured 10-byte namespace ID in Eddystone-UID frames that may |
Vincent Coubard |
0:4c8f8bf32a99 | 207 | * be used to group a particular set of beacons. |
Vincent Coubard |
0:4c8f8bf32a99 | 208 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 209 | UIDNamespaceID_t uidNamespaceID; |
Vincent Coubard |
0:4c8f8bf32a99 | 210 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 211 | * The configured 6-byte instance ID that may be used to uniquely |
Vincent Coubard |
0:4c8f8bf32a99 | 212 | * identify individual devices in a group. |
Vincent Coubard |
0:4c8f8bf32a99 | 213 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 214 | UIDInstanceID_t uidInstanceID; |
Vincent Coubard |
0:4c8f8bf32a99 | 215 | }; |
Vincent Coubard |
0:4c8f8bf32a99 | 216 | |
Vincent Coubard |
0:4c8f8bf32a99 | 217 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 218 | * Enumeration that defines the various error codes for EddystoneService. |
Vincent Coubard |
0:4c8f8bf32a99 | 219 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 220 | enum EddystoneError_t { |
Vincent Coubard |
0:4c8f8bf32a99 | 221 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 222 | * No error occurred. |
Vincent Coubard |
0:4c8f8bf32a99 | 223 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 224 | EDDYSTONE_ERROR_NONE, |
Vincent Coubard |
0:4c8f8bf32a99 | 225 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 226 | * The supplied advertising interval is invalid. The interval may be |
Vincent Coubard |
0:4c8f8bf32a99 | 227 | * too short/long for the type of advertising packets being broadcast. |
Vincent Coubard |
0:4c8f8bf32a99 | 228 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 229 | * @note For the acceptable range of advertising interval refer to the |
Vincent Coubard |
0:4c8f8bf32a99 | 230 | * following functions in mbed BLE API: |
Vincent Coubard |
0:4c8f8bf32a99 | 231 | * - Gap::getMinNonConnectableAdvertisingInterval() |
Vincent Coubard |
0:4c8f8bf32a99 | 232 | * - Gap::getMinAdvertisingInterval() |
Vincent Coubard |
0:4c8f8bf32a99 | 233 | * - Gap::getMaxAdvertisingInterval() |
Vincent Coubard |
0:4c8f8bf32a99 | 234 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 235 | EDDYSTONE_ERROR_INVALID_ADVERTISING_INTERVAL, |
Vincent Coubard |
0:4c8f8bf32a99 | 236 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 237 | * The result of executing a call when the the EddystoneService is in |
Vincent Coubard |
0:4c8f8bf32a99 | 238 | * the incorrect operation mode. |
Vincent Coubard |
0:4c8f8bf32a99 | 239 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 240 | EDDYSTONE_ERROR_INVALID_STATE |
Vincent Coubard |
0:4c8f8bf32a99 | 241 | }; |
Vincent Coubard |
0:4c8f8bf32a99 | 242 | |
Vincent Coubard |
0:4c8f8bf32a99 | 243 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 244 | * Enumeration that defines the available frame types within Eddystone |
Vincent Coubard |
0:4c8f8bf32a99 | 245 | * advertising packets. |
Vincent Coubard |
0:4c8f8bf32a99 | 246 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 247 | enum FrameType { |
Vincent Coubard |
0:4c8f8bf32a99 | 248 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 249 | * The Eddystone-URL frame. Refer to |
Vincent Coubard |
0:4c8f8bf32a99 | 250 | * https://github.com/google/eddystone/tree/master/eddystone-url. |
Vincent Coubard |
0:4c8f8bf32a99 | 251 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 252 | EDDYSTONE_FRAME_URL, |
Vincent Coubard |
0:4c8f8bf32a99 | 253 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 254 | * The Eddystone-URL frame. Refer to |
Vincent Coubard |
0:4c8f8bf32a99 | 255 | * https://github.com/google/eddystone/tree/master/eddystone-uid. |
Vincent Coubard |
0:4c8f8bf32a99 | 256 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 257 | EDDYSTONE_FRAME_UID, |
Vincent Coubard |
0:4c8f8bf32a99 | 258 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 259 | * The Eddystone-URL frame. Refer to |
Vincent Coubard |
0:4c8f8bf32a99 | 260 | * https://github.com/google/eddystone/tree/master/eddystone-tlm. |
Vincent Coubard |
0:4c8f8bf32a99 | 261 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 262 | EDDYSTONE_FRAME_TLM, |
Vincent Coubard |
0:4c8f8bf32a99 | 263 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 264 | * The total number Eddystone frame types. |
Vincent Coubard |
0:4c8f8bf32a99 | 265 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 266 | NUM_EDDYSTONE_FRAMES |
Vincent Coubard |
0:4c8f8bf32a99 | 267 | }; |
Vincent Coubard |
0:4c8f8bf32a99 | 268 | |
Vincent Coubard |
0:4c8f8bf32a99 | 269 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 270 | * The size of the advertising frame queue. |
Vincent Coubard |
0:4c8f8bf32a99 | 271 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 272 | * @note [WARNING] If the advertising rate for any of the frames is higher |
Vincent Coubard |
0:4c8f8bf32a99 | 273 | * than 100ms then frames will be dropped, this value must be |
Vincent Coubard |
0:4c8f8bf32a99 | 274 | * increased. |
Vincent Coubard |
0:4c8f8bf32a99 | 275 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 276 | static const uint16_t ADV_FRAME_QUEUE_SIZE = NUM_EDDYSTONE_FRAMES; |
Vincent Coubard |
0:4c8f8bf32a99 | 277 | |
Vincent Coubard |
0:4c8f8bf32a99 | 278 | |
Vincent Coubard |
0:4c8f8bf32a99 | 279 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 280 | * Constructor that Initializes the EddystoneService using parameters from |
Vincent Coubard |
0:4c8f8bf32a99 | 281 | * the supplied EddystoneParams_t. This constructor is particularly useful |
Vincent Coubard |
0:4c8f8bf32a99 | 282 | * for configuring the EddystoneService with parameters fetched from |
Vincent Coubard |
0:4c8f8bf32a99 | 283 | * persistent storage. |
Vincent Coubard |
0:4c8f8bf32a99 | 284 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 285 | * @param[in] bleIn |
Vincent Coubard |
0:4c8f8bf32a99 | 286 | * The BLE instance. |
Vincent Coubard |
0:4c8f8bf32a99 | 287 | * @param[in] paramIn |
Vincent Coubard |
0:4c8f8bf32a99 | 288 | * The input Eddystone configuration parameters. |
Vincent Coubard |
0:4c8f8bf32a99 | 289 | * @param[in] radioPowerLevelsIn |
Vincent Coubard |
0:4c8f8bf32a99 | 290 | * The value set internally into the radion tx power. |
Vincent Coubard |
0:4c8f8bf32a99 | 291 | * @param[in] advConfigIntervalIn |
Vincent Coubard |
0:4c8f8bf32a99 | 292 | * The advertising interval for advertising packets of the |
Vincent Coubard |
0:4c8f8bf32a99 | 293 | * Eddystone-URL Configuration Service. |
Vincent Coubard |
0:4c8f8bf32a99 | 294 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 295 | EddystoneService(BLE &bleIn, |
Vincent Coubard |
0:4c8f8bf32a99 | 296 | EddystoneParams_t ¶msIn, |
Vincent Coubard |
0:4c8f8bf32a99 | 297 | const PowerLevels_t &radioPowerLevelsIn, |
Vincent Coubard |
0:4c8f8bf32a99 | 298 | events::EventQueue& eventQueue, |
Vincent Coubard |
0:4c8f8bf32a99 | 299 | uint32_t advConfigIntervalIn = DEFAULT_CONFIG_PERIOD_MSEC); |
Vincent Coubard |
0:4c8f8bf32a99 | 300 | |
Vincent Coubard |
0:4c8f8bf32a99 | 301 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 302 | * Constructor to initialize the EddystoneService to default values. |
Vincent Coubard |
0:4c8f8bf32a99 | 303 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 304 | * @param[in] bleIn |
Vincent Coubard |
0:4c8f8bf32a99 | 305 | * The BLE instance. |
Vincent Coubard |
0:4c8f8bf32a99 | 306 | * @param[in] advPowerLevelsIn |
Vincent Coubard |
0:4c8f8bf32a99 | 307 | * The value of the Eddystone-URL Configuration Service TX |
Vincent Coubard |
0:4c8f8bf32a99 | 308 | * Power Mode characteristic. |
Vincent Coubard |
0:4c8f8bf32a99 | 309 | * @param[in] radioPowerLevelsIn |
Vincent Coubard |
0:4c8f8bf32a99 | 310 | * The value set internally into the radion tx power. |
Vincent Coubard |
0:4c8f8bf32a99 | 311 | * @param[in] advConfigIntervalIn |
Vincent Coubard |
0:4c8f8bf32a99 | 312 | * The advertising interval for advertising packets of the |
Vincent Coubard |
0:4c8f8bf32a99 | 313 | * Eddystone-URL Configuration Service. |
Vincent Coubard |
0:4c8f8bf32a99 | 314 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 315 | * @note When using this constructor the setURLData(), setTMLData() and |
Vincent Coubard |
0:4c8f8bf32a99 | 316 | * setUIDData() functions must be called to initialize |
Vincent Coubard |
0:4c8f8bf32a99 | 317 | * EddystoneService manually. |
Vincent Coubard |
0:4c8f8bf32a99 | 318 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 319 | EddystoneService(BLE &bleIn, |
Vincent Coubard |
0:4c8f8bf32a99 | 320 | const PowerLevels_t &advPowerLevelsIn, |
Vincent Coubard |
0:4c8f8bf32a99 | 321 | const PowerLevels_t &radioPowerLevelsIn, |
Vincent Coubard |
0:4c8f8bf32a99 | 322 | EventQueue &eventQueue, |
Vincent Coubard |
0:4c8f8bf32a99 | 323 | uint32_t advConfigIntervalIn = DEFAULT_CONFIG_PERIOD_MSEC); |
Vincent Coubard |
0:4c8f8bf32a99 | 324 | |
Vincent Coubard |
0:4c8f8bf32a99 | 325 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 326 | * Setup callback to update BatteryVoltage in Eddystone-TLM frames |
Vincent Coubard |
0:4c8f8bf32a99 | 327 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 328 | * @param[in] tlmBatteryVoltageCallbackIn |
Vincent Coubard |
0:4c8f8bf32a99 | 329 | * The callback being registered. |
Vincent Coubard |
0:4c8f8bf32a99 | 330 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 331 | void onTLMBatteryVoltageUpdate(TlmUpdateCallback_t tlmBatteryVoltageCallbackIn); |
Vincent Coubard |
0:4c8f8bf32a99 | 332 | |
Vincent Coubard |
0:4c8f8bf32a99 | 333 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 334 | * Setup callback to update BeaconTemperature in Eddystone-TLM frames |
Vincent Coubard |
0:4c8f8bf32a99 | 335 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 336 | * @param[in] tlmBeaconTemperatureCallbackIn |
Vincent Coubard |
0:4c8f8bf32a99 | 337 | * The callback being registered. |
Vincent Coubard |
0:4c8f8bf32a99 | 338 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 339 | void onTLMBeaconTemperatureUpdate(TlmUpdateCallback_t tlmBeaconTemperatureCallbackIn); |
Vincent Coubard |
0:4c8f8bf32a99 | 340 | |
Vincent Coubard |
0:4c8f8bf32a99 | 341 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 342 | * Set the Eddystone-TLM frame version. The other components of |
Vincent Coubard |
0:4c8f8bf32a99 | 343 | * Eddystone-TLM frames are updated just before the frame is broadcast |
Vincent Coubard |
0:4c8f8bf32a99 | 344 | * since information such as beacon temperature and time since boot changes |
Vincent Coubard |
0:4c8f8bf32a99 | 345 | * relatively quickly. |
Vincent Coubard |
0:4c8f8bf32a99 | 346 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 347 | * @param[in] tlmVersionIn |
Vincent Coubard |
0:4c8f8bf32a99 | 348 | * The Eddyston-TLM version to set. |
Vincent Coubard |
0:4c8f8bf32a99 | 349 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 350 | void setTLMData(uint8_t tlmVersionIn = 0); |
Vincent Coubard |
0:4c8f8bf32a99 | 351 | |
Vincent Coubard |
0:4c8f8bf32a99 | 352 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 353 | * Set the Eddystone-URL frame URL data. |
Vincent Coubard |
0:4c8f8bf32a99 | 354 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 355 | * @param[in] urlDataIn |
Vincent Coubard |
0:4c8f8bf32a99 | 356 | * A pointer to the plain null terminated string representing |
Vincent Coubard |
0:4c8f8bf32a99 | 357 | * a URL to be encoded. |
Vincent Coubard |
0:4c8f8bf32a99 | 358 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 359 | void setURLData(const char *urlDataIn); |
Vincent Coubard |
0:4c8f8bf32a99 | 360 | |
Vincent Coubard |
0:4c8f8bf32a99 | 361 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 362 | * Set the Eddystone-UID namespace and instance IDs. |
Vincent Coubard |
0:4c8f8bf32a99 | 363 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 364 | * @param[in] uidNamespaceIDIn |
Vincent Coubard |
0:4c8f8bf32a99 | 365 | * The new Eddystone-UID namespace ID. |
Vincent Coubard |
0:4c8f8bf32a99 | 366 | * @param[in] uidInstanceIDIn |
Vincent Coubard |
0:4c8f8bf32a99 | 367 | * The new Eddystone-UID instance ID. |
Vincent Coubard |
0:4c8f8bf32a99 | 368 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 369 | void setUIDData(const UIDNamespaceID_t &uidNamespaceIDIn, const UIDInstanceID_t &uidInstanceIDIn); |
Vincent Coubard |
0:4c8f8bf32a99 | 370 | |
Vincent Coubard |
0:4c8f8bf32a99 | 371 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 372 | * Set the interval of the Eddystone-URL frames. |
Vincent Coubard |
0:4c8f8bf32a99 | 373 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 374 | * @param[in] urlFrameIntervalIn |
Vincent Coubard |
0:4c8f8bf32a99 | 375 | * The new frame interval in milliseconds. The default is |
Vincent Coubard |
0:4c8f8bf32a99 | 376 | * DEFAULT_URL_FRAME_PERIOD_MSEC. |
Vincent Coubard |
0:4c8f8bf32a99 | 377 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 378 | * @note A value of zero disables Eddystone-URL frame transmissions. |
Vincent Coubard |
0:4c8f8bf32a99 | 379 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 380 | void setURLFrameAdvertisingInterval(uint16_t urlFrameIntervalIn = DEFAULT_URL_FRAME_PERIOD_MSEC); |
Vincent Coubard |
0:4c8f8bf32a99 | 381 | |
Vincent Coubard |
0:4c8f8bf32a99 | 382 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 383 | * Set the interval of the Eddystone-UID frames. |
Vincent Coubard |
0:4c8f8bf32a99 | 384 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 385 | * @param[in] uidFrameIntervalIn |
Vincent Coubard |
0:4c8f8bf32a99 | 386 | * The new frame interval in milliseconds. The default is |
Vincent Coubard |
0:4c8f8bf32a99 | 387 | * DEFAULT_UID_FRAME_PERIOD_MSEC. |
Vincent Coubard |
0:4c8f8bf32a99 | 388 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 389 | * @note A value of zero disables Eddystone-UID frame transmissions. |
Vincent Coubard |
0:4c8f8bf32a99 | 390 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 391 | void setUIDFrameAdvertisingInterval(uint16_t uidFrameIntervalIn = DEFAULT_UID_FRAME_PERIOD_MSEC); |
Vincent Coubard |
0:4c8f8bf32a99 | 392 | |
Vincent Coubard |
0:4c8f8bf32a99 | 393 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 394 | * Set the interval for the Eddystone-TLM frames. |
Vincent Coubard |
0:4c8f8bf32a99 | 395 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 396 | * @param[in] tlmFrameIntervalIn |
Vincent Coubard |
0:4c8f8bf32a99 | 397 | * The new frame interval in milliseconds. The default is |
Vincent Coubard |
0:4c8f8bf32a99 | 398 | * DEFAULT_TLM_FRAME_PERIOD_MSEC. |
Vincent Coubard |
0:4c8f8bf32a99 | 399 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 400 | * @note A value of zero desables Eddystone-TLM frames. |
Vincent Coubard |
0:4c8f8bf32a99 | 401 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 402 | void setTLMFrameAdvertisingInterval(uint16_t tlmFrameIntervalIn = DEFAULT_TLM_FRAME_PERIOD_MSEC); |
Vincent Coubard |
0:4c8f8bf32a99 | 403 | |
Vincent Coubard |
0:4c8f8bf32a99 | 404 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 405 | * Change the EddystoneService OperationMode to EDDYSTONE_MODE_CONFIG. |
Vincent Coubard |
0:4c8f8bf32a99 | 406 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 407 | * @retval EDDYSTONE_ERROR_NONE if the operation succeeded. |
Vincent Coubard |
0:4c8f8bf32a99 | 408 | * @retval EDDYSONE_ERROR_INVALID_ADVERTISING_INTERVAL if the configured |
Vincent Coubard |
0:4c8f8bf32a99 | 409 | * advertising interval is zero. |
Vincent Coubard |
0:4c8f8bf32a99 | 410 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 411 | * @note If EddystoneService was previously in EDDYSTONE_MODE_BEACON, then |
Vincent Coubard |
0:4c8f8bf32a99 | 412 | * the resources allocated to that mode of operation such as memory |
Vincent Coubard |
0:4c8f8bf32a99 | 413 | * are freed and the BLE instance shutdown before the new operation |
Vincent Coubard |
0:4c8f8bf32a99 | 414 | * mode is configured. |
Vincent Coubard |
0:4c8f8bf32a99 | 415 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 416 | EddystoneError_t startConfigService(void); |
Vincent Coubard |
0:4c8f8bf32a99 | 417 | |
Vincent Coubard |
0:4c8f8bf32a99 | 418 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 419 | * Change the EddystoneService OperationMode to EDDYSTONE_MODE_BEACON. |
Vincent Coubard |
0:4c8f8bf32a99 | 420 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 421 | * @retval EDDYSTONE_ERROR_NONE if the operation succeeded. |
Vincent Coubard |
0:4c8f8bf32a99 | 422 | * @retval EDDYSONE_ERROR_INVALID_ADVERTISING_INTERVAL if the configured |
Vincent Coubard |
0:4c8f8bf32a99 | 423 | * advertising interval is zero. |
Vincent Coubard |
0:4c8f8bf32a99 | 424 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 425 | * @note If EddystoneService was previously in EDDYSTONE_MODE_CONFIG, then |
Vincent Coubard |
0:4c8f8bf32a99 | 426 | * the resources allocated to that mode of operation such as memory |
Vincent Coubard |
0:4c8f8bf32a99 | 427 | * are freed and the BLE instance shutdown before the new operation |
Vincent Coubard |
0:4c8f8bf32a99 | 428 | * mode is configured. |
Vincent Coubard |
0:4c8f8bf32a99 | 429 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 430 | EddystoneError_t startBeaconService(void); |
Vincent Coubard |
0:4c8f8bf32a99 | 431 | |
Vincent Coubard |
0:4c8f8bf32a99 | 432 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 433 | * Change the EddystoneService OperationMode to EDDYSTONE_MODE_NONE. |
Vincent Coubard |
0:4c8f8bf32a99 | 434 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 435 | * @retval EDDYSTONE_ERROR_NONE if the operation succeeded. |
Vincent Coubard |
0:4c8f8bf32a99 | 436 | * @retval EDDYSTONE_ERROR_INVALID_STATE if the state of the |
Vincent Coubard |
0:4c8f8bf32a99 | 437 | * EddystoneService already is EDDYSTONE_MODE_NONE. |
Vincent Coubard |
0:4c8f8bf32a99 | 438 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 439 | * @note If EddystoneService was previously in EDDYSTONE_MODE_CONFIG or |
Vincent Coubard |
0:4c8f8bf32a99 | 440 | * EDDYSTONE_MODE_BEACON, then the resources allocated to that mode |
Vincent Coubard |
0:4c8f8bf32a99 | 441 | * of operation such as memory are freed and the BLE instance |
Vincent Coubard |
0:4c8f8bf32a99 | 442 | * shutdown before the new operation mode is configured. |
Vincent Coubard |
0:4c8f8bf32a99 | 443 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 444 | EddystoneError_t stopCurrentService(void); |
Vincent Coubard |
0:4c8f8bf32a99 | 445 | |
Vincent Coubard |
0:4c8f8bf32a99 | 446 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 447 | * Set the Comple Local Name for the BLE device. This not only updates |
Vincent Coubard |
0:4c8f8bf32a99 | 448 | * the value of the Device Name Characteristic, it also updates the scan |
Vincent Coubard |
0:4c8f8bf32a99 | 449 | * response payload if the EddystoneService is currently in |
Vincent Coubard |
0:4c8f8bf32a99 | 450 | * EDDYSTONE_MODE_CONFIG. |
Vincent Coubard |
0:4c8f8bf32a99 | 451 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 452 | * @param[in] deviceNameIn |
Vincent Coubard |
0:4c8f8bf32a99 | 453 | * A pointer to a null terminated string containing the new |
Vincent Coubard |
0:4c8f8bf32a99 | 454 | * device name. |
Vincent Coubard |
0:4c8f8bf32a99 | 455 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 456 | * @return BLE_ERROR_NONE if the name was successfully set. Otherwise an |
Vincent Coubard |
0:4c8f8bf32a99 | 457 | * appropriate error. |
Vincent Coubard |
0:4c8f8bf32a99 | 458 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 459 | * @note EddystoneService does not make an internal copy of the string |
Vincent Coubard |
0:4c8f8bf32a99 | 460 | * pointed to by @p deviceNameIn. Therefore, the user is responsible |
Vincent Coubard |
0:4c8f8bf32a99 | 461 | * for ensuring that the string persists in memory as long as it is |
Vincent Coubard |
0:4c8f8bf32a99 | 462 | * in use by the EddystoneService. |
Vincent Coubard |
0:4c8f8bf32a99 | 463 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 464 | * @note The device name is not considered an Eddystone configuration |
Vincent Coubard |
0:4c8f8bf32a99 | 465 | * parameter; therefore, it is not contained within the |
Vincent Coubard |
0:4c8f8bf32a99 | 466 | * EddystoneParams_t structure and must be stored to persistent |
Vincent Coubard |
0:4c8f8bf32a99 | 467 | * storage separately. |
Vincent Coubard |
0:4c8f8bf32a99 | 468 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 469 | ble_error_t setCompleteDeviceName(const char *deviceNameIn); |
Vincent Coubard |
0:4c8f8bf32a99 | 470 | |
Vincent Coubard |
0:4c8f8bf32a99 | 471 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 472 | * Get the Eddystone Configuration parameters. This is particularly useful |
Vincent Coubard |
0:4c8f8bf32a99 | 473 | * for storing the configuration parameters in persistent storage. |
Vincent Coubard |
0:4c8f8bf32a99 | 474 | * It is not the responsibility of the Eddystone implementation to store |
Vincent Coubard |
0:4c8f8bf32a99 | 475 | * the configured parameters in persistent storage since this is |
Vincent Coubard |
0:4c8f8bf32a99 | 476 | * platform-specific. |
Vincent Coubard |
0:4c8f8bf32a99 | 477 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 478 | * @param[out] params |
Vincent Coubard |
0:4c8f8bf32a99 | 479 | * A reference to an EddystoneParams_t structure with the |
Vincent Coubard |
0:4c8f8bf32a99 | 480 | * configured parameters of the EddystoneService. |
Vincent Coubard |
0:4c8f8bf32a99 | 481 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 482 | void getEddystoneParams(EddystoneParams_t ¶ms); |
Vincent Coubard |
0:4c8f8bf32a99 | 483 | |
Vincent Coubard |
0:4c8f8bf32a99 | 484 | private: |
Vincent Coubard |
0:4c8f8bf32a99 | 485 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 486 | * Helper function used only once during construction of an |
Vincent Coubard |
0:4c8f8bf32a99 | 487 | * EddystoneService object to avoid duplicated code. |
Vincent Coubard |
0:4c8f8bf32a99 | 488 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 489 | * @param[in] advPowerLevelsIn |
Vincent Coubard |
0:4c8f8bf32a99 | 490 | * The value of the Eddystone-URL Configuration Service TX |
Vincent Coubard |
0:4c8f8bf32a99 | 491 | * Power Mode characteristic. |
Vincent Coubard |
0:4c8f8bf32a99 | 492 | * @param[in] radioPowerLevelsIn |
Vincent Coubard |
0:4c8f8bf32a99 | 493 | * The value set internally into the radion tx power. |
Vincent Coubard |
0:4c8f8bf32a99 | 494 | * @param[in] advConfigIntervalIn |
Vincent Coubard |
0:4c8f8bf32a99 | 495 | * The advertising interval for advertising packets of the |
Vincent Coubard |
0:4c8f8bf32a99 | 496 | * Eddystone-URL Configuration Service. |
Vincent Coubard |
0:4c8f8bf32a99 | 497 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 498 | void eddystoneConstructorHelper(const PowerLevels_t &advPowerLevelsIn, |
Vincent Coubard |
0:4c8f8bf32a99 | 499 | const PowerLevels_t &radioPowerLevelsIn, |
Vincent Coubard |
0:4c8f8bf32a99 | 500 | uint32_t advConfigIntervalIn); |
Vincent Coubard |
0:4c8f8bf32a99 | 501 | |
Vincent Coubard |
0:4c8f8bf32a99 | 502 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 503 | * Helper funtion that will be registered as an initialization complete |
Vincent Coubard |
0:4c8f8bf32a99 | 504 | * callback when BLE::shutdown() is called. This is necessary when changing |
Vincent Coubard |
0:4c8f8bf32a99 | 505 | * Eddystone OperationModes. Once the BLE initialization is complete, this |
Vincent Coubard |
0:4c8f8bf32a99 | 506 | * callback will initialize all the necessary resource to operate |
Vincent Coubard |
0:4c8f8bf32a99 | 507 | * Eddystone service in the selected mode. |
Vincent Coubard |
0:4c8f8bf32a99 | 508 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 509 | * @param[in] initContext |
Vincent Coubard |
0:4c8f8bf32a99 | 510 | * The context provided by BLE API when initialization |
Vincent Coubard |
0:4c8f8bf32a99 | 511 | * completes. |
Vincent Coubard |
0:4c8f8bf32a99 | 512 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 513 | void bleInitComplete(BLE::InitializationCompleteCallbackContext* initContext); |
Vincent Coubard |
0:4c8f8bf32a99 | 514 | |
Vincent Coubard |
0:4c8f8bf32a99 | 515 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 516 | * When in EDDYSTONE_MODE_BEACON this function is called to update the |
Vincent Coubard |
0:4c8f8bf32a99 | 517 | * advertising payload to contain the information related to the specified |
Vincent Coubard |
0:4c8f8bf32a99 | 518 | * FrameType. |
Vincent Coubard |
0:4c8f8bf32a99 | 519 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 520 | * @param[in] frameType |
Vincent Coubard |
0:4c8f8bf32a99 | 521 | * The frame to populate the advertising payload with. |
Vincent Coubard |
0:4c8f8bf32a99 | 522 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 523 | void swapAdvertisedFrame(FrameType frameType); |
Vincent Coubard |
0:4c8f8bf32a99 | 524 | |
Vincent Coubard |
0:4c8f8bf32a99 | 525 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 526 | * Helper function that manages the BLE radio that is used to broadcast |
Vincent Coubard |
0:4c8f8bf32a99 | 527 | * advertising packets. To advertise frames at the configured intervals |
Vincent Coubard |
0:4c8f8bf32a99 | 528 | * the actual advertising interval of the BLE instance is set to the value |
Vincent Coubard |
0:4c8f8bf32a99 | 529 | * returned by Gap::getMaxAdvertisingInterval() from the BLE API. When a |
Vincent Coubard |
0:4c8f8bf32a99 | 530 | * frame needs to be advertised, the enqueueFrame() callbacks add the frame |
Vincent Coubard |
0:4c8f8bf32a99 | 531 | * type to the advFrameQueue and post a manageRadio() callback. When the |
Vincent Coubard |
0:4c8f8bf32a99 | 532 | * callback is executed, the frame is dequeued and advertised using the |
Vincent Coubard |
0:4c8f8bf32a99 | 533 | * radio (by updating the advertising payload). manageRadio() also posts a |
Vincent Coubard |
0:4c8f8bf32a99 | 534 | * callback to itself Gap::getMinNonConnectableAdvertisingInterval() |
Vincent Coubard |
0:4c8f8bf32a99 | 535 | * milliseconds later. In this callback, manageRadio() will advertise the |
Vincent Coubard |
0:4c8f8bf32a99 | 536 | * next frame in the queue, yet if there is none it calls |
Vincent Coubard |
0:4c8f8bf32a99 | 537 | * Gap::stopAdvertising() and does not post any further callbacks. |
Vincent Coubard |
0:4c8f8bf32a99 | 538 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 539 | void manageRadio(void); |
Vincent Coubard |
0:4c8f8bf32a99 | 540 | |
Vincent Coubard |
0:4c8f8bf32a99 | 541 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 542 | * Regular callbacks posted at the rate of urlFramePeriod, uidFramePeriod |
Vincent Coubard |
0:4c8f8bf32a99 | 543 | * and tlmFramePeriod milliseconds enqueue frames to be advertised. If the |
Vincent Coubard |
0:4c8f8bf32a99 | 544 | * frame queue is currently empty, then this function directly calls |
Vincent Coubard |
0:4c8f8bf32a99 | 545 | * manageRadio() to broadcast the required FrameType. |
Vincent Coubard |
0:4c8f8bf32a99 | 546 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 547 | * @param[in] frameType |
Vincent Coubard |
0:4c8f8bf32a99 | 548 | * The FrameType to enqueue for broadcasting. |
Vincent Coubard |
0:4c8f8bf32a99 | 549 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 550 | void enqueueFrame(FrameType frameType); |
Vincent Coubard |
0:4c8f8bf32a99 | 551 | |
Vincent Coubard |
0:4c8f8bf32a99 | 552 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 553 | * Helper function that updates the advertising payload when in |
Vincent Coubard |
0:4c8f8bf32a99 | 554 | * EDDYSTONE_MODE_BEACON to contain a new frame. |
Vincent Coubard |
0:4c8f8bf32a99 | 555 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 556 | * @param[in] rawFrame |
Vincent Coubard |
0:4c8f8bf32a99 | 557 | * The raw bytes of the frame to advertise. |
Vincent Coubard |
0:4c8f8bf32a99 | 558 | * @param[in] rawFrameLength |
Vincent Coubard |
0:4c8f8bf32a99 | 559 | * The length in bytes of the array pointed to by @p rawFrame. |
Vincent Coubard |
0:4c8f8bf32a99 | 560 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 561 | void updateAdvertisementPacket(const uint8_t* rawFrame, size_t rawFrameLength); |
Vincent Coubard |
0:4c8f8bf32a99 | 562 | |
Vincent Coubard |
0:4c8f8bf32a99 | 563 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 564 | * Helper function that updates the information in the Eddystone-TLM frames |
Vincent Coubard |
0:4c8f8bf32a99 | 565 | * Internally, this function executes the registered callbacks to update |
Vincent Coubard |
0:4c8f8bf32a99 | 566 | * beacon Battery Voltage and Temperature (if available). Furthermore, this |
Vincent Coubard |
0:4c8f8bf32a99 | 567 | * function updates the raw frame data. This operation must be done fairly |
Vincent Coubard |
0:4c8f8bf32a99 | 568 | * often because the Eddystone-TLM frame Time Since Boot must have a 0.1 |
Vincent Coubard |
0:4c8f8bf32a99 | 569 | * seconds resolution according to the Eddystone specification. |
Vincent Coubard |
0:4c8f8bf32a99 | 570 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 571 | void updateRawTLMFrame(void); |
Vincent Coubard |
0:4c8f8bf32a99 | 572 | |
Vincent Coubard |
0:4c8f8bf32a99 | 573 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 574 | * Initialize the resources required when switching to |
Vincent Coubard |
0:4c8f8bf32a99 | 575 | * EDDYSTONE_MODE_BEACON. |
Vincent Coubard |
0:4c8f8bf32a99 | 576 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 577 | void setupBeaconService(void); |
Vincent Coubard |
0:4c8f8bf32a99 | 578 | |
Vincent Coubard |
0:4c8f8bf32a99 | 579 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 580 | * Initialize the resources required when switching to |
Vincent Coubard |
0:4c8f8bf32a99 | 581 | * EDDYSTONE_MODE_CONFIG. This includes the GATT services and |
Vincent Coubard |
0:4c8f8bf32a99 | 582 | * characteristics required by the Eddystone-URL Configuration Service. |
Vincent Coubard |
0:4c8f8bf32a99 | 583 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 584 | void setupConfigService(void); |
Vincent Coubard |
0:4c8f8bf32a99 | 585 | |
Vincent Coubard |
0:4c8f8bf32a99 | 586 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 587 | * Free the resources acquired by a call to setupConfigService(). |
Vincent Coubard |
0:4c8f8bf32a99 | 588 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 589 | void freeConfigCharacteristics(void); |
Vincent Coubard |
0:4c8f8bf32a99 | 590 | |
Vincent Coubard |
0:4c8f8bf32a99 | 591 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 592 | * Free the resources acquired by a call to setupBeaconService() and |
Vincent Coubard |
0:4c8f8bf32a99 | 593 | * cancel all pending callbacks that operate the radio and frame queue. |
Vincent Coubard |
0:4c8f8bf32a99 | 594 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 595 | * @note This call will not modify the current state of the BLE device. |
Vincent Coubard |
0:4c8f8bf32a99 | 596 | * EddystoneService::stopBeaconService should only be called after |
Vincent Coubard |
0:4c8f8bf32a99 | 597 | * a call to BLE::shutdown(). |
Vincent Coubard |
0:4c8f8bf32a99 | 598 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 599 | void stopBeaconService(void); |
Vincent Coubard |
0:4c8f8bf32a99 | 600 | |
Vincent Coubard |
0:4c8f8bf32a99 | 601 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 602 | * Helper function used to update the GATT database following any |
Vincent Coubard |
0:4c8f8bf32a99 | 603 | * change to the internal state of the service object. |
Vincent Coubard |
0:4c8f8bf32a99 | 604 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 605 | void updateCharacteristicValues(void); |
Vincent Coubard |
0:4c8f8bf32a99 | 606 | |
Vincent Coubard |
0:4c8f8bf32a99 | 607 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 608 | * Setup the payload of advertising packets for Eddystone-URL Configuration |
Vincent Coubard |
0:4c8f8bf32a99 | 609 | * Service. |
Vincent Coubard |
0:4c8f8bf32a99 | 610 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 611 | void setupEddystoneConfigAdvertisements(void); |
Vincent Coubard |
0:4c8f8bf32a99 | 612 | |
Vincent Coubard |
0:4c8f8bf32a99 | 613 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 614 | * Helper function to setup the payload of scan response packets for |
Vincent Coubard |
0:4c8f8bf32a99 | 615 | * Eddystone-URL Configuration Service. |
Vincent Coubard |
0:4c8f8bf32a99 | 616 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 617 | void setupEddystoneConfigScanResponse(void); |
Vincent Coubard |
0:4c8f8bf32a99 | 618 | |
Vincent Coubard |
0:4c8f8bf32a99 | 619 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 620 | * Callback registered to the BLE API to authorize write operations to the |
Vincent Coubard |
0:4c8f8bf32a99 | 621 | * Eddystone-URL Configuration Service Lock characteristic. |
Vincent Coubard |
0:4c8f8bf32a99 | 622 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 623 | * @param[in] authParams |
Vincent Coubard |
0:4c8f8bf32a99 | 624 | * Write authentication information. |
Vincent Coubard |
0:4c8f8bf32a99 | 625 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 626 | void lockAuthorizationCallback(GattWriteAuthCallbackParams *authParams); |
Vincent Coubard |
0:4c8f8bf32a99 | 627 | |
Vincent Coubard |
0:4c8f8bf32a99 | 628 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 629 | * Callback registered to the BLE API to authorize write operations to the |
Vincent Coubard |
0:4c8f8bf32a99 | 630 | * Eddystone-URL Configuration Service Unlock characteristic. |
Vincent Coubard |
0:4c8f8bf32a99 | 631 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 632 | * @param[in] authParams |
Vincent Coubard |
0:4c8f8bf32a99 | 633 | * Write authentication information. |
Vincent Coubard |
0:4c8f8bf32a99 | 634 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 635 | void unlockAuthorizationCallback(GattWriteAuthCallbackParams *authParams); |
Vincent Coubard |
0:4c8f8bf32a99 | 636 | |
Vincent Coubard |
0:4c8f8bf32a99 | 637 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 638 | * Callback registered to the BLE API to authorize write operations to the |
Vincent Coubard |
0:4c8f8bf32a99 | 639 | * Eddystone-URL Configuration Service URI Data characteristic. |
Vincent Coubard |
0:4c8f8bf32a99 | 640 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 641 | * @param[in] authParams |
Vincent Coubard |
0:4c8f8bf32a99 | 642 | * Write authentication information. |
Vincent Coubard |
0:4c8f8bf32a99 | 643 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 644 | void urlDataWriteAuthorizationCallback(GattWriteAuthCallbackParams *authParams); |
Vincent Coubard |
0:4c8f8bf32a99 | 645 | |
Vincent Coubard |
0:4c8f8bf32a99 | 646 | void powerModeAuthorizationCallback(GattWriteAuthCallbackParams *authParams); |
Vincent Coubard |
0:4c8f8bf32a99 | 647 | |
Vincent Coubard |
0:4c8f8bf32a99 | 648 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 649 | * Callback registered to the BLE API to authorize write operations to the |
Vincent Coubard |
0:4c8f8bf32a99 | 650 | * following Eddystone-URL Configuration Service characteristics: |
Vincent Coubard |
0:4c8f8bf32a99 | 651 | * - Flags |
Vincent Coubard |
0:4c8f8bf32a99 | 652 | * - Beacon Period |
Vincent Coubard |
0:4c8f8bf32a99 | 653 | * - Reset |
Vincent Coubard |
0:4c8f8bf32a99 | 654 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 655 | * @param[in] authParams |
Vincent Coubard |
0:4c8f8bf32a99 | 656 | * Write authentication information. |
Vincent Coubard |
0:4c8f8bf32a99 | 657 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 658 | template <typename T> |
Vincent Coubard |
0:4c8f8bf32a99 | 659 | void basicAuthorizationCallback(GattWriteAuthCallbackParams *authParams); |
Vincent Coubard |
0:4c8f8bf32a99 | 660 | |
Vincent Coubard |
0:4c8f8bf32a99 | 661 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 662 | * This callback is invoked when a GATT client attempts to modify any of the |
Vincent Coubard |
0:4c8f8bf32a99 | 663 | * characteristics of this service. Attempts to do so are also applied to |
Vincent Coubard |
0:4c8f8bf32a99 | 664 | * the internal state of this service object. |
Vincent Coubard |
0:4c8f8bf32a99 | 665 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 666 | * @param[in] writeParams |
Vincent Coubard |
0:4c8f8bf32a99 | 667 | * Information about the values that are being written. |
Vincent Coubard |
0:4c8f8bf32a99 | 668 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 669 | void onDataWrittenCallback(const GattWriteCallbackParams *writeParams); |
Vincent Coubard |
0:4c8f8bf32a99 | 670 | |
Vincent Coubard |
0:4c8f8bf32a99 | 671 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 672 | * Correct the advertising interval for non-connectable packets. |
Vincent Coubard |
0:4c8f8bf32a99 | 673 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 674 | * @param[in] beaconPeriodIn |
Vincent Coubard |
0:4c8f8bf32a99 | 675 | * The input interval in milliseconds. |
Vincent Coubard |
0:4c8f8bf32a99 | 676 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 677 | * @return The corrected interval in milliseconds. |
Vincent Coubard |
0:4c8f8bf32a99 | 678 | * |
Vincent Coubard |
0:4c8f8bf32a99 | 679 | * @note For the acceptable range of advertising interval refer to the |
Vincent Coubard |
0:4c8f8bf32a99 | 680 | * following functions in mbed BLE API: |
Vincent Coubard |
0:4c8f8bf32a99 | 681 | * - Gap::getMinNonConnectableAdvertisingInterval() |
Vincent Coubard |
0:4c8f8bf32a99 | 682 | * - Gap::getMaxAdvertisingInterval() |
Vincent Coubard |
0:4c8f8bf32a99 | 683 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 684 | uint16_t correctAdvertisementPeriod(uint16_t beaconPeriodIn) const; |
Vincent Coubard |
0:4c8f8bf32a99 | 685 | |
Vincent Coubard |
0:4c8f8bf32a99 | 686 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 687 | * BLE instance that EddystoneService will operate on. |
Vincent Coubard |
0:4c8f8bf32a99 | 688 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 689 | BLE &ble; |
Vincent Coubard |
0:4c8f8bf32a99 | 690 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 691 | * The advertising interval for Eddystone-URL Config Service advertising |
Vincent Coubard |
0:4c8f8bf32a99 | 692 | * packets. |
Vincent Coubard |
0:4c8f8bf32a99 | 693 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 694 | uint32_t advConfigInterval; |
Vincent Coubard |
0:4c8f8bf32a99 | 695 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 696 | * Current EddystoneServce operation mode. |
Vincent Coubard |
0:4c8f8bf32a99 | 697 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 698 | uint8_t operationMode; |
Vincent Coubard |
0:4c8f8bf32a99 | 699 | |
Vincent Coubard |
0:4c8f8bf32a99 | 700 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 701 | * Encapsulation of a URL frame. |
Vincent Coubard |
0:4c8f8bf32a99 | 702 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 703 | URLFrame urlFrame; |
Vincent Coubard |
0:4c8f8bf32a99 | 704 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 705 | * Encapsulation of a UID frame. |
Vincent Coubard |
0:4c8f8bf32a99 | 706 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 707 | UIDFrame uidFrame; |
Vincent Coubard |
0:4c8f8bf32a99 | 708 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 709 | * Encapsulation of a TLM frame. |
Vincent Coubard |
0:4c8f8bf32a99 | 710 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 711 | TLMFrame tlmFrame; |
Vincent Coubard |
0:4c8f8bf32a99 | 712 | |
Vincent Coubard |
0:4c8f8bf32a99 | 713 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 714 | * The value set internally into the radion tx power. |
Vincent Coubard |
0:4c8f8bf32a99 | 715 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 716 | PowerLevels_t radioPowerLevels; |
Vincent Coubard |
0:4c8f8bf32a99 | 717 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 718 | * An array containing possible values for advertised tx power in Eddystone |
Vincent Coubard |
0:4c8f8bf32a99 | 719 | * frames. Also, the value of the Eddystone-URL Configuration Service |
Vincent Coubard |
0:4c8f8bf32a99 | 720 | * Advertised TX Power Levels characteristic. |
Vincent Coubard |
0:4c8f8bf32a99 | 721 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 722 | PowerLevels_t advPowerLevels; |
Vincent Coubard |
0:4c8f8bf32a99 | 723 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 724 | * The value of the Eddystone-URL Configuration Service Lock State |
Vincent Coubard |
0:4c8f8bf32a99 | 725 | * characteristic. |
Vincent Coubard |
0:4c8f8bf32a99 | 726 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 727 | bool lockState; |
Vincent Coubard |
0:4c8f8bf32a99 | 728 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 729 | * The value of the Eddystone-URL Configuration Service reset |
Vincent Coubard |
0:4c8f8bf32a99 | 730 | * characteristic. |
Vincent Coubard |
0:4c8f8bf32a99 | 731 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 732 | bool resetFlag; |
Vincent Coubard |
0:4c8f8bf32a99 | 733 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 734 | * The value of the Eddystone-URL Configuration Service Lock |
Vincent Coubard |
0:4c8f8bf32a99 | 735 | * characteristic. |
Vincent Coubard |
0:4c8f8bf32a99 | 736 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 737 | Lock_t lock; |
Vincent Coubard |
0:4c8f8bf32a99 | 738 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 739 | * The value of the Eddystone-URL Configuration Service Unlock |
Vincent Coubard |
0:4c8f8bf32a99 | 740 | * characteristic. |
Vincent Coubard |
0:4c8f8bf32a99 | 741 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 742 | Lock_t unlock; |
Vincent Coubard |
0:4c8f8bf32a99 | 743 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 744 | * The value of the Eddystone-URL Configuration Service Flags |
Vincent Coubard |
0:4c8f8bf32a99 | 745 | * characteristic. |
Vincent Coubard |
0:4c8f8bf32a99 | 746 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 747 | uint8_t flags; |
Vincent Coubard |
0:4c8f8bf32a99 | 748 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 749 | * The value of the Eddystone-URL Configuration Service TX Power Mode |
Vincent Coubard |
0:4c8f8bf32a99 | 750 | * characteristic. |
Vincent Coubard |
0:4c8f8bf32a99 | 751 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 752 | uint8_t txPowerMode; |
Vincent Coubard |
0:4c8f8bf32a99 | 753 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 754 | * The value of the Eddystone-URL Configuration Service Beacon Period |
Vincent Coubard |
0:4c8f8bf32a99 | 755 | * characteristic. Also, the advertising interval (in milliseconds) of |
Vincent Coubard |
0:4c8f8bf32a99 | 756 | * Eddystone-URL frames. |
Vincent Coubard |
0:4c8f8bf32a99 | 757 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 758 | uint16_t urlFramePeriod; |
Vincent Coubard |
0:4c8f8bf32a99 | 759 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 760 | * The advertising interval (in milliseconds) of Eddystone-UID frames. |
Vincent Coubard |
0:4c8f8bf32a99 | 761 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 762 | uint16_t uidFramePeriod; |
Vincent Coubard |
0:4c8f8bf32a99 | 763 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 764 | * The advertising interval (in milliseconds) of Eddystone-TLM frames. |
Vincent Coubard |
0:4c8f8bf32a99 | 765 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 766 | uint16_t tlmFramePeriod; |
Vincent Coubard |
0:4c8f8bf32a99 | 767 | |
Vincent Coubard |
0:4c8f8bf32a99 | 768 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 769 | * Pointer to the BLE API characteristic encapsulation for the Eddystone-URL |
Vincent Coubard |
0:4c8f8bf32a99 | 770 | * Configuration Service Lock State characteristic. |
Vincent Coubard |
0:4c8f8bf32a99 | 771 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 772 | ReadOnlyGattCharacteristic<bool> *lockStateChar; |
Vincent Coubard |
0:4c8f8bf32a99 | 773 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 774 | * Pointer to the BLE API characteristic encapsulation for the Eddystone-URL |
Vincent Coubard |
0:4c8f8bf32a99 | 775 | * Configuration Service Lock characteristic. |
Vincent Coubard |
0:4c8f8bf32a99 | 776 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 777 | WriteOnlyArrayGattCharacteristic<uint8_t, sizeof(Lock_t)> *lockChar; |
Vincent Coubard |
0:4c8f8bf32a99 | 778 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 779 | * Pointer to the BLE API characteristic encapsulation for the Eddystone-URL |
Vincent Coubard |
0:4c8f8bf32a99 | 780 | * Configuration Service Unlock characteristic. |
Vincent Coubard |
0:4c8f8bf32a99 | 781 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 782 | WriteOnlyArrayGattCharacteristic<uint8_t, sizeof(Lock_t)> *unlockChar; |
Vincent Coubard |
0:4c8f8bf32a99 | 783 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 784 | * Pointer to the BLE API characteristic encapsulation for the Eddystone-URL |
Vincent Coubard |
0:4c8f8bf32a99 | 785 | * Configuration Service URI Data characteristic. |
Vincent Coubard |
0:4c8f8bf32a99 | 786 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 787 | GattCharacteristic *urlDataChar; |
Vincent Coubard |
0:4c8f8bf32a99 | 788 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 789 | * Pointer to the BLE API characteristic encapsulation for the Eddystone-URL |
Vincent Coubard |
0:4c8f8bf32a99 | 790 | * Configuration Service Flags characteristic. |
Vincent Coubard |
0:4c8f8bf32a99 | 791 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 792 | ReadWriteGattCharacteristic<uint8_t> *flagsChar; |
Vincent Coubard |
0:4c8f8bf32a99 | 793 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 794 | * Pointer to the BLE API characteristic encapsulation for the Eddystone-URL |
Vincent Coubard |
0:4c8f8bf32a99 | 795 | * Configuration Service Advertised TX Power Levels characteristic. |
Vincent Coubard |
0:4c8f8bf32a99 | 796 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 797 | ReadWriteArrayGattCharacteristic<int8_t, sizeof(PowerLevels_t)> *advPowerLevelsChar; |
Vincent Coubard |
0:4c8f8bf32a99 | 798 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 799 | * Pointer to the BLE API characteristic encapsulation for the Eddystone-URL |
Vincent Coubard |
0:4c8f8bf32a99 | 800 | * Configuration Service TX Power Mode characteristic. |
Vincent Coubard |
0:4c8f8bf32a99 | 801 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 802 | ReadWriteGattCharacteristic<uint8_t> *txPowerModeChar; |
Vincent Coubard |
0:4c8f8bf32a99 | 803 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 804 | * Pointer to the BLE API characteristic encapsulation for the Eddystone-URL |
Vincent Coubard |
0:4c8f8bf32a99 | 805 | * Configuration Service Beacon Period characteristic. |
Vincent Coubard |
0:4c8f8bf32a99 | 806 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 807 | ReadWriteGattCharacteristic<uint16_t> *beaconPeriodChar; |
Vincent Coubard |
0:4c8f8bf32a99 | 808 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 809 | * Pointer to the BLE API characteristic encapsulation for the Eddystone-URL |
Vincent Coubard |
0:4c8f8bf32a99 | 810 | * Configuration Service Reset characteristic. |
Vincent Coubard |
0:4c8f8bf32a99 | 811 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 812 | WriteOnlyGattCharacteristic<bool> *resetChar; |
Vincent Coubard |
0:4c8f8bf32a99 | 813 | |
Vincent Coubard |
0:4c8f8bf32a99 | 814 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 815 | * Pointer to the raw bytes that will be used to populate Eddystone-URL |
Vincent Coubard |
0:4c8f8bf32a99 | 816 | * frames. |
Vincent Coubard |
0:4c8f8bf32a99 | 817 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 818 | uint8_t *rawUrlFrame; |
Vincent Coubard |
0:4c8f8bf32a99 | 819 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 820 | * Pointer to the raw bytes that will be used to populate Eddystone-UID |
Vincent Coubard |
0:4c8f8bf32a99 | 821 | * frames. |
Vincent Coubard |
0:4c8f8bf32a99 | 822 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 823 | uint8_t *rawUidFrame; |
Vincent Coubard |
0:4c8f8bf32a99 | 824 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 825 | * Pointer to the raw bytes that will be used to populate Eddystone-TLM |
Vincent Coubard |
0:4c8f8bf32a99 | 826 | * frames. |
Vincent Coubard |
0:4c8f8bf32a99 | 827 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 828 | uint8_t *rawTlmFrame; |
Vincent Coubard |
0:4c8f8bf32a99 | 829 | |
Vincent Coubard |
0:4c8f8bf32a99 | 830 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 831 | * Circular buffer that represents of Eddystone frames to be advertised. |
Vincent Coubard |
0:4c8f8bf32a99 | 832 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 833 | CircularBuffer<FrameType, ADV_FRAME_QUEUE_SIZE> advFrameQueue; |
Vincent Coubard |
0:4c8f8bf32a99 | 834 | |
Vincent Coubard |
0:4c8f8bf32a99 | 835 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 836 | * The registered callback to update the Eddystone-TLM frame Battery |
Vincent Coubard |
0:4c8f8bf32a99 | 837 | * Voltage. |
Vincent Coubard |
0:4c8f8bf32a99 | 838 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 839 | TlmUpdateCallback_t tlmBatteryVoltageCallback; |
Vincent Coubard |
0:4c8f8bf32a99 | 840 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 841 | * The registered callback to update the Eddystone-TLM frame Beacon |
Vincent Coubard |
0:4c8f8bf32a99 | 842 | * Temperature. |
Vincent Coubard |
0:4c8f8bf32a99 | 843 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 844 | TlmUpdateCallback_t tlmBeaconTemperatureCallback; |
Vincent Coubard |
0:4c8f8bf32a99 | 845 | |
Vincent Coubard |
0:4c8f8bf32a99 | 846 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 847 | * Timer that keeps track of the time since boot. |
Vincent Coubard |
0:4c8f8bf32a99 | 848 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 849 | Timer timeSinceBootTimer; |
Vincent Coubard |
0:4c8f8bf32a99 | 850 | |
Vincent Coubard |
0:4c8f8bf32a99 | 851 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 852 | * Callback handle to keep track of periodic |
Vincent Coubard |
0:4c8f8bf32a99 | 853 | * enqueueFrame(EDDYSTONE_FRAME_UID) callbacks that populate the |
Vincent Coubard |
0:4c8f8bf32a99 | 854 | * advFrameQueue. |
Vincent Coubard |
0:4c8f8bf32a99 | 855 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 856 | int uidFrameCallbackHandle; |
Vincent Coubard |
0:4c8f8bf32a99 | 857 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 858 | * Minar callback handle to keep track of periodic |
Vincent Coubard |
0:4c8f8bf32a99 | 859 | * enqueueFrame(EDDYSTONE_FRAME_URL) callbacks that populate the |
Vincent Coubard |
0:4c8f8bf32a99 | 860 | * advFrameQueue. |
Vincent Coubard |
0:4c8f8bf32a99 | 861 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 862 | int urlFrameCallbackHandle; |
Vincent Coubard |
0:4c8f8bf32a99 | 863 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 864 | * Minar callback handle to keep track of periodic |
Vincent Coubard |
0:4c8f8bf32a99 | 865 | * enqueueFrame(EDDYSTONE_FRAME_TLM) callbacks that populate the |
Vincent Coubard |
0:4c8f8bf32a99 | 866 | * advFrameQueue. |
Vincent Coubard |
0:4c8f8bf32a99 | 867 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 868 | int tlmFrameCallbackHandle; |
Vincent Coubard |
0:4c8f8bf32a99 | 869 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 870 | * Minar callback handle to keep track of manageRadio() callbacks. |
Vincent Coubard |
0:4c8f8bf32a99 | 871 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 872 | int radioManagerCallbackHandle; |
Vincent Coubard |
0:4c8f8bf32a99 | 873 | |
Vincent Coubard |
0:4c8f8bf32a99 | 874 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 875 | * GattCharacteristic table used to populate the BLE ATT table in the |
Vincent Coubard |
0:4c8f8bf32a99 | 876 | * GATT Server. |
Vincent Coubard |
0:4c8f8bf32a99 | 877 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 878 | GattCharacteristic *charTable[TOTAL_CHARACTERISTICS]; |
Vincent Coubard |
0:4c8f8bf32a99 | 879 | |
Vincent Coubard |
0:4c8f8bf32a99 | 880 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 881 | * Pointer to the device name currently being used. |
Vincent Coubard |
0:4c8f8bf32a99 | 882 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 883 | const char *deviceName; |
Vincent Coubard |
0:4c8f8bf32a99 | 884 | |
Vincent Coubard |
0:4c8f8bf32a99 | 885 | /** |
Vincent Coubard |
0:4c8f8bf32a99 | 886 | * Event queue used to post callbacks s |
Vincent Coubard |
0:4c8f8bf32a99 | 887 | */ |
Vincent Coubard |
0:4c8f8bf32a99 | 888 | EventQueue& eventQueue; |
Vincent Coubard |
0:4c8f8bf32a99 | 889 | }; |
Vincent Coubard |
0:4c8f8bf32a99 | 890 | |
Vincent Coubard |
0:4c8f8bf32a99 | 891 | #endif /* __EDDYSTONESERVICE_H__ */ |