The eddystone config service allows you to configure the eddystone frame data over BLE for a set period of time and then starts an eddystone beacon. This example defaults to 30 seconds of config time.

Dependencies:   BLE_API mbed nRF51822 X_NUCLEO_IDB0XA1

Fork of BLE_EddystoneBeaconConfigServiceRelease by Austin Blackstone

This is the eddystone config service. This code starts up and for a user configured time period (default 30 seconds) will advertise the configuration service.

The configuration service allows for modifying various frames of the eddystone specification.

For more details on the Configuration Service please see : https://github.com/google/eddystone/blob/master/eddystone-url/docs/config-service-spec.md

Committer:
Vincent Coubard
Date:
Tue Sep 20 14:21:04 2016 +0100
Revision:
8:f53d48e5d64f
Parent:
6:321047f0190a
Update libraries and add support of ST shield.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andresag 6:321047f0190a 1 /* mbed Microcontroller Library
andresag 6:321047f0190a 2 * Copyright (c) 2006-2015 ARM Limited
andresag 6:321047f0190a 3 *
andresag 6:321047f0190a 4 * Licensed under the Apache License, Version 2.0 (the "License");
andresag 6:321047f0190a 5 * you may not use this file except in compliance with the License.
andresag 6:321047f0190a 6 * You may obtain a copy of the License at
andresag 6:321047f0190a 7 *
andresag 6:321047f0190a 8 * http://www.apache.org/licenses/LICENSE-2.0
andresag 6:321047f0190a 9 *
andresag 6:321047f0190a 10 * Unless required by applicable law or agreed to in writing, software
andresag 6:321047f0190a 11 * distributed under the License is distributed on an "AS IS" BASIS,
andresag 6:321047f0190a 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
andresag 6:321047f0190a 13 * See the License for the specific language governing permissions and
andresag 6:321047f0190a 14 * limitations under the License.
andresag 6:321047f0190a 15 */
andresag 6:321047f0190a 16
andresag 6:321047f0190a 17 #include "TLMFrame.h"
andresag 6:321047f0190a 18
andresag 6:321047f0190a 19 TLMFrame::TLMFrame(uint8_t tlmVersionIn,
andresag 6:321047f0190a 20 uint16_t tlmBatteryVoltageIn,
andresag 6:321047f0190a 21 uint16_t tlmBeaconTemperatureIn,
andresag 6:321047f0190a 22 uint32_t tlmPduCountIn,
andresag 6:321047f0190a 23 uint32_t tlmTimeSinceBootIn) :
andresag 6:321047f0190a 24 tlmVersion(tlmVersionIn),
andresag 6:321047f0190a 25 lastTimeSinceBootRead(0),
andresag 6:321047f0190a 26 tlmBatteryVoltage(tlmBatteryVoltageIn),
andresag 6:321047f0190a 27 tlmBeaconTemperature(tlmBeaconTemperatureIn),
andresag 6:321047f0190a 28 tlmPduCount(tlmPduCountIn),
andresag 6:321047f0190a 29 tlmTimeSinceBoot(tlmTimeSinceBootIn)
andresag 6:321047f0190a 30 {
andresag 6:321047f0190a 31 }
andresag 6:321047f0190a 32
andresag 6:321047f0190a 33 void TLMFrame::setTLMData(uint8_t tlmVersionIn)
andresag 6:321047f0190a 34 {
andresag 6:321047f0190a 35 /* According to the Eddystone spec BatteryVoltage is 0 and
andresag 6:321047f0190a 36 * BeaconTemperature is 0x8000 if not supported
andresag 6:321047f0190a 37 */
andresag 6:321047f0190a 38 tlmVersion = tlmVersionIn;
andresag 6:321047f0190a 39 tlmBatteryVoltage = 0;
andresag 6:321047f0190a 40 tlmBeaconTemperature = 0x8000;
andresag 6:321047f0190a 41 tlmPduCount = 0;
andresag 6:321047f0190a 42 tlmTimeSinceBoot = 0;
andresag 6:321047f0190a 43 }
andresag 6:321047f0190a 44
andresag 6:321047f0190a 45 void TLMFrame::constructTLMFrame(uint8_t *rawFrame)
andresag 6:321047f0190a 46 {
andresag 6:321047f0190a 47 size_t index = 0;
andresag 6:321047f0190a 48 rawFrame[index++] = EDDYSTONE_UUID[0]; // 16-bit Eddystone UUID
andresag 6:321047f0190a 49 rawFrame[index++] = EDDYSTONE_UUID[1];
andresag 6:321047f0190a 50 rawFrame[index++] = FRAME_TYPE_TLM; // Eddystone frame type = Telemetry
andresag 6:321047f0190a 51 rawFrame[index++] = tlmVersion; // TLM Version Number
andresag 6:321047f0190a 52 rawFrame[index++] = (uint8_t)(tlmBatteryVoltage >> 8); // Battery Voltage[0]
andresag 6:321047f0190a 53 rawFrame[index++] = (uint8_t)(tlmBatteryVoltage >> 0); // Battery Voltage[1]
andresag 6:321047f0190a 54 rawFrame[index++] = (uint8_t)(tlmBeaconTemperature >> 8); // Beacon Temp[0]
andresag 6:321047f0190a 55 rawFrame[index++] = (uint8_t)(tlmBeaconTemperature >> 0); // Beacon Temp[1]
andresag 6:321047f0190a 56 rawFrame[index++] = (uint8_t)(tlmPduCount >> 24); // PDU Count [0]
andresag 6:321047f0190a 57 rawFrame[index++] = (uint8_t)(tlmPduCount >> 16); // PDU Count [1]
andresag 6:321047f0190a 58 rawFrame[index++] = (uint8_t)(tlmPduCount >> 8); // PDU Count [2]
andresag 6:321047f0190a 59 rawFrame[index++] = (uint8_t)(tlmPduCount >> 0); // PDU Count [3]
andresag 6:321047f0190a 60 rawFrame[index++] = (uint8_t)(tlmTimeSinceBoot >> 24); // Time Since Boot [0]
andresag 6:321047f0190a 61 rawFrame[index++] = (uint8_t)(tlmTimeSinceBoot >> 16); // Time Since Boot [1]
andresag 6:321047f0190a 62 rawFrame[index++] = (uint8_t)(tlmTimeSinceBoot >> 8); // Time Since Boot [2]
andresag 6:321047f0190a 63 rawFrame[index++] = (uint8_t)(tlmTimeSinceBoot >> 0); // Time Since Boot [3]
andresag 6:321047f0190a 64 }
andresag 6:321047f0190a 65
andresag 6:321047f0190a 66 size_t TLMFrame::getRawFrameSize(void) const
andresag 6:321047f0190a 67 {
andresag 6:321047f0190a 68 return FRAME_SIZE_TLM + EDDYSTONE_UUID_SIZE;
andresag 6:321047f0190a 69 }
andresag 6:321047f0190a 70
andresag 6:321047f0190a 71 void TLMFrame::updateTimeSinceBoot(uint32_t nowInMillis)
andresag 6:321047f0190a 72 {
andresag 6:321047f0190a 73 tlmTimeSinceBoot += (nowInMillis - lastTimeSinceBootRead) / 100;
andresag 6:321047f0190a 74 lastTimeSinceBootRead = nowInMillis;
andresag 6:321047f0190a 75 }
andresag 6:321047f0190a 76
andresag 6:321047f0190a 77 void TLMFrame::updateBatteryVoltage(uint16_t tlmBatteryVoltageIn)
andresag 6:321047f0190a 78 {
andresag 6:321047f0190a 79 tlmBatteryVoltage = tlmBatteryVoltageIn;
andresag 6:321047f0190a 80 }
andresag 6:321047f0190a 81
andresag 6:321047f0190a 82 void TLMFrame::updateBeaconTemperature(uint16_t tlmBeaconTemperatureIn)
andresag 6:321047f0190a 83 {
andresag 6:321047f0190a 84 tlmBeaconTemperature = tlmBeaconTemperatureIn;
andresag 6:321047f0190a 85 }
andresag 6:321047f0190a 86
andresag 6:321047f0190a 87 void TLMFrame::updatePduCount(void)
andresag 6:321047f0190a 88 {
andresag 6:321047f0190a 89 tlmPduCount++;
andresag 6:321047f0190a 90 }
andresag 6:321047f0190a 91
andresag 6:321047f0190a 92 uint16_t TLMFrame::getBatteryVoltage(void) const
andresag 6:321047f0190a 93 {
andresag 6:321047f0190a 94 return tlmBatteryVoltage;
andresag 6:321047f0190a 95 }
andresag 6:321047f0190a 96
andresag 6:321047f0190a 97 uint16_t TLMFrame::getBeaconTemperature(void) const
andresag 6:321047f0190a 98 {
andresag 6:321047f0190a 99 return tlmBeaconTemperature;
andresag 6:321047f0190a 100 }
andresag 6:321047f0190a 101
andresag 6:321047f0190a 102 uint8_t TLMFrame::getTLMVersion(void) const
andresag 6:321047f0190a 103 {
andresag 6:321047f0190a 104 return tlmVersion;
andresag 6:321047f0190a 105 }