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/EddystoneTypes.h@3:5120491ba317, 2016-07-29 (annotated)
- Committer:
- mbed_official
- Date:
- Fri Jul 29 22:45:40 2016 +0100
- Revision:
- 3:5120491ba317
- Parent:
- 2:9ee673e0b86a
Merge branch 'master' of https://github.com/ARMmbed/mbed-os-example-ble
Commit copied from https://github.com/ARMmbed/mbed-os-example-ble
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 3:5120491ba317 | 1 | /* mbed Microcontroller Library |
mbed_official | 3:5120491ba317 | 2 | * Copyright (c) 2006-2015 ARM Limited |
mbed_official | 3:5120491ba317 | 3 | * |
mbed_official | 3:5120491ba317 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
mbed_official | 3:5120491ba317 | 5 | * you may not use this file except in compliance with the License. |
mbed_official | 3:5120491ba317 | 6 | * You may obtain a copy of the License at |
mbed_official | 3:5120491ba317 | 7 | * |
mbed_official | 3:5120491ba317 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
mbed_official | 3:5120491ba317 | 9 | * |
mbed_official | 3:5120491ba317 | 10 | * Unless required by applicable law or agreed to in writing, software |
mbed_official | 3:5120491ba317 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
mbed_official | 3:5120491ba317 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
mbed_official | 3:5120491ba317 | 13 | * See the License for the specific language governing permissions and |
mbed_official | 3:5120491ba317 | 14 | * limitations under the License. |
mbed_official | 3:5120491ba317 | 15 | */ |
mbed_official | 3:5120491ba317 | 16 | |
mbed_official | 3:5120491ba317 | 17 | #ifndef __EDDYSTONETYPES_H__ |
mbed_official | 3:5120491ba317 | 18 | #define __EDDYSTONETYPES_H__ |
mbed_official | 3:5120491ba317 | 19 | |
mbed_official | 3:5120491ba317 | 20 | #include <stdint.h> |
mbed_official | 3:5120491ba317 | 21 | #include <stddef.h> |
mbed_official | 3:5120491ba317 | 22 | |
mbed_official | 3:5120491ba317 | 23 | #ifndef YOTTA_CFG_EDDYSTONE_DEFAULT_DEVICE_NAME |
mbed_official | 3:5120491ba317 | 24 | #define YOTTA_CFG_EDDYSTONE_DEFAULT_DEVICE_NAME "EDDYSTONE CONFIG" |
mbed_official | 3:5120491ba317 | 25 | #endif |
mbed_official | 3:5120491ba317 | 26 | |
mbed_official | 3:5120491ba317 | 27 | #ifndef YOTTA_CFG_EDDYSTONE_DEFAULT_URL |
mbed_official | 3:5120491ba317 | 28 | #define YOTTA_CFG_EDDYSTONE_DEFAULT_URL "https://www.mbed.com/" |
mbed_official | 3:5120491ba317 | 29 | #endif |
mbed_official | 3:5120491ba317 | 30 | |
mbed_official | 3:5120491ba317 | 31 | /** |
mbed_official | 3:5120491ba317 | 32 | * Macro to expand a 16-bit Eddystone UUID to 128-bit UUID. |
mbed_official | 3:5120491ba317 | 33 | */ |
mbed_official | 3:5120491ba317 | 34 | #define UUID_URL_BEACON(FIRST, SECOND) { \ |
mbed_official | 3:5120491ba317 | 35 | 0xee, 0x0c, FIRST, SECOND, 0x87, 0x86, 0x40, 0xba, \ |
mbed_official | 3:5120491ba317 | 36 | 0xab, 0x96, 0x99, 0xb9, 0x1a, 0xc9, 0x81, 0xd8, \ |
mbed_official | 3:5120491ba317 | 37 | } |
mbed_official | 3:5120491ba317 | 38 | |
mbed_official | 3:5120491ba317 | 39 | /** |
mbed_official | 3:5120491ba317 | 40 | * Eddystone 16-bit UUID. |
mbed_official | 3:5120491ba317 | 41 | */ |
mbed_official | 3:5120491ba317 | 42 | const uint8_t EDDYSTONE_UUID[] = {0xAA, 0xFE}; |
mbed_official | 3:5120491ba317 | 43 | |
mbed_official | 3:5120491ba317 | 44 | /** |
mbed_official | 3:5120491ba317 | 45 | * 128-bit UUID for Eddystone-URL Configuration Service. |
mbed_official | 3:5120491ba317 | 46 | */ |
mbed_official | 3:5120491ba317 | 47 | const uint8_t UUID_URL_BEACON_SERVICE[] = UUID_URL_BEACON(0x20, 0x80); |
mbed_official | 3:5120491ba317 | 48 | /** |
mbed_official | 3:5120491ba317 | 49 | * 128-bit UUID for Eddystone-URL Configuration Service Lock State |
mbed_official | 3:5120491ba317 | 50 | * characteristic. |
mbed_official | 3:5120491ba317 | 51 | */ |
mbed_official | 3:5120491ba317 | 52 | const uint8_t UUID_LOCK_STATE_CHAR[] = UUID_URL_BEACON(0x20, 0x81); |
mbed_official | 3:5120491ba317 | 53 | /** |
mbed_official | 3:5120491ba317 | 54 | * 128-bit UUID for Eddystone-URL Configuration Service Lock |
mbed_official | 3:5120491ba317 | 55 | * characteristic. |
mbed_official | 3:5120491ba317 | 56 | */ |
mbed_official | 3:5120491ba317 | 57 | const uint8_t UUID_LOCK_CHAR[] = UUID_URL_BEACON(0x20, 0x82); |
mbed_official | 3:5120491ba317 | 58 | /** |
mbed_official | 3:5120491ba317 | 59 | * 128-bit UUID for Eddystone-URL Configuration Service Unlock |
mbed_official | 3:5120491ba317 | 60 | * characteristic. |
mbed_official | 3:5120491ba317 | 61 | */ |
mbed_official | 3:5120491ba317 | 62 | const uint8_t UUID_UNLOCK_CHAR[] = UUID_URL_BEACON(0x20, 0x83); |
mbed_official | 3:5120491ba317 | 63 | /** |
mbed_official | 3:5120491ba317 | 64 | * 128-bit UUID for Eddystone-URL Configuration Service URI Data |
mbed_official | 3:5120491ba317 | 65 | * characteristic. |
mbed_official | 3:5120491ba317 | 66 | */ |
mbed_official | 3:5120491ba317 | 67 | const uint8_t UUID_URL_DATA_CHAR[] = UUID_URL_BEACON(0x20, 0x84); |
mbed_official | 3:5120491ba317 | 68 | /** |
mbed_official | 3:5120491ba317 | 69 | * 128-bit UUID for Eddystone-URL Configuration Service Flags |
mbed_official | 3:5120491ba317 | 70 | * characteristic. |
mbed_official | 3:5120491ba317 | 71 | */ |
mbed_official | 3:5120491ba317 | 72 | const uint8_t UUID_FLAGS_CHAR[] = UUID_URL_BEACON(0x20, 0x85); |
mbed_official | 3:5120491ba317 | 73 | /** |
mbed_official | 3:5120491ba317 | 74 | * 128-bit UUID for Eddystone-URL Configuration Service Advertised TX Power |
mbed_official | 3:5120491ba317 | 75 | * Levels characteristic. |
mbed_official | 3:5120491ba317 | 76 | */ |
mbed_official | 3:5120491ba317 | 77 | const uint8_t UUID_ADV_POWER_LEVELS_CHAR[] = UUID_URL_BEACON(0x20, 0x86); |
mbed_official | 3:5120491ba317 | 78 | /** |
mbed_official | 3:5120491ba317 | 79 | * 128-bit UUID for Eddystone-URL Configuration Service TX Power Mode |
mbed_official | 3:5120491ba317 | 80 | * characteristic. |
mbed_official | 3:5120491ba317 | 81 | */ |
mbed_official | 3:5120491ba317 | 82 | const uint8_t UUID_TX_POWER_MODE_CHAR[] = UUID_URL_BEACON(0x20, 0x87); |
mbed_official | 3:5120491ba317 | 83 | /** |
mbed_official | 3:5120491ba317 | 84 | * 128-bit UUID for Eddystone-URL Configuration Service Beacon Period |
mbed_official | 3:5120491ba317 | 85 | * characteristic. |
mbed_official | 3:5120491ba317 | 86 | */ |
mbed_official | 3:5120491ba317 | 87 | const uint8_t UUID_BEACON_PERIOD_CHAR[] = UUID_URL_BEACON(0x20, 0x88); |
mbed_official | 3:5120491ba317 | 88 | /** |
mbed_official | 3:5120491ba317 | 89 | * 128-bit UUID for Eddystone-URL Configuration Service Reset |
mbed_official | 3:5120491ba317 | 90 | * characteristic. |
mbed_official | 3:5120491ba317 | 91 | */ |
mbed_official | 3:5120491ba317 | 92 | const uint8_t UUID_RESET_CHAR[] = UUID_URL_BEACON(0x20, 0x89); |
mbed_official | 3:5120491ba317 | 93 | |
mbed_official | 3:5120491ba317 | 94 | /** |
mbed_official | 3:5120491ba317 | 95 | * Default name for the BLE Device Name characteristic. |
mbed_official | 3:5120491ba317 | 96 | */ |
mbed_official | 3:5120491ba317 | 97 | const char DEFAULT_DEVICE_NAME[] = YOTTA_CFG_EDDYSTONE_DEFAULT_DEVICE_NAME; |
mbed_official | 3:5120491ba317 | 98 | |
mbed_official | 3:5120491ba317 | 99 | /** |
mbed_official | 3:5120491ba317 | 100 | * Default URL used by EddystoneService. |
mbed_official | 3:5120491ba317 | 101 | */ |
mbed_official | 3:5120491ba317 | 102 | const char DEFAULT_URL[] = YOTTA_CFG_EDDYSTONE_DEFAULT_URL; |
mbed_official | 3:5120491ba317 | 103 | |
mbed_official | 3:5120491ba317 | 104 | /** |
mbed_official | 3:5120491ba317 | 105 | * Enumeration that defines the Eddystone power levels for the Eddystone-URL |
mbed_official | 3:5120491ba317 | 106 | * Configuration Service TX Power Mode characteristic. Refer to |
mbed_official | 3:5120491ba317 | 107 | * https://github.com/google/eddystone/blob/master/eddystone-url/docs/config-service-spec.md#37-tx-power-mode. |
mbed_official | 3:5120491ba317 | 108 | */ |
mbed_official | 3:5120491ba317 | 109 | enum PowerModes { |
mbed_official | 3:5120491ba317 | 110 | /** |
mbed_official | 3:5120491ba317 | 111 | * Lowest transmit power mode. |
mbed_official | 3:5120491ba317 | 112 | */ |
mbed_official | 3:5120491ba317 | 113 | TX_POWER_MODE_LOWEST, |
mbed_official | 3:5120491ba317 | 114 | /** |
mbed_official | 3:5120491ba317 | 115 | * Low transmit power mode. |
mbed_official | 3:5120491ba317 | 116 | */ |
mbed_official | 3:5120491ba317 | 117 | TX_POWER_MODE_LOW, |
mbed_official | 3:5120491ba317 | 118 | /** |
mbed_official | 3:5120491ba317 | 119 | * Medium transmit power mode. |
mbed_official | 3:5120491ba317 | 120 | */ |
mbed_official | 3:5120491ba317 | 121 | TX_POWER_MODE_MEDIUM, |
mbed_official | 3:5120491ba317 | 122 | /** |
mbed_official | 3:5120491ba317 | 123 | * Highest transmit power mode. |
mbed_official | 3:5120491ba317 | 124 | */ |
mbed_official | 3:5120491ba317 | 125 | TX_POWER_MODE_HIGH, |
mbed_official | 3:5120491ba317 | 126 | /** |
mbed_official | 3:5120491ba317 | 127 | * Total number of power modes. |
mbed_official | 3:5120491ba317 | 128 | */ |
mbed_official | 3:5120491ba317 | 129 | NUM_POWER_MODES |
mbed_official | 3:5120491ba317 | 130 | }; |
mbed_official | 3:5120491ba317 | 131 | |
mbed_official | 3:5120491ba317 | 132 | /** |
mbed_official | 3:5120491ba317 | 133 | * Type for the 128-bit for Eddystone-URL Configuration Service Lock and Unlock |
mbed_official | 3:5120491ba317 | 134 | * characteristic value. |
mbed_official | 3:5120491ba317 | 135 | */ |
mbed_official | 3:5120491ba317 | 136 | typedef uint8_t Lock_t[16]; |
mbed_official | 3:5120491ba317 | 137 | /** |
mbed_official | 3:5120491ba317 | 138 | * Type for the 128-bit for Eddystone-URL Configuration Service Advertised TX |
mbed_official | 3:5120491ba317 | 139 | * Power Levels characteristic value. |
mbed_official | 3:5120491ba317 | 140 | */ |
mbed_official | 3:5120491ba317 | 141 | typedef int8_t PowerLevels_t[NUM_POWER_MODES]; |
mbed_official | 3:5120491ba317 | 142 | |
mbed_official | 3:5120491ba317 | 143 | /** |
mbed_official | 3:5120491ba317 | 144 | * Maximum length of an encoded URL for Eddystone. |
mbed_official | 3:5120491ba317 | 145 | */ |
mbed_official | 3:5120491ba317 | 146 | const uint16_t URL_DATA_MAX = 18; |
mbed_official | 3:5120491ba317 | 147 | /** |
mbed_official | 3:5120491ba317 | 148 | * Type for an encoded URL for Eddystone. |
mbed_official | 3:5120491ba317 | 149 | */ |
mbed_official | 3:5120491ba317 | 150 | typedef uint8_t UrlData_t[URL_DATA_MAX]; |
mbed_official | 3:5120491ba317 | 151 | |
mbed_official | 3:5120491ba317 | 152 | /** |
mbed_official | 3:5120491ba317 | 153 | * Size in bytes of UID namespace ID. |
mbed_official | 3:5120491ba317 | 154 | */ |
mbed_official | 3:5120491ba317 | 155 | const size_t UID_NAMESPACEID_SIZE = 10; |
mbed_official | 3:5120491ba317 | 156 | /** |
mbed_official | 3:5120491ba317 | 157 | * Type for the UID namespace ID. |
mbed_official | 3:5120491ba317 | 158 | */ |
mbed_official | 3:5120491ba317 | 159 | typedef uint8_t UIDNamespaceID_t[UID_NAMESPACEID_SIZE]; |
mbed_official | 3:5120491ba317 | 160 | /** |
mbed_official | 3:5120491ba317 | 161 | * Size in bytes of UID instance ID. |
mbed_official | 3:5120491ba317 | 162 | */ |
mbed_official | 3:5120491ba317 | 163 | const size_t UID_INSTANCEID_SIZE = 6; |
mbed_official | 3:5120491ba317 | 164 | /** |
mbed_official | 3:5120491ba317 | 165 | * Type for the UID instance ID. |
mbed_official | 3:5120491ba317 | 166 | */ |
mbed_official | 3:5120491ba317 | 167 | typedef uint8_t UIDInstanceID_t[UID_INSTANCEID_SIZE]; |
mbed_official | 3:5120491ba317 | 168 | |
mbed_official | 3:5120491ba317 | 169 | /** |
mbed_official | 3:5120491ba317 | 170 | * Type for callbacks to update Eddystone-TLM frame Batery Voltage and Beacon |
mbed_official | 3:5120491ba317 | 171 | * Temperature. |
mbed_official | 3:5120491ba317 | 172 | */ |
mbed_official | 3:5120491ba317 | 173 | typedef uint16_t (*TlmUpdateCallback_t) (uint16_t); |
mbed_official | 3:5120491ba317 | 174 | |
mbed_official | 3:5120491ba317 | 175 | /** |
mbed_official | 3:5120491ba317 | 176 | * Size of Eddystone UUID. Needed to construct all frames raw bytes. |
mbed_official | 3:5120491ba317 | 177 | */ |
mbed_official | 3:5120491ba317 | 178 | const uint16_t EDDYSTONE_UUID_SIZE = sizeof(EDDYSTONE_UUID); |
mbed_official | 3:5120491ba317 | 179 | |
mbed_official | 3:5120491ba317 | 180 | #endif /* __EDDYSTONETYPES_H__ */ |