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