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.

Committer:
bcostm
Date:
Fri Jul 28 10:07:05 2017 +0200
Revision:
41:97bbb1eb43d7
Parent:
3:5120491ba317
Add DISCO_L475VG_IOT01A in mbed_app.json

Who changed what in which revision?

UserRevisionLine numberNew 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 __TLMFRAME_H__
mbed_official 3:5120491ba317 18 #define __TLMFRAME_H__
mbed_official 3:5120491ba317 19
mbed_official 3:5120491ba317 20 #include "EddystoneTypes.h"
mbed_official 3:5120491ba317 21
mbed_official 3:5120491ba317 22 /**
mbed_official 3:5120491ba317 23 * Class that encapsulates data that belongs to the Eddystone-TLM frame. For
mbed_official 3:5120491ba317 24 * more information refer to https://github.com/google/eddystone/tree/master/eddystone-tlm.
mbed_official 3:5120491ba317 25 */
mbed_official 3:5120491ba317 26 class TLMFrame
mbed_official 3:5120491ba317 27 {
mbed_official 3:5120491ba317 28 public:
mbed_official 3:5120491ba317 29 /**
mbed_official 3:5120491ba317 30 * Construct a new instance of this class.
mbed_official 3:5120491ba317 31 *
mbed_official 3:5120491ba317 32 * @param[in] tlmVersionIn
mbed_official 3:5120491ba317 33 * Eddystone-TLM version number to use.
mbed_official 3:5120491ba317 34 * @param[in] tlmBatteryVoltageIn
mbed_official 3:5120491ba317 35 * Initial value for the Eddystone-TLM Battery Voltage.
mbed_official 3:5120491ba317 36 * @param[in] tlmBeaconTemperatureIn
mbed_official 3:5120491ba317 37 * Initial value for the Eddystone-TLM Beacon Temperature.
mbed_official 3:5120491ba317 38 * @param[in] tlmPduCountIn
mbed_official 3:5120491ba317 39 * Initial value for the Eddystone-TLM Advertising PDU Count.
mbed_official 3:5120491ba317 40 * @param[in] tlmTimeSinceBootIn
mbed_official 3:5120491ba317 41 * Intitial value for the Eddystone-TLM time since boot timer.
mbed_official 3:5120491ba317 42 8 This timer has a 0.1 second resolution.
mbed_official 3:5120491ba317 43 */
mbed_official 3:5120491ba317 44 TLMFrame(uint8_t tlmVersionIn = 0,
mbed_official 3:5120491ba317 45 uint16_t tlmBatteryVoltageIn = 0,
mbed_official 3:5120491ba317 46 uint16_t tlmBeaconTemperatureIn = 0x8000,
mbed_official 3:5120491ba317 47 uint32_t tlmPduCountIn = 0,
mbed_official 3:5120491ba317 48 uint32_t tlmTimeSinceBootIn = 0);
mbed_official 3:5120491ba317 49
mbed_official 3:5120491ba317 50 /**
mbed_official 3:5120491ba317 51 * Set the Eddystone-TLM version number.
mbed_official 3:5120491ba317 52 */
mbed_official 3:5120491ba317 53 void setTLMData(uint8_t tlmVersionIn = 0);
mbed_official 3:5120491ba317 54
mbed_official 3:5120491ba317 55 /**
mbed_official 3:5120491ba317 56 * Construct the raw bytes of the Eddystone-TLM frame that will be directly
mbed_official 3:5120491ba317 57 * used in the advertising packets.
mbed_official 3:5120491ba317 58 *
mbed_official 3:5120491ba317 59 * @param[in] rawFrame
mbed_official 3:5120491ba317 60 * Pointer to the location where the raw frame will be stored.
mbed_official 3:5120491ba317 61 */
mbed_official 3:5120491ba317 62 void constructTLMFrame(uint8_t *rawFrame);
mbed_official 3:5120491ba317 63
mbed_official 3:5120491ba317 64 /**
mbed_official 3:5120491ba317 65 * Get the size of the Eddystone-TLM frame constructed with the
mbed_official 3:5120491ba317 66 * current state of the TLMFrame object.
mbed_official 3:5120491ba317 67 *
mbed_official 3:5120491ba317 68 * @return The size in bytes of the Eddystone-TLM frame.
mbed_official 3:5120491ba317 69 */
mbed_official 3:5120491ba317 70 size_t getRawFrameSize(void) const;
mbed_official 3:5120491ba317 71
mbed_official 3:5120491ba317 72 /**
mbed_official 3:5120491ba317 73 * Update the time since boot.
mbed_official 3:5120491ba317 74 *
mbed_official 3:5120491ba317 75 * @param[in] nowInMillis
mbed_official 3:5120491ba317 76 * The time since boot in milliseconds.
mbed_official 3:5120491ba317 77 */
mbed_official 3:5120491ba317 78 void updateTimeSinceBoot(uint32_t nowInMillis);
mbed_official 3:5120491ba317 79
mbed_official 3:5120491ba317 80 /**
mbed_official 3:5120491ba317 81 * Update the Battery Voltage.
mbed_official 3:5120491ba317 82 *
mbed_official 3:5120491ba317 83 * @param[in] tlmBatteryVoltageIn
mbed_official 3:5120491ba317 84 * The new Battery Voltage value.
mbed_official 3:5120491ba317 85 */
mbed_official 3:5120491ba317 86 void updateBatteryVoltage(uint16_t tlmBatteryVoltageIn);
mbed_official 3:5120491ba317 87
mbed_official 3:5120491ba317 88 /**
mbed_official 3:5120491ba317 89 * Update the Beacon Temperature.
mbed_official 3:5120491ba317 90 *
mbed_official 3:5120491ba317 91 * @param[in] tlmBeaconTemperatureIn
mbed_official 3:5120491ba317 92 * The new Beacon Temperature value.
mbed_official 3:5120491ba317 93 */
mbed_official 3:5120491ba317 94 void updateBeaconTemperature(uint16_t tlmBeaconTemperatureIn);
mbed_official 3:5120491ba317 95
mbed_official 3:5120491ba317 96 /**
mbed_official 3:5120491ba317 97 * Increment the current PDU counter by 1.
mbed_official 3:5120491ba317 98 */
mbed_official 3:5120491ba317 99 void updatePduCount(void);
mbed_official 3:5120491ba317 100
mbed_official 3:5120491ba317 101 /**
mbed_official 3:5120491ba317 102 * Get the current Battery Voltage.
mbed_official 3:5120491ba317 103 *
mbed_official 3:5120491ba317 104 * @return The Battery Voltage.
mbed_official 3:5120491ba317 105 */
mbed_official 3:5120491ba317 106 uint16_t getBatteryVoltage(void) const;
mbed_official 3:5120491ba317 107
mbed_official 3:5120491ba317 108 /**
mbed_official 3:5120491ba317 109 * Get the current Beacon Temperature.
mbed_official 3:5120491ba317 110 *
mbed_official 3:5120491ba317 111 * @return The Beacon Temperature.
mbed_official 3:5120491ba317 112 */
mbed_official 3:5120491ba317 113 uint16_t getBeaconTemperature(void) const;
mbed_official 3:5120491ba317 114
mbed_official 3:5120491ba317 115 /**
mbed_official 3:5120491ba317 116 * Get the current TLM Version number.
mbed_official 3:5120491ba317 117 *
mbed_official 3:5120491ba317 118 * @return The TLM Version number.
mbed_official 3:5120491ba317 119 */
mbed_official 3:5120491ba317 120 uint8_t getTLMVersion(void) const;
mbed_official 3:5120491ba317 121
mbed_official 3:5120491ba317 122 private:
mbed_official 3:5120491ba317 123 /**
mbed_official 3:5120491ba317 124 * The byte ID of an Eddystone-TLM frame.
mbed_official 3:5120491ba317 125 */
mbed_official 3:5120491ba317 126 static const uint8_t FRAME_TYPE_TLM = 0x20;
mbed_official 3:5120491ba317 127 /**
mbed_official 3:5120491ba317 128 * The size of an Eddystone-TLM frame.
mbed_official 3:5120491ba317 129 */
mbed_official 3:5120491ba317 130 static const uint8_t FRAME_SIZE_TLM = 14;
mbed_official 3:5120491ba317 131
mbed_official 3:5120491ba317 132 /**
mbed_official 3:5120491ba317 133 * Eddystone-TLM version value.
mbed_official 3:5120491ba317 134 */
mbed_official 3:5120491ba317 135 uint8_t tlmVersion;
mbed_official 3:5120491ba317 136 /**
mbed_official 3:5120491ba317 137 * Time since boot in milliseconds.
mbed_official 3:5120491ba317 138 */
mbed_official 3:5120491ba317 139 uint32_t lastTimeSinceBootRead;
mbed_official 3:5120491ba317 140 /**
mbed_official 3:5120491ba317 141 * Eddystone-TLM Battery Voltage value.
mbed_official 3:5120491ba317 142 */
mbed_official 3:5120491ba317 143 uint16_t tlmBatteryVoltage;
mbed_official 3:5120491ba317 144 /**
mbed_official 3:5120491ba317 145 * Eddystone-TLM Beacon temperature value.
mbed_official 3:5120491ba317 146 */
mbed_official 3:5120491ba317 147 uint16_t tlmBeaconTemperature;
mbed_official 3:5120491ba317 148 /**
mbed_official 3:5120491ba317 149 * Eddystone-TLM Advertising PDU Count.
mbed_official 3:5120491ba317 150 */
mbed_official 3:5120491ba317 151 uint32_t tlmPduCount;
mbed_official 3:5120491ba317 152 /**
mbed_official 3:5120491ba317 153 * Eddystone-TLM time since boot with 0.1 second resolution.
mbed_official 3:5120491ba317 154 */
mbed_official 3:5120491ba317 155 uint32_t tlmTimeSinceBoot;
mbed_official 3:5120491ba317 156 };
mbed_official 3:5120491ba317 157
mbed_official 3:5120491ba317 158 #endif /* __TLMFRAME_H__ */