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