LCOV - code coverage report
Current view: top level - zephyr/bluetooth - gap.h Coverage Total Hit
Test: new.info Lines: 64.9 % 74 48
Test Date: 2025-09-25 19:22:35

            Line data    Source code
       1            1 : /** @file
       2              :  *  @brief Bluetooth Generic Access Profile defines and Assigned Numbers.
       3              :  */
       4              : 
       5              : /*
       6              :  * Copyright (c) 2019 Nordic Semiconductor ASA
       7              :  *
       8              :  * SPDX-License-Identifier: Apache-2.0
       9              :  */
      10              : 
      11              : #ifndef ZEPHYR_INCLUDE_BLUETOOTH_GAP_H_
      12              : #define ZEPHYR_INCLUDE_BLUETOOTH_GAP_H_
      13              : 
      14              : #include <zephyr/bluetooth/assigned_numbers.h>
      15              : #include <zephyr/bluetooth/byteorder.h>
      16              : #include <zephyr/sys/util_macro.h>
      17              : 
      18              : #ifdef __cplusplus
      19              : extern "C" {
      20              : #endif
      21              : 
      22              : /**
      23              :  * @brief Bluetooth Generic Access Profile defines and Assigned Numbers.
      24              :  * @defgroup bt_gap_defines Defines and Assigned Numbers
      25              :  * @ingroup bt_gap
      26              :  * @{
      27              :  */
      28              : 
      29              : /**
      30              :  * @name Company Identifiers (see Bluetooth Assigned Numbers)
      31              :  * @{
      32              :  */
      33            1 : #define BT_COMP_ID_LF           0x05f1 /**< The Linux Foundation */
      34              : /**
      35              :  * @}
      36              :  */
      37              : 
      38              : /**
      39              :  * @name Defined GAP timers
      40              :  * @{
      41              :  */
      42            0 : #define BT_GAP_SCAN_FAST_INTERVAL_MIN           0x0030  /* 30 ms    */
      43            0 : #define BT_GAP_SCAN_FAST_INTERVAL               0x0060  /* 60 ms    */
      44            0 : #define BT_GAP_SCAN_FAST_WINDOW                 0x0030  /* 30 ms    */
      45            0 : #define BT_GAP_SCAN_SLOW_INTERVAL_1             0x0800  /* 1.28 s   */
      46            0 : #define BT_GAP_SCAN_SLOW_WINDOW_1               0x0012  /* 11.25 ms */
      47            0 : #define BT_GAP_SCAN_SLOW_INTERVAL_2             0x1000  /* 2.56 s   */
      48            0 : #define BT_GAP_SCAN_SLOW_WINDOW_2               0x0012  /* 11.25 ms */
      49            0 : #define BT_GAP_ADV_FAST_INT_MIN_1               0x0030  /* 30 ms    */
      50            0 : #define BT_GAP_ADV_FAST_INT_MAX_1               0x0060  /* 60 ms    */
      51            0 : #define BT_GAP_ADV_FAST_INT_MIN_2               0x00a0  /* 100 ms   */
      52            0 : #define BT_GAP_ADV_FAST_INT_MAX_2               0x00f0  /* 150 ms   */
      53            0 : #define BT_GAP_ADV_SLOW_INT_MIN                 0x0640  /* 1 s      */
      54            0 : #define BT_GAP_ADV_SLOW_INT_MAX                 0x0780  /* 1.2 s    */
      55            0 : #define BT_GAP_PER_ADV_FAST_INT_MIN_1           0x0018  /* 30 ms    */
      56            0 : #define BT_GAP_PER_ADV_FAST_INT_MAX_1           0x0030  /* 60 ms    */
      57            0 : #define BT_GAP_PER_ADV_FAST_INT_MIN_2           0x0050  /* 100 ms   */
      58            0 : #define BT_GAP_PER_ADV_FAST_INT_MAX_2           0x0078  /* 150 ms   */
      59            0 : #define BT_GAP_PER_ADV_SLOW_INT_MIN             0x0320  /* 1 s      */
      60            0 : #define BT_GAP_PER_ADV_SLOW_INT_MAX             0x03C0  /* 1.2 s    */
      61            0 : #define BT_GAP_INIT_CONN_INT_MIN                0x0018  /* 30 ms    */
      62            0 : #define BT_GAP_INIT_CONN_INT_MAX                0x0028  /* 50 ms    */
      63              : /**
      64              :  * @}
      65              :  */
      66              : 
      67              : /** LE PHY types */
      68            1 : enum bt_gap_le_phy {
      69              :         /** Convenience macro for when no PHY is set. */
      70              :         BT_GAP_LE_PHY_NONE                    = 0,
      71              :         /** LE 1M PHY */
      72              :         BT_GAP_LE_PHY_1M                      = BIT(0),
      73              :          /** LE 2M PHY */
      74              :         BT_GAP_LE_PHY_2M                      = BIT(1),
      75              :         /** LE Coded PHY, coding scheme not specified */
      76              :         BT_GAP_LE_PHY_CODED                   = BIT(2),
      77              :         /** LE Coded S=8 PHY. Only used for advertising reports
      78              :          * when Kconfig BT_EXT_ADV_CODING_SELECTION is enabled.
      79              :          */
      80              :         BT_GAP_LE_PHY_CODED_S8                = BIT(3),
      81              :         /** LE Coded S=2 PHY. Only used for advertising reports
      82              :          * when Kconfig BT_EXT_ADV_CODING_SELECTION is enabled.
      83              :          */
      84              :         BT_GAP_LE_PHY_CODED_S2                = BIT(4),
      85              : };
      86              : 
      87              : /** Advertising PDU types */
      88            1 : enum bt_gap_adv_type {
      89              :         /** Scannable and connectable advertising. */
      90              :         BT_GAP_ADV_TYPE_ADV_IND               = 0x00,
      91              :         /** Directed connectable advertising. */
      92              :         BT_GAP_ADV_TYPE_ADV_DIRECT_IND        = 0x01,
      93              :         /** Non-connectable and scannable advertising. */
      94              :         BT_GAP_ADV_TYPE_ADV_SCAN_IND          = 0x02,
      95              :         /** Non-connectable and non-scannable advertising. */
      96              :         BT_GAP_ADV_TYPE_ADV_NONCONN_IND       = 0x03,
      97              :         /** Additional advertising data requested by an active scanner. */
      98              :         BT_GAP_ADV_TYPE_SCAN_RSP              = 0x04,
      99              :         /** Extended advertising, see advertising properties. */
     100              :         BT_GAP_ADV_TYPE_EXT_ADV               = 0x05,
     101              : };
     102              : 
     103              : /** Advertising PDU properties */
     104            1 : enum bt_gap_adv_prop {
     105              :         /** Connectable advertising. */
     106              :         BT_GAP_ADV_PROP_CONNECTABLE           = BIT(0),
     107              :         /** Scannable advertising. */
     108              :         BT_GAP_ADV_PROP_SCANNABLE             = BIT(1),
     109              :         /** Directed advertising. */
     110              :         BT_GAP_ADV_PROP_DIRECTED              = BIT(2),
     111              :         /** Additional advertising data requested by an active scanner. */
     112              :         BT_GAP_ADV_PROP_SCAN_RESPONSE         = BIT(3),
     113              :         /** Extended advertising. */
     114              :         BT_GAP_ADV_PROP_EXT_ADV               = BIT(4),
     115              : };
     116              : 
     117              : /** Maximum advertising data length. */
     118            1 : #define BT_GAP_ADV_MAX_ADV_DATA_LEN             31
     119              : /** Maximum extended advertising data length.
     120              :  *
     121              :  *  @note The maximum advertising data length that can be sent by an extended
     122              :  *        advertiser is defined by the controller.
     123              :  */
     124            1 : #define BT_GAP_ADV_MAX_EXT_ADV_DATA_LEN         1650
     125              : 
     126            0 : #define BT_GAP_TX_POWER_INVALID                 0x7f
     127            0 : #define BT_GAP_RSSI_INVALID                     0x7f
     128            0 : #define BT_GAP_SID_INVALID                      0xff
     129            0 : #define BT_GAP_NO_TIMEOUT                       0x0000
     130              : 
     131              : /* The maximum allowed high duty cycle directed advertising timeout, 1.28
     132              :  * seconds in 10 ms unit.
     133              :  */
     134            0 : #define BT_GAP_ADV_HIGH_DUTY_CYCLE_MAX_TIMEOUT  128
     135              : 
     136              : /** Default data length */
     137            1 : #define BT_GAP_DATA_LEN_DEFAULT                 0x001b /* 27 bytes */
     138              : /** Maximum data length */
     139            1 : #define BT_GAP_DATA_LEN_MAX                     0x00fb /* 251 bytes */
     140              : 
     141              : /** Default data time */
     142            1 : #define BT_GAP_DATA_TIME_DEFAULT                0x0148 /* 328 us */
     143              : /** Maximum data time */
     144            1 : #define BT_GAP_DATA_TIME_MAX                    0x4290 /* 17040 us */
     145              : 
     146              : /** Minimum advertising set number */
     147            1 : #define BT_GAP_SID_MIN                          0x00
     148              : /** Maximum advertising set number */
     149            1 : #define BT_GAP_SID_MAX                          0x0F
     150              : /** Maximum number of consecutive periodic advertisement events that can be
     151              :  *  skipped after a successful receive.
     152              :  */
     153            1 : #define BT_GAP_PER_ADV_MAX_SKIP                 0x01F3
     154              : /** Minimum Periodic Advertising Timeout (N * 10 ms) */
     155            1 : #define BT_GAP_PER_ADV_MIN_TIMEOUT              0x000A /* 100 ms */
     156              : /** Maximum Periodic Advertising Timeout (N * 10 ms) */
     157            1 : #define BT_GAP_PER_ADV_MAX_TIMEOUT              0x4000 /* 163.84 s */
     158              : /** Minimum Periodic Advertising Interval (N * 1.25 ms) */
     159            1 : #define BT_GAP_PER_ADV_MIN_INTERVAL             0x0006 /* 7.5 ms */
     160              : /** Maximum Periodic Advertising Interval (N * 1.25 ms) */
     161            1 : #define BT_GAP_PER_ADV_MAX_INTERVAL             0xFFFF /* 81.91875 s */
     162              : 
     163              : /**
     164              :  * @brief Convert periodic advertising interval (N * 0.625 ms) to microseconds
     165              :  *
     166              :  * Value range of @p _interval is @ref BT_LE_ADV_INTERVAL_MIN to @ref BT_LE_ADV_INTERVAL_MAX
     167              :  */
     168            1 : #define BT_GAP_ADV_INTERVAL_TO_US(_interval) ((uint32_t)((_interval) * 625U))
     169              : 
     170              : /**
     171              :  * @brief Convert periodic advertising interval (N * 0.625 ms) to milliseconds
     172              :  *
     173              :  * Value range of @p _interval is @ref BT_LE_ADV_INTERVAL_MIN to @ref BT_LE_ADV_INTERVAL_MAX
     174              :  *
     175              :  * @note When intervals cannot be represented in milliseconds, this will round down.
     176              :  * For example BT_GAP_ADV_INTERVAL_TO_MS(0x0021) will become 20 ms instead of 20.625 ms
     177              :  */
     178            1 : #define BT_GAP_ADV_INTERVAL_TO_MS(_interval) (BT_GAP_ADV_INTERVAL_TO_US(_interval) / USEC_PER_MSEC)
     179              : 
     180              : /**
     181              :  * @brief Convert isochronous interval (N * 1.25 ms) to microseconds
     182              :  *
     183              :  * Value range of @p _interval is @ref BT_HCI_ISO_INTERVAL_MIN to @ref BT_HCI_ISO_INTERVAL_MAX
     184              :  */
     185            1 : #define BT_GAP_ISO_INTERVAL_TO_US(_interval) ((uint32_t)((_interval) * 1250U))
     186              : 
     187              : /**
     188              :  * @brief Convert isochronous interval (N * 1.25 ms) to milliseconds
     189              :  *
     190              :  * Value range of @p _interval is @ref BT_HCI_ISO_INTERVAL_MIN to @ref BT_HCI_ISO_INTERVAL_MAX
     191              :  *
     192              :  * @note When intervals cannot be represented in milliseconds, this will round down.
     193              :  * For example BT_GAP_ISO_INTERVAL_TO_MS(0x0005) will become 6 ms instead of 6.25 ms
     194              :  */
     195            1 : #define BT_GAP_ISO_INTERVAL_TO_MS(_interval) (BT_GAP_ISO_INTERVAL_TO_US(_interval) / USEC_PER_MSEC)
     196              : 
     197              : /** @brief Convert periodic advertising interval (N * 1.25 ms) to microseconds *
     198              :  *
     199              :  * Value range of @p _interval is @ref BT_HCI_LE_PER_ADV_INTERVAL_MIN to @ref
     200              :  * BT_HCI_LE_PER_ADV_INTERVAL_MAX
     201              :  */
     202            1 : #define BT_GAP_PER_ADV_INTERVAL_TO_US(_interval) ((uint32_t)((_interval) * 1250U))
     203              : 
     204              : /**
     205              :  * @brief Convert periodic advertising interval (N * 1.25 ms) to milliseconds
     206              :  *
     207              :  * @note When intervals cannot be represented in milliseconds, this will round down.
     208              :  * For example BT_GAP_PER_ADV_INTERVAL_TO_MS(0x0009) will become 11 ms instead of 11.25 ms
     209              :  */
     210            1 : #define BT_GAP_PER_ADV_INTERVAL_TO_MS(_interval)                                                   \
     211              :         (BT_GAP_PER_ADV_INTERVAL_TO_US(_interval) / USEC_PER_MSEC)
     212              : 
     213              : /**
     214              :  * @brief Convert microseconds to advertising interval units (0.625 ms)
     215              :  *
     216              :  * Value range of @p _interval is 20000 to 1024000
     217              :  *
     218              :  * @note If @p _interval is not a multiple of the unit, it will round down to nearest.
     219              :  * For example BT_GAP_US_TO_ADV_INTERVAL(21000) will become 20625 microseconds
     220              :  */
     221            1 : #define BT_GAP_US_TO_ADV_INTERVAL(_interval) ((uint16_t)((_interval) / 625U))
     222              : 
     223              : /**
     224              :  * @brief Convert milliseconds to advertising interval units (0.625 ms)
     225              :  *
     226              :  * Value range of @p _interval is 20 to 1024
     227              :  *
     228              :  * @note If @p _interval is not a multiple of the unit, it will round down to nearest.
     229              :  * For example BT_GAP_MS_TO_ADV_INTERVAL(21) will become 20.625 milliseconds
     230              :  */
     231            1 : #define BT_GAP_MS_TO_ADV_INTERVAL(_interval)                                                       \
     232              :         (BT_GAP_US_TO_ADV_INTERVAL((_interval) * USEC_PER_MSEC))
     233              : 
     234              : /**
     235              :  * @brief Convert microseconds to periodic advertising interval units (1.25 ms)
     236              :  *
     237              :  * Value range of @p _interval is 7500 to 81918750
     238              :  *
     239              :  * @note If @p _interval is not a multiple of the unit, it will round down to nearest.
     240              :  * For example BT_GAP_US_TO_PER_ADV_INTERVAL(11000) will become 10000 microseconds
     241              :  */
     242            1 : #define BT_GAP_US_TO_PER_ADV_INTERVAL(_interval) ((uint16_t)((_interval) / 1250U))
     243              : 
     244              : /**
     245              :  * @brief Convert milliseconds to periodic advertising interval units (1.25 ms)
     246              :  *
     247              :  * Value range of @p _interval is 7.5 to 81918.75
     248              :  *
     249              :  * @note If @p _interval is not a multiple of the unit, it will round down to nearest.
     250              :  * For example BT_GAP_MS_TO_PER_ADV_INTERVAL(11) will become 10 milliseconds
     251              :  */
     252            1 : #define BT_GAP_MS_TO_PER_ADV_INTERVAL(_interval)                                                   \
     253              :         (BT_GAP_US_TO_PER_ADV_INTERVAL((_interval) * USEC_PER_MSEC))
     254              : 
     255              : /**
     256              :  * @brief Convert milliseconds to periodic advertising sync timeout units (10 ms)
     257              :  *
     258              :  * Value range of @p _timeout is 100 to 163840
     259              :  *
     260              :  * @note If @p _timeout is not a multiple of the unit, it will round down to nearest.
     261              :  * For example BT_GAP_MS_TO_PER_ADV_SYNC_TIMEOUT(4005) will become 4000 milliseconds
     262              :  */
     263            1 : #define BT_GAP_MS_TO_PER_ADV_SYNC_TIMEOUT(_timeout) ((uint16_t)((_timeout) / 10U))
     264              : 
     265              : /**
     266              :  * @brief Convert microseconds to periodic advertising sync timeout units (10 ms)
     267              :  *
     268              :  * Value range of @p _timeout is 100000 to 163840000
     269              :  *
     270              :  * @note If @p _timeout is not a multiple of the unit, it will round down to nearest.
     271              :  * For example BT_GAP_MS_TO_PER_ADV_SYNC_TIMEOUT(4005000) will become 4000000 microseconds
     272              :  */
     273            1 : #define BT_GAP_US_TO_PER_ADV_SYNC_TIMEOUT(_timeout)                                                \
     274              :         (BT_GAP_MS_TO_PER_ADV_SYNC_TIMEOUT((_timeout) / USEC_PER_MSEC))
     275              : 
     276              : /**
     277              :  * @brief Convert microseconds to scan interval units (0.625 ms)
     278              :  *
     279              :  * Value range of @p _interval is 2500 to 40959375 if @kconfig{CONFIG_BT_EXT_ADV} else
     280              :  * 2500 to 10240000
     281              :  *
     282              :  * @note If @p _interval is not a multiple of the unit, it will round down to nearest.
     283              :  * For example BT_GAP_US_TO_SCAN_INTERVAL(21000) will become 20625 microseconds
     284              :  */
     285            1 : #define BT_GAP_US_TO_SCAN_INTERVAL(_interval) ((uint16_t)((_interval) / 625U))
     286              : 
     287              : /**
     288              :  * @brief Convert milliseconds to scan interval units (0.625 ms)
     289              :  *
     290              :  * Value range of @p _interval is 2.5 to 40959.375 if @kconfig{CONFIG_BT_EXT_ADV} else
     291              :  * 2500 to 10240
     292              :  *
     293              :  * @note If @p _interval is not a multiple of the unit, it will round down to nearest.
     294              :  * For example BT_GAP_MS_TO_SCAN_INTERVAL(21) will become 20.625 milliseconds
     295              :  */
     296            1 : #define BT_GAP_MS_TO_SCAN_INTERVAL(_interval)                                                      \
     297              :         (BT_GAP_US_TO_SCAN_INTERVAL((_interval) * USEC_PER_MSEC))
     298              : 
     299              : /**
     300              :  * @brief Convert microseconds to scan window units (0.625 ms)
     301              :  *
     302              :  * Value range of @p _window is 2500 to 40959375 if @kconfig{CONFIG_BT_EXT_ADV} else
     303              :  * 2500 to 10240000
     304              :  *
     305              :  * @note If @p _window is not a multiple of the unit, it will round down to nearest.
     306              :  * For example BT_GAP_US_TO_SCAN_WINDOW(21000) will become 20625 microseconds
     307              :  */
     308            1 : #define BT_GAP_US_TO_SCAN_WINDOW(_window) ((uint16_t)((_window) / 625U))
     309              : 
     310              : /**
     311              :  * @brief Convert milliseconds to scan window units (0.625 ms)
     312              :  *
     313              :  * Value range of @p _window is 2.5 to 40959.375 if @kconfig{CONFIG_BT_EXT_ADV} else
     314              :  * 2500 to 10240
     315              :  *
     316              :  * @note If @p _window is not a multiple of the unit, it will round down to nearest.
     317              :  * For example BT_GAP_MS_TO_SCAN_WINDOW(21) will become 20.625 milliseconds
     318              :  */
     319            1 : #define BT_GAP_MS_TO_SCAN_WINDOW(_window) (BT_GAP_US_TO_SCAN_WINDOW((_window) * USEC_PER_MSEC))
     320              : 
     321              : /**
     322              :  * @brief Convert microseconds to connection interval units (1.25 ms)
     323              :  *
     324              :  * Value range of @p _interval is 7500 to 4000000
     325              :  *
     326              :  * @note If @p _interval is not a multiple of the unit, it will round down to nearest.
     327              :  * For example BT_GAP_US_TO_CONN_INTERVAL(21000) will become 20000 microseconds
     328              :  */
     329            1 : #define BT_GAP_US_TO_CONN_INTERVAL(_interval) ((uint16_t)((_interval) / 1250U))
     330              : 
     331              : /**
     332              :  * @brief Convert milliseconds to connection interval units (1.25 ms)
     333              :  *
     334              :  * Value range of @p _interval is 7.5 to 4000
     335              :  *
     336              :  * @note If @p _interval is not a multiple of the unit, it will round down to nearest.
     337              :  * For example BT_GAP_MS_TO_CONN_INTERVAL(21) will become 20 milliseconds
     338              :  */
     339            1 : #define BT_GAP_MS_TO_CONN_INTERVAL(_interval)                                                      \
     340              :         (BT_GAP_US_TO_CONN_INTERVAL((_interval) * USEC_PER_MSEC))
     341              : 
     342              : /**
     343              :  * @brief Convert milliseconds to connection supervision timeout units (10 ms)
     344              :  *
     345              :  * Value range of @p _timeout is 100 to 32000
     346              :  *
     347              :  * @note If @p _timeout is not a multiple of the unit, it will round down to nearest.
     348              :  * For example BT_GAP_MS_TO_CONN_TIMEOUT(4005) will become 4000 milliseconds
     349              :  */
     350            1 : #define BT_GAP_MS_TO_CONN_TIMEOUT(_timeout) ((uint16_t)((_timeout) / 10U))
     351              : 
     352              : /**
     353              :  * @brief Convert microseconds to connection supervision timeout units (10 ms)
     354              : 
     355              :  * Value range of @p _timeout is 100000 to 32000000
     356              :  *
     357              :  * @note If @p _timeout is not a multiple of the unit, it will round down to nearest.
     358              :  * For example BT_GAP_MS_TO_CONN_TIMEOUT(4005000) will become 4000000 microseconds
     359              :  */
     360            1 : #define BT_GAP_US_TO_CONN_TIMEOUT(_timeout) (BT_GAP_MS_TO_CONN_TIMEOUT((_timeout) / USEC_PER_MSEC))
     361              : 
     362              : /**
     363              :  * @brief Convert milliseconds to connection event length units (0.625)
     364              :  *
     365              :  * Value range of @p _event_len is 0 to 40959375
     366              :  *
     367              :  * @note If @p _event_len is not a multiple of the unit, it will round down to nearest.
     368              :  * For example BT_GAP_US_TO_CONN_EVENT_LEN(21000) will become 20625 milliseconds
     369              :  */
     370            1 : #define BT_GAP_US_TO_CONN_EVENT_LEN(_event_len) ((uint16_t)((_event_len) / 625U))
     371              : 
     372              : /**
     373              :  * @brief Convert milliseconds to connection event length units (0.625)
     374              :  *
     375              :  * Value range of @p _event_len is 0 to 40959.375
     376              :  *
     377              :  * @note If @p _event_len is not a multiple of the unit, it will round down to nearest.
     378              :  * For example BT_GAP_MS_TO_CONN_EVENT_LEN(21) will become 20.625 milliseconds
     379              :  */
     380            1 : #define BT_GAP_MS_TO_CONN_EVENT_LEN(_event_len)                                                    \
     381              :         (BT_GAP_US_TO_CONN_EVENT_LEN((_event_len) * USEC_PER_MSEC))
     382              : 
     383              : /** Constant Tone Extension (CTE) types */
     384            1 : enum bt_gap_cte {
     385              :         /** Angle of Arrival */
     386              :         BT_GAP_CTE_AOA = 0x00,
     387              :         /** Angle of Departure with 1 us slots */
     388              :         BT_GAP_CTE_AOD_1US = 0x01,
     389              :         /** Angle of Departure with 2 us slots */
     390              :         BT_GAP_CTE_AOD_2US = 0x02,
     391              :         /** No extensions */
     392              :         BT_GAP_CTE_NONE = 0xFF,
     393              : };
     394              : 
     395              : /** @brief Peripheral sleep clock accuracy (SCA) in ppm (parts per million) */
     396            1 : enum bt_gap_sca {
     397              :         BT_GAP_SCA_UNKNOWN = 0,   /**< Unknown */
     398              :         BT_GAP_SCA_251_500 = 0,   /**< 251 ppm to 500 ppm */
     399              :         BT_GAP_SCA_151_250 = 1,   /**< 151 ppm to 250 ppm */
     400              :         BT_GAP_SCA_101_150 = 2,   /**< 101 ppm to 150 ppm */
     401              :         BT_GAP_SCA_76_100 = 3,    /**< 76 ppm to 100 ppm */
     402              :         BT_GAP_SCA_51_75 = 4,     /**< 51 ppm to 75 ppm */
     403              :         BT_GAP_SCA_31_50 = 5,     /**< 31 ppm to 50 ppm */
     404              :         BT_GAP_SCA_21_30 = 6,     /**< 21 ppm to 30 ppm */
     405              :         BT_GAP_SCA_0_20 = 7,      /**< 0 ppm to 20 ppm */
     406              : };
     407              : 
     408              : /**
     409              :  * @brief Encode 40 least significant bits of 64-bit LE Supported Features into array values
     410              :  *        in little-endian format.
     411              :  *
     412              :  * Helper macro to encode 40 least significant bits of 64-bit LE Supported Features value into
     413              :  * advertising data. The number of bits that are encoded is a number of LE Supported Features
     414              :  * defined by BT 5.3 Core specification.
     415              :  *
     416              :  * Example of how to encode the `0x000000DFF00DF00D` into advertising data.
     417              :  *
     418              :  * @code
     419              :  * BT_DATA_BYTES(BT_DATA_LE_SUPPORTED_FEATURES, BT_LE_SUPP_FEAT_40_ENCODE(0x000000DFF00DF00D))
     420              :  * @endcode
     421              :  *
     422              :  * @param w64 LE Supported Features value (64-bits)
     423              :  *
     424              :  * @return The comma separated values for LE Supported Features value that
     425              :  *         may be used directly as an argument for @ref BT_DATA_BYTES.
     426              :  */
     427            1 : #define BT_LE_SUPP_FEAT_40_ENCODE(w64) BT_BYTES_LIST_LE40(w64)
     428              : 
     429              : /** @brief Encode 4 least significant bytes of 64-bit LE Supported Features into
     430              :  *         4 bytes long array of values in little-endian format.
     431              :  *
     432              :  *  Helper macro to encode 64-bit LE Supported Features value into advertising
     433              :  *  data. The macro encodes 4 least significant bytes into advertising data.
     434              :  *  Other 4 bytes are not encoded.
     435              :  *
     436              :  *  Example of how to encode the `0x000000DFF00DF00D` into advertising data.
     437              :  *
     438              :  *  @code
     439              :  *  BT_DATA_BYTES(BT_DATA_LE_SUPPORTED_FEATURES, BT_LE_SUPP_FEAT_32_ENCODE(0x000000DFF00DF00D))
     440              :  *  @endcode
     441              :  *
     442              :  * @param w64 LE Supported Features value (64-bits)
     443              :  *
     444              :  * @return The comma separated values for LE Supported Features value that
     445              :  *         may be used directly as an argument for @ref BT_DATA_BYTES.
     446              :  */
     447            1 : #define BT_LE_SUPP_FEAT_32_ENCODE(w64) BT_BYTES_LIST_LE32(w64)
     448              : 
     449              : /**
     450              :  * @brief Encode 3 least significant bytes of 64-bit LE Supported Features into
     451              :  *        3 bytes long array of values in little-endian format.
     452              :  *
     453              :  * Helper macro to encode 64-bit LE Supported Features value into advertising
     454              :  * data. The macro encodes 3 least significant bytes into advertising data.
     455              :  * Other 5 bytes are not encoded.
     456              :  *
     457              :  * Example of how to encode the `0x000000DFF00DF00D` into advertising data.
     458              :  *
     459              :  * @code
     460              :  * BT_DATA_BYTES(BT_DATA_LE_SUPPORTED_FEATURES, BT_LE_SUPP_FEAT_24_ENCODE(0x000000DFF00DF00D))
     461              :  * @endcode
     462              :  *
     463              :  * @param w64 LE Supported Features value (64-bits)
     464              :  *
     465              :  * @return The comma separated values for LE Supported Features value that
     466              :  *         may be used directly as an argument for @ref BT_DATA_BYTES.
     467              :  */
     468            1 : #define BT_LE_SUPP_FEAT_24_ENCODE(w64) BT_BYTES_LIST_LE24(w64)
     469              : 
     470              : /**
     471              :  * @brief Encode 2 least significant bytes of 64-bit LE Supported Features into
     472              :  *        2 bytes long array of values in little-endian format.
     473              :  *
     474              :  * Helper macro to encode 64-bit LE Supported Features value into advertising
     475              :  * data. The macro encodes 3 least significant bytes into advertising data.
     476              :  * Other 6 bytes are not encoded.
     477              :  *
     478              :  * Example of how to encode the `0x000000DFF00DF00D` into advertising data.
     479              :  *
     480              :  * @code
     481              :  * BT_DATA_BYTES(BT_DATA_LE_SUPPORTED_FEATURES, BT_LE_SUPP_FEAT_16_ENCODE(0x000000DFF00DF00D))
     482              :  * @endcode
     483              :  *
     484              :  * @param w64 LE Supported Features value (64-bits)
     485              :  *
     486              :  * @return The comma separated values for LE Supported Features value that
     487              :  *         may be used directly as an argument for @ref BT_DATA_BYTES.
     488              :  */
     489            1 : #define BT_LE_SUPP_FEAT_16_ENCODE(w64) BT_BYTES_LIST_LE16(w64)
     490              : 
     491              : /**
     492              :  * @brief Encode the least significant byte of 64-bit LE Supported Features into
     493              :  *        single byte long array.
     494              :  *
     495              :  * Helper macro to encode 64-bit LE Supported Features value into advertising
     496              :  * data. The macro encodes the least significant byte into advertising data.
     497              :  * Other 7 bytes are not encoded.
     498              :  *
     499              :  * Example of how to encode the `0x000000DFF00DF00D` into advertising data.
     500              :  *
     501              :  * @code
     502              :  * BT_DATA_BYTES(BT_DATA_LE_SUPPORTED_FEATURES, BT_LE_SUPP_FEAT_8_ENCODE(0x000000DFF00DF00D))
     503              :  * @endcode
     504              :  *
     505              :  * @param w64 LE Supported Features value (64-bits)
     506              :  *
     507              :  * @return The value of least significant byte of LE Supported Features value
     508              :  *         that may be used directly as an argument for @ref BT_DATA_BYTES.
     509              :  */
     510            1 : #define BT_LE_SUPP_FEAT_8_ENCODE(w64) \
     511              :         (((w64) >> 0) & 0xFF)
     512              : 
     513              : /**
     514              :  * @brief Validate whether LE Supported Features value does not use bits that are reserved for
     515              :  *        future use.
     516              :  *
     517              :  * Helper macro to check if @p w64 has zeros as bits 40-63. The macro is compliant with BT 5.3
     518              :  * Core Specification where bits 0-40 has assigned values. In case of invalid value, build time
     519              :  * error is reported.
     520              :  */
     521            1 : #define BT_LE_SUPP_FEAT_VALIDATE(w64) \
     522              :         BUILD_ASSERT(!((w64) & (~BIT64_MASK(40))), \
     523              :                      "RFU bit in LE Supported Features are not zeros.")
     524              : 
     525              : /**
     526              :  * @}
     527              :  */
     528              : 
     529              : #ifdef __cplusplus
     530              : }
     531              : #endif
     532              : 
     533              : #endif /* ZEPHYR_INCLUDE_BLUETOOTH_GAP_H_ */
        

Generated by: LCOV version 2.0-1