Mistake on this page?
Report an issue in GitHub or email us
EddystoneConfigService.h
1 /* mbed Microcontroller Library
2  * Copyright (c) 2006-2013 ARM Limited
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef SERVICES_EDDYSTONE_BEACON_CONFIG_SERVICE_H_
18 #define SERVICES_EDDYSTONE_BEACON_CONFIG_SERVICE_H_
19 
20 #warning ble/services/EddystoneConfigService.h is deprecated. Please use the example in 'github.com/ARMmbed/ble-examples/tree/master/BLE_EddystoneService'.
21 
22 #if BLE_FEATURE_GATT_SERVER
23 
24 #include "ble/BLE.h"
25 #include "ble/services/EddystoneService.h"
26 #include "Timer.h"
27 #include "Ticker.h"
28 
29 #define UUID_URI_BEACON(FIRST, SECOND) { \
30  0xee, 0x0c, FIRST, SECOND, 0x87, 0x86, 0x40, 0xba, \
31  0xab, 0x96, 0x99, 0xb9, 0x1a, 0xc9, 0x81, 0xd8, \
32 }
33 
34 static const uint8_t UUID_URI_BEACON_SERVICE[] = UUID_URI_BEACON(0x20, 0x80);
35 static const uint8_t UUID_LOCK_STATE_CHAR[] = UUID_URI_BEACON(0x20, 0x81);
36 static const uint8_t UUID_LOCK_CHAR[] = UUID_URI_BEACON(0x20, 0x82);
37 static const uint8_t UUID_UNLOCK_CHAR[] = UUID_URI_BEACON(0x20, 0x83);
38 static const uint8_t UUID_URI_DATA_CHAR[] = UUID_URI_BEACON(0x20, 0x84);
39 static const uint8_t UUID_FLAGS_CHAR[] = UUID_URI_BEACON(0x20, 0x85);
40 static const uint8_t UUID_ADV_POWER_LEVELS_CHAR[] = UUID_URI_BEACON(0x20, 0x86);
41 static const uint8_t UUID_TX_POWER_MODE_CHAR[] = UUID_URI_BEACON(0x20, 0x87);
42 static const uint8_t UUID_BEACON_PERIOD_CHAR[] = UUID_URI_BEACON(0x20, 0x88);
43 static const uint8_t UUID_RESET_CHAR[] = UUID_URI_BEACON(0x20, 0x89);
44 extern const uint8_t BEACON_EDDYSTONE[2];
45 
46 /**
47 * @class EddystoneConfigService
48 * @brief Eddystone Configuration Service. Used to set URL, adjust power levels, and set flags.
49 * See https://github.com/google/eddystone
50 *
51 */
53 {
54 public:
55  /**
56  * @brief Transmission Power Modes for UriBeacon
57  */
58  enum {
59  TX_POWER_MODE_LOWEST,
60  TX_POWER_MODE_LOW,
61  TX_POWER_MODE_MEDIUM,
62  TX_POWER_MODE_HIGH,
63  NUM_POWER_MODES
64  };
65 
66  static const unsigned ADVERTISING_INTERVAL_MSEC = 1000; // Advertising interval for config service.
67  static const unsigned SERVICE_DATA_MAX = 31; // Maximum size of service data in ADV packets.
68 
69  typedef uint8_t Lock_t[16]; /* 128 bits. */
70  typedef int8_t PowerLevels_t[NUM_POWER_MODES];
71 
72  // There are currently three subframes defined: URI, UID, and TLM.
73 #define EDDYSTONE_MAX_FRAMETYPE 3
74  static const unsigned URI_DATA_MAX = 18;
75  typedef uint8_t UriData_t[URI_DATA_MAX];
76 
77  // UID Frame Type subfields.
78  static const size_t UID_NAMESPACEID_SIZE = 10;
79  typedef uint8_t UIDNamespaceID_t[UID_NAMESPACEID_SIZE];
80  static const size_t UID_INSTANCEID_SIZE = 6;
81  typedef uint8_t UIDInstanceID_t[UID_INSTANCEID_SIZE];
82 
83  // Eddystone Frame Type ID.
84  static const uint8_t FRAME_TYPE_UID = 0x00;
85  static const uint8_t FRAME_TYPE_URL = 0x10;
86  static const uint8_t FRAME_TYPE_TLM = 0x20;
87 
88  static const uint8_t FRAME_SIZE_TLM = 14; // TLM frame is a constant 14B.
89  static const uint8_t FRAME_SIZE_UID = 20; // includes RFU bytes.
90 
91  struct Params_t {
92  // Config Data
93  bool isConfigured; // Flag for configuration being complete:
94  // True = configured, False = not configured. Reset at instantiation, used for external callbacks.
95  uint8_t lockedState;
96  Lock_t lock;
97  uint8_t flags;
98  PowerLevels_t advPowerLevels; // Current value of AdvertisedPowerLevels.
99  uint8_t txPowerMode; // Firmware power levels used with setTxPower().
100  uint16_t beaconPeriod;
101  // TLM Frame Data
102  uint8_t tlmVersion; // Version of TLM packet.
103  bool tlmEnabled;
104  float tlmBeaconPeriod; // How often to broadcat TLM frame, in seconds.
105  // URI Frame Data
106  uint8_t uriDataLength;
107  UriData_t uriData;
108  bool uriEnabled;
109  float uriBeaconPeriod; // How often to broadcast URIFrame, in seconds.
110  // UID Frame Data
111  UIDNamespaceID_t uidNamespaceID; // UUID type, Namespace ID, 10B.
112  UIDInstanceID_t uidInstanceID; // UUID type, Instance ID, 6B.
113  bool uidEnabled;
114  float uidBeaconPeriod; // How often to broadcast UID Frame, in seconds.
115  };
116 
117  /**
118  * @param[in] bleIn
119  * BLEDevice object for the underlying controller.
120  * @param[in,out] paramsIn
121  * Reference to application-visible beacon state, loaded
122  * from persistent storage at startup.
123  * @param[in] defaultAdvPowerLevelsIn
124  * Default power-levels array; applies only if resetToDefaultsFlag is true.
125  *
126  * @param[in] radioPowerLevelsIn
127  * Transmission power-levels to use in TX.
128  */
130  Params_t &paramsIn,
131  PowerLevels_t &defaultAdvPowerLevelsIn,
132  PowerLevels_t &radioPowerLevelsIn) :
133  ble(bleIn),
134  params(paramsIn), // Initialize URL data.
135  defaultAdvPowerLevels(defaultAdvPowerLevelsIn),
136  radioPowerLevels(radioPowerLevelsIn),
137  initSucceeded(false),
138  resetFlag(),
139  defaultUidNamespaceID(), // Initialize UID data.
140  defaultUidInstanceID(),
141  defaultUidPower(defaultAdvPowerLevelsIn[params.txPowerMode]),
142  uidIsSet(false),
143  defaultUriDataLength(),
144  defaultUriData(),
145  defaultUrlPower(defaultAdvPowerLevelsIn[params.txPowerMode]),
146  urlIsSet(false),
147  tlmIsSet(false),
148  lockedStateChar(UUID_LOCK_STATE_CHAR, &params.lockedState),
149  lockChar(UUID_LOCK_CHAR, &params.lock),
150  uriDataChar(UUID_URI_DATA_CHAR, params.uriData, 0, URI_DATA_MAX,
151  GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE),
152  unlockChar(UUID_UNLOCK_CHAR, &params.lock),
153  flagsChar(UUID_FLAGS_CHAR, &params.flags),
154  advPowerLevelsChar(UUID_ADV_POWER_LEVELS_CHAR, &params.advPowerLevels),
155  txPowerModeChar(UUID_TX_POWER_MODE_CHAR, &params.txPowerMode),
156  beaconPeriodChar(UUID_BEACON_PERIOD_CHAR, &params.beaconPeriod),
157  resetChar(UUID_RESET_CHAR, &resetFlag) {
158  // Set Eddystone as not configured yet. Used to exit config before timeout if GATT services are written to.
159  params.isConfigured = false;
160 
161  lockChar.setWriteAuthorizationCallback(this, &EddystoneConfigService::lockAuthorizationCallback);
162  unlockChar.setWriteAuthorizationCallback(this, &EddystoneConfigService::unlockAuthorizationCallback);
163  uriDataChar.setWriteAuthorizationCallback(this, &EddystoneConfigService::uriDataWriteAuthorizationCallback);
164  flagsChar.setWriteAuthorizationCallback(this, &EddystoneConfigService::basicAuthorizationCallback<uint8_t>);
165  advPowerLevelsChar.setWriteAuthorizationCallback(this, &EddystoneConfigService::basicAuthorizationCallback<PowerLevels_t>);
166  txPowerModeChar.setWriteAuthorizationCallback(this, &EddystoneConfigService::powerModeAuthorizationCallback);
167  beaconPeriodChar.setWriteAuthorizationCallback(this, &EddystoneConfigService::basicAuthorizationCallback<uint16_t>);
168  resetChar.setWriteAuthorizationCallback(this, &EddystoneConfigService::basicAuthorizationCallback<uint8_t>);
169 
170  static GattCharacteristic *charTable[] = {
171  &lockedStateChar, &lockChar, &unlockChar, &uriDataChar,
172  &flagsChar, &advPowerLevelsChar, &txPowerModeChar, &beaconPeriodChar, &resetChar
173  };
174 
175  GattService configService(UUID_URI_BEACON_SERVICE, charTable, sizeof(charTable) / sizeof(GattCharacteristic *));
176 
177  ble.addService(configService);
178  ble.onDataWritten(this, &EddystoneConfigService::onDataWrittenCallback);
179  }
180 
181  /**
182  * @brief Start EddystoneConfig advertising. This function should be called
183  * after the EddystoneConfig constructor and after all the frames have been added.
184  *
185  * @param[in] resetToDefaultsFlag
186  * Applies to the state of the 'paramsIn' parameter.
187  * If true, it indicates that paramsIn is potentially
188  * un-initialized, and default values should be used
189  * instead. Otherwise, paramsIn overrides the defaults.
190  */
191  void start(bool resetToDefaultsFlag){
192  INFO("reset to defaults flag = %d", resetToDefaultsFlag);
193  if (!resetToDefaultsFlag && (params.uriDataLength > URI_DATA_MAX)) {
194  INFO("Reset to Defaults triggered");
195  resetToDefaultsFlag = true;
196  }
197 
198  if (resetToDefaultsFlag) {
199  resetToDefaults();
200  } else {
201  updateCharacteristicValues();
202  }
203 
204  setupEddystoneConfigAdvertisements(); /* Set up advertising for the config service. */
205  initSucceeded = true;
206  }
207 
208  /*
209  * Check if Eddystone initialized successfully.
210  */
211  bool initSuccessfully(void) const {
212  return initSucceeded;
213  }
214 
215  /*
216  * @brief Function to update the default values for the TLM frame. Only applied if Reset Defaults is applied.
217  *
218  * @param[in] tlmVersionIn Version of the TLM frame being used.
219  * @param[in] advPeriodInMin How long between TLM frames being advertised, measured in minutes.
220  *
221  */
222  void setDefaultTLMFrameData(uint8_t tlmVersionIn = 0, float advPeriodInSec = 60){
223  DBG("Setting Default TLM Data, version = %d, advPeriodInMind= %f", tlmVersionIn, advPeriodInSec);
224  defaultTlmVersion = tlmVersionIn;
225  TlmBatteryVoltage = 0;
226  TlmBeaconTemp = 0x8000;
227  TlmPduCount = 0;
228  TlmTimeSinceBoot = 0;
229  defaultTlmAdvPeriod = advPeriodInSec;
230  tlmIsSet = true; // Flag to add this to Eddystone service when config is done.
231  }
232 
233  /*
234  * @brief Function to update the default values for the URI frame. Only applied if Reset Defaults is applied.
235  *
236  * @param[in] uriIn URL to advertise.
237  * @param[in] advPeriod How long to advertise the URL, measured in number of ADV frames.
238  *
239  */
240  void setDefaultURIFrameData(const char *uriIn, float advPeriod = 1){
241  DBG("Setting Default URI Data");
242  // Set URL Frame
243  EddystoneService::encodeURL(uriIn, defaultUriData, defaultUriDataLength); // Encode URL to URL Formatting.
244  if (defaultUriDataLength > URI_DATA_MAX) {
245  return;
246  }
247  INFO("\t URI input = %s : %d", uriIn, defaultUriDataLength);
248  INFO("\t default URI = %s : %d ", defaultUriData, defaultUriDataLength );
249  defaultUriAdvPeriod = advPeriod;
250  urlIsSet = true; // Flag to add this to Eddystone service when config is done.
251  }
252 
253  /*
254  * @brief Function to update the default values for the UID frame. Only applied if Reset Defaults is applied.
255  *
256  * @param[in] namespaceID 10Byte Namespace ID.
257  * @param[in] instanceID 6Byte Instance ID.
258  * @param[in] advPeriod How long to advertise the URL, measured in the number of ADV frames.
259  *
260  */
261  void setDefaultUIDFrameData(UIDNamespaceID_t *namespaceID, UIDInstanceID_t *instanceID, float advPeriod = 10){
262  //Set UID frame
263  DBG("Setting default UID Data");
264  memcpy(defaultUidNamespaceID, namespaceID, UID_NAMESPACEID_SIZE);
265  memcpy(defaultUidInstanceID, instanceID, UID_INSTANCEID_SIZE);
266  defaultUidAdvPeriod = advPeriod;
267  uidIsSet = true; // Flag to add this to Eddystone service when config is done.
268  }
269 
270  /* Start out by advertising the config service for a limited time after
271  * startup, then switch to the normal non-connectible beacon functionality.
272  */
273  void setupEddystoneConfigAdvertisements() {
274  const char DEVICE_NAME[] = "eddystone Config";
275 
276  ble.clearAdvertisingPayload();
277 
279 
280  // UUID is in a different order in the ADV frame (!)
281  uint8_t reversedServiceUUID[sizeof(UUID_URI_BEACON_SERVICE)];
282  for (unsigned int i = 0; i < sizeof(UUID_URI_BEACON_SERVICE); i++) {
283  reversedServiceUUID[i] = UUID_URI_BEACON_SERVICE[sizeof(UUID_URI_BEACON_SERVICE) - i - 1];
284  }
285  ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_128BIT_SERVICE_IDS, reversedServiceUUID, sizeof(reversedServiceUUID));
286  ble.accumulateAdvertisingPayload(GapAdvertisingData::GENERIC_TAG);
287  ble.accumulateScanResponse(GapAdvertisingData::COMPLETE_LOCAL_NAME, reinterpret_cast<const uint8_t *>(&DEVICE_NAME), sizeof(DEVICE_NAME));
288  ble.accumulateScanResponse(
290  reinterpret_cast<uint8_t *>(&defaultAdvPowerLevels[EddystoneConfigService::TX_POWER_MODE_LOW]),
291  sizeof(uint8_t));
292 
293  ble.setTxPower(radioPowerLevels[params.txPowerMode]);
294  ble.setDeviceName(reinterpret_cast<const uint8_t *>(&DEVICE_NAME));
296  ble.setAdvertisingInterval(ADVERTISING_INTERVAL_MSEC);
297  }
298 
299  /*
300  * This function actually impliments the Eddystone Beacon service. It can be called with the help of the wrapper function
301  * to load saved config params, or it can be called explicitly to reset the Eddystone beacon to hardcoded values on each reset.
302  *
303  */
304  void setupEddystoneAdvertisements() {
305  DBG("Switching Config -> adv");
306  // Save params to storage.
307  extern void saveURIBeaconConfigParams(const Params_t *paramsP); /* forward declaration; necessary to avoid a circular dependency. */
308  saveURIBeaconConfigParams(&params);
309  INFO("Saved Params to Memory.")
310  // Set up Eddystone Service.
311  static EddystoneService eddyServ(ble, params.beaconPeriod, radioPowerLevels[params.txPowerMode]);
312  // Set configured frames (TLM, UID, URI and so on).
313  if (params.tlmEnabled) {
314  eddyServ.setTLMFrameData(params.tlmVersion, params.tlmBeaconPeriod);
315  }
316  if (params.uriEnabled) {
317  eddyServ.setURLFrameEncodedData(params.advPowerLevels[params.txPowerMode], (const char *) params.uriData, params.uriDataLength, params.uriBeaconPeriod);
318  }
319  if (params.uidEnabled) {
320  eddyServ.setUIDFrameData(params.advPowerLevels[params.txPowerMode],
321  (uint8_t *)params.uidNamespaceID,
322  (uint8_t *)params.uidInstanceID,
323  params.uidBeaconPeriod);
324  }
325  // Start advertising the Eddystone service.
326  eddyServ.start();
327  }
328 
329 private:
330  /*
331  * This callback is invoked when a GATT client attempts to modify any of the
332  * characteristics of this service. Attempts to do so are also applied to
333  * the internal state of this service object.
334  */
335  void onDataWrittenCallback(const GattWriteCallbackParams *writeParams) {
336  uint16_t handle = writeParams->handle;
337 
338  if (handle == lockChar.getValueHandle()) {
339  // Validated earlier.
340  memcpy(params.lock, writeParams->data, sizeof(Lock_t));
341  // Set the state to be locked by the lock code (note: zeros are a valid lock).
342  params.lockedState = true;
343  INFO("Device Locked");
344  } else if (handle == unlockChar.getValueHandle()) {
345  // Validated earlier.
346  params.lockedState = false;
347  INFO("Device Unlocked");
348  } else if (handle == uriDataChar.getValueHandle()) {
349  params.uriDataLength = writeParams->len;
350  memset(params.uriData, 0x00, URI_DATA_MAX); // Clear URI string.
351  memcpy(params.uriData, writeParams->data, writeParams->len); // Set URI string.
352  params.uriEnabled = true;
353  INFO("URI = %s, URILen = %d", writeParams->data, writeParams->len);
354  } else if (handle == flagsChar.getValueHandle()) {
355  params.flags = *(writeParams->data);
356  INFO("flagsChar = 0x%x", params.flags);
357  } else if (handle == advPowerLevelsChar.getValueHandle()) {
358  memcpy(params.advPowerLevels, writeParams->data, sizeof(PowerLevels_t));
359  INFO("PowerLevelsChar = %4x", params.advPowerLevels);
360  } else if (handle == txPowerModeChar.getValueHandle()) {
361  params.txPowerMode = *(writeParams->data);
362  INFO("TxPowerModeChar = %d", params.txPowerMode);
363  } else if (handle == beaconPeriodChar.getValueHandle()) {
364  params.beaconPeriod = *((uint16_t *)(writeParams->data));
365  INFO("BeaconPeriod = %d", params.beaconPeriod);
366 
367  /* Re-map beaconPeriod to within permissible bounds if necessary. */
368  if (params.beaconPeriod != 0) {
369  bool paramsUpdated = false;
370  if (params.beaconPeriod < ble.getMinAdvertisingInterval()) {
371  params.beaconPeriod = ble.getMinAdvertisingInterval();
372  paramsUpdated = true;
373  } else if (params.beaconPeriod > ble.getMaxAdvertisingInterval()) {
374  params.beaconPeriod = ble.getMaxAdvertisingInterval();
375  paramsUpdated = true;
376  }
377  if (paramsUpdated) {
378  ble.updateCharacteristicValue(beaconPeriodChar.getValueHandle(), reinterpret_cast<uint8_t *>(&params.beaconPeriod), sizeof(uint16_t));
379  }
380  }
381  } else if (handle == resetChar.getValueHandle()) {
382  INFO("Reset triggered from Config Service, resetting to defaults");
383  resetToDefaults();
384  }
385  updateCharacteristicValues();
386  params.isConfigured = true; // Some configuration data has been passed; on disconnect switch to advertising mode.
387  }
388 
389  /*
390  * Reset the default values.
391  */
392  void resetToDefaults(void) {
393  INFO("Resetting to defaults");
394  // General.
395  params.lockedState = false;
396  memset(params.lock, 0, sizeof(Lock_t));
397  params.flags = 0x10;
398  memcpy(params.advPowerLevels, defaultAdvPowerLevels, sizeof(PowerLevels_t));
399  params.txPowerMode = TX_POWER_MODE_LOW;
400  params.beaconPeriod = (uint16_t) defaultUriAdvPeriod * 1000;
401 
402  // TLM Frame.
403  params.tlmVersion = defaultTlmVersion;
404  params.tlmBeaconPeriod = defaultTlmAdvPeriod;
405  params.tlmEnabled = tlmIsSet;
406 
407  // URL Frame.
408  memcpy(params.uriData, defaultUriData, URI_DATA_MAX);
409  params.uriDataLength = defaultUriDataLength;
410  params.uriBeaconPeriod = defaultUriAdvPeriod;
411  params.uriEnabled = urlIsSet;
412 
413  // UID Frame.
414  memcpy(params.uidNamespaceID, defaultUidNamespaceID, UID_NAMESPACEID_SIZE);
415  memcpy(params.uidInstanceID, defaultUidInstanceID, UID_INSTANCEID_SIZE);
416  params.uidBeaconPeriod = defaultUidAdvPeriod;
417  params.uidEnabled = uidIsSet;
418 
419  updateCharacteristicValues();
420  }
421 
422  /*
423  * Internal helper function used to update the GATT database following any
424  * change to the internal state of the service object.
425  */
426  void updateCharacteristicValues(void) {
427  ble.updateCharacteristicValue(lockedStateChar.getValueHandle(), &params.lockedState, 1);
428  ble.updateCharacteristicValue(uriDataChar.getValueHandle(), params.uriData, params.uriDataLength);
429  ble.updateCharacteristicValue(flagsChar.getValueHandle(), &params.flags, 1);
430  ble.updateCharacteristicValue(beaconPeriodChar.getValueHandle(),
431  reinterpret_cast<uint8_t *>(&params.beaconPeriod), sizeof(uint16_t));
432  ble.updateCharacteristicValue(txPowerModeChar.getValueHandle(), &params.txPowerMode, 1);
433  ble.updateCharacteristicValue(advPowerLevelsChar.getValueHandle(),
434  reinterpret_cast<uint8_t *>(params.advPowerLevels), sizeof(PowerLevels_t));
435  }
436 
437 private:
438  void lockAuthorizationCallback(GattWriteAuthCallbackParams *authParams) {
439  if (params.lockedState) {
441  } else if (authParams->len != sizeof(Lock_t)) {
443  } else if (authParams->offset != 0) {
445  } else {
447  }
448  }
449 
450  void unlockAuthorizationCallback(GattWriteAuthCallbackParams *authParams) {
451  if ((!params.lockedState) && (authParams->len == sizeof(Lock_t))) {
453  } else if (authParams->len != sizeof(Lock_t)) {
455  } else if (authParams->offset != 0) {
457  } else if (memcmp(authParams->data, params.lock, sizeof(Lock_t)) != 0) {
459  } else {
461  }
462  }
463 
464  void uriDataWriteAuthorizationCallback(GattWriteAuthCallbackParams *authParams) {
465  if (params.lockedState) {
467  } else if (authParams->offset != 0) {
469  } else {
471  }
472  }
473 
474  void powerModeAuthorizationCallback(GattWriteAuthCallbackParams *authParams) {
475  if (params.lockedState) {
477  } else if (authParams->len != sizeof(uint8_t)) {
479  } else if (authParams->offset != 0) {
481  } else if (*((uint8_t *)authParams->data) >= NUM_POWER_MODES) {
483  } else {
485  }
486  }
487 
488  template <typename T>
489  void basicAuthorizationCallback(GattWriteAuthCallbackParams *authParams) {
490  if (params.lockedState) {
492  } else if (authParams->len != sizeof(T)) {
494  } else if (authParams->offset != 0) {
496  } else {
498  }
499  }
500 
501  BLEDevice &ble;
502  Params_t &params;
503  mbed::Ticker timeSinceBootTick;
504  mbed::Timeout switchFrame;
505  // Default value that is restored on reset.
506  PowerLevels_t &defaultAdvPowerLevels; // This goes into the advertising frames (radio power measured at 1m from device).
507  PowerLevels_t &radioPowerLevels; // This configures the power levels of the radio.
508  uint8_t lockedState;
509  bool initSucceeded;
510  uint8_t resetFlag;
511  bool switchFlag;
512 
513  //UID default value that is restored on reset.
514  UIDNamespaceID_t defaultUidNamespaceID;
515  UIDInstanceID_t defaultUidInstanceID;
516  float defaultUidAdvPeriod;
517  int8_t defaultUidPower;
518  uint16_t uidRFU;
519  bool uidIsSet;
520 
521  //URI default value that is restored on reset.
522  uint8_t defaultUriDataLength;
523  UriData_t defaultUriData;
524  int8_t defaultUrlPower;
525  float defaultUriAdvPeriod;
526  bool urlIsSet;
527 
528  //TLM default value that is restored on reset.
529  uint8_t defaultTlmVersion;
530  float defaultTlmAdvPeriod;
531  volatile uint16_t TlmBatteryVoltage;
532  volatile uint16_t TlmBeaconTemp;
533  volatile uint32_t TlmPduCount;
534  volatile uint32_t TlmTimeSinceBoot;
535  bool tlmIsSet;
536 
537  ReadOnlyGattCharacteristic<uint8_t> lockedStateChar;
539  GattCharacteristic uriDataChar;
543  ReadWriteGattCharacteristic<uint8_t> txPowerModeChar;
544  ReadWriteGattCharacteristic<uint16_t> beaconPeriodChar;
546 };
547 
548 #endif // BLE_FEATURE_GATT_SERVER
549 
550 #endif // SERVICES_EDDYSTONE_BEACON_CONFIG_SERVICE_H_
GattAuthCallbackReply_t authorizationReply
Authorization result.
const uint8_t * data
Incoming data.
const uint8_t * data
Pointer to the data to write.
Abstract away BLE-capable radio transceivers or SOCs.
Definition: BLE.h:139
GATT write authorization request event.
Peripheral device is discoverable at any moment.
ATT Error: The specified offset was past the end of the attribute.
GATT Write event definition.
uint16_t len
Length (in bytes) of the data to write.
Peripheral device is LE only and does not support Bluetooth Enhanced DataRate.
EddystoneConfigService(BLEDevice &bleIn, Params_t &paramsIn, PowerLevels_t &defaultAdvPowerLevelsIn, PowerLevels_t &radioPowerLevelsIn)
Representation of a GattServer characteristic.
void start(bool resetToDefaultsFlag)
Start EddystoneConfig advertising.
uint16_t offset
Offset for the write operation.
uint16_t len
Length of the incoming data.
GattAttribute::Handle_t handle
Handle of the attribute to which the write operation applies.
A Ticker is used to call a function at a recurring interval.
Definition: Ticker.h:67
Eddystone Configuration Service.
Representation of a GattServer service.
Definition: GattService.h:38
Device is connectable, scannable and doesn&#39;t expect connection from a specific peer.
bool setURLFrameEncodedData(int8_t power, const char *encodedUrlIn, uint8_t encodedUrlInLength, float urlAdvPeriodIn)
Set Eddystone URL Frame information.
Entry namespace for all BLE API definitions.
void setUIDFrameData(int8_t power, UIDNamespaceID_t namespaceID, UIDInstanceID_t instanceID, float uidAdvPeriodIn, uint16_t RFU=0x0000)
Set Eddystone UID Frame information.
ATT Error: Used in ATT as "insufficient authorization".
A Timeout is used to call a function at a point in the future.
Definition: Timeout.h:58
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.