ST / Mbed OS mbed-os-example-ble-EddystoneService

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:
mbed_official
Date:
Thu Jul 28 23:14:36 2016 +0100
Revision:
1:9db4d46bb63f
Parent:
0:4c8f8bf32a99
Child:
2:9ee673e0b86a
Merge branch 'master' of https://github.com/ARMmbed/mbed-os-example-ble


Commit copied from ./src/github.com/ARMmbed/mbed-os-example-ble

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 1:9db4d46bb63f 1 /* mbed Microcontroller Library
mbed_official 1:9db4d46bb63f 2 * Copyright (c) 2006-2015 ARM Limited
mbed_official 1:9db4d46bb63f 3 *
mbed_official 1:9db4d46bb63f 4 * Licensed under the Apache License, Version 2.0 (the "License");
mbed_official 1:9db4d46bb63f 5 * you may not use this file except in compliance with the License.
mbed_official 1:9db4d46bb63f 6 * You may obtain a copy of the License at
mbed_official 1:9db4d46bb63f 7 *
mbed_official 1:9db4d46bb63f 8 * http://www.apache.org/licenses/LICENSE-2.0
mbed_official 1:9db4d46bb63f 9 *
mbed_official 1:9db4d46bb63f 10 * Unless required by applicable law or agreed to in writing, software
mbed_official 1:9db4d46bb63f 11 * distributed under the License is distributed on an "AS IS" BASIS,
mbed_official 1:9db4d46bb63f 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mbed_official 1:9db4d46bb63f 13 * See the License for the specific language governing permissions and
mbed_official 1:9db4d46bb63f 14 * limitations under the License.
mbed_official 1:9db4d46bb63f 15 */
mbed_official 1:9db4d46bb63f 16
mbed_official 1:9db4d46bb63f 17 #ifndef __TLMFRAME_H__
mbed_official 1:9db4d46bb63f 18 #define __TLMFRAME_H__
mbed_official 1:9db4d46bb63f 19
mbed_official 1:9db4d46bb63f 20 #include "EddystoneTypes.h"
mbed_official 1:9db4d46bb63f 21
mbed_official 1:9db4d46bb63f 22 /**
mbed_official 1:9db4d46bb63f 23 * Class that encapsulates data that belongs to the Eddystone-TLM frame. For
mbed_official 1:9db4d46bb63f 24 * more information refer to https://github.com/google/eddystone/tree/master/eddystone-tlm.
mbed_official 1:9db4d46bb63f 25 */
mbed_official 1:9db4d46bb63f 26 class TLMFrame
mbed_official 1:9db4d46bb63f 27 {
mbed_official 1:9db4d46bb63f 28 public:
mbed_official 1:9db4d46bb63f 29 /**
mbed_official 1:9db4d46bb63f 30 * Construct a new instance of this class.
mbed_official 1:9db4d46bb63f 31 *
mbed_official 1:9db4d46bb63f 32 * @param[in] tlmVersionIn
mbed_official 1:9db4d46bb63f 33 * Eddystone-TLM version number to use.
mbed_official 1:9db4d46bb63f 34 * @param[in] tlmBatteryVoltageIn
mbed_official 1:9db4d46bb63f 35 * Initial value for the Eddystone-TLM Battery Voltage.
mbed_official 1:9db4d46bb63f 36 * @param[in] tlmBeaconTemperatureIn
mbed_official 1:9db4d46bb63f 37 * Initial value for the Eddystone-TLM Beacon Temperature.
mbed_official 1:9db4d46bb63f 38 * @param[in] tlmPduCountIn
mbed_official 1:9db4d46bb63f 39 * Initial value for the Eddystone-TLM Advertising PDU Count.
mbed_official 1:9db4d46bb63f 40 * @param[in] tlmTimeSinceBootIn
mbed_official 1:9db4d46bb63f 41 * Intitial value for the Eddystone-TLM time since boot timer.
mbed_official 1:9db4d46bb63f 42 8 This timer has a 0.1 second resolution.
mbed_official 1:9db4d46bb63f 43 */
mbed_official 1:9db4d46bb63f 44 TLMFrame(uint8_t tlmVersionIn = 0,
mbed_official 1:9db4d46bb63f 45 uint16_t tlmBatteryVoltageIn = 0,
mbed_official 1:9db4d46bb63f 46 uint16_t tlmBeaconTemperatureIn = 0x8000,
mbed_official 1:9db4d46bb63f 47 uint32_t tlmPduCountIn = 0,
mbed_official 1:9db4d46bb63f 48 uint32_t tlmTimeSinceBootIn = 0);
mbed_official 1:9db4d46bb63f 49
mbed_official 1:9db4d46bb63f 50 /**
mbed_official 1:9db4d46bb63f 51 * Set the Eddystone-TLM version number.
mbed_official 1:9db4d46bb63f 52 */
mbed_official 1:9db4d46bb63f 53 void setTLMData(uint8_t tlmVersionIn = 0);
mbed_official 1:9db4d46bb63f 54
mbed_official 1:9db4d46bb63f 55 /**
mbed_official 1:9db4d46bb63f 56 * Construct the raw bytes of the Eddystone-TLM frame that will be directly
mbed_official 1:9db4d46bb63f 57 * used in the advertising packets.
mbed_official 1:9db4d46bb63f 58 *
mbed_official 1:9db4d46bb63f 59 * @param[in] rawFrame
mbed_official 1:9db4d46bb63f 60 * Pointer to the location where the raw frame will be stored.
mbed_official 1:9db4d46bb63f 61 */
mbed_official 1:9db4d46bb63f 62 void constructTLMFrame(uint8_t *rawFrame);
mbed_official 1:9db4d46bb63f 63
mbed_official 1:9db4d46bb63f 64 /**
mbed_official 1:9db4d46bb63f 65 * Get the size of the Eddystone-TLM frame constructed with the
mbed_official 1:9db4d46bb63f 66 * current state of the TLMFrame object.
mbed_official 1:9db4d46bb63f 67 *
mbed_official 1:9db4d46bb63f 68 * @return The size in bytes of the Eddystone-TLM frame.
mbed_official 1:9db4d46bb63f 69 */
mbed_official 1:9db4d46bb63f 70 size_t getRawFrameSize(void) const;
mbed_official 1:9db4d46bb63f 71
mbed_official 1:9db4d46bb63f 72 /**
mbed_official 1:9db4d46bb63f 73 * Update the time since boot.
mbed_official 1:9db4d46bb63f 74 *
mbed_official 1:9db4d46bb63f 75 * @param[in] nowInMillis
mbed_official 1:9db4d46bb63f 76 * The time since boot in milliseconds.
mbed_official 1:9db4d46bb63f 77 */
mbed_official 1:9db4d46bb63f 78 void updateTimeSinceBoot(uint32_t nowInMillis);
mbed_official 1:9db4d46bb63f 79
mbed_official 1:9db4d46bb63f 80 /**
mbed_official 1:9db4d46bb63f 81 * Update the Battery Voltage.
mbed_official 1:9db4d46bb63f 82 *
mbed_official 1:9db4d46bb63f 83 * @param[in] tlmBatteryVoltageIn
mbed_official 1:9db4d46bb63f 84 * The new Battery Voltage value.
mbed_official 1:9db4d46bb63f 85 */
mbed_official 1:9db4d46bb63f 86 void updateBatteryVoltage(uint16_t tlmBatteryVoltageIn);
mbed_official 1:9db4d46bb63f 87
mbed_official 1:9db4d46bb63f 88 /**
mbed_official 1:9db4d46bb63f 89 * Update the Beacon Temperature.
mbed_official 1:9db4d46bb63f 90 *
mbed_official 1:9db4d46bb63f 91 * @param[in] tlmBeaconTemperatureIn
mbed_official 1:9db4d46bb63f 92 * The new Beacon Temperature value.
mbed_official 1:9db4d46bb63f 93 */
mbed_official 1:9db4d46bb63f 94 void updateBeaconTemperature(uint16_t tlmBeaconTemperatureIn);
mbed_official 1:9db4d46bb63f 95
mbed_official 1:9db4d46bb63f 96 /**
mbed_official 1:9db4d46bb63f 97 * Increment the current PDU counter by 1.
mbed_official 1:9db4d46bb63f 98 */
mbed_official 1:9db4d46bb63f 99 void updatePduCount(void);
mbed_official 1:9db4d46bb63f 100
mbed_official 1:9db4d46bb63f 101 /**
mbed_official 1:9db4d46bb63f 102 * Get the current Battery Voltage.
mbed_official 1:9db4d46bb63f 103 *
mbed_official 1:9db4d46bb63f 104 * @return The Battery Voltage.
mbed_official 1:9db4d46bb63f 105 */
mbed_official 1:9db4d46bb63f 106 uint16_t getBatteryVoltage(void) const;
mbed_official 1:9db4d46bb63f 107
mbed_official 1:9db4d46bb63f 108 /**
mbed_official 1:9db4d46bb63f 109 * Get the current Beacon Temperature.
mbed_official 1:9db4d46bb63f 110 *
mbed_official 1:9db4d46bb63f 111 * @return The Beacon Temperature.
mbed_official 1:9db4d46bb63f 112 */
mbed_official 1:9db4d46bb63f 113 uint16_t getBeaconTemperature(void) const;
mbed_official 1:9db4d46bb63f 114
mbed_official 1:9db4d46bb63f 115 /**
mbed_official 1:9db4d46bb63f 116 * Get the current TLM Version number.
mbed_official 1:9db4d46bb63f 117 *
mbed_official 1:9db4d46bb63f 118 * @return The TLM Version number.
mbed_official 1:9db4d46bb63f 119 */
mbed_official 1:9db4d46bb63f 120 uint8_t getTLMVersion(void) const;
mbed_official 1:9db4d46bb63f 121
mbed_official 1:9db4d46bb63f 122 private:
mbed_official 1:9db4d46bb63f 123 /**
mbed_official 1:9db4d46bb63f 124 * The byte ID of an Eddystone-TLM frame.
mbed_official 1:9db4d46bb63f 125 */
mbed_official 1:9db4d46bb63f 126 static const uint8_t FRAME_TYPE_TLM = 0x20;
mbed_official 1:9db4d46bb63f 127 /**
mbed_official 1:9db4d46bb63f 128 * The size of an Eddystone-TLM frame.
mbed_official 1:9db4d46bb63f 129 */
mbed_official 1:9db4d46bb63f 130 static const uint8_t FRAME_SIZE_TLM = 14;
mbed_official 1:9db4d46bb63f 131
mbed_official 1:9db4d46bb63f 132 /**
mbed_official 1:9db4d46bb63f 133 * Eddystone-TLM version value.
mbed_official 1:9db4d46bb63f 134 */
mbed_official 1:9db4d46bb63f 135 uint8_t tlmVersion;
mbed_official 1:9db4d46bb63f 136 /**
mbed_official 1:9db4d46bb63f 137 * Time since boot in milliseconds.
mbed_official 1:9db4d46bb63f 138 */
mbed_official 1:9db4d46bb63f 139 uint32_t lastTimeSinceBootRead;
mbed_official 1:9db4d46bb63f 140 /**
mbed_official 1:9db4d46bb63f 141 * Eddystone-TLM Battery Voltage value.
mbed_official 1:9db4d46bb63f 142 */
mbed_official 1:9db4d46bb63f 143 uint16_t tlmBatteryVoltage;
mbed_official 1:9db4d46bb63f 144 /**
mbed_official 1:9db4d46bb63f 145 * Eddystone-TLM Beacon temperature value.
mbed_official 1:9db4d46bb63f 146 */
mbed_official 1:9db4d46bb63f 147 uint16_t tlmBeaconTemperature;
mbed_official 1:9db4d46bb63f 148 /**
mbed_official 1:9db4d46bb63f 149 * Eddystone-TLM Advertising PDU Count.
mbed_official 1:9db4d46bb63f 150 */
mbed_official 1:9db4d46bb63f 151 uint32_t tlmPduCount;
mbed_official 1:9db4d46bb63f 152 /**
mbed_official 1:9db4d46bb63f 153 * Eddystone-TLM time since boot with 0.1 second resolution.
mbed_official 1:9db4d46bb63f 154 */
mbed_official 1:9db4d46bb63f 155 uint32_t tlmTimeSinceBoot;
mbed_official 1:9db4d46bb63f 156 };
mbed_official 1:9db4d46bb63f 157
mbed_official 1:9db4d46bb63f 158 #endif /* __TLMFRAME_H__ */