Mistake on this page?
Report an issue in GitHub or email us
BLETypes.h
1 /* mbed Microcontroller Library
2  * Copyright (c) 2017-2017 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_TYPES_H_
18 #define BLE_TYPES_H_
19 
20 #include <stddef.h>
21 #include <stdint.h>
22 #include <string.h>
23 #include "ble/SafeEnum.h"
24 #include "platform/Span.h"
25 #include "ble/gap/Types.h"
26 
27 /**
28  * @addtogroup ble
29  * @{
30  * @addtogroup common
31  * @{
32  */
33 
34 namespace ble {
35 
36 using mbed::Span;
37 using mbed::make_Span;
39 
40 /** Special advertising set handle used for the legacy advertising set. */
42 
43 /** Special advertising set handle used as return or parameter to signify an invalid handle. */
45 
46 /** Maximum advertising data length that can fit in a legacy PDU. */
47 static const uint8_t LEGACY_ADVERTISING_MAX_SIZE = 0x1F;
48 
49 /** Features supported by the controller.
50  * @see BLUETOOTH SPECIFICATION Version 5.0 | Vol 6, Part B - 4.6 */
51 struct controller_supported_features_t : SafeEnum<controller_supported_features_t, uint8_t> {
52  enum type {
53  LE_ENCRYPTION = 0,
54  CONNECTION_PARAMETERS_REQUEST_PROCEDURE,
55  EXTENDED_REJECT_INDICATION,
56  SLAVE_INITIATED_FEATURES_EXCHANGE,
57  LE_PING,
58  LE_DATA_PACKET_LENGTH_EXTENSION,
59  LL_PRIVACY,
60  EXTENDED_SCANNER_FILTER_POLICIES,
61  LE_2M_PHY,
62  STABLE_MODULATION_INDEX_TRANSMITTER,
63  STABLE_MODULATION_INDEX_RECEIVER,
64  LE_CODED_PHY,
65  LE_EXTENDED_ADVERTISING,
66  LE_PERIODIC_ADVERTISING,
67  CHANNEL_SELECTION_ALGORITHM_2,
68  LE_POWER_CLASS
69  };
70 
71  /**
72  * Construct a new instance of ControllerSupportedFeatures_t.
73  */
75 };
76 
77 /**
78  * Opaque reference to a connection.
79  *
80  * Internally a connection handle is an unsigned integer capable of holding a
81  * pointer.
82  *
83  * The real type (either a pointer to an object or an integer) is opaque for
84  * users and platform dependent.
85  */
86 typedef uintptr_t connection_handle_t;
87 
88 /**
89  * Reference to an attribute in a GATT database.
90  */
91 typedef uint16_t attribute_handle_t;
92 
93  /**
94  * Inclusive range of GATT attributes handles.
95  *
96  * @note Instances can be constructed with the help of the factory function
97  * attribute_handle_range().
98  */
100  /**
101  * Beginning of the range.
102  */
103  attribute_handle_t begin;
104 
105  /**
106  * End of the range.
107  */
108  attribute_handle_t end;
109 
110  /**
111  * Equal operator for attribute_handle_range_t.
112  *
113  * @param[in] lhs Left hand side of the expression.
114  * @param[in] rhs Right hand side of the expression.
115  *
116  * @return true if lhs is equal to rhs and false otherwise.
117  */
118  friend bool operator==(
120  ) {
121  return (lhs.begin == rhs.begin) && (lhs.end == rhs.end);
122  }
123 
124  /**
125  * Not equal operator for attribute_handle_range_t.
126  *
127  * @param[in] lhs Left hand side of the expression.
128  * @param[in] rhs Right hand side of the expression.
129  *
130  * @return true if lhs is not equal to rhs and false otherwise.
131  */
132  friend bool operator!=(
134  ) {
135  return !(lhs == rhs);
136  }
137 };
138 
139 
140 /**
141  * Construct an attribute_handle_range_t from its first and last attribute handle.
142  *
143  * @param[in] begin Handle at the beginning of the range.
144  * @param[in] end Handle at the end of the range.
145  *
146  * @return An instance of attribute_handle_range_t where
147  * attribute_handle_range_t::begin is equal to begin and
148  * attribute_handle_range_t::end is equal to end.
149  *
150  * @note This function is defined instead of a constructor to keep "POD-ness"
151  * of attribute_handle_range_t.
152  */
154  attribute_handle_t begin,
155  attribute_handle_t end
156 ) {
157  attribute_handle_range_t result = {
158  begin,
159  end
160  };
161  return result;
162 }
163 
164 /**
165  * Type that describes link's encryption state.
166  */
167 struct link_encryption_t : SafeEnum<link_encryption_t, uint8_t> {
168  /** struct scoped enum wrapped by the class */
169  enum type {
170  NOT_ENCRYPTED, /**< The link is not secured. */
171  ENCRYPTION_IN_PROGRESS, /**< Link security is being established. */
172  ENCRYPTED, /**< The link is secure. */
173  ENCRYPTED_WITH_MITM, /**< The link is secure and authenticated. */
174  ENCRYPTED_WITH_SC_AND_MITM /**< The link is secure and authenticated with a secure connection key. */
175  };
176 
177  /**
178  * Construct a new instance of link_encryption_t.
179  */
181 };
182 
183 /**
184  * Type that describe a pairing failure.
185  */
186 struct pairing_failure_t : SafeEnum<pairing_failure_t, uint8_t> {
187  /** struct scoped enum wrapped by the class */
188  enum type {
189  PASSKEY_ENTRY_FAILED = 0x01,
190  OOB_NOT_AVAILABLE = 0x02,
191  AUTHENTICATION_REQUIREMENTS = 0x03,
192  CONFIRM_VALUE_FAILED = 0x04,
193  PAIRING_NOT_SUPPORTED = 0x05,
194  ENCRYPTION_KEY_SIZE = 0x06,
195  COMMAND_NOT_SUPPORTED = 0x07,
196  UNSPECIFIED_REASON = 0x08,
197  REPEATED_ATTEMPTS = 0x09,
198  INVALID_PARAMETERS = 0x0A,
199  DHKEY_CHECK_FAILED = 0x0B,
200  NUMERIC_COMPARISON_FAILED = 0x0c,
201  BR_EDR_PAIRING_IN_PROGRESS = 0x0D,
202  CROSS_TRANSPORT_KEY_DERIVATION_OR_GENERATION_NOT_ALLOWED = 0x0E
203  };
204 
205  /**
206  * Construct a new instance of pairing_failure_t.
207  */
209 };
210 
211 
212 /**
213  * Type that describe the IO capability of a device; it is used during Pairing
214  * Feature exchange.
215  */
216 struct io_capability_t : SafeEnum<io_capability_t, uint8_t> {
217  enum type {
218  DISPLAY_ONLY = 0x00,
219  DISPLAY_YES_NO = 0x01,
220  KEYBOARD_ONLY = 0x02,
221  NO_INPUT_NO_OUTPUT = 0x03,
222  KEYBOARD_DISPLAY = 0x04
223  };
224 
225  /**
226  * Construct a new instance of io_capability_t.
227  */
228  io_capability_t(type value) : SafeEnum<io_capability_t, uint8_t>(value) { }
229 };
230 
231 /**
232  * Passkey stored as a number.
233  */
234 typedef uint32_t passkey_num_t;
235 
236 /**
237  * Passkey stored as a string of digits.
238  */
240 public:
241  static const uint8_t PASSKEY_LEN = 6;
242  static const uint8_t NUMBER_OFFSET = '0';
243 
244  /**
245  * Default to all zeroes
246  */
248  memset(ascii, NUMBER_OFFSET, PASSKEY_LEN);
249  }
250 
251  /**
252  * Initialize a data from a string.
253  *
254  * @param[in] passkey value of the data.
255  */
256  PasskeyAscii(const uint8_t* passkey) {
257  if (passkey) {
258  memcpy(ascii, passkey, PASSKEY_LEN);
259  } else {
260  memset(ascii, NUMBER_OFFSET, PASSKEY_LEN);
261  }
262  }
263 
264  /**
265  * Initialize a data from a number.
266  *
267  * @param[in] passkey value of the data.
268  */
269  PasskeyAscii(passkey_num_t passkey) {
270  for (int i = 5, m = 100000; i >= 0; --i, m /= 10) {
271  uint32_t result = passkey / m;
272  ascii[i] = NUMBER_OFFSET + result;
273  passkey -= result * m;
274  }
275  }
276 
277  /**
278  * Cast to number.
279  */
280  operator passkey_num_t() {
281  return to_num(ascii);
282  }
283 
284  /**
285  * Convert ASCII string of digits into a number.
286  * @param[in] ascii ASCII string of 6 digits stored as ASCII characters
287  * @return Passkey as a number.
288  */
289  static uint32_t to_num(const uint8_t *ascii) {
290  uint32_t passkey = 0;
291  for (size_t i = 0, m = 1; i < PASSKEY_LEN; ++i, m *= 10) {
292  passkey += (ascii[i] - NUMBER_OFFSET) * m;
293  }
294  return passkey;
295  }
296 
297  /**
298  * Return the pointer to the buffer holding the string.
299  */
300  uint8_t* value() {
301  return ascii;
302  }
303 private:
304  uint8_t ascii[PASSKEY_LEN];
305 };
306 
307 /**
308  * Returns true if every byte is equal to zero
309  */
310 template <class byte_array_class>
311 bool is_all_zeros(byte_array_class &byte_array) {
312  for (size_t i = 0; i < byte_array.size(); i++) {
313  if (byte_array[i] != 0) {
314  return false;
315  }
316  }
317  return true;
318 }
319 
320 /**
321  * Zero out all bytes
322  */
323 template <class byte_array_class>
324 void set_all_zeros(byte_array_class &byte_array) {
325  memset(&byte_array[0], 0x00, byte_array.size());
326 }
327 
328 /**
329  * Model fixed size array values.
330  * @tparam array_size The size of the array.
331  */
332 template <size_t array_size>
333 struct byte_array_t {
334  /**
335  * Size of the array; accessible at compile time.
336  */
337  static const size_t size_ = array_size;
338 
339  /**
340  * Default to all zeroes
341  */
343  memset(_value, 0x00, sizeof(_value));
344  }
345 
346  /**
347  * Initialize a data from an array of bytes.
348  *
349  * @param[in] input_value value of the data.
350  */
351  byte_array_t(const uint8_t *input_value) {
352  memcpy(_value, input_value, sizeof(_value));
353  }
354 
355  /**
356  * Initialize a data from an buffer of bytes.
357  *
358  * @param[in] input_value pointer to buffer.
359  * @param[in] size buffer size
360  */
361  byte_array_t(const uint8_t* input_value, size_t size) {
362  memcpy(_value, input_value, size);
363  }
364 
365  /**
366  * Equal operator between two octet types.
367  */
368  friend bool operator==(const byte_array_t& lhs, const byte_array_t& rhs) {
369  return memcmp(lhs._value, rhs._value, sizeof(lhs._value)) == 0;
370  }
371 
372  /**
373  * Non equal operator between two octet types.
374  */
375  friend bool operator!=(const byte_array_t& lhs, const byte_array_t& rhs) {
376  return !(lhs == rhs);
377  }
378 
379  /**
380  * Subscript operator to access data content
381  */
382  uint8_t& operator[](size_t i) {
383  return _value[i];
384  }
385 
386  /**
387  * Subscript operator to access data content
388  */
389  uint8_t operator[](size_t i) const {
390  return _value[i];
391  }
392 
393  /**
394  * Return the pointer to the buffer holding data.
395  */
396  const uint8_t* data() const {
397  return _value;
398  }
399 
400  /**
401  * Return the pointer to the buffer holding data.
402  */
403  uint8_t* data() {
404  return _value;
405  }
406 
407  /**
408  * Size in byte of a data.
409  */
410  static size_t size() {
411  return array_size;
412  }
413 
414 protected:
415  uint8_t _value[array_size];
416 };
417 
418 /**
419  * Construct a fixed size Span from a byte_array_t.
420  *
421  * @param src byte_array_t to create a Span from.
422  *
423  * @return A Span to @p src.
424  */
425 template<size_t Size>
427 {
428  return Span<uint8_t, Size>(src.data(), src.size());
429 }
430 
431 /**
432  * Construct a fixed size Span from a const byte_array_t.
433  *
434  * @param src byte_array_t to create a Span from.
435  *
436  * @return A Span to @p src.
437  */
438 template<size_t Size>
440 {
441  return Span<const uint8_t, Size>(src.data(), src.size());
442 }
443 
444 /** 128 bit keys used by paired devices */
446 typedef byte_array_t<16> csrk_t;
447 typedef byte_array_t<16> ltk_t;
448 
449 /** Used to identify LTK for legacy pairing connections */
451 typedef byte_array_t<8> rand_t;
452 
453 /** Out of band data exchanged during pairing */
454 typedef byte_array_t<16> oob_tk_t; /**< legacy pairing TK */
455 typedef byte_array_t<16> oob_lesc_value_t; /**< secure connections oob random 128 value */
456 typedef byte_array_t<16> oob_confirm_t; /**< secure connections oob confirmation value */
457 
458 /** data to be encrypted */
460 
461 /** public key coordinate, two of which define the public key */
463 
464 /** Diffie-Hellman key */
466 
467 /** counter for signed data writes done by GattClient */
468 typedef uint32_t sign_count_t;
469 
470 /**
471  * MAC address data type.
472  */
473 struct address_t : public byte_array_t<6> {
474  /**
475  * Create an invalid mac address, equal to 00:00:00:00:00:00
476  */
478  memset(_value, 0x00, sizeof(_value));
479  }
480 
481  /**
482  * Initialize a data from an array of bytes.
483  *
484  * @param[in] input_value value of the data.
485  */
486  address_t(const uint8_t *input_value) {
487  memcpy(_value, input_value, sizeof(_value));
488  }
489 };
490 
491 /**
492  * Type that describes a random device address type.
493  */
494 struct random_address_type_t : SafeEnum<random_address_type_t, uint8_t> {
495  /** struct scoped enum wrapped by the class */
496  enum type {
497  STATIC, /**< Random static device address. */
498  NON_RESOLVABLE_PRIVATE, /**< Random non resolvable private address. */
499  RESOLVABLE_PRIVATE /**< Random resolvable private address. */
500  };
501 
502  /**
503  * Construct a new instance of random_address_type_t.
504  */
506  SafeEnum<random_address_type_t, uint8_t>(value) { }
507 };
508 
509 /**
510  * Security requirement that can be attached to an attribute operation.
511  */
512 struct att_security_requirement_t : SafeEnum<att_security_requirement_t, uint8_t> {
513  /**
514  * Number of bits required to store the value.
515  *
516  * This value can be used to define a bitfield that host a value of this
517  * enum.
518  */
519  static const uint8_t size = 2;
520 
521  /** struct scoped enum wrapped by the class */
522  enum type {
523  /**
524  * The operation does not have security requirements.
525  *
526  * It is equivalent to: SecurityMode 1 level 1: No authentication, no
527  * encryption and no signing required.
528  *
529  * @note This security mode is not applicable for signed operation.
530  *
531  * @note Equivalent to SecurityManager::SECURITY_MODE_ENCRYPTION_OPEN_LINK.
532  */
534 
535  /**
536  * The operation requires security and there's no requirement towards
537  * peer authentication.
538  *
539  * @note Security can be achieved either by signing messages or
540  * encrypting the link.
541  *
542  * @note Signing is only applicable for signed write operations.
543  *
544  * @note Equivalent to SecurityManager::SECURITY_MODE_ENCRYPTION_NO_MITM
545  * or SecurityManager::SECURITY_MODE_SIGNED_NO_MITM.
546  */
548 
549  /**
550  * The operation requires security and the peer must be authenticated.
551  *
552  * @note Security can be achieved either by signing messages or
553  * encrypting the link.
554  *
555  * @note Equivalent to SecurityManager::SECURITY_MODE_ENCRYPTION_WITH_MITM
556  * or SecurityManager::SECURITY_MODE_SIGNED_WITH_MITM.
557  */
559 
560  /**
561  * The operation require encryption with an authenticated peer that
562  * paired using secure connection pairing.
563  *
564  * @note This security mode is not applicable for signed operation;
565  * security is achieved with link encryption.
566  */
567  SC_AUTHENTICATED
568  };
569 
570  /**
571  * Construct a new instance of att_security_requirement_t.
572  */
574  SafeEnum<att_security_requirement_t, uint8_t>(value) { }
575 };
576 
577 /**
578  * Type that describes a peer device address type.
579  */
580 struct peer_address_type_t :SafeEnum<peer_address_type_t, uint8_t> {
581  /** struct scoped enum wrapped by the class */
582  enum type {
583  /**
584  * Public device address.
585  */
586  PUBLIC = 0,
587 
588  /**
589  * Random address.
590  *
591  * Use Gap::getRandomAddressType to retrieve the type of the random
592  * address.
593  */
595 
596  /**
597  * A Public address used as a device identity address.
598  */
600 
601  /**
602  * A Random static address used as a device identity address.
603  */
605 
606  /**
607  * No address provided (anonymous advertisement).
608  */
609  ANONYMOUS = 0xFF
610  };
611 
612  /**
613  * Construct a new instance of peer_address_type_t.
614  */
616  SafeEnum<peer_address_type_t, uint8_t>(value) { }
617 
618  /**
619  * Default initialization of peer_address_type_t.
620  */
622  SafeEnum<peer_address_type_t, uint8_t>(PUBLIC) { }
623 };
624 
625 /**
626  * Type that describes a bluetooth PHY(sical) transport.
627  */
628 struct phy_t : SafeEnum<phy_t, uint8_t> {
629  /** struct scoped enum wrapped by the class */
630  enum type {
631  /**
632  * No phy selected.
633  *
634  * @note This value can be used to indicate the absence of phy
635  */
636  NONE = 0,
637 
638  /**
639  * 1Mbit/s LE.
640  *
641  * @note This physical transport was available since Bluetooth 4.0
642  */
643  LE_1M = 1,
644 
645  /**
646  * 2Mbit/s LE.
647  *
648  * Modulation is similar to LE_1M but differs in rate. Therefore range
649  * performances are in the same ballpark as LE_1M while the increased rate
650  * minimize time spent to transfer or receive a packet which leads to a
651  * better power consumption and/or faster transfer.
652  *
653  * @note This transport has been introduced with the Bluetooth 5.
654  * @note When operating at 2Mbit/s range is not exactly identical to the
655  * range at 1Mbit/s due to a loss in sensitivity.
656  */
657  LE_2M = 2,
658 
659  /**
660  * LE Coded PHY.
661  *
662  * This transport reuse the 1Mbit/s channel with different coding schemes.
663  * Either two (S=2) or eight (S=8) symbols can be used to represent a
664  * bit while the 1Mbit/s transport use 1 symbol to code 1 bit of data.
665  *
666  * Here is the data rate of the two coding schemes:
667  * - S=2: 500kbit/s
668  * - S=8: 125kbit/s
669  *
670  * The goal of the coded PHY is to increase the range of BLE devices.
671  * Of course given it takes more time to transfer data, transmission
672  * and reception last longer which leads to an increase in power
673  * consumption.
674  *
675  * @note This transport has been introduced with the Bluetooth 5.
676  */
677  LE_CODED
678  };
679 
680  /**
681  * Construct a new instance of phy_t.
682  */
684  SafeEnum<phy_t, uint8_t>(value) { }
685 
686  explicit phy_t(uint8_t raw_value) : SafeEnum(raw_value) { }
687 };
688 
689 /**
690  * Type that describe a set of PHY(sical) transports. This is used to
691  * indicate preference for the PHY transports set within it.
692  */
693 class phy_set_t {
694 public:
695  enum PhysFlags_t {
696  PHY_SET_1M = 0x01,
697  PHY_SET_2M = 0x02,
698  PHY_SET_CODED = 0x04
699  };
700 
701  /**
702  * Create set that indicates no preference.
703  */
704  phy_set_t() : _value(0) { }
705 
706  /**
707  * Create a set based on the mask specified in the Bluetooth spec.
708  *
709  * @param value Octet containing the set of preferred PHYs
710  */
711  phy_set_t(uint8_t value) : _value(value) { }
712 
713  /**
714  * Create a set based on individual settings.
715  *
716  * @param phy_1m Prefer LE 1M
717  * @param phy_2m Prefer LE 2M if avaiable
718  * @param phy_coded Prefer coded modulation if avaiable
719  */
720  phy_set_t(bool phy_1m, bool phy_2m, bool phy_coded) :
721  _value()
722  {
723  set_1m(phy_1m);
724  set_2m(phy_2m);
725  set_coded(phy_coded);
726  }
727 
728  /**
729  * Create a set from a single phy.
730  *
731  * @param phy The phy to add to the set.
732  */
733  phy_set_t(phy_t phy) : _value()
734  {
735  switch (phy.value()) {
736  case phy_t::LE_1M:
737  set_1m(true);
738  break;
739  case phy_t::LE_2M:
740  set_2m(true);
741  break;
742  case phy_t::LE_CODED:
743  set_coded(true);
744  break;
745  default:
746  break;
747  }
748  }
749 
750  /** Prefer 1M PHY. */
751  void set_1m(bool enabled = true) {
752  if (enabled) {
753  _value |= PHY_SET_1M;
754  } else {
755  _value &= ~PHY_SET_1M;
756  }
757  }
758 
759  /** Prefer 2M PHY. */
760  void set_2m(bool enabled = true) {
761  if (enabled) {
762  _value |= PHY_SET_2M;
763  } else {
764  _value &= ~PHY_SET_2M;
765  }
766  }
767 
768  /** Prefer coded PHY. */
769  void set_coded(bool enabled = true) {
770  if (enabled) {
771  _value |= PHY_SET_CODED;
772  } else {
773  _value &= ~PHY_SET_CODED;
774  }
775  }
776 
777  bool get_1m() const {
778  return (_value & PHY_SET_1M);
779  }
780 
781  bool get_2m() const {
782  return (_value & PHY_SET_2M);
783  }
784 
785  bool get_coded() const {
786  return (_value & PHY_SET_CODED);
787  }
788 
789  operator uint8_t() const {
790  return _value;
791  }
792 
793  uint8_t value() const {
794  return _value;
795  }
796 
797  uint8_t count() const {
798  return (get_1m() ? 1 : 0) + (get_2m() ? 1 : 0) + (get_coded() ? 1 : 0);
799  }
800 
801 private:
802  uint8_t _value;
803 };
804 
805 /**
806  * Type describing the number of symbols per bit in le coded PHY.
807  */
808 struct coded_symbol_per_bit_t :SafeEnum<coded_symbol_per_bit_t, uint8_t> {
809  /** struct scoped enum wrapped by the class */
810  enum type {
811  /**
812  * The Number of symbol used to code a bit is undefined.
813  */
815 
816  /**
817  * Two symbols to code a bit.
818  */
819  S2,
820 
821  /**
822  * Eight symbols to code a bit.
823  */
824  S8
825  };
826 
827  /**
828  * Construct a new instance of coded_symbol_per_bit_t.
829  */
831  SafeEnum<coded_symbol_per_bit_t, uint8_t>(value) { }
832 };
833 
834 } // namespace ble
835 
836 /**
837  * @}
838  * @}
839  */
840 
841 #endif /* BLE_TYPES_H_ */
static const advertising_handle_t INVALID_ADVERTISING_HANDLE
Special advertising set handle used as return or parameter to signify an invalid handle.
Definition: BLETypes.h:44
Span< uint8_t, Size > make_Span(byte_array_t< Size > &src)
Construct a fixed size Span from a byte_array_t.
Definition: BLETypes.h:426
type
struct scoped enum wrapped by the class
Definition: BLETypes.h:630
byte_array_t(const uint8_t *input_value)
Initialize a data from an array of bytes.
Definition: BLETypes.h:351
byte_array_t< 32 > dhkey_t
Diffie-Hellman key.
Definition: BLETypes.h:465
byte_array_t()
Default to all zeroes.
Definition: BLETypes.h:342
phy_set_t(uint8_t value)
Create a set based on the mask specified in the Bluetooth spec.
Definition: BLETypes.h:711
address_t(const uint8_t *input_value)
Initialize a data from an array of bytes.
Definition: BLETypes.h:486
pairing_failure_t(type value)
Construct a new instance of pairing_failure_t.
Definition: BLETypes.h:208
uintptr_t connection_handle_t
Opaque reference to a connection.
Definition: BLETypes.h:86
random_address_type_t(type value)
Construct a new instance of random_address_type_t.
Definition: BLETypes.h:505
friend bool operator==(const attribute_handle_range_t &lhs, const attribute_handle_range_t &rhs)
Equal operator for attribute_handle_range_t.
Definition: BLETypes.h:118
Span< T, Extent > make_Span(T *elements)
Generate a Span from a pointer to a C/C++ array.
Definition: Span.h:933
address_t()
Create an invalid mac address, equal to 00:00:00:00:00:00.
Definition: BLETypes.h:477
friend bool operator==(const byte_array_t &lhs, const byte_array_t &rhs)
Equal operator between two octet types.
Definition: BLETypes.h:368
coded_symbol_per_bit_t(type value)
Construct a new instance of coded_symbol_per_bit_t.
Definition: BLETypes.h:830
Type that describes a random device address type.
Definition: BLETypes.h:494
Model fixed size array values.
Definition: BLETypes.h:333
const uint8_t * data() const
Return the pointer to the buffer holding data.
Definition: BLETypes.h:396
uint8_t * data()
Return the pointer to the buffer holding data.
Definition: BLETypes.h:403
Type describing the number of symbols per bit in le coded PHY.
Definition: BLETypes.h:808
Security requirement that can be attached to an attribute operation.
Definition: BLETypes.h:512
Span< const uint8_t, Size > make_const_Span(const byte_array_t< Size > &src)
Construct a fixed size Span from a const byte_array_t.
Definition: BLETypes.h:439
The Number of symbol used to code a bit is undefined.
Definition: BLETypes.h:814
The operation requires security and there&#39;s no requirement towards peer authentication.
Definition: BLETypes.h:547
Inclusive range of GATT attributes handles.
Definition: BLETypes.h:99
byte_array_t< 16 > encryption_block_t
data to be encrypted
Definition: BLETypes.h:459
phy_set_t()
Create set that indicates no preference.
Definition: BLETypes.h:704
peer_address_type_t(type value)
Construct a new instance of peer_address_type_t.
Definition: BLETypes.h:615
uint8_t value() const
Explicit access to the inner value of the SafeEnum instance.
Definition: SafeEnum.h:202
uint8_t & operator[](size_t i)
Subscript operator to access data content.
Definition: BLETypes.h:382
The operation does not have security requirements.
Definition: BLETypes.h:533
peer_address_type_t()
Default initialization of peer_address_type_t.
Definition: BLETypes.h:621
type
struct scoped enum wrapped by the class
Definition: BLETypes.h:522
LE Coded PHY.
Definition: BLETypes.h:677
A Random static address used as a device identity address.
Definition: BLETypes.h:604
Helper class used to define safe enumerations.
Definition: SafeEnum.h:109
byte_array_t(const uint8_t *input_value, size_t size)
Initialize a data from an buffer of bytes.
Definition: BLETypes.h:361
SafeEnum(uint8_t value)
Construction of an enumeration value.
Definition: SafeEnum.h:119
controller_supported_features_t(type value)
Construct a new instance of ControllerSupportedFeatures_t.
Definition: BLETypes.h:74
void set_2m(bool enabled=true)
Prefer 2M PHY.
Definition: BLETypes.h:760
Passkey stored as a string of digits.
Definition: BLETypes.h:239
type
struct scoped enum wrapped by the class
Definition: BLETypes.h:188
byte_array_t< 16 > oob_tk_t
Out of band data exchanged during pairing.
Definition: BLETypes.h:454
static const advertising_handle_t LEGACY_ADVERTISING_HANDLE
Special advertising set handle used for the legacy advertising set.
Definition: BLETypes.h:41
Span< const T, Extent > make_const_Span(const T(&elements)[Extent])
Generate a Span to a const content from a reference to a C/C++ array.
Definition: Span.h:972
MAC address data type.
Definition: BLETypes.h:473
void set_all_zeros(byte_array_class &byte_array)
Zero out all bytes.
Definition: BLETypes.h:324
attribute_handle_t end
End of the range.
Definition: BLETypes.h:108
type
struct scoped enum wrapped by the class
Definition: BLETypes.h:810
PasskeyAscii(passkey_num_t passkey)
Initialize a data from a number.
Definition: BLETypes.h:269
Type that describes a bluetooth PHY(sical) transport.
Definition: BLETypes.h:628
io_capability_t(type value)
Construct a new instance of io_capability_t.
Definition: BLETypes.h:228
type
struct scoped enum wrapped by the class
Definition: BLETypes.h:496
Random non resolvable private address.
Definition: BLETypes.h:498
static const uint8_t LEGACY_ADVERTISING_MAX_SIZE
Maximum advertising data length that can fit in a legacy PDU.
Definition: BLETypes.h:47
byte_array_t< 32 > public_key_coord_t
public key coordinate, two of which define the public key
Definition: BLETypes.h:462
attribute_handle_t begin
Beginning of the range.
Definition: BLETypes.h:103
Nonowning view to a sequence of contiguous elements.
Definition: Span.h:214
uint8_t advertising_handle_t
Handle of an advertising set.
Definition: Types.h:134
PasskeyAscii(const uint8_t *passkey)
Initialize a data from a string.
Definition: BLETypes.h:256
Two symbols to code a bit.
Definition: BLETypes.h:819
uint8_t operator[](size_t i) const
Subscript operator to access data content.
Definition: BLETypes.h:389
byte_array_t< 16 > oob_lesc_value_t
secure connections oob random 128 value
Definition: BLETypes.h:455
static size_t size()
Size in byte of a data.
Definition: BLETypes.h:410
friend bool operator!=(const attribute_handle_range_t &lhs, const attribute_handle_range_t &rhs)
Not equal operator for attribute_handle_range_t.
Definition: BLETypes.h:132
phy_t(type value)
Construct a new instance of phy_t.
Definition: BLETypes.h:683
uint32_t sign_count_t
counter for signed data writes done by GattClient
Definition: BLETypes.h:468
Type that describes a peer device address type.
Definition: BLETypes.h:580
friend bool operator!=(const byte_array_t &lhs, const byte_array_t &rhs)
Non equal operator between two octet types.
Definition: BLETypes.h:375
Type that describe a set of PHY(sical) transports.
Definition: BLETypes.h:693
A Public address used as a device identity address.
Definition: BLETypes.h:599
byte_array_t< 2 > ediv_t
Used to identify LTK for legacy pairing connections.
Definition: BLETypes.h:450
phy_set_t(bool phy_1m, bool phy_2m, bool phy_coded)
Create a set based on individual settings.
Definition: BLETypes.h:720
2Mbit/s LE.
Definition: BLETypes.h:657
1Mbit/s LE.
Definition: BLETypes.h:643
att_security_requirement_t(type value)
Construct a new instance of att_security_requirement_t.
Definition: BLETypes.h:573
bool is_all_zeros(byte_array_class &byte_array)
Returns true if every byte is equal to zero.
Definition: BLETypes.h:311
static attribute_handle_range_t attribute_handle_range(attribute_handle_t begin, attribute_handle_t end)
Construct an attribute_handle_range_t from its first and last attribute handle.
Definition: BLETypes.h:153
type
struct scoped enum wrapped by the class
Definition: BLETypes.h:582
The operation requires security and the peer must be authenticated.
Definition: BLETypes.h:558
void set_1m(bool enabled=true)
Prefer 1M PHY.
Definition: BLETypes.h:751
uint8_t * value()
Return the pointer to the buffer holding the string.
Definition: BLETypes.h:300
phy_set_t(phy_t phy)
Create a set from a single phy.
Definition: BLETypes.h:733
Type that describe a pairing failure.
Definition: BLETypes.h:186
byte_array_t< 16 > oob_confirm_t
secure connections oob confirmation value
Definition: BLETypes.h:456
void set_coded(bool enabled=true)
Prefer coded PHY.
Definition: BLETypes.h:769
Entry namespace for all BLE API definitions.
byte_array_t< 16 > irk_t
128 bit keys used by paired devices
Definition: BLETypes.h:445
static uint32_t to_num(const uint8_t *ascii)
Convert ASCII string of digits into a number.
Definition: BLETypes.h:289
uint16_t attribute_handle_t
Reference to an attribute in a GATT database.
Definition: BLETypes.h:91
Features supported by the controller.
Definition: BLETypes.h:51
Type that describe the IO capability of a device; it is used during Pairing Feature exchange...
Definition: BLETypes.h:216
uint32_t passkey_num_t
Passkey stored as a number.
Definition: BLETypes.h:234
Random static device address.
Definition: BLETypes.h:497
PasskeyAscii()
Default to all zeroes.
Definition: BLETypes.h:247
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.