Mbed OS Reference
Loading...
Searching...
No Matches
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
24namespace 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 */
44struct 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 */
121
122 /**
123 * Service Data.
124 */
126
127 /**
128 * Service Data.
129 */
131
132 /**
133 * Appearance, refer to AdvertisingData::Appearance_t.
134 */
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
261private:
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 */
277struct 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 */
284
285 /**
286 * Generic Phone.
287 */
289
290 /**
291 * Generic Computer.
292 */
294
295 /**
296 * Generic Watch.
297 */
299
300 /**
301 * Sports Watch.
302 */
304
305 /**
306 * Generic Clock.
307 */
309
310 /**
311 * Generic Display.
312 */
314
315 /**
316 * Generic Remote Control.
317 */
319
320 /**
321 * Generic Eye Glasses.
322 */
324
325 /**
326 * Generic Tag.
327 */
329
330 /**
331 * Generic Keyring.
332 */
334
335 /**
336 * Generic Media Player.
337 */
339
340 /**
341 * Generic Bar Code Scanner.
342 */
344
345 /**
346 * Generic Thermometer.
347 */
349
350 /**
351 * Ear Thermometer.
352 */
354
355 /**
356 * Generic Heart Rate Sensor.
357 */
359
360 /**
361 * Belt Heart Rate Sensor.
362 */
364
365 /**
366 * Generic Blood Pressure.
367 */
369
370 /**
371 * Arm Blood Pressure.
372 */
374
375 /**
376 * Wrist Blood Pressure.
377 */
379
380 /**
381 * Human Interface Device (HID).
382 */
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 */
409
410 /**
411 * Card Reader.
412 */
414
415 /**
416 * Digital Pen.
417 */
419
420 /**
421 * Bar Code Scanner.
422 */
424
425 /**
426 * Generic Glucose Meter.
427 */
429
430 /**
431 * Generic Running/Walking Sensor.
432 */
434
435 /**
436 * In Shoe Running/Walking Sensor.
437 */
439
440 /**
441 * On Shoe Running/Walking Sensor.
442 */
444
445 /**
446 * On Hip Running/Walking Sensor.
447 */
449
450 /**
451 * Generic Cycling.
452 */
454
455 /**
456 * Cycling Computer.
457 */
459
460 /**
461 * Cycling Speed Sensor.
462 */
464
465 /**
466 * Cycling Cadence Sensor.
467 */
469
470 /**
471 * Cycling Power Sensor.
472 */
474
475 /**
476 * Cycling Speed and Cadence Sensor.
477 */
479
480 /**
481 * Generic Pulse Oximeter.
482 */
484
485 /**
486 * Fingertip Pulse Oximeter.
487 */
489
490 /**
491 * Wrist Worn Pulse Oximeter.
492 */
494
495 /**
496 * Generic Weight Scale.
497 */
499
500 /**
501 * Generic Outdoor.
502 */
504
505 /**
506 * Outdoor Location Display Device.
507 */
509
510 /**
511 * Outdoor Location and Navigation Display Device.
512 */
514
515 /**
516 * Outdoor Location Pod.
517 */
519
520 /**
521 * Outdoor Location and Navigation Pod.
522 */
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
Entry namespace for all BLE API definitions.
Helper class used to define safe enumerations.
uint8_t value() const
Explicit access to the inner value of the SafeEnum instance.
Enumeration of values for the adv_data_type_t::APPEARANCE.
type
struct scoped enum wrapped by the class
@ BARCODE_SCANNER
Bar Code Scanner.
@ GENERIC_WEIGHT_SCALE
Generic Weight Scale.
@ HUMAN_INTERFACE_DEVICE_HID
Human Interface Device (HID).
@ PULSE_OXIMETER_GENERIC
Generic Pulse Oximeter.
@ OUTDOOR_LOCATION_AND_NAVIGATION_DISPLAY_DEVICE
Outdoor Location and Navigation Display Device.
@ GENERIC_EYE_GLASSES
Generic Eye Glasses.
@ OUTDOOR_LOCATION_AND_NAVIGATION_POD
Outdoor Location and Navigation Pod.
@ GENERIC_COMPUTER
Generic Computer.
@ CYCLING_CYCLING_COMPUTER
Cycling Computer.
@ PULSE_OXIMETER_WRIST_WORN
Wrist Worn Pulse Oximeter.
@ RUNNING_WALKING_SENSOR_ON_HIP
On Hip Running/Walking Sensor.
@ CYCLING_SPEED_SENSOR
Cycling Speed Sensor.
@ HEART_RATE_SENSOR_HEART_RATE_BELT
Belt Heart Rate Sensor.
@ RUNNING_WALKING_SENSOR_IN_SHOE
In Shoe Running/Walking Sensor.
@ GENERIC_REMOTE_CONTROL
Generic Remote Control.
@ UNKNOWN
Unknown or unspecified appearance type.
@ OUTDOOR_LOCATION_DISPLAY_DEVICE
Outdoor Location Display Device.
@ DIGITIZER_TABLET
Digitizer Tablet.
@ PULSE_OXIMETER_FINGERTIP
Fingertip Pulse Oximeter.
@ RUNNING_WALKING_SENSOR_ON_SHOE
On Shoe Running/Walking Sensor.
@ GENERIC_BARCODE_SCANNER
Generic Bar Code Scanner.
@ GENERIC_BLOOD_PRESSURE
Generic Blood Pressure.
@ CYCLING_SPEED_AND_CADENCE_SENSOR
Cycling Speed and Cadence Sensor.
@ GENERIC_RUNNING_WALKING_SENSOR
Generic Running/Walking Sensor.
@ CYCLING_POWER_SENSOR
Cycling Power Sensor.
@ GENERIC_THERMOMETER
Generic Thermometer.
@ BLOOD_PRESSURE_WRIST
Wrist Blood Pressure.
@ BLOOD_PRESSURE_ARM
Arm Blood Pressure.
@ GENERIC_GLUCOSE_METER
Generic Glucose Meter.
@ GENERIC_HEART_RATE_SENSOR
Generic Heart Rate Sensor.
@ CYCLING_CADENCE_SENSOR
Cycling Cadence Sensor.
@ GENERIC_MEDIA_PLAYER
Generic Media Player.
@ OUTDOOR_LOCATION_POD
Outdoor Location Pod.
adv_data_appearance_t(type value)
Construct a new instance of adv_data_appearance_t.
Set of advertising flags.
adv_data_flags_t(uint8_t value=0)
Create from raw value.
@ LE_LIMITED_DISCOVERABLE
Discoverable for a limited period of time.
@ SIMULTANEOUS_LE_BREDR_C
Not relevant - dual mode only.
@ LE_GENERAL_DISCOVERABLE
Discoverable at any moment.
@ BREDR_NOT_SUPPORTED
LE only and does not support Bluetooth Enhanced DataRate.
@ SIMULTANEOUS_LE_BREDR_H
Not relevant - dual mode only.
adv_data_type_t(type value)
Construct a new instance of adv_data_type_t.
type
struct scoped enum wrapped by the class
@ COMPLETE_LIST_128BIT_SERVICE_IDS
Complete list of 128-bit Service IDs.
@ MANUFACTURER_SPECIFIC_DATA
Manufacturer Specific Data.
@ FLAGS
Flags, refer to AdvertisingData::Flags_t.
@ COMPLETE_LOCAL_NAME
Complete Local Name.
@ SLAVE_CONNECTION_INTERVAL_RANGE
Slave Connection Interval Range.
@ COMPLETE_LIST_16BIT_SERVICE_IDS
Complete list of 16-bit Service IDs.
@ SHORTENED_LOCAL_NAME
Shortened Local Name.
@ APPEARANCE
Appearance, refer to AdvertisingData::Appearance_t.
@ INCOMPLETE_LIST_16BIT_SERVICE_IDS
Incomplete list of 16-bit Service IDs.
@ INCOMPLETE_LIST_128BIT_SERVICE_IDS
Incomplete list of 128-bit Service IDs.
@ COMPLETE_LIST_32BIT_SERVICE_IDS
Complete list of 32-bit Service IDs (not relevant for Bluetooth 4.0).
@ SERVICE_DATA_16BIT_ID
Service Data.
@ TX_POWER_LEVEL
TX Power Level (in dBm).
@ LIST_16BIT_SOLICITATION_IDS
List of 128-bit service UUIDs the device is looking for.
@ ADVERTISING_INTERVAL
Advertising Interval.
@ LIST_128BIT_SOLICITATION_IDS
List of 128-bit service UUIDs the device is looking for.
@ SERVICE_DATA_128BIT_ID
Service Data.
@ INCOMPLETE_LIST_32BIT_SERVICE_IDS
Incomplete list of 32-bit Service IDs (not relevant for Bluetooth 4.0).