Mistake on this page?
Report an issue in GitHub or email us
AdvertisingDataTypes.h
1 /* mbed Microcontroller Library
2  * Copyright (c) 2006-2020 ARM Limited
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #ifndef BLE_GAP_ADVERTISINGDATATYPES_H
20 #define BLE_GAP_ADVERTISINGDATATYPES_H
21 
22 #include "ble/common/SafeEnum.h"
23 
24 namespace ble {
25 
26 /**
27  * @addtogroup ble
28  * @{
29  * @addtogroup gap
30  * @{
31  */
32 
33 /*!
34  * List of standard Advertising Data types.
35  *
36  * These AD types are used to describe the capabilities of the peripheral
37  * and are inserted inside the advertising or scan response payloads.
38  *
39  * @par Source
40  *
41  * @li @c Bluetooth Core Specification 4.0 (Vol. 3), Part C, Section 11, 18.
42  * @li @c https://www.bluetooth.org/en-us/specification/assigned-numbers/generic-access-profile.
43  */
44 struct adv_data_type_t : SafeEnum<adv_data_type_t, uint8_t> {
45  /** struct scoped enum wrapped by the class */
46  enum type {
47  /**
48  * Flags, refer to AdvertisingData::Flags_t.
49  */
50  FLAGS = 0x01,
51 
52  /**
53  * Incomplete list of 16-bit Service IDs.
54  */
56 
57  /**
58  * Complete list of 16-bit Service IDs.
59  */
61 
62  /**
63  * Incomplete list of 32-bit Service IDs (not relevant for Bluetooth 4.0).
64  */
66 
67  /**
68  * Complete list of 32-bit Service IDs (not relevant for Bluetooth 4.0).
69  */
71 
72  /**
73  * Incomplete list of 128-bit Service IDs.
74  */
76 
77  /**
78  * Complete list of 128-bit Service IDs.
79  */
81 
82  /**
83  * Shortened Local Name.
84  */
86 
87  /**
88  * Complete Local Name.
89  */
91 
92  /**
93  * TX Power Level (in dBm).
94  */
96 
97  /**
98  * Device ID.
99  */
100  DEVICE_ID = 0x10,
101 
102  /**
103  * Slave Connection Interval Range.
104  */
106 
107  /**
108  * List of 128-bit service UUIDs the device is looking for.
109  */
111 
112  /**
113  * List of 128-bit service UUIDs the device is looking for.
114  */
116 
117  /**
118  * Service Data.
119  */
120  SERVICE_DATA = 0x16,
121 
122  /**
123  * Service Data.
124  */
126 
127  /**
128  * Service Data.
129  */
131 
132  /**
133  * Appearance, refer to AdvertisingData::Appearance_t.
134  */
135  APPEARANCE = 0x19,
136 
137  /**
138  * Advertising Interval.
139  */
141 
142  /**
143  * Manufacturer Specific Data.
144  */
146  };
147 
148  /**
149  * Construct a new instance of adv_data_type_t.
150  */
152  {
153  }
154 };
155 
156 
157 /**
158  * Set of advertising flags.
159  *
160  * @note LE_LIMITED_DISCOVERABLE and LE_GENERAL_DISCOVERABLE are mutually
161  * exclusive
162  *
163  * @li @c Bluetooth Core Specification 4.0 (Vol. 3), Part C, Section 18.1.
164  */
166  enum {
167  LE_LIMITED_DISCOVERABLE = 0x01, /**< Discoverable for a limited period of time.*/
168  LE_GENERAL_DISCOVERABLE = 0x02, /**< Discoverable at any moment. */
169  BREDR_NOT_SUPPORTED = 0x04, /**< LE only and does not support Bluetooth Enhanced DataRate. */
170  SIMULTANEOUS_LE_BREDR_C = 0x08, /**< Not relevant - dual mode only. */
171  SIMULTANEOUS_LE_BREDR_H = 0x10 /**< Not relevant - dual mode only. */
172  };
173 
174  static const uint8_t default_flags = BREDR_NOT_SUPPORTED | LE_GENERAL_DISCOVERABLE;
175 
176  /** Create from raw value */
177  adv_data_flags_t(uint8_t value = 0) : _value(value)
178  {
179  }
180 
181  adv_data_flags_t &setGeneralDiscoverable(bool enable = true)
182  {
183  _value &= ~0x03U;
184  if (enable) {
185  _value |= LE_GENERAL_DISCOVERABLE;
186  }
187  return *this;
188  }
189 
190  adv_data_flags_t &setLimitedDiscoverable(bool enable = true)
191  {
192  _value &= ~0x03U;
193  if (enable) {
194  _value |= LE_LIMITED_DISCOVERABLE;
195  }
196  return *this;
197  }
198 
199  adv_data_flags_t &setBredrNotSupported(bool enable = true)
200  {
201  _value &= ~BREDR_NOT_SUPPORTED;
202  if (enable) {
203  _value |= BREDR_NOT_SUPPORTED;
204  }
205  return *this;
206  }
207 
208  adv_data_flags_t &setSimultaneousLeBredrC(bool enable = true)
209  {
210  _value &= ~SIMULTANEOUS_LE_BREDR_C;
211  if (enable) {
212  _value |= SIMULTANEOUS_LE_BREDR_C;
213  }
214  return *this;
215  }
216 
217  adv_data_flags_t &setSimultaneousLeBredrH(bool enable = true)
218  {
219  _value &= ~SIMULTANEOUS_LE_BREDR_H;
220  if (enable) {
221  _value |= SIMULTANEOUS_LE_BREDR_H;
222  }
223  return *this;
224  }
225 
226  bool getGeneralDiscoverable() const
227  {
228  return _value & LE_GENERAL_DISCOVERABLE;
229  }
230 
231  bool getlimitedDiscoverable() const
232  {
233  return _value & LE_LIMITED_DISCOVERABLE;
234  }
235 
236  bool getBrEdrNotSupported() const
237  {
238  return _value & BREDR_NOT_SUPPORTED;
239  }
240 
241  bool getSimultaneousLeBredrC() const
242  {
243  return _value & SIMULTANEOUS_LE_BREDR_C;
244  }
245 
246  bool getSimultaneousLeBredrH() const
247  {
248  return _value & SIMULTANEOUS_LE_BREDR_H;
249  }
250 
251  void clear()
252  {
253  _value = 0;
254  }
255 
256  uint8_t value() const
257  {
258  return _value;
259  }
260 
261 private:
262  uint8_t _value;
263 };
264 
265 
266 /**
267  * Enumeration of values for the adv_data_type_t::APPEARANCE.
268  *
269  * These values describe the physical shape or appearance of the device.
270  *
271  * @par Source
272  *
273  * @li @c Bluetooth Core Specification Supplement, Part A, Section 1.12.
274  * @li @c Bluetooth Core Specification 4.0 (Vol. 3), Part C, Section 12.2.
275  * @li @c https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.gap.appearance.xml.
276  */
277 struct adv_data_appearance_t : SafeEnum<adv_data_appearance_t, uint16_t> {
278  /** struct scoped enum wrapped by the class */
279  enum type {
280  /**
281  * Unknown or unspecified appearance type.
282  */
283  UNKNOWN = 0,
284 
285  /**
286  * Generic Phone.
287  */
288  GENERIC_PHONE = 64,
289 
290  /**
291  * Generic Computer.
292  */
293  GENERIC_COMPUTER = 128,
294 
295  /**
296  * Generic Watch.
297  */
298  GENERIC_WATCH = 192,
299 
300  /**
301  * Sports Watch.
302  */
303  WATCH_SPORTS_WATCH = 193,
304 
305  /**
306  * Generic Clock.
307  */
308  GENERIC_CLOCK = 256,
309 
310  /**
311  * Generic Display.
312  */
313  GENERIC_DISPLAY = 320,
314 
315  /**
316  * Generic Remote Control.
317  */
318  GENERIC_REMOTE_CONTROL = 384,
319 
320  /**
321  * Generic Eye Glasses.
322  */
323  GENERIC_EYE_GLASSES = 448,
324 
325  /**
326  * Generic Tag.
327  */
328  GENERIC_TAG = 512,
329 
330  /**
331  * Generic Keyring.
332  */
333  GENERIC_KEYRING = 576,
334 
335  /**
336  * Generic Media Player.
337  */
338  GENERIC_MEDIA_PLAYER = 640,
339 
340  /**
341  * Generic Bar Code Scanner.
342  */
343  GENERIC_BARCODE_SCANNER = 704,
344 
345  /**
346  * Generic Thermometer.
347  */
348  GENERIC_THERMOMETER = 768,
349 
350  /**
351  * Ear Thermometer.
352  */
353  THERMOMETER_EAR = 769,
354 
355  /**
356  * Generic Heart Rate Sensor.
357  */
358  GENERIC_HEART_RATE_SENSOR = 832,
359 
360  /**
361  * Belt Heart Rate Sensor.
362  */
363  HEART_RATE_SENSOR_HEART_RATE_BELT = 833,
364 
365  /**
366  * Generic Blood Pressure.
367  */
368  GENERIC_BLOOD_PRESSURE = 896,
369 
370  /**
371  * Arm Blood Pressure.
372  */
373  BLOOD_PRESSURE_ARM = 897,
374 
375  /**
376  * Wrist Blood Pressure.
377  */
378  BLOOD_PRESSURE_WRIST = 898,
379 
380  /**
381  * Human Interface Device (HID).
382  */
383  HUMAN_INTERFACE_DEVICE_HID = 960,
384 
385  /**
386  * Keyboard.
387  */
388  KEYBOARD = 961,
389 
390  /**
391  * Mouse.
392  */
393  MOUSE = 962,
394 
395  /**
396  * Joystick.
397  */
398  JOYSTICK = 963,
399 
400  /**
401  * Gamepad.
402  */
403  GAMEPAD = 964,
404 
405  /**
406  * Digitizer Tablet.
407  */
408  DIGITIZER_TABLET = 965,
409 
410  /**
411  * Card Reader.
412  */
413  CARD_READER = 966,
414 
415  /**
416  * Digital Pen.
417  */
418  DIGITAL_PEN = 967,
419 
420  /**
421  * Bar Code Scanner.
422  */
423  BARCODE_SCANNER = 968,
424 
425  /**
426  * Generic Glucose Meter.
427  */
428  GENERIC_GLUCOSE_METER = 1024,
429 
430  /**
431  * Generic Running/Walking Sensor.
432  */
433  GENERIC_RUNNING_WALKING_SENSOR = 1088,
434 
435  /**
436  * In Shoe Running/Walking Sensor.
437  */
438  RUNNING_WALKING_SENSOR_IN_SHOE = 1089,
439 
440  /**
441  * On Shoe Running/Walking Sensor.
442  */
443  RUNNING_WALKING_SENSOR_ON_SHOE = 1090,
444 
445  /**
446  * On Hip Running/Walking Sensor.
447  */
448  RUNNING_WALKING_SENSOR_ON_HIP = 1091,
449 
450  /**
451  * Generic Cycling.
452  */
453  GENERIC_CYCLING = 1152,
454 
455  /**
456  * Cycling Computer.
457  */
458  CYCLING_CYCLING_COMPUTER = 1153,
459 
460  /**
461  * Cycling Speed Sensor.
462  */
463  CYCLING_SPEED_SENSOR = 1154,
464 
465  /**
466  * Cycling Cadence Sensor.
467  */
468  CYCLING_CADENCE_SENSOR = 1155,
469 
470  /**
471  * Cycling Power Sensor.
472  */
473  CYCLING_POWER_SENSOR = 1156,
474 
475  /**
476  * Cycling Speed and Cadence Sensor.
477  */
478  CYCLING_SPEED_AND_CADENCE_SENSOR = 1157,
479 
480  /**
481  * Generic Pulse Oximeter.
482  */
483  PULSE_OXIMETER_GENERIC = 3136,
484 
485  /**
486  * Fingertip Pulse Oximeter.
487  */
488  PULSE_OXIMETER_FINGERTIP = 3137,
489 
490  /**
491  * Wrist Worn Pulse Oximeter.
492  */
493  PULSE_OXIMETER_WRIST_WORN = 3138,
494 
495  /**
496  * Generic Weight Scale.
497  */
498  GENERIC_WEIGHT_SCALE = 3200,
499 
500  /**
501  * Generic Outdoor.
502  */
503  OUTDOOR_GENERIC = 5184,
504 
505  /**
506  * Outdoor Location Display Device.
507  */
508  OUTDOOR_LOCATION_DISPLAY_DEVICE = 5185,
509 
510  /**
511  * Outdoor Location and Navigation Display Device.
512  */
513  OUTDOOR_LOCATION_AND_NAVIGATION_DISPLAY_DEVICE = 5186,
514 
515  /**
516  * Outdoor Location Pod.
517  */
518  OUTDOOR_LOCATION_POD = 5187,
519 
520  /**
521  * Outdoor Location and Navigation Pod.
522  */
523  OUTDOOR_LOCATION_AND_NAVIGATION_POD = 5188
524  };
525 
526  /**
527  * Construct a new instance of adv_data_appearance_t.
528  */
530  {
531  }
532 };
533 
534 /**
535  * @}
536  * @}
537  */
538 
539 } // namespace ble
540 
541 #endif //BLE_GAP_ADVERTISINGDATATYPES_H
adv_data_flags_t(uint8_t value=0)
Create from raw value.
type
struct scoped enum wrapped by the class
Flags, refer to AdvertisingData::Flags_t.
Enumeration of values for the adv_data_type_t::APPEARANCE.
adv_data_type_t(type value)
Construct a new instance of adv_data_type_t.
uint8_t value() const
Explicit access to the inner value of the SafeEnum instance.
Helper class used to define safe enumerations.
Set of advertising flags.
List of 128-bit service UUIDs the device is looking for.
Incomplete list of 32-bit Service IDs (not relevant for Bluetooth 4.0).
Complete list of 32-bit Service IDs (not relevant for Bluetooth 4.0).
Entry namespace for all BLE API definitions.
adv_data_appearance_t(type value)
Construct a new instance of adv_data_appearance_t.
Appearance, refer to AdvertisingData::Appearance_t.
type
struct scoped enum wrapped by the class
List of 128-bit service UUIDs the device is looking for.
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.