BLE EddystoneService example

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 
00023 #ifndef YOTTA_CFG_EDDYSTONE_DEFAULT_DEVICE_NAME
00024     #define YOTTA_CFG_EDDYSTONE_DEFAULT_DEVICE_NAME "EDDYSTONE CONFIG"
00025 #endif
00026 
00027 #ifndef YOTTA_CFG_EDDYSTONE_DEFAULT_URL
00028     #define YOTTA_CFG_EDDYSTONE_DEFAULT_URL "https://www.mbed.com/"
00029 #endif
00030 
00031 /**
00032  * Macro to expand a 16-bit Eddystone UUID to 128-bit UUID.
00033  */
00034 #define UUID_URL_BEACON(FIRST, SECOND) {                         \
00035         0xee, 0x0c, FIRST, SECOND, 0x87, 0x86, 0x40, 0xba,       \
00036         0xab, 0x96, 0x99, 0xb9, 0x1a, 0xc9, 0x81, 0xd8,          \
00037 }
00038 
00039 /**
00040  * Eddystone 16-bit UUID.
00041  */
00042 const uint8_t EDDYSTONE_UUID[] = {0xAA, 0xFE};
00043 
00044 /**
00045  * 128-bit UUID for Eddystone-URL Configuration Service.
00046  */
00047 const uint8_t UUID_URL_BEACON_SERVICE[]    = UUID_URL_BEACON(0x20, 0x80);
00048 /**
00049  * 128-bit UUID for Eddystone-URL Configuration Service Lock State
00050  * characteristic.
00051  */
00052 const uint8_t UUID_LOCK_STATE_CHAR[]       = UUID_URL_BEACON(0x20, 0x81);
00053 /**
00054  * 128-bit UUID for Eddystone-URL Configuration Service Lock
00055  * characteristic.
00056  */
00057 const uint8_t UUID_LOCK_CHAR[]             = UUID_URL_BEACON(0x20, 0x82);
00058 /**
00059  * 128-bit UUID for Eddystone-URL Configuration Service Unlock
00060  * characteristic.
00061  */
00062 const uint8_t UUID_UNLOCK_CHAR[]           = UUID_URL_BEACON(0x20, 0x83);
00063 /**
00064  * 128-bit UUID for Eddystone-URL Configuration Service URI Data
00065  * characteristic.
00066  */
00067 const uint8_t UUID_URL_DATA_CHAR[]         = UUID_URL_BEACON(0x20, 0x84);
00068 /**
00069  * 128-bit UUID for Eddystone-URL Configuration Service Flags
00070  * characteristic.
00071  */
00072 const uint8_t UUID_FLAGS_CHAR[]            = UUID_URL_BEACON(0x20, 0x85);
00073 /**
00074  * 128-bit UUID for Eddystone-URL Configuration Service Advertised TX Power
00075  * Levels characteristic.
00076  */
00077 const uint8_t UUID_ADV_POWER_LEVELS_CHAR[] = UUID_URL_BEACON(0x20, 0x86);
00078 /**
00079  * 128-bit UUID for Eddystone-URL Configuration Service TX Power Mode
00080  * characteristic.
00081  */
00082 const uint8_t UUID_TX_POWER_MODE_CHAR[]    = UUID_URL_BEACON(0x20, 0x87);
00083 /**
00084  * 128-bit UUID for Eddystone-URL Configuration Service Beacon Period
00085  * characteristic.
00086  */
00087 const uint8_t UUID_BEACON_PERIOD_CHAR[]    = UUID_URL_BEACON(0x20, 0x88);
00088 /**
00089  * 128-bit UUID for Eddystone-URL Configuration Service Reset
00090  * characteristic.
00091  */
00092 const uint8_t UUID_RESET_CHAR[]            = UUID_URL_BEACON(0x20, 0x89);
00093 
00094 /**
00095  * Default name for the BLE Device Name characteristic.
00096  */
00097 const char DEFAULT_DEVICE_NAME[] = YOTTA_CFG_EDDYSTONE_DEFAULT_DEVICE_NAME;
00098 
00099 /**
00100  * Default URL used  by EddystoneService.
00101  */
00102 const char DEFAULT_URL[] = YOTTA_CFG_EDDYSTONE_DEFAULT_URL;
00103 
00104 /**
00105  * Enumeration that defines the Eddystone power levels for the Eddystone-URL
00106  * Configuration Service TX Power Mode characteristic. Refer to
00107  * https://github.com/google/eddystone/blob/master/eddystone-url/docs/config-service-spec.md#37-tx-power-mode.
00108  */
00109 enum PowerModes {
00110     /**
00111      * Lowest transmit power mode.
00112      */
00113     TX_POWER_MODE_LOWEST,
00114     /**
00115      * Low transmit power mode.
00116      */
00117     TX_POWER_MODE_LOW,
00118     /**
00119      * Medium transmit power mode.
00120      */
00121     TX_POWER_MODE_MEDIUM,
00122     /**
00123      * Highest transmit power mode.
00124      */
00125     TX_POWER_MODE_HIGH,
00126     /**
00127      * Total number of power modes.
00128      */
00129     NUM_POWER_MODES
00130 };
00131 
00132 /**
00133  * Type for the 128-bit for Eddystone-URL Configuration Service Lock and Unlock
00134  * characteristic value.
00135  */
00136 typedef uint8_t Lock_t[16];
00137 /**
00138  * Type for the 128-bit for Eddystone-URL Configuration Service Advertised TX
00139  * Power Levels characteristic value.
00140  */
00141 typedef int8_t PowerLevels_t[NUM_POWER_MODES];
00142 
00143 /**
00144  * Maximum length of an encoded URL for Eddystone.
00145  */
00146 const uint16_t URL_DATA_MAX = 18;
00147 /**
00148  * Type for an encoded URL for Eddystone.
00149  */
00150 typedef uint8_t UrlData_t[URL_DATA_MAX];
00151 
00152 /**
00153  * Size in bytes of UID namespace ID.
00154  */
00155 const size_t UID_NAMESPACEID_SIZE = 10;
00156 /**
00157  * Type for the UID namespace ID.
00158  */
00159 typedef uint8_t UIDNamespaceID_t[UID_NAMESPACEID_SIZE];
00160 /**
00161  * Size in bytes of UID instance ID.
00162  */
00163 const size_t UID_INSTANCEID_SIZE = 6;
00164 /**
00165  * Type for the UID instance ID.
00166  */
00167 typedef uint8_t UIDInstanceID_t[UID_INSTANCEID_SIZE];
00168 
00169 /**
00170  * Type for callbacks to update Eddystone-TLM frame Batery Voltage and Beacon
00171  * Temperature.
00172  */
00173 typedef uint16_t (*TlmUpdateCallback_t) (uint16_t);
00174 
00175 /**
00176  * Size of Eddystone UUID. Needed to construct all frames raw bytes.
00177  */
00178 const uint16_t EDDYSTONE_UUID_SIZE = sizeof(EDDYSTONE_UUID);
00179 
00180 #endif /* __EDDYSTONETYPES_H__ */