1 /**
2   ******************************************************************************
3   * @file    ble_types.h
4   * @author  GPM WBL Application Team
5   * @brief   Header file for Bluetooth Low Energy stack types.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2024 STMicroelectronics.
10   * All rights reserved.
11   *
12   * This software is licensed under terms that can be found in the LICENSE file
13   * in the root directory of this software component.
14   * If no LICENSE file comes with this software, it is provided AS-IS.
15   *
16   ******************************************************************************
17   */
18 #ifndef _BLE_TYPES_H_
19 #define _BLE_TYPES_H_
20 
21 #include <stdint.h>
22 
23 /** Documentation for C struct Handle_Packets_Pair_Entry_t */
24 typedef PACKED(struct) packed_Handle_Packets_Pair_Entry_t_s {
25   /** Connection handle
26    */
27   uint16_t Connection_Handle;
28   /** The number of HCI Data Packets that have been completed (transmitted or flushed)
29    *  for the associated Connection_Handle since the previous time the event was
30    *  returned.
31    */
32   uint16_t HC_Num_Of_Completed_Packets;
33 } packed_Handle_Packets_Pair_Entry_t;
34 
35 /** Documentation for C struct Attribute_Group_Handle_Pair_t */
36 typedef PACKED(struct) packed_Attribute_Group_Handle_Pair_t_s {
37   /** Found Attribute handle
38    */
39   uint16_t Found_Attribute_Handle;
40   /** Group End handle
41    */
42   uint16_t Group_End_Handle;
43 } packed_Attribute_Group_Handle_Pair_t;
44 
45 /** Documentation for C struct Advertising_Report_t */
46 typedef PACKED(struct) packed_Advertising_Report_t_s {
47   /** Type of advertising report event: ADV_IND: Connectable undirected advertising',
48    *  ADV_DIRECT_IND: Connectable directed advertising, ADV_SCAN_IND: Scannable
49    *  undirected advertising, ADV_NONCONN_IND: Non connectable undirected
50    *  advertising, SCAN_RSP: Scan response.
51    *  Values:
52    *  - 0x00: ADV_IND
53    *  - 0x01: ADV_DIRECT_IND
54    *  - 0x02: ADV_SCAN_IND
55    *  - 0x03: ADV_NONCONN_IND
56    *  - 0x04: SCAN_RSP
57    */
58   uint8_t Event_Type;
59   /** 0x00 Public Device Address 0x01 Random Device Address 0x02 Public Identity
60    *  Address (Corresponds to Resolved Private Address) 0x03 Random (Static)
61    *  Identity Address (Corresponds to Resolved Private Address)
62    *  Values:
63    *  - 0x00: Public Device Address
64    *  - 0x01: Random Device Address
65    *  - 0x02: Public Identity Address
66    *  - 0x03: Random (Static) Identity Address
67    */
68   uint8_t Address_Type;
69   /** Public Device Address, Random Device Address, Public Identity Address or Random
70    *  (static) Identity Address of the advertising device.
71    */
72   uint8_t Address[6];
73   /** Length of the Data[i] field for each device which responded.
74    *  Values:
75    *  - 0 ... 31
76    */
77   uint8_t Data_Length;
78   /** Data_Length octets of advertising or scan response data formatted as defined in
79    *  [Vol 3] Part C, Section 8, plus one byte for RSSI (signed integer, dBm units).
80    */
81   uint8_t Data_RSSI[0];
82 } packed_Advertising_Report_t;
83 
84 /** Documentation for C struct Direct_Advertising_Report_t */
85 typedef PACKED(struct) packed_Direct_Advertising_Report_t_s {
86   /** Advertising type
87    *  Values:
88    *  - 0x01: Connectable directed advertising (ADV_DIRECT_IND)
89    */
90   uint8_t Event_Type;
91   /** 0x00 Public Device Address 0x01 Random Device Address 0x02 Public Identity
92    *  Address (Corresponds to Resolved Private Address) 0x03 Random (Static)
93    *  Identity Address (Corresponds to Resolved Private Address)
94    *  Values:
95    *  - 0x00: Public Device Address
96    *  - 0x01: Random Device Address
97    *  - 0x02: Public Identity Address
98    *  - 0x03: Random (Static) Identity Address
99    */
100   uint8_t Address_Type;
101   /** Public Device Address, Random Device Address, Public Identity Address or Random
102    *  (static) Identity Address of the advertising device.
103    */
104   uint8_t Address[6];
105   /** 0x01 Random Device Address
106    *  Values:
107    *  - 0x01: Random Device Address
108    */
109   uint8_t Direct_Address_Type;
110   /** Random Device Address
111    */
112   uint8_t Direct_Address[6];
113   /** N Size: 1 Octet (signed integer) Units: dBm
114    *  Values:
115    *  - -127 ... 20
116    *  - 127: RSSI not available
117    */
118   int8_t RSSI;
119 } packed_Direct_Advertising_Report_t;
120 
121 /** Documentation for C struct Extended_Advertising_Report_t */
122 typedef PACKED(struct) packed_Extended_Advertising_Report_t_s {
123   /** Event Type parameter. Bits from 0 to 4: 0 Connectable advertising 1 Scannable
124    *  advertising 2 Directed advertising 3 Scan response 4 Legacy advertising
125    *  PDUs used Bits 5-6 Data status: 00b = Complete 01b = Incomplete, more data
126    *  to come 10b = Incomplete, data truncated, no more to come 11b = Reserved
127    *  for future use
128    *  Flags:
129    *  - 0x0001: Connectable advertising
130    *  - 0x0002: Scannable advertising
131    *  - 0x0004: Directed advertising
132    *  - 0x0008: Scan response
133    *  - 0x0010: Legacy advertising PDUs used
134    */
135   uint16_t Event_Type;
136   /** Address Type
137    *  Values:
138    *  - 0x00: Public Device Address
139    *  - 0x01: Random Device Address
140    *  - 0x02: Public Identity Address (corresponds to Resolved Private Address)
141    *  - 0x03: Random (static) Identity Address (corresponds to Resolved Private
142 Address)
143    *  - 0xFF: No address provided (anonymous advertisement)
144    */
145   uint8_t Address_Type;
146   /** Public Device Address, Random Device Address, Public Identity Address or Random
147    *  (static) Identity Address of the advertising device.
148    */
149   uint8_t Address[6];
150   /** PHY used to send the advertising PDU on the primary advertising physical
151    *  channel.
152    *  Values:
153    *  - 0x01: LE_1M_PHY
154    *  - 0x03: LE_CODED_PHY
155    */
156   uint8_t Primary_PHY;
157   /** This parameter indicates the PHY used to send the advertising PDU(s), if any, on
158    *  the secondary advertising physical channel.
159    *  Values:
160    *  - 0x00: No packets
161    *  - 0x01: LE_1M_PHY
162    *  - 0x02: LE_2M_PHY
163    *  - 0x03: LE_CODED_PHY
164    */
165   uint8_t Secondary_PHY;
166   /** Advertising SID subfield in the ADI field of the PDU
167    *  Values:
168    *  - 0x00 ... 0x0F
169    *  - 0xFF: NA
170    */
171   uint8_t Advertising_SID;
172   /** Tx Power. Units: dBm.
173    *  Values:
174    *  - -127 ... 126
175    *  - 127: NA
176    */
177   int8_t TX_Power;
178   /** RSSI value; Units: dBm; All other values Reserved for future use.
179    *  Values:
180    *  - -127 ... 20
181    *  - 127: NA
182    */
183   int8_t RSSI;
184   /** Interval of the periodic advertising. Time = N * 1.25 ms; Time Range: 7.5 ms to
185    *  81,918.75 s.
186    *  Values:
187    *  - 0x0000 (NaN) : NA
188    *  - 0x0006 (7.50 ms)  ... 0xFFFF (NaN)
189    */
190   uint16_t Periodic_Advertising_Interval;
191   /** Direct address type
192    *  Values:
193    *  - 0x00: Public Device Address
194    *  - 0x01: Random Device Address
195    *  - 0x02: Public Identity Address (Corresponds to Resolved PrivateAddress)
196    *  - 0x03: Random (static) Identity Address (Corresponds to Resolved PrivateAddress)
197    *  - 0x04 ... 0xFD: Reserved for future use
198    *  - 0xFE: Random Device Address (Controller unable to resolve)
199    *  - 0xFF: Reserved for future use
200    */
201   uint8_t Direct_Address_Type;
202   /** Public Device Address, Random Device Address, Public Identity Address or Random
203    *  (static) Identity Address of the target device
204    */
205   uint8_t Direct_Address[6];
206   /** Length of the Data[i] field for each device which responded
207    *  Values:
208    *  - 0 ... 229
209    */
210   uint8_t Data_Length;
211   /** Data_Length[i] octets of advertising or scan response data formatted as defined
212    *  in [Vol 3] Part C, Section 11. Note: Each element of this array has a
213    *  variable length.
214    */
215   uint8_t Data[0];
216 } packed_Extended_Advertising_Report_t;
217 
218 /** Documentation for C struct Samples_t */
219 typedef PACKED(struct) packed_Samples_t_s {
220   /** The list of I samples for the reported packet. Each sample is a signed integer.
221    *  The list is in the order of the sampling points within the packet.
222    */
223   int8_t I_Sample;
224   /** The list of Q samples for the reported packet. Each sample is a signed integer.
225    *  The list is in the order of the sampling points within the packet.
226    */
227   int8_t Q_Sample;
228 } packed_Samples_t;
229 
230 /** Documentation for C struct Periodic_Advertising_Response_t */
231 typedef PACKED(struct) packed_Periodic_Advertising_Response_t_s {
232   /** Range: -127 to +20 (units: dBm). If 0x7F, Tx Power information is not available.
233    *  Values:
234    *  - -127 ... 20
235    *  - 127: NA
236    */
237   int8_t TX_Power;
238   /** Range: -127 to +20 (units: dBm) If 0x7F, RSSI is not available.
239    *  Values:
240    *  - -127 ... 20
241    *  - 127: NA
242    */
243   int8_t RSSI;
244   /** CTE type in the response.
245    *  Values:
246    *  - 0x00: AoA
247    *  - 0x01: AoD_1us
248    *  - 0x02: AoD_2us
249    *  - 0xFF: NO_CTE
250    */
251   uint8_t CTE_Type;
252   /** The response slot the data was received in.
253    */
254   uint8_t Response_Slot;
255   /** 0x00: Data complete 0x01: Data incomplete, more data to come 0xFF: Failed to
256    *  receive an AUX_SYNC_SUBEVENT_RSP PDU
257    *  Values:
258    *  - 0x00: DATA_COMPLETE
259    *  - 0x01: MORE_DATA
260    *  - 0xFF: RX_FAILED
261    */
262   uint8_t Data_Status;
263   /** Length of the Data field.
264    */
265   uint8_t Data_Length;
266   /** Periodic advertising response data formatted as defined in [Vol 3] Part C,
267    *  Section 11. Note: Each element of this array has a variable length.
268    */
269   uint8_t Data[0];
270 } packed_Periodic_Advertising_Response_t;
271 
272 #endif /* _BLE_TYPES_H_ */
273