Roy Want / Mbed OS beaconCompileReadyFork
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers EddystoneTypes.h Source File

EddystoneTypes.h

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2006-2015 ARM Limited
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef __EDDYSTONETYPES_H__
00018 #define __EDDYSTONETYPES_H__
00019 
00020 #include <stdint.h>
00021 #include <stddef.h>
00022 #include "Eddystone_config.h"
00023 
00024 /**
00025  * Macro to expand a 16-bit Eddystone UUID to 128-bit UUID.
00026  */
00027 #define UUID_ES_BEACON(FIRST, SECOND) {                          \
00028         0xa3, 0x0c8, FIRST, SECOND, 0x8e, 0xd3, 0x4b, 0xdf,      \
00029         0x8a, 0x39, 0xa0, 0x1b, 0xeb, 0xed, 0xe2, 0x95,          \
00030 }
00031 
00032 /**
00033  * Eddystone 16-bit UUID.
00034  */
00035 const uint8_t EDDYSTONE_UUID[] = {0xAA, 0xFE};
00036 
00037 /**
00038  * Size of Eddystone UID. Needed to construct all frames raw bytes.
00039  */
00040 const uint16_t EDDYSTONE_UUID_SIZE = sizeof(EDDYSTONE_UUID);
00041 
00042 /** BEGINING OF CHARACTERISTICS */
00043 
00044 /**
00045  * 128-bit UUID for Eddystone-GATT Configuration Service.
00046  */
00047 const uint8_t UUID_ES_BEACON_SERVICE[]         = UUID_ES_BEACON(0x75, 0x00);
00048 
00049 /**
00050  * 128-bit UUID for Eddystone-URL Configuration Service Capabilities
00051  * characteristic.
00052  */
00053 const uint8_t UUID_CAPABILITIES_CHAR[]          = UUID_ES_BEACON(0x75, 0x01);
00054 
00055 /**
00056  * 128-bit UUID for Eddystone-URL Configuration Service Active Slot
00057  * characteristic.
00058  */
00059 const uint8_t UUID_ACTIVE_SLOT_CHAR[]           = UUID_ES_BEACON(0x75, 0x02);
00060 
00061 /**
00062  * 128-bit UUID for Eddystone-URL Configuration Service Advertising Interval
00063  * characteristic.
00064  */
00065 const uint8_t UUID_ADV_INTERVAL_CHAR[]          = UUID_ES_BEACON(0x75, 0x03);
00066 
00067 /**
00068  * 128-bit UUID for Eddystone-URL Configuration Service Radio Tx Power
00069  * characteristic.
00070  */
00071 const uint8_t UUID_RADIO_TX_POWER_CHAR[]        = UUID_ES_BEACON(0x75, 0x04);
00072 
00073 /**
00074  * 128-bit UUID for Eddystone-URL Configuration Service Adv Tx Power
00075  * characteristic.
00076  */
00077 const uint8_t UUID_ADV_TX_POWER_CHAR[]          = UUID_ES_BEACON(0x75, 0x05);
00078 
00079 /**
00080  * 128-bit UUID for Eddystone-URL Configuration Service Lock State
00081  * characteristic.
00082  */
00083 const uint8_t UUID_LOCK_STATE_CHAR[]            = UUID_ES_BEACON(0x75, 0x06);
00084 
00085 /**
00086  * 128-bit UUID for Eddystone-URL Configuration Service Unlock
00087  * characteristic.
00088  */
00089 const uint8_t UUID_UNLOCK_CHAR[]                = UUID_ES_BEACON(0x75, 0x07);
00090 
00091 /**
00092  * 128-bit UUID for Eddystone-URL Configuration Service Public ECDH Key
00093  * characteristic.
00094  */
00095 const uint8_t UUID_PUBLIC_ECDH_KEY_CHAR[]       = UUID_ES_BEACON(0x75, 0x08);
00096 
00097 /**
00098  * 128-bit UUID for Eddystone-URL Configuration Service EID Identity Key
00099  * characteristic.
00100  */
00101 const uint8_t UUID_EID_IDENTITY_KEY_CHAR[]      = UUID_ES_BEACON(0x75, 0x09);
00102 
00103 /**
00104  * 128-bit UUID for Eddystone-URL Configuration Service Adv Slot Data
00105  * characteristic.
00106  */
00107 const uint8_t UUID_ADV_SLOT_DATA_CHAR[]         = UUID_ES_BEACON(0x75, 0x0a);
00108 
00109 /**
00110  * 128-bit UUID for Eddystone-URL Configuration Service Reset
00111  * characteristic.
00112  */
00113 const uint8_t UUID_FACTORY_RESET_CHAR[]         = UUID_ES_BEACON(0x75, 0x0b);
00114 
00115 /**
00116  * 128-bit UUID for Eddystone-URL Configuration Service Remain Connectable
00117  * characteristic.
00118  */
00119 const uint8_t UUID_REMAIN_CONNECTABLE_CHAR[]    = UUID_ES_BEACON(0x75, 0x0c);
00120 
00121 /** END OF CHARACTERISTICS  */
00122 
00123 /**
00124  * Default Lock State used  by EddystoneService.
00125  */
00126 const uint8_t DEFAULT_LOCK_STATE_DATA[] = {DEFAULT_LOCK_STATE};
00127 
00128 /**
00129  * A type defining the size of the READ ONLY capability characteristic
00130  */
00131 typedef uint8_t Capability_t[CAP_HDR_LEN + NUM_POWER_MODES];
00132 
00133 /**
00134  * Type for the 128-bit for Eddystone-URL Configuration Service Lock and Unlock
00135  * characteristic value.
00136  */
00137 typedef uint8_t Lock_t[16];
00138 
00139 /**
00140  * Type for the 128-bit for Eddystone-URL Configuration Service Advertised TX
00141  * Power Levels characteristic value.
00142  */
00143 typedef int8_t PowerLevels_t[NUM_POWER_MODES];
00144 
00145 /**
00146  * Type representing the power level set for each slot
00147  */
00148 typedef int8_t SlotTxPowerLevels_t[MAX_ADV_SLOTS];
00149 
00150 /**
00151  * Type representing the adv interval set for each slot
00152  */
00153 typedef uint16_t SlotAdvIntervals_t[MAX_ADV_SLOTS];
00154 
00155 /**
00156  * Type representing the buffer used to represent the LockState and potentially
00157  * an updated key
00158  */
00159 typedef uint8_t LockState_t[17];
00160 
00161 /**
00162  * Type representing the EID private ECDH Key
00163  */
00164 typedef uint8_t PrivateEcdhKey_t[32];
00165 
00166 /**
00167  * Type representing the EID public ECDH Key
00168  */
00169 typedef uint8_t PublicEcdhKey_t[32];
00170 
00171 /**
00172  * Type representing the EID Identity Key
00173  */
00174 typedef uint8_t EidIdentityKey_t[16];
00175 
00176 /**
00177  * Type representing the storage for a single slot
00178  */
00179 typedef uint8_t Slot_t[32]; 
00180 
00181 /**
00182  * Type representing the storage for all slots given MAX_ADV_SLOTS
00183  */
00184 typedef uint8_t SlotStorage_t[MAX_ADV_SLOTS * sizeof(Slot_t)];
00185 
00186 /**
00187  * Type representing the current frame types if each slot
00188  */
00189 typedef uint8_t SlotFrameTypes_t[MAX_ADV_SLOTS];
00190 
00191 /**
00192  * Type representing the EID rotation period exp for each slot
00193  */
00194 typedef uint8_t SlotEidRotationPeriodExps_t[MAX_ADV_SLOTS];
00195 
00196 /**
00197  * Type representing the EID next rotation time for each slot
00198  */
00199 typedef uint32_t SlotEidNextRotationTimes_t[MAX_ADV_SLOTS];
00200 
00201 /**
00202  * Type representing the EID identity keys for each slot
00203  */
00204 typedef EidIdentityKey_t SlotEidIdentityKeys_t[MAX_ADV_SLOTS];
00205 
00206 /**
00207  * Size in bytes of UID namespace ID.
00208  */
00209 const size_t UID_NAMESPACEID_SIZE = 10;
00210 
00211 /**
00212  * Type for the UID namespace ID.
00213  */
00214 typedef uint8_t UIDNamespaceID_t[UID_NAMESPACEID_SIZE];
00215 
00216 /**
00217  * Size in bytes of UID instance ID.
00218  */
00219 const size_t UID_INSTANCEID_SIZE = 6;
00220 
00221 /**
00222  * Type for the UID instance ID.
00223  */
00224 typedef uint8_t UIDInstanceID_t[UID_INSTANCEID_SIZE];
00225 
00226 /**
00227  * Type for callbacks to update Eddystone-TLM frame Batery Voltage and Beacon
00228  * Temperature.
00229  */
00230 typedef uint16_t (*TlmUpdateCallback_t) (uint16_t);
00231 
00232 
00233 #endif /* __EDDYSTONETYPES_H__ */