• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Chipsea Technologies (Shenzhen) Corp., Ltd. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef _HAL_GAP_H
16 #define _HAL_GAP_H
17 
18 #include <stdint.h>
19 #include "compiler.h"
20 
21 /// BD address length
22 #define GAP_BD_ADDR_LEN       (6)
23 /// LE Channel map length
24 #define GAP_LE_CHNL_MAP_LEN   (0x05)
25 /// LE Feature Flags Length
26 #define GAP_LE_FEATS_LEN      (0x08)
27 /// ADV Data and Scan Response length
28 #define GAP_ADV_DATA_LEN      (0x1F)
29 #define GAP_SCAN_RSP_DATA_LEN (0x1F)
30 /// Random number length
31 #define GAP_RAND_NB_LEN       (0x08)
32 /// Key length
33 #define GAP_KEY_LEN           (16)
34 /// P256 Key Len
35 #define GAP_P256_KEY_LEN      (0x20)
36 
37 
38 ///***** AD Type Flag - Bit set *******/
39 /// Limited discovery flag - AD Flag
40 #define GAP_LE_LIM_DISCOVERABLE_FLG             0x01
41 /// General discovery flag - AD Flag
42 #define GAP_LE_GEN_DISCOVERABLE_FLG             0x02
43 /// Legacy BT not supported - AD Flag
44 #define GAP_BR_EDR_NOT_SUPPORTED                0x04
45 /// Dual mode for controller supported (BR/EDR/LE) - AD Flag
46 #define GAP_SIMUL_BR_EDR_LE_CONTROLLER          0x08
47 /// Dual mode for host supported (BR/EDR/LE) - AD Flag
48 #define GAP_SIMUL_BR_EDR_LE_HOST                0x10
49 
50 /*********** GAP Miscellaneous Defines *************/
51 /// Invalid connection index
52 #define GAP_INVALID_CONIDX                      0xFF
53 
54 /// Invalid connection handle
55 #define GAP_INVALID_CONHDL                      0xFFFF
56 
57 /// Connection interval min (N*1.250ms)
58 #define GAP_CNX_INTERVAL_MIN            6       //(0x06)
59 /// Connection interval Max (N*1.250ms)
60 #define GAP_CNX_INTERVAL_MAX            3200    //(0xC80)
61 /// Connection latency min (N*cnx evt)
62 #define GAP_CNX_LATENCY_MIN             0       //(0x00)
63 /// Connection latency Max (N*cnx evt
64 #define GAP_CNX_LATENCY_MAX             499     //(0x1F3)
65 /// Supervision TO min (N*10ms)
66 #define GAP_CNX_SUP_TO_MIN              10      //(0x0A)
67 /// Supervision TO Max (N*10ms)
68 #define GAP_CNX_SUP_TO_MAX              3200    //(0xC80)
69 
70 
71 
72 /// Length of resolvable random address prand part
73 #define GAP_ADDR_PRAND_LEN            (3)
74 /// Length of resolvable random address hash part
75 #define GAP_ADDR_HASH_LEN             (3)
76 
77 /// Number of bytes needed for a bit field indicated presence of a given Advertising Flag value
78 /// in the Advertising or the Scan Response data
79 /// Advertising Flags is a 8-bit value, hence 256 value are possible
80 /// -> 256 / 8 bytes = 32 bytes are needed
81 #define GAP_AD_TYPE_BITFIELD_BYTES                          (32)
82 
83 /*
84  * DEFINES - Optional for BLE application usage
85  ****************************************************************************************
86  */
87 
88 /// Central idle timer
89 /// TGAP(conn_pause_central)
90 /// recommended value: 1 s: (100 for ke timer)
91 #define GAP_TMR_CONN_PAUSE_CT                               0x0064
92 
93 /// Minimum time upon connection establishment before the peripheral
94 /// starts a connection update procedure: TGAP(conn_pause_peripheral)
95 /// recommended value: 5 s: (500 for ke timer)
96 #define GAP_TMR_CONN_PAUSE_PH                               0x01F4
97 
98 /// Minimum time to perform scanning when user initiated
99 /// TGAP(scan_fast_period)
100 /// recommended value: 30.72 s: (3072 for ke timer)
101 #define GAP_TMR_SCAN_FAST_PERIOD                            0x0C00
102 
103 /// Minimum time to perform advertising when user initiated
104 /// TGAP(adv_fast_period)
105 /// recommended value: 30 s: (3000 for ke timer)
106 #define GAP_TMR_ADV_FAST_PERIOD                             0x0BB8
107 
108 /// Scan interval used during Link Layer Scanning State when
109 /// performing the Limited Discovery procedure
110 /// TGAP(lim_disc_scan_int)
111 /// recommended value: 11.25ms; (18 decimal)
112 #define GAP_LIM_DISC_SCAN_INT                               0x0012
113 
114 /// Scan interval in any discovery or connection establishment
115 /// procedure when user initiated: TGAP(scan_fast_interval)
116 /// recommended value: 30 to 60 ms; N * 0.625
117 #define GAP_SCAN_FAST_INTV                                  0x0030
118 
119 /// Scan window in any discovery or connection establishment
120 /// procedure when user initiated: TGAP(scan_fast_window)
121 /// recommended value: 30 ms; N * 0.625
122 #define GAP_SCAN_FAST_WIND                                  0x0030
123 
124 /// Scan interval in any discovery or connection establishment
125 /// procedure when background scanning: TGAP(scan_slow_interval1)
126 /// recommended value: 1.28 s : 0x00CD (205); N * 0.625
127 #define GAP_SCAN_SLOW_INTV1                                 0x00CD
128 
129 /// Scan interval in any discovery or connection establishment
130 /// procedure when background scanning: TGAP(scan_slow_interval2)
131 /// recommended value: 2.56 s : 0x019A (410); N * 0.625
132 #define GAP_SCAN_SLOW_INTV2                                 0x019A
133 
134 /// Scan window in any discovery or connection establishment
135 /// procedure when background scanning: TGAP(scan_slow_window1)
136 /// recommended value: 11.25 ms : 0x0012 (18); N * 0.625
137 #define GAP_SCAN_SLOW_WIND1                                 0x0012
138 
139 /// Scan window in any discovery or connection establishment
140 /// procedure when background scanning: TGAP(scan_slow_window2)
141 /// recommended value: 22.5 ms : 0x0024 (36); N * 0.625
142 #define GAP_SCAN_SLOW_WIND2                                 0x0024
143 
144 /// Minimum to maximum advertisement interval in any discoverable
145 /// or connectable mode when user initiated: TGAP(adv_fast_interval1)
146 /// recommended value: 30 to 60 ms; N * 0.625
147 #define GAP_ADV_FAST_INTV1                                  0x0030
148 
149 /// Minimum to maximum advertisement interval in any discoverable
150 /// or connectable mode when user initiated: TGAP(adv_fast_interval2)
151 /// recommended value: 100 to 150 ms; N * 0.625
152 #define GAP_ADV_FAST_INTV2                                  0x0064
153 
154 /// Minimum to maximum advertisement interval in any discoverable or
155 /// connectable mode when background advertising: TGAP(adv_slow_interval)
156 /// recommended value: 1 to 1.2 s : 0x00B0 (176); N * 0.625
157 #define GAP_ADV_SLOW_INTV                                   0x00B0
158 
159 /// Minimum to maximum connection interval upon any connection
160 /// establishment: TGAP(initial_conn_interval)
161 /// recommended value: 30 to 50 ms ; N * 1.25 ms
162 #define GAP_INIT_CONN_MIN_INTV                              0x0018
163 #define GAP_INIT_CONN_MAX_INTV                              0x0028
164 
165 /// RW Defines
166 #define GAP_INQ_SCAN_INTV                                   0x0012
167 #define GAP_INQ_SCAN_WIND                                   0x0012
168 
169 /// Connection supervision timeout
170 /// recommended value: 20s
171 #define GAP_CONN_SUPERV_TIMEOUT                             0x07D0
172 
173 /// Minimum connection event
174 /// default value: 0x0000
175 #define GAP_CONN_MIN_CE                                     0x0000
176 
177 /// Maximum connection event
178 /// default value: 0xFFFF
179 #define GAP_CONN_MAX_CE                                     0xFFFF
180 
181 /// Connection latency
182 /// default value: 0x0000
183 #define GAP_CONN_LATENCY                                    0x0000
184 
185 /// GAP Device name Characteristic
186 /// Default device name
187 #define GAP_DEV_NAME                                        "RIVIERAWAVES-BLE"
188 
189 /// GAP Appearance or Icon Characteristic - 2 octets
190 /// Current appearance value is 0x0000 (unknown appearance)
191 /// Description:
192 /// http://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.gap.appearance.xml
193 #define GAP_APPEARANCE                                      0x0000
194 
195 ///GAP Peripheral Preferred Connection Parameter - 8 octets
196 #define GAP_PPCP_CONN_INTV_MAX                              0x0064
197 #define GAP_PPCP_CONN_INTV_MIN                              0x00C8
198 #define GAP_PPCP_SLAVE_LATENCY                              0x0000
199 #define GAP_PPCP_STO_MULT                                   0x07D0
200 
201 /*
202  * Macros
203  ****************************************************************************************
204  */
205 
206 #define GAP_AD_TYPE_SET_BIT(bitfield, adv_flag)                             \
207                 bitfield[adv_flag / 8] |= CO_BIT(adv_flag % 8)
208 
209 #define GAP_AD_TYPE_CHECK_BIT(bitfield, adv_flag)                           \
210                 (bitfield[adv_flag / 8] & CO_BIT(adv_flag % 8))
211 
212 /*
213  * Enumerations
214  ****************************************************************************************
215  */
216 /// GAP Advertising Flags
217 enum gap_ad_type
218 {
219     /// Flag
220     GAP_AD_TYPE_FLAGS                      = 0x01,//!< GAP_AD_TYPE_FLAGS
221     /// Use of more than 16 bits UUID
222     GAP_AD_TYPE_MORE_16_BIT_UUID           = 0x02,//!< GAP_AD_TYPE_MORE_16_BIT_UUID
223     /// Complete list of 16 bit UUID
224     GAP_AD_TYPE_COMPLETE_LIST_16_BIT_UUID  = 0x03,//!< GAP_AD_TYPE_COMPLETE_LIST_16_BIT_UUID
225     /// Use of more than 32 bit UUD
226     GAP_AD_TYPE_MORE_32_BIT_UUID           = 0x04,//!< GAP_AD_TYPE_MORE_32_BIT_UUID
227     /// Complete list of 32 bit UUID
228     GAP_AD_TYPE_COMPLETE_LIST_32_BIT_UUID  = 0x05,//!< GAP_AD_TYPE_COMPLETE_LIST_32_BIT_UUID
229     /// Use of more than 128 bit UUID
230     GAP_AD_TYPE_MORE_128_BIT_UUID          = 0x06,//!< GAP_AD_TYPE_MORE_128_BIT_UUID
231     /// Complete list of 128 bit UUID
232     GAP_AD_TYPE_COMPLETE_LIST_128_BIT_UUID = 0x07,//!< GAP_AD_TYPE_COMPLETE_LIST_128_BIT_UUID
233     /// Shortened device name
234     GAP_AD_TYPE_SHORTENED_NAME             = 0x08,//!< GAP_AD_TYPE_SHORTENED_NAME
235     /// Complete device name
236     GAP_AD_TYPE_COMPLETE_NAME              = 0x09,//!< GAP_AD_TYPE_COMPLETE_NAME
237     /// Transmit power
238     GAP_AD_TYPE_TRANSMIT_POWER             = 0x0A,//!< GAP_AD_TYPE_TRANSMIT_POWER
239     /// Class of device
240     GAP_AD_TYPE_CLASS_OF_DEVICE            = 0x0D,//!< GAP_AD_TYPE_CLASS_OF_DEVICE
241     /// Simple Pairing Hash C
242     GAP_AD_TYPE_SP_HASH_C                  = 0x0E,//!< GAP_AD_TYPE_SP_HASH_C
243     /// Simple Pairing Randomizer
244     GAP_AD_TYPE_SP_RANDOMIZER_R            = 0x0F,//!< GAP_AD_TYPE_SP_RANDOMIZER_R
245     /// Temporary key value
246     GAP_AD_TYPE_TK_VALUE                   = 0x10,//!< GAP_AD_TYPE_TK_VALUE
247     /// Out of Band Flag
248     GAP_AD_TYPE_OOB_FLAGS                  = 0x11,//!< GAP_AD_TYPE_OOB_FLAGS
249     /// Slave connection interval range
250     GAP_AD_TYPE_SLAVE_CONN_INT_RANGE       = 0x12,//!< GAP_AD_TYPE_SLAVE_CONN_INT_RANGE
251     /// Require 16 bit service UUID
252     GAP_AD_TYPE_RQRD_16_BIT_SVC_UUID       = 0x14,//!< GAP_AD_TYPE_RQRD_16_BIT_SVC_UUID
253     /// Require 32 bit service UUID
254     GAP_AD_TYPE_RQRD_32_BIT_SVC_UUID       = 0x1F,//!< GAP_AD_TYPE_RQRD_32_BIT_SVC_UUID
255     /// Require 128 bit service UUID
256     GAP_AD_TYPE_RQRD_128_BIT_SVC_UUID      = 0x15,//!< GAP_AD_TYPE_RQRD_128_BIT_SVC_UUID
257     /// Service data 16-bit UUID
258     GAP_AD_TYPE_SERVICE_16_BIT_DATA        = 0x16,//!< GAP_AD_TYPE_SERVICE_16_BIT_DATA
259     /// Service data 32-bit UUID
260     GAP_AD_TYPE_SERVICE_32_BIT_DATA        = 0x20,//!< GAP_AD_TYPE_SERVICE_32_BIT_DATA
261     /// Service data 128-bit UUID
262     GAP_AD_TYPE_SERVICE_128_BIT_DATA       = 0x21,//!< GAP_AD_TYPE_SERVICE_128_BIT_DATA
263     /// Public Target Address
264     GAP_AD_TYPE_PUB_TGT_ADDR               = 0x17,//!< GAP_AD_TYPE_PUB_TGT_ADDR
265     /// Random Target Address
266     GAP_AD_TYPE_RAND_TGT_ADDR              = 0x18,//!< GAP_AD_TYPE_RAND_TGT_ADDR
267     /// Appearance
268     GAP_AD_TYPE_APPEARANCE                 = 0x19,//!< GAP_AD_TYPE_APPEARANCE
269     /// Advertising Interval
270     GAP_AD_TYPE_ADV_INTV                   = 0x1A,//!< GAP_AD_TYPE_ADV_INTV
271     /// LE Bluetooth Device Address
272     GAP_AD_TYPE_LE_BT_ADDR                 = 0x1B,//!< GAP_AD_TYPE_LE_BT_ADDR
273     /// LE Role
274     GAP_AD_TYPE_LE_ROLE                    = 0x1C,//!< GAP_AD_TYPE_LE_ROLE
275     /// Simple Pairing Hash C-256
276     GAP_AD_TYPE_SPAIR_HASH                 = 0x1D,//!< GAP_AD_TYPE_SPAIR_HASH
277     /// Simple Pairing Randomizer R-256
278     GAP_AD_TYPE_SPAIR_RAND                 = 0x1E,//!< GAP_AD_TYPE_SPAIR_RAND
279     /// 3D Information Data
280     GAP_AD_TYPE_3D_INFO                    = 0x3D,//!< GAP_AD_TYPE_3D_INFO
281 
282     /// Manufacturer specific data
283     GAP_AD_TYPE_MANU_SPECIFIC_DATA         = 0xFF,//!< GAP_AD_TYPE_MANU_SPECIFIC_DATA
284 };
285 
286 
287 /// Random Address type
288 enum gap_rnd_addr_type
289 {
290     /// Static random address           - 11 (MSB->LSB)
291     GAP_STATIC_ADDR     = 0xC0,
292     /// Private non resolvable address  - 01 (MSB->LSB)
293     GAP_NON_RSLV_ADDR   = 0x00,
294     /// Private resolvable address      - 01 (MSB->LSB)
295     GAP_RSLV_ADDR       = 0x40,
296 };
297 
298 /// Boolean value set
299 enum
300 {
301     /// Disable
302     GAP_DISABLE = 0x00,
303     /// Enable
304     GAP_ENABLE
305 };
306 
307 
308 /// GAP Attribute database handles
309 /// Generic Access Profile Service
310 enum
311 {
312     GAP_IDX_PRIM_SVC,
313     GAP_IDX_CHAR_DEVNAME,
314     GAP_IDX_DEVNAME,
315     GAP_IDX_CHAR_ICON,
316     GAP_IDX_ICON,
317     GAP_IDX_CHAR_SLAVE_PREF_PARAM,
318     GAP_IDX_SLAVE_PREF_PARAM,
319     GAP_IDX_CHAR_CNT_ADDR_RESOL,
320     GAP_IDX_CNT_ADDR_RESOL,
321     GAP_IDX_CHAR_RSLV_PRIV_ADDR_ONLY,
322     GAP_IDX_RSLV_PRIV_ADDR_ONLY,
323     GAP_IDX_NUMBER
324 };
325 
326 
327 
328 /****************** GAP Role **********************/
329 enum gap_role
330 {
331     /// No role set yet
332     GAP_ROLE_NONE        = 0x00,
333 
334     /// Observer role
335     GAP_ROLE_OBSERVER    = 0x01,
336 
337     /// Broadcaster role
338     GAP_ROLE_BROADCASTER = 0x02,
339 
340     /// Master/Central role
341     GAP_ROLE_CENTRAL     = (0x04 | GAP_ROLE_OBSERVER),
342 
343     /// Peripheral/Slave role
344     GAP_ROLE_PERIPHERAL  = (0x08 | GAP_ROLE_BROADCASTER),
345 
346     /// Device has all role, both peripheral and central
347     GAP_ROLE_ALL         = (GAP_ROLE_CENTRAL | GAP_ROLE_PERIPHERAL),
348 };
349 
350 /// IO Capability Values
351 enum gap_io_cap
352 {
353     /// Display Only
354     GAP_IO_CAP_DISPLAY_ONLY = 0x00,
355     /// Display Yes No
356     GAP_IO_CAP_DISPLAY_YES_NO,
357     /// Keyboard Only
358     GAP_IO_CAP_KB_ONLY,
359     /// No Input No Output
360     GAP_IO_CAP_NO_INPUT_NO_OUTPUT,
361     /// Keyboard Display
362     GAP_IO_CAP_KB_DISPLAY,
363     GAP_IO_CAP_LAST
364 };
365 
366 /// TK Type
367 enum gap_tk_type
368 {
369     ///  TK get from out of band method
370     GAP_TK_OOB         = 0x00,
371     /// TK generated and shall be displayed by local device
372     GAP_TK_DISPLAY,
373     /// TK shall be entered by user using device keyboard
374     GAP_TK_KEY_ENTRY
375 };
376 
377 /// OOB Data Present Flag Values
378 enum gap_oob
379 {
380     /// OOB Data not present
381     GAP_OOB_AUTH_DATA_NOT_PRESENT = 0x00,
382     /// OOB data present
383     GAP_OOB_AUTH_DATA_PRESENT,
384     GAP_OOB_AUTH_DATA_LAST
385 };
386 
387 /// Authentication mask
388 enum gap_auth_mask
389 {
390     /// No Flag set
391     GAP_AUTH_NONE    = 0,
392     /// Bond authentication
393     GAP_AUTH_BOND    = (1 << 0),
394     /// Man In the middle protection
395     GAP_AUTH_MITM    = (1 << 2),
396     /// Secure Connection
397     GAP_AUTH_SEC_CON = (1 << 3),
398     /// Key Notification
399     GAP_AUTH_KEY_NOTIF = (1 << 4)
400 };
401 
402 /// Security Link Level
403 enum gap_lk_sec_lvl
404 {
405     /// No authentication
406     GAP_LK_NO_AUTH             = 0,
407     /// Unauthenticated link
408     GAP_LK_UNAUTH,
409     /// Authenticated link
410     GAP_LK_AUTH,
411     /// Secure Connection link
412     GAP_LK_SEC_CON,
413 };
414 
415 /// Authentication Requirements
416 enum gap_auth
417 {
418     /// No MITM No Bonding
419     GAP_AUTH_REQ_NO_MITM_NO_BOND  = (GAP_AUTH_NONE),
420     /// No MITM Bonding
421     GAP_AUTH_REQ_NO_MITM_BOND     = (GAP_AUTH_BOND),
422     /// MITM No Bonding
423     GAP_AUTH_REQ_MITM_NO_BOND     = (GAP_AUTH_MITM),
424     /// MITM and Bonding
425     GAP_AUTH_REQ_MITM_BOND        = (GAP_AUTH_MITM | GAP_AUTH_BOND),
426     /// SEC_CON and No Bonding
427     GAP_AUTH_REQ_SEC_CON_NO_BOND  = (GAP_AUTH_SEC_CON | GAP_AUTH_MITM),
428     /// SEC_CON and Bonding
429     GAP_AUTH_REQ_SEC_CON_BOND     = (GAP_AUTH_SEC_CON | GAP_AUTH_MITM | GAP_AUTH_BOND),
430 
431     GAP_AUTH_REQ_LAST,
432 
433     /// Mask of  authentication features without reserved flag
434     GAP_AUTH_REQ_MASK             = 0x1F,
435 };
436 
437 /// Key Distribution Flags
438 enum gap_kdist
439 {
440     /// No Keys to distribute
441     GAP_KDIST_NONE = 0x00,
442     /// Encryption key in distribution
443     GAP_KDIST_ENCKEY = (1 << 0),
444     /// IRK (ID key)in distribution
445     GAP_KDIST_IDKEY  = (1 << 1),
446     /// CSRK(Signature key) in distribution
447     GAP_KDIST_SIGNKEY= (1 << 2),
448     /// LTK in distribution
449     GAP_KDIST_LINKKEY=   (1 << 3),
450 
451     GAP_KDIST_LAST =   (1 << 4)
452 };
453 
454 /// Security Defines
455 enum gap_sec_req
456 {
457     /// No security (no authentication and encryption)
458     GAP_NO_SEC = 0x00,
459     /// Unauthenticated pairing with encryption
460     GAP_SEC1_NOAUTH_PAIR_ENC,
461     /// Authenticated pairing with encryption
462     GAP_SEC1_AUTH_PAIR_ENC,
463     /// Unauthenticated pairing with data signing
464     GAP_SEC2_NOAUTH_DATA_SGN,
465     /// Authentication pairing with data signing
466     GAP_SEC2_AUTH_DATA_SGN,
467     /// Secure Connection pairing with encryption
468     GAP_SEC1_SEC_CON_PAIR_ENC,
469 };
470 
471 /// Bit field use to select the preferred TX or RX LE PHY. 0 means no preferences
472 enum gap_phy
473 {
474     /// No preferred PHY
475     GAP_PHY_ANY               = 0x00,
476     /// LE 1M PHY preferred for an active link
477     GAP_PHY_LE_1MBPS          = (1 << 0),
478     /// LE 2M PHY preferred for an active link
479     GAP_PHY_LE_2MBPS          = (1 << 1),
480     /// LE Coded PHY preferred for an active link
481     GAP_PHY_LE_CODED          = (1 << 2),
482 };
483 
484 /// Enumeration of TX/RX PHY used for Test Mode
485 enum gap_test_phy
486 {
487     /// LE 1M PHY (TX or RX)
488     GAP_TEST_PHY_1MBPS        = 1,
489     /// LE 2M PHY (TX or RX)
490     GAP_TEST_PHY_2MBPS        = 2,
491     /// LE Coded PHY (RX Only)
492     GAP_TEST_PHY_CODED        = 3,
493     /// LE Coded PHY with S=8 data coding (TX Only)
494     GAP_TEST_PHY_125KBPS      = 3,
495     /// LE Coded PHY with S=2 data coding (TX Only)
496     GAP_TEST_PHY_500KBPS      = 4,
497 };
498 
499 /// Modulation index
500 enum gap_modulation_idx
501 {
502     /// Assume transmitter will have a standard modulation index
503     GAP_MODULATION_STANDARD,
504     /// Assume transmitter will have a stable modulation index
505     GAP_MODULATION_STABLE,
506 };
507 
508 /// Packet Payload type for test mode
509 enum gap_pkt_pld_type
510 {
511     /// PRBS9 sequence "11111111100000111101..." (in transmission order)
512     GAP_PKT_PLD_PRBS9,
513     /// Repeated "11110000" (in transmission order)
514     GAP_PKT_PLD_REPEATED_11110000,
515     /// Repeated "10101010" (in transmission order)
516     GAP_PKT_PLD_REPEATED_10101010,
517     /// PRBS15 sequence
518     GAP_PKT_PLD_PRBS15,
519     /// Repeated "11111111" (in transmission order) sequence
520     GAP_PKT_PLD_REPEATED_11111111,
521     /// Repeated "00000000" (in transmission order) sequence
522     GAP_PKT_PLD_REPEATED_00000000,
523     /// Repeated "00001111" (in transmission order) sequence
524     GAP_PKT_PLD_REPEATED_00001111,
525     /// Repeated "01010101" (in transmission order) sequence
526     GAP_PKT_PLD_REPEATED_01010101,
527 };
528 /*************** GAP Structures ********************/
529 
530 /// Device name
531 /*@TRACE*/
532 struct gap_dev_name
533 {
534     /// name length
535     uint16_t length;
536     /// name value
537     uint8_t value[__ARRAY_EMPTY];
538 };
539 
540 /// Slave preferred connection parameters
541 /*@TRACE*/
542 struct gap_slv_pref
543 {
544     /// Connection interval minimum
545     uint16_t con_intv_min;
546     /// Connection interval maximum
547     uint16_t con_intv_max;
548     /// Slave latency
549     uint16_t slave_latency;
550     /// Connection supervision timeout multiplier
551     uint16_t conn_timeout;
552 };
553 
554 ///BD Address structure
555 /*@TRACE*/
556 typedef struct
557 {
558     ///6-byte array address value
559     uint8_t  addr[GAP_BD_ADDR_LEN];
560 } bd_addr_t;
561 
562 ///Channel map structure
563 /*@TRACE*/
564 typedef struct
565 {
566     ///5-byte channel map array
567     uint8_t map[GAP_LE_CHNL_MAP_LEN];
568 } le_chnl_map_t;
569 
570 
571 ///Random number structure
572 /*@TRACE*/
573 typedef struct
574 {
575     ///8-byte array for random number
576     uint8_t     nb[GAP_RAND_NB_LEN];
577 } rand_nb_t;
578 
579 /// P256 Public key data format
580 typedef struct
581 {
582     /// X Coordinate of the key
583     uint8_t x[GAP_P256_KEY_LEN];
584     /// X Coordinate of the key
585     uint8_t y[GAP_P256_KEY_LEN];
586 } public_key_t;
587 
588 /// Address information about a device address
589 /*@TRACE*/
590 struct gap_bdaddr
591 {
592     /// BD Address of device
593     bd_addr_t addr;
594     /// Address type of the device 0=public/1=private random
595     uint8_t addr_type;
596 };
597 
598 /// Resolving list device information
599 /*@TRACE*/
600 struct gap_ral_dev_info
601 {
602     /// Device identity
603     struct gap_bdaddr addr;
604     /// Privacy Mode
605     uint8_t priv_mode;
606     /// Peer IRK
607     uint8_t peer_irk[GAP_KEY_LEN];
608     /// Local IRK
609     uint8_t local_irk[GAP_KEY_LEN];
610 };
611 
612 /// Generic Security key structure
613 /*@TRACE*/
614 struct gap_sec_key
615 {
616     /// Key value MSB -> LSB
617     uint8_t key[GAP_KEY_LEN];
618 };
619 
620 #endif // _HAL_GAP_H
621