1 /******************************************************************************
2 * @file ble_hci_le.c
3 * @author MCD Application Team
4 * @date 23 May 2019
5 * @brief Source file for ble api STM32WB (hci_le)
6 * Auto-generated file: do not edit!
7 ******************************************************************************
8 * @attention
9 *
10 * <h2><center>© Copyright (c) 2019 STMicroelectronics.
11 * All rights reserved.</center></h2>
12 *
13 * This software component is licensed by ST under Ultimate Liberty license
14 * SLA0044, the "License"; You may not use this file except in compliance with
15 * the License. You may obtain a copy of the License at:
16 * www.st.com/SLA0044
17 *
18 ******************************************************************************
19 */
20
21 #include "ble_hci_le.h"
22
hci_disconnect(uint16_t Connection_Handle,uint8_t Reason)23 tBleStatus hci_disconnect(uint16_t Connection_Handle,
24 uint8_t Reason)
25 {
26 struct hci_request rq;
27 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
28 hci_disconnect_cp0 *cp0 = (hci_disconnect_cp0*)(cmd_buffer);
29 tBleStatus status = 0;
30 int index_input = 0;
31 cp0->Connection_Handle = htob(Connection_Handle, 2);
32 index_input += 2;
33 cp0->Reason = htob(Reason, 1);
34 index_input += 1;
35 Osal_MemSet(&rq, 0, sizeof(rq));
36 rq.ogf = 0x01;
37 rq.ocf = 0x006;
38 rq.event = 0x0F;
39 rq.cparam = cmd_buffer;
40 rq.clen = index_input;
41 rq.rparam = &status;
42 rq.rlen = 1;
43 if (hci_send_req(&rq, FALSE) < 0)
44 return BLE_STATUS_TIMEOUT;
45 if (status)
46 {
47 return status;
48 }
49 return BLE_STATUS_SUCCESS;
50 }
51
hci_read_remote_version_information(uint16_t Connection_Handle)52 tBleStatus hci_read_remote_version_information(uint16_t Connection_Handle)
53 {
54 struct hci_request rq;
55 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
56 hci_read_remote_version_information_cp0 *cp0 = (hci_read_remote_version_information_cp0*)(cmd_buffer);
57 tBleStatus status = 0;
58 int index_input = 0;
59 cp0->Connection_Handle = htob(Connection_Handle, 2);
60 index_input += 2;
61 Osal_MemSet(&rq, 0, sizeof(rq));
62 rq.ogf = 0x01;
63 rq.ocf = 0x01d;
64 rq.event = 0x0F;
65 rq.cparam = cmd_buffer;
66 rq.clen = index_input;
67 rq.rparam = &status;
68 rq.rlen = 1;
69 if (hci_send_req(&rq, FALSE) < 0)
70 return BLE_STATUS_TIMEOUT;
71 if (status)
72 {
73 return status;
74 }
75 return BLE_STATUS_SUCCESS;
76 }
77
hci_set_event_mask(uint8_t Event_Mask[8])78 tBleStatus hci_set_event_mask(uint8_t Event_Mask[8])
79 {
80 struct hci_request rq;
81 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
82 hci_set_event_mask_cp0 *cp0 = (hci_set_event_mask_cp0*)(cmd_buffer);
83 tBleStatus status = 0;
84 int index_input = 0;
85 Osal_MemCpy((void *) &cp0->Event_Mask, (const void *) Event_Mask, 8);
86 index_input += 8;
87 Osal_MemSet(&rq, 0, sizeof(rq));
88 rq.ogf = 0x03;
89 rq.ocf = 0x001;
90 rq.cparam = cmd_buffer;
91 rq.clen = index_input;
92 rq.rparam = &status;
93 rq.rlen = 1;
94 if (hci_send_req(&rq, FALSE) < 0)
95 return BLE_STATUS_TIMEOUT;
96 if (status)
97 {
98 return status;
99 }
100 return BLE_STATUS_SUCCESS;
101 }
102
hci_reset(void)103 tBleStatus hci_reset(void)
104 {
105 struct hci_request rq;
106 tBleStatus status = 0;
107 Osal_MemSet(&rq, 0, sizeof(rq));
108 rq.ogf = 0x03;
109 rq.ocf = 0x003;
110 rq.rparam = &status;
111 rq.rlen = 1;
112 if (hci_send_req(&rq, FALSE) < 0)
113 return BLE_STATUS_TIMEOUT;
114 if (status)
115 {
116 return status;
117 }
118 return BLE_STATUS_SUCCESS;
119 }
120
hci_read_transmit_power_level(uint16_t Connection_Handle,uint8_t Type,uint8_t * Transmit_Power_Level)121 tBleStatus hci_read_transmit_power_level(uint16_t Connection_Handle,
122 uint8_t Type,
123 uint8_t *Transmit_Power_Level)
124 {
125 struct hci_request rq;
126 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
127 hci_read_transmit_power_level_cp0 *cp0 = (hci_read_transmit_power_level_cp0*)(cmd_buffer);
128 hci_read_transmit_power_level_rp0 resp;
129 Osal_MemSet(&resp, 0, sizeof(resp));
130 int index_input = 0;
131 cp0->Connection_Handle = htob(Connection_Handle, 2);
132 index_input += 2;
133 cp0->Type = htob(Type, 1);
134 index_input += 1;
135 Osal_MemSet(&rq, 0, sizeof(rq));
136 rq.ogf = 0x03;
137 rq.ocf = 0x02d;
138 rq.cparam = cmd_buffer;
139 rq.clen = index_input;
140 rq.rparam = &resp;
141 rq.rlen = sizeof(resp);
142 if (hci_send_req(&rq, FALSE) < 0)
143 return BLE_STATUS_TIMEOUT;
144 if (resp.Status)
145 {
146 return resp.Status;
147 }
148 *Transmit_Power_Level = btoh(resp.Transmit_Power_Level, 1);
149 return BLE_STATUS_SUCCESS;
150 }
151
hci_set_controller_to_host_flow_control(uint8_t Flow_Control_Enable)152 tBleStatus hci_set_controller_to_host_flow_control(uint8_t Flow_Control_Enable)
153 {
154 struct hci_request rq;
155 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
156 hci_set_controller_to_host_flow_control_cp0 *cp0 = (hci_set_controller_to_host_flow_control_cp0*)(cmd_buffer);
157 tBleStatus status = 0;
158 int index_input = 0;
159 cp0->Flow_Control_Enable = htob(Flow_Control_Enable, 1);
160 index_input += 1;
161 Osal_MemSet(&rq, 0, sizeof(rq));
162 rq.ogf = 0x03;
163 rq.ocf = 0x031;
164 rq.event = 0x0F;
165 rq.cparam = cmd_buffer;
166 rq.clen = index_input;
167 rq.rparam = &status;
168 rq.rlen = 1;
169 if (hci_send_req(&rq, FALSE) < 0)
170 return BLE_STATUS_TIMEOUT;
171 if (status)
172 {
173 return status;
174 }
175 return BLE_STATUS_SUCCESS;
176 }
177
hci_host_buffer_size(uint16_t Host_ACL_Data_Packet_Length,uint8_t Host_Synchronous_Data_Packet_Length,uint16_t Host_Total_Num_ACL_Data_Packets,uint16_t Host_Total_Num_Synchronous_Data_Packets)178 tBleStatus hci_host_buffer_size(uint16_t Host_ACL_Data_Packet_Length,
179 uint8_t Host_Synchronous_Data_Packet_Length,
180 uint16_t Host_Total_Num_ACL_Data_Packets,
181 uint16_t Host_Total_Num_Synchronous_Data_Packets)
182 {
183 struct hci_request rq;
184 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
185 hci_host_buffer_size_cp0 *cp0 = (hci_host_buffer_size_cp0*)(cmd_buffer);
186 tBleStatus status = 0;
187 int index_input = 0;
188 cp0->Host_ACL_Data_Packet_Length = htob(Host_ACL_Data_Packet_Length, 2);
189 index_input += 2;
190 cp0->Host_Synchronous_Data_Packet_Length = htob(Host_Synchronous_Data_Packet_Length, 1);
191 index_input += 1;
192 cp0->Host_Total_Num_ACL_Data_Packets = htob(Host_Total_Num_ACL_Data_Packets, 2);
193 index_input += 2;
194 cp0->Host_Total_Num_Synchronous_Data_Packets = htob(Host_Total_Num_Synchronous_Data_Packets, 2);
195 index_input += 2;
196 Osal_MemSet(&rq, 0, sizeof(rq));
197 rq.ogf = 0x03;
198 rq.ocf = 0x033;
199 rq.event = 0x0F;
200 rq.cparam = cmd_buffer;
201 rq.clen = index_input;
202 rq.rparam = &status;
203 rq.rlen = 1;
204 if (hci_send_req(&rq, FALSE) < 0)
205 return BLE_STATUS_TIMEOUT;
206 if (status)
207 {
208 return status;
209 }
210 return BLE_STATUS_SUCCESS;
211 }
212
hci_host_number_of_completed_packets(uint8_t Number_Of_Handles,Host_Nb_Of_Completed_Pkt_Pair_t Host_Nb_Of_Completed_Pkt_Pair[])213 tBleStatus hci_host_number_of_completed_packets(uint8_t Number_Of_Handles,
214 Host_Nb_Of_Completed_Pkt_Pair_t Host_Nb_Of_Completed_Pkt_Pair[])
215 {
216 struct hci_request rq;
217 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
218 hci_host_number_of_completed_packets_cp0 *cp0 = (hci_host_number_of_completed_packets_cp0*)(cmd_buffer);
219 tBleStatus status = 0;
220 int index_input = 0;
221 cp0->Number_Of_Handles = htob(Number_Of_Handles, 1);
222 index_input += 1;
223 Osal_MemCpy((void*) &cp0->Host_Nb_Of_Completed_Pkt_Pair, (const void *) Host_Nb_Of_Completed_Pkt_Pair, Number_Of_Handles * (sizeof(Host_Nb_Of_Completed_Pkt_Pair_t)));
224 index_input += Number_Of_Handles * (sizeof(Host_Nb_Of_Completed_Pkt_Pair_t));
225 Osal_MemSet(&rq, 0, sizeof(rq));
226 rq.ogf = 0x03;
227 rq.ocf = 0x035;
228 rq.event = 0x0F;
229 rq.cparam = cmd_buffer;
230 rq.clen = index_input;
231 rq.rparam = &status;
232 rq.rlen = 1;
233 if (hci_send_req(&rq, FALSE) < 0)
234 return BLE_STATUS_TIMEOUT;
235 if (status)
236 {
237 return status;
238 }
239 return BLE_STATUS_SUCCESS;
240 }
241
hci_read_local_version_information(uint8_t * HCI_Version,uint16_t * HCI_Revision,uint8_t * LMP_PAL_Version,uint16_t * Manufacturer_Name,uint16_t * LMP_PAL_Subversion)242 tBleStatus hci_read_local_version_information(uint8_t *HCI_Version,
243 uint16_t *HCI_Revision,
244 uint8_t *LMP_PAL_Version,
245 uint16_t *Manufacturer_Name,
246 uint16_t *LMP_PAL_Subversion)
247 {
248 struct hci_request rq;
249 hci_read_local_version_information_rp0 resp;
250 Osal_MemSet(&resp, 0, sizeof(resp));
251 Osal_MemSet(&rq, 0, sizeof(rq));
252 rq.ogf = 0x04;
253 rq.ocf = 0x001;
254 rq.rparam = &resp;
255 rq.rlen = sizeof(resp);
256 if (hci_send_req(&rq, FALSE) < 0)
257 return BLE_STATUS_TIMEOUT;
258 if (resp.Status)
259 {
260 return resp.Status;
261 }
262 *HCI_Version = btoh(resp.HCI_Version, 1);
263 *HCI_Revision = btoh(resp.HCI_Revision, 2);
264 *LMP_PAL_Version = btoh(resp.LMP_PAL_Version, 1);
265 *Manufacturer_Name = btoh(resp.Manufacturer_Name, 2);
266 *LMP_PAL_Subversion = btoh(resp.LMP_PAL_Subversion, 2);
267 return BLE_STATUS_SUCCESS;
268 }
269
hci_read_local_supported_commands(uint8_t Supported_Commands[64])270 tBleStatus hci_read_local_supported_commands(uint8_t Supported_Commands[64])
271 {
272 struct hci_request rq;
273 hci_read_local_supported_commands_rp0 resp;
274 Osal_MemSet(&resp, 0, sizeof(resp));
275 Osal_MemSet(&rq, 0, sizeof(rq));
276 rq.ogf = 0x04;
277 rq.ocf = 0x002;
278 rq.rparam = &resp;
279 rq.rlen = sizeof(resp);
280 if (hci_send_req(&rq, FALSE) < 0)
281 return BLE_STATUS_TIMEOUT;
282 if (resp.Status)
283 {
284 return resp.Status;
285 }
286 Osal_MemCpy((void *) Supported_Commands, (const void *) resp.Supported_Commands, 64);
287 return BLE_STATUS_SUCCESS;
288 }
289
hci_read_local_supported_features(uint8_t LMP_Features[8])290 tBleStatus hci_read_local_supported_features(uint8_t LMP_Features[8])
291 {
292 struct hci_request rq;
293 hci_read_local_supported_features_rp0 resp;
294 Osal_MemSet(&resp, 0, sizeof(resp));
295 Osal_MemSet(&rq, 0, sizeof(rq));
296 rq.ogf = 0x04;
297 rq.ocf = 0x003;
298 rq.rparam = &resp;
299 rq.rlen = sizeof(resp);
300 if (hci_send_req(&rq, FALSE) < 0)
301 return BLE_STATUS_TIMEOUT;
302 if (resp.Status)
303 {
304 return resp.Status;
305 }
306 Osal_MemCpy((void *) LMP_Features, (const void *) resp.LMP_Features, 8);
307 return BLE_STATUS_SUCCESS;
308 }
309
hci_read_bd_addr(uint8_t BD_ADDR[6])310 tBleStatus hci_read_bd_addr(uint8_t BD_ADDR[6])
311 {
312 struct hci_request rq;
313 hci_read_bd_addr_rp0 resp;
314 Osal_MemSet(&resp, 0, sizeof(resp));
315 Osal_MemSet(&rq, 0, sizeof(rq));
316 rq.ogf = 0x04;
317 rq.ocf = 0x009;
318 rq.rparam = &resp;
319 rq.rlen = sizeof(resp);
320 if (hci_send_req(&rq, FALSE) < 0)
321 return BLE_STATUS_TIMEOUT;
322 if (resp.Status)
323 {
324 return resp.Status;
325 }
326 Osal_MemCpy((void *) BD_ADDR, (const void *) resp.BD_ADDR, 6);
327 return BLE_STATUS_SUCCESS;
328 }
329
hci_read_rssi(uint16_t Connection_Handle,uint8_t * RSSI)330 tBleStatus hci_read_rssi(uint16_t Connection_Handle,
331 uint8_t *RSSI)
332 {
333 struct hci_request rq;
334 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
335 hci_read_rssi_cp0 *cp0 = (hci_read_rssi_cp0*)(cmd_buffer);
336 hci_read_rssi_rp0 resp;
337 Osal_MemSet(&resp, 0, sizeof(resp));
338 int index_input = 0;
339 cp0->Connection_Handle = htob(Connection_Handle, 2);
340 index_input += 2;
341 Osal_MemSet(&rq, 0, sizeof(rq));
342 rq.ogf = 0x05;
343 rq.ocf = 0x005;
344 rq.cparam = cmd_buffer;
345 rq.clen = index_input;
346 rq.rparam = &resp;
347 rq.rlen = sizeof(resp);
348 if (hci_send_req(&rq, FALSE) < 0)
349 return BLE_STATUS_TIMEOUT;
350 if (resp.Status)
351 {
352 return resp.Status;
353 }
354 *RSSI = btoh(resp.RSSI, 1);
355 return BLE_STATUS_SUCCESS;
356 }
357
hci_le_set_event_mask(uint8_t LE_Event_Mask[8])358 tBleStatus hci_le_set_event_mask(uint8_t LE_Event_Mask[8])
359 {
360 struct hci_request rq;
361 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
362 hci_le_set_event_mask_cp0 *cp0 = (hci_le_set_event_mask_cp0*)(cmd_buffer);
363 tBleStatus status = 0;
364 int index_input = 0;
365 Osal_MemCpy((void *) &cp0->LE_Event_Mask, (const void *) LE_Event_Mask, 8);
366 index_input += 8;
367 Osal_MemSet(&rq, 0, sizeof(rq));
368 rq.ogf = 0x08;
369 rq.ocf = 0x001;
370 rq.cparam = cmd_buffer;
371 rq.clen = index_input;
372 rq.rparam = &status;
373 rq.rlen = 1;
374 if (hci_send_req(&rq, FALSE) < 0)
375 return BLE_STATUS_TIMEOUT;
376 if (status)
377 {
378 return status;
379 }
380 return BLE_STATUS_SUCCESS;
381 }
382
hci_le_read_buffer_size(uint16_t * HC_LE_ACL_Data_Packet_Length,uint8_t * HC_Total_Num_LE_ACL_Data_Packets)383 tBleStatus hci_le_read_buffer_size(uint16_t *HC_LE_ACL_Data_Packet_Length,
384 uint8_t *HC_Total_Num_LE_ACL_Data_Packets)
385 {
386 struct hci_request rq;
387 hci_le_read_buffer_size_rp0 resp;
388 Osal_MemSet(&resp, 0, sizeof(resp));
389 Osal_MemSet(&rq, 0, sizeof(rq));
390 rq.ogf = 0x08;
391 rq.ocf = 0x002;
392 rq.rparam = &resp;
393 rq.rlen = sizeof(resp);
394 if (hci_send_req(&rq, FALSE) < 0)
395 return BLE_STATUS_TIMEOUT;
396 if (resp.Status)
397 {
398 return resp.Status;
399 }
400 *HC_LE_ACL_Data_Packet_Length = btoh(resp.HC_LE_ACL_Data_Packet_Length, 2);
401 *HC_Total_Num_LE_ACL_Data_Packets = btoh(resp.HC_Total_Num_LE_ACL_Data_Packets, 1);
402 return BLE_STATUS_SUCCESS;
403 }
404
hci_le_read_local_supported_features(uint8_t LE_Features[8])405 tBleStatus hci_le_read_local_supported_features(uint8_t LE_Features[8])
406 {
407 struct hci_request rq;
408 hci_le_read_local_supported_features_rp0 resp;
409 Osal_MemSet(&resp, 0, sizeof(resp));
410 Osal_MemSet(&rq, 0, sizeof(rq));
411 rq.ogf = 0x08;
412 rq.ocf = 0x003;
413 rq.rparam = &resp;
414 rq.rlen = sizeof(resp);
415 if (hci_send_req(&rq, FALSE) < 0)
416 return BLE_STATUS_TIMEOUT;
417 if (resp.Status)
418 {
419 return resp.Status;
420 }
421 Osal_MemCpy((void *) LE_Features, (const void *) resp.LE_Features, 8);
422 return BLE_STATUS_SUCCESS;
423 }
424
hci_le_set_random_address(uint8_t Random_Address[6])425 tBleStatus hci_le_set_random_address(uint8_t Random_Address[6])
426 {
427 struct hci_request rq;
428 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
429 hci_le_set_random_address_cp0 *cp0 = (hci_le_set_random_address_cp0*)(cmd_buffer);
430 tBleStatus status = 0;
431 int index_input = 0;
432 Osal_MemCpy((void *) &cp0->Random_Address, (const void *) Random_Address, 6);
433 index_input += 6;
434 Osal_MemSet(&rq, 0, sizeof(rq));
435 rq.ogf = 0x08;
436 rq.ocf = 0x005;
437 rq.cparam = cmd_buffer;
438 rq.clen = index_input;
439 rq.rparam = &status;
440 rq.rlen = 1;
441 if (hci_send_req(&rq, FALSE) < 0)
442 return BLE_STATUS_TIMEOUT;
443 if (status)
444 {
445 return status;
446 }
447 return BLE_STATUS_SUCCESS;
448 }
449
hci_le_set_advertising_parameters(uint16_t Advertising_Interval_Min,uint16_t Advertising_Interval_Max,uint8_t Advertising_Type,uint8_t Own_Address_Type,uint8_t Peer_Address_Type,uint8_t Peer_Address[6],uint8_t Advertising_Channel_Map,uint8_t Advertising_Filter_Policy)450 tBleStatus hci_le_set_advertising_parameters(uint16_t Advertising_Interval_Min,
451 uint16_t Advertising_Interval_Max,
452 uint8_t Advertising_Type,
453 uint8_t Own_Address_Type,
454 uint8_t Peer_Address_Type,
455 uint8_t Peer_Address[6],
456 uint8_t Advertising_Channel_Map,
457 uint8_t Advertising_Filter_Policy)
458 {
459 struct hci_request rq;
460 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
461 hci_le_set_advertising_parameters_cp0 *cp0 = (hci_le_set_advertising_parameters_cp0*)(cmd_buffer);
462 tBleStatus status = 0;
463 int index_input = 0;
464 cp0->Advertising_Interval_Min = htob(Advertising_Interval_Min, 2);
465 index_input += 2;
466 cp0->Advertising_Interval_Max = htob(Advertising_Interval_Max, 2);
467 index_input += 2;
468 cp0->Advertising_Type = htob(Advertising_Type, 1);
469 index_input += 1;
470 cp0->Own_Address_Type = htob(Own_Address_Type, 1);
471 index_input += 1;
472 cp0->Peer_Address_Type = htob(Peer_Address_Type, 1);
473 index_input += 1;
474 Osal_MemCpy((void *) &cp0->Peer_Address, (const void *) Peer_Address, 6);
475 index_input += 6;
476 cp0->Advertising_Channel_Map = htob(Advertising_Channel_Map, 1);
477 index_input += 1;
478 cp0->Advertising_Filter_Policy = htob(Advertising_Filter_Policy, 1);
479 index_input += 1;
480 Osal_MemSet(&rq, 0, sizeof(rq));
481 rq.ogf = 0x08;
482 rq.ocf = 0x006;
483 rq.cparam = cmd_buffer;
484 rq.clen = index_input;
485 rq.rparam = &status;
486 rq.rlen = 1;
487 if (hci_send_req(&rq, FALSE) < 0)
488 return BLE_STATUS_TIMEOUT;
489 if (status)
490 {
491 return status;
492 }
493 return BLE_STATUS_SUCCESS;
494 }
495
hci_le_read_advertising_channel_tx_power(uint8_t * Transmit_Power_Level)496 tBleStatus hci_le_read_advertising_channel_tx_power(uint8_t *Transmit_Power_Level)
497 {
498 struct hci_request rq;
499 hci_le_read_advertising_channel_tx_power_rp0 resp;
500 Osal_MemSet(&resp, 0, sizeof(resp));
501 Osal_MemSet(&rq, 0, sizeof(rq));
502 rq.ogf = 0x08;
503 rq.ocf = 0x007;
504 rq.rparam = &resp;
505 rq.rlen = sizeof(resp);
506 if (hci_send_req(&rq, FALSE) < 0)
507 return BLE_STATUS_TIMEOUT;
508 if (resp.Status)
509 {
510 return resp.Status;
511 }
512 *Transmit_Power_Level = btoh(resp.Transmit_Power_Level, 1);
513 return BLE_STATUS_SUCCESS;
514 }
515
hci_le_set_advertising_data(uint8_t Advertising_Data_Length,uint8_t Advertising_Data[31])516 tBleStatus hci_le_set_advertising_data(uint8_t Advertising_Data_Length,
517 uint8_t Advertising_Data[31])
518 {
519 struct hci_request rq;
520 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
521 hci_le_set_advertising_data_cp0 *cp0 = (hci_le_set_advertising_data_cp0*)(cmd_buffer);
522 tBleStatus status = 0;
523 int index_input = 0;
524 cp0->Advertising_Data_Length = htob(Advertising_Data_Length, 1);
525 index_input += 1;
526 Osal_MemCpy((void *) &cp0->Advertising_Data, (const void *) Advertising_Data, 31);
527 index_input += 31;
528 Osal_MemSet(&rq, 0, sizeof(rq));
529 rq.ogf = 0x08;
530 rq.ocf = 0x008;
531 rq.cparam = cmd_buffer;
532 rq.clen = index_input;
533 rq.rparam = &status;
534 rq.rlen = 1;
535 if (hci_send_req(&rq, FALSE) < 0)
536 return BLE_STATUS_TIMEOUT;
537 if (status)
538 {
539 return status;
540 }
541 return BLE_STATUS_SUCCESS;
542 }
543
hci_le_set_scan_response_data(uint8_t Scan_Response_Data_Length,uint8_t Scan_Response_Data[31])544 tBleStatus hci_le_set_scan_response_data(uint8_t Scan_Response_Data_Length,
545 uint8_t Scan_Response_Data[31])
546 {
547 struct hci_request rq;
548 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
549 hci_le_set_scan_response_data_cp0 *cp0 = (hci_le_set_scan_response_data_cp0*)(cmd_buffer);
550 tBleStatus status = 0;
551 int index_input = 0;
552 cp0->Scan_Response_Data_Length = htob(Scan_Response_Data_Length, 1);
553 index_input += 1;
554 Osal_MemCpy((void *) &cp0->Scan_Response_Data, (const void *) Scan_Response_Data, 31);
555 index_input += 31;
556 Osal_MemSet(&rq, 0, sizeof(rq));
557 rq.ogf = 0x08;
558 rq.ocf = 0x009;
559 rq.cparam = cmd_buffer;
560 rq.clen = index_input;
561 rq.rparam = &status;
562 rq.rlen = 1;
563 if (hci_send_req(&rq, FALSE) < 0)
564 return BLE_STATUS_TIMEOUT;
565 if (status)
566 {
567 return status;
568 }
569 return BLE_STATUS_SUCCESS;
570 }
571
hci_le_set_advertise_enable(uint8_t Advertising_Enable)572 tBleStatus hci_le_set_advertise_enable(uint8_t Advertising_Enable)
573 {
574 struct hci_request rq;
575 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
576 hci_le_set_advertise_enable_cp0 *cp0 = (hci_le_set_advertise_enable_cp0*)(cmd_buffer);
577 tBleStatus status = 0;
578 int index_input = 0;
579 cp0->Advertising_Enable = htob(Advertising_Enable, 1);
580 index_input += 1;
581 Osal_MemSet(&rq, 0, sizeof(rq));
582 rq.ogf = 0x08;
583 rq.ocf = 0x00a;
584 rq.cparam = cmd_buffer;
585 rq.clen = index_input;
586 rq.rparam = &status;
587 rq.rlen = 1;
588 if (hci_send_req(&rq, FALSE) < 0)
589 return BLE_STATUS_TIMEOUT;
590 if (status)
591 {
592 return status;
593 }
594 return BLE_STATUS_SUCCESS;
595 }
596
hci_le_set_scan_parameters(uint8_t LE_Scan_Type,uint16_t LE_Scan_Interval,uint16_t LE_Scan_Window,uint8_t Own_Address_Type,uint8_t Scanning_Filter_Policy)597 tBleStatus hci_le_set_scan_parameters(uint8_t LE_Scan_Type,
598 uint16_t LE_Scan_Interval,
599 uint16_t LE_Scan_Window,
600 uint8_t Own_Address_Type,
601 uint8_t Scanning_Filter_Policy)
602 {
603 struct hci_request rq;
604 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
605 hci_le_set_scan_parameters_cp0 *cp0 = (hci_le_set_scan_parameters_cp0*)(cmd_buffer);
606 tBleStatus status = 0;
607 int index_input = 0;
608 cp0->LE_Scan_Type = htob(LE_Scan_Type, 1);
609 index_input += 1;
610 cp0->LE_Scan_Interval = htob(LE_Scan_Interval, 2);
611 index_input += 2;
612 cp0->LE_Scan_Window = htob(LE_Scan_Window, 2);
613 index_input += 2;
614 cp0->Own_Address_Type = htob(Own_Address_Type, 1);
615 index_input += 1;
616 cp0->Scanning_Filter_Policy = htob(Scanning_Filter_Policy, 1);
617 index_input += 1;
618 Osal_MemSet(&rq, 0, sizeof(rq));
619 rq.ogf = 0x08;
620 rq.ocf = 0x00b;
621 rq.cparam = cmd_buffer;
622 rq.clen = index_input;
623 rq.rparam = &status;
624 rq.rlen = 1;
625 if (hci_send_req(&rq, FALSE) < 0)
626 return BLE_STATUS_TIMEOUT;
627 if (status)
628 {
629 return status;
630 }
631 return BLE_STATUS_SUCCESS;
632 }
633
hci_le_set_scan_enable(uint8_t LE_Scan_Enable,uint8_t Filter_Duplicates)634 tBleStatus hci_le_set_scan_enable(uint8_t LE_Scan_Enable,
635 uint8_t Filter_Duplicates)
636 {
637 struct hci_request rq;
638 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
639 hci_le_set_scan_enable_cp0 *cp0 = (hci_le_set_scan_enable_cp0*)(cmd_buffer);
640 tBleStatus status = 0;
641 int index_input = 0;
642 cp0->LE_Scan_Enable = htob(LE_Scan_Enable, 1);
643 index_input += 1;
644 cp0->Filter_Duplicates = htob(Filter_Duplicates, 1);
645 index_input += 1;
646 Osal_MemSet(&rq, 0, sizeof(rq));
647 rq.ogf = 0x08;
648 rq.ocf = 0x00c;
649 rq.cparam = cmd_buffer;
650 rq.clen = index_input;
651 rq.rparam = &status;
652 rq.rlen = 1;
653 if (hci_send_req(&rq, FALSE) < 0)
654 return BLE_STATUS_TIMEOUT;
655 if (status)
656 {
657 return status;
658 }
659 return BLE_STATUS_SUCCESS;
660 }
661
hci_le_create_connection(uint16_t LE_Scan_Interval,uint16_t LE_Scan_Window,uint8_t Initiator_Filter_Policy,uint8_t Peer_Address_Type,uint8_t Peer_Address[6],uint8_t Own_Address_Type,uint16_t Conn_Interval_Min,uint16_t Conn_Interval_Max,uint16_t Conn_Latency,uint16_t Supervision_Timeout,uint16_t Minimum_CE_Length,uint16_t Maximum_CE_Length)662 tBleStatus hci_le_create_connection(uint16_t LE_Scan_Interval,
663 uint16_t LE_Scan_Window,
664 uint8_t Initiator_Filter_Policy,
665 uint8_t Peer_Address_Type,
666 uint8_t Peer_Address[6],
667 uint8_t Own_Address_Type,
668 uint16_t Conn_Interval_Min,
669 uint16_t Conn_Interval_Max,
670 uint16_t Conn_Latency,
671 uint16_t Supervision_Timeout,
672 uint16_t Minimum_CE_Length,
673 uint16_t Maximum_CE_Length)
674 {
675 struct hci_request rq;
676 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
677 hci_le_create_connection_cp0 *cp0 = (hci_le_create_connection_cp0*)(cmd_buffer);
678 tBleStatus status = 0;
679 int index_input = 0;
680 cp0->LE_Scan_Interval = htob(LE_Scan_Interval, 2);
681 index_input += 2;
682 cp0->LE_Scan_Window = htob(LE_Scan_Window, 2);
683 index_input += 2;
684 cp0->Initiator_Filter_Policy = htob(Initiator_Filter_Policy, 1);
685 index_input += 1;
686 cp0->Peer_Address_Type = htob(Peer_Address_Type, 1);
687 index_input += 1;
688 Osal_MemCpy((void *) &cp0->Peer_Address, (const void *) Peer_Address, 6);
689 index_input += 6;
690 cp0->Own_Address_Type = htob(Own_Address_Type, 1);
691 index_input += 1;
692 cp0->Conn_Interval_Min = htob(Conn_Interval_Min, 2);
693 index_input += 2;
694 cp0->Conn_Interval_Max = htob(Conn_Interval_Max, 2);
695 index_input += 2;
696 cp0->Conn_Latency = htob(Conn_Latency, 2);
697 index_input += 2;
698 cp0->Supervision_Timeout = htob(Supervision_Timeout, 2);
699 index_input += 2;
700 cp0->Minimum_CE_Length = htob(Minimum_CE_Length, 2);
701 index_input += 2;
702 cp0->Maximum_CE_Length = htob(Maximum_CE_Length, 2);
703 index_input += 2;
704 Osal_MemSet(&rq, 0, sizeof(rq));
705 rq.ogf = 0x08;
706 rq.ocf = 0x00d;
707 rq.event = 0x0F;
708 rq.cparam = cmd_buffer;
709 rq.clen = index_input;
710 rq.rparam = &status;
711 rq.rlen = 1;
712 if (hci_send_req(&rq, FALSE) < 0)
713 return BLE_STATUS_TIMEOUT;
714 if (status)
715 {
716 return status;
717 }
718 return BLE_STATUS_SUCCESS;
719 }
720
hci_le_create_connection_cancel(void)721 tBleStatus hci_le_create_connection_cancel(void)
722 {
723 struct hci_request rq;
724 tBleStatus status = 0;
725 Osal_MemSet(&rq, 0, sizeof(rq));
726 rq.ogf = 0x08;
727 rq.ocf = 0x00e;
728 rq.rparam = &status;
729 rq.rlen = 1;
730 if (hci_send_req(&rq, FALSE) < 0)
731 return BLE_STATUS_TIMEOUT;
732 if (status)
733 {
734 return status;
735 }
736 return BLE_STATUS_SUCCESS;
737 }
738
hci_le_read_white_list_size(uint8_t * White_List_Size)739 tBleStatus hci_le_read_white_list_size(uint8_t *White_List_Size)
740 {
741 struct hci_request rq;
742 hci_le_read_white_list_size_rp0 resp;
743 Osal_MemSet(&resp, 0, sizeof(resp));
744 Osal_MemSet(&rq, 0, sizeof(rq));
745 rq.ogf = 0x08;
746 rq.ocf = 0x00f;
747 rq.rparam = &resp;
748 rq.rlen = sizeof(resp);
749 if (hci_send_req(&rq, FALSE) < 0)
750 return BLE_STATUS_TIMEOUT;
751 if (resp.Status)
752 {
753 return resp.Status;
754 }
755 *White_List_Size = btoh(resp.White_List_Size, 1);
756 return BLE_STATUS_SUCCESS;
757 }
758
hci_le_clear_white_list(void)759 tBleStatus hci_le_clear_white_list(void)
760 {
761 struct hci_request rq;
762 tBleStatus status = 0;
763 Osal_MemSet(&rq, 0, sizeof(rq));
764 rq.ogf = 0x08;
765 rq.ocf = 0x010;
766 rq.rparam = &status;
767 rq.rlen = 1;
768 if (hci_send_req(&rq, FALSE) < 0)
769 return BLE_STATUS_TIMEOUT;
770 if (status)
771 {
772 return status;
773 }
774 return BLE_STATUS_SUCCESS;
775 }
776
hci_le_add_device_to_white_list(uint8_t Address_Type,uint8_t Address[6])777 tBleStatus hci_le_add_device_to_white_list(uint8_t Address_Type,
778 uint8_t Address[6])
779 {
780 struct hci_request rq;
781 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
782 hci_le_add_device_to_white_list_cp0 *cp0 = (hci_le_add_device_to_white_list_cp0*)(cmd_buffer);
783 tBleStatus status = 0;
784 int index_input = 0;
785 cp0->Address_Type = htob(Address_Type, 1);
786 index_input += 1;
787 Osal_MemCpy((void *) &cp0->Address, (const void *) Address, 6);
788 index_input += 6;
789 Osal_MemSet(&rq, 0, sizeof(rq));
790 rq.ogf = 0x08;
791 rq.ocf = 0x011;
792 rq.cparam = cmd_buffer;
793 rq.clen = index_input;
794 rq.rparam = &status;
795 rq.rlen = 1;
796 if (hci_send_req(&rq, FALSE) < 0)
797 return BLE_STATUS_TIMEOUT;
798 if (status)
799 {
800 return status;
801 }
802 return BLE_STATUS_SUCCESS;
803 }
804
hci_le_remove_device_from_white_list(uint8_t Address_Type,uint8_t Address[6])805 tBleStatus hci_le_remove_device_from_white_list(uint8_t Address_Type,
806 uint8_t Address[6])
807 {
808 struct hci_request rq;
809 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
810 hci_le_remove_device_from_white_list_cp0 *cp0 = (hci_le_remove_device_from_white_list_cp0*)(cmd_buffer);
811 tBleStatus status = 0;
812 int index_input = 0;
813 cp0->Address_Type = htob(Address_Type, 1);
814 index_input += 1;
815 Osal_MemCpy((void *) &cp0->Address, (const void *) Address, 6);
816 index_input += 6;
817 Osal_MemSet(&rq, 0, sizeof(rq));
818 rq.ogf = 0x08;
819 rq.ocf = 0x012;
820 rq.cparam = cmd_buffer;
821 rq.clen = index_input;
822 rq.rparam = &status;
823 rq.rlen = 1;
824 if (hci_send_req(&rq, FALSE) < 0)
825 return BLE_STATUS_TIMEOUT;
826 if (status)
827 {
828 return status;
829 }
830 return BLE_STATUS_SUCCESS;
831 }
832
hci_le_connection_update(uint16_t Connection_Handle,uint16_t Conn_Interval_Min,uint16_t Conn_Interval_Max,uint16_t Conn_Latency,uint16_t Supervision_Timeout,uint16_t Minimum_CE_Length,uint16_t Maximum_CE_Length)833 tBleStatus hci_le_connection_update(uint16_t Connection_Handle,
834 uint16_t Conn_Interval_Min,
835 uint16_t Conn_Interval_Max,
836 uint16_t Conn_Latency,
837 uint16_t Supervision_Timeout,
838 uint16_t Minimum_CE_Length,
839 uint16_t Maximum_CE_Length)
840 {
841 struct hci_request rq;
842 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
843 hci_le_connection_update_cp0 *cp0 = (hci_le_connection_update_cp0*)(cmd_buffer);
844 tBleStatus status = 0;
845 int index_input = 0;
846 cp0->Connection_Handle = htob(Connection_Handle, 2);
847 index_input += 2;
848 cp0->Conn_Interval_Min = htob(Conn_Interval_Min, 2);
849 index_input += 2;
850 cp0->Conn_Interval_Max = htob(Conn_Interval_Max, 2);
851 index_input += 2;
852 cp0->Conn_Latency = htob(Conn_Latency, 2);
853 index_input += 2;
854 cp0->Supervision_Timeout = htob(Supervision_Timeout, 2);
855 index_input += 2;
856 cp0->Minimum_CE_Length = htob(Minimum_CE_Length, 2);
857 index_input += 2;
858 cp0->Maximum_CE_Length = htob(Maximum_CE_Length, 2);
859 index_input += 2;
860 Osal_MemSet(&rq, 0, sizeof(rq));
861 rq.ogf = 0x08;
862 rq.ocf = 0x013;
863 rq.event = 0x0F;
864 rq.cparam = cmd_buffer;
865 rq.clen = index_input;
866 rq.rparam = &status;
867 rq.rlen = 1;
868 if (hci_send_req(&rq, FALSE) < 0)
869 return BLE_STATUS_TIMEOUT;
870 if (status)
871 {
872 return status;
873 }
874 return BLE_STATUS_SUCCESS;
875 }
876
hci_le_set_host_channel_classification(uint8_t LE_Channel_Map[5])877 tBleStatus hci_le_set_host_channel_classification(uint8_t LE_Channel_Map[5])
878 {
879 struct hci_request rq;
880 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
881 hci_le_set_host_channel_classification_cp0 *cp0 = (hci_le_set_host_channel_classification_cp0*)(cmd_buffer);
882 tBleStatus status = 0;
883 int index_input = 0;
884 Osal_MemCpy((void *) &cp0->LE_Channel_Map, (const void *) LE_Channel_Map, 5);
885 index_input += 5;
886 Osal_MemSet(&rq, 0, sizeof(rq));
887 rq.ogf = 0x08;
888 rq.ocf = 0x014;
889 rq.cparam = cmd_buffer;
890 rq.clen = index_input;
891 rq.rparam = &status;
892 rq.rlen = 1;
893 if (hci_send_req(&rq, FALSE) < 0)
894 return BLE_STATUS_TIMEOUT;
895 if (status)
896 {
897 return status;
898 }
899 return BLE_STATUS_SUCCESS;
900 }
901
hci_le_read_channel_map(uint16_t Connection_Handle,uint8_t LE_Channel_Map[5])902 tBleStatus hci_le_read_channel_map(uint16_t Connection_Handle,
903 uint8_t LE_Channel_Map[5])
904 {
905 struct hci_request rq;
906 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
907 hci_le_read_channel_map_cp0 *cp0 = (hci_le_read_channel_map_cp0*)(cmd_buffer);
908 hci_le_read_channel_map_rp0 resp;
909 Osal_MemSet(&resp, 0, sizeof(resp));
910 int index_input = 0;
911 cp0->Connection_Handle = htob(Connection_Handle, 2);
912 index_input += 2;
913 Osal_MemSet(&rq, 0, sizeof(rq));
914 rq.ogf = 0x08;
915 rq.ocf = 0x015;
916 rq.cparam = cmd_buffer;
917 rq.clen = index_input;
918 rq.rparam = &resp;
919 rq.rlen = sizeof(resp);
920 if (hci_send_req(&rq, FALSE) < 0)
921 return BLE_STATUS_TIMEOUT;
922 if (resp.Status)
923 {
924 return resp.Status;
925 }
926 Osal_MemCpy((void *) LE_Channel_Map, (const void *) resp.LE_Channel_Map, 5);
927 return BLE_STATUS_SUCCESS;
928 }
929
hci_le_read_remote_used_features(uint16_t Connection_Handle)930 tBleStatus hci_le_read_remote_used_features(uint16_t Connection_Handle)
931 {
932 struct hci_request rq;
933 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
934 hci_le_read_remote_used_features_cp0 *cp0 = (hci_le_read_remote_used_features_cp0*)(cmd_buffer);
935 tBleStatus status = 0;
936 int index_input = 0;
937 cp0->Connection_Handle = htob(Connection_Handle, 2);
938 index_input += 2;
939 Osal_MemSet(&rq, 0, sizeof(rq));
940 rq.ogf = 0x08;
941 rq.ocf = 0x016;
942 rq.event = 0x0F;
943 rq.cparam = cmd_buffer;
944 rq.clen = index_input;
945 rq.rparam = &status;
946 rq.rlen = 1;
947 if (hci_send_req(&rq, FALSE) < 0)
948 return BLE_STATUS_TIMEOUT;
949 if (status)
950 {
951 return status;
952 }
953 return BLE_STATUS_SUCCESS;
954 }
955
hci_le_encrypt(uint8_t Key[16],uint8_t Plaintext_Data[16],uint8_t Encrypted_Data[16])956 tBleStatus hci_le_encrypt(uint8_t Key[16],
957 uint8_t Plaintext_Data[16],
958 uint8_t Encrypted_Data[16])
959 {
960 struct hci_request rq;
961 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
962 hci_le_encrypt_cp0 *cp0 = (hci_le_encrypt_cp0*)(cmd_buffer);
963 hci_le_encrypt_rp0 resp;
964 Osal_MemSet(&resp, 0, sizeof(resp));
965 int index_input = 0;
966 Osal_MemCpy((void *) &cp0->Key, (const void *) Key, 16);
967 index_input += 16;
968 Osal_MemCpy((void *) &cp0->Plaintext_Data, (const void *) Plaintext_Data, 16);
969 index_input += 16;
970 Osal_MemSet(&rq, 0, sizeof(rq));
971 rq.ogf = 0x08;
972 rq.ocf = 0x017;
973 rq.cparam = cmd_buffer;
974 rq.clen = index_input;
975 rq.rparam = &resp;
976 rq.rlen = sizeof(resp);
977 if (hci_send_req(&rq, FALSE) < 0)
978 return BLE_STATUS_TIMEOUT;
979 if (resp.Status)
980 {
981 return resp.Status;
982 }
983 Osal_MemCpy((void *) Encrypted_Data, (const void *) resp.Encrypted_Data, 16);
984 return BLE_STATUS_SUCCESS;
985 }
986
hci_le_rand(uint8_t Random_Number[8])987 tBleStatus hci_le_rand(uint8_t Random_Number[8])
988 {
989 struct hci_request rq;
990 hci_le_rand_rp0 resp;
991 Osal_MemSet(&resp, 0, sizeof(resp));
992 Osal_MemSet(&rq, 0, sizeof(rq));
993 rq.ogf = 0x08;
994 rq.ocf = 0x018;
995 rq.rparam = &resp;
996 rq.rlen = sizeof(resp);
997 if (hci_send_req(&rq, FALSE) < 0)
998 return BLE_STATUS_TIMEOUT;
999 if (resp.Status)
1000 {
1001 return resp.Status;
1002 }
1003 Osal_MemCpy((void *) Random_Number, (const void *) resp.Random_Number, 8);
1004 return BLE_STATUS_SUCCESS;
1005 }
1006
hci_le_start_encryption(uint16_t Connection_Handle,uint8_t Random_Number[8],uint16_t Encrypted_Diversifier,uint8_t Long_Term_Key[16])1007 tBleStatus hci_le_start_encryption(uint16_t Connection_Handle,
1008 uint8_t Random_Number[8],
1009 uint16_t Encrypted_Diversifier,
1010 uint8_t Long_Term_Key[16])
1011 {
1012 struct hci_request rq;
1013 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1014 hci_le_start_encryption_cp0 *cp0 = (hci_le_start_encryption_cp0*)(cmd_buffer);
1015 tBleStatus status = 0;
1016 int index_input = 0;
1017 cp0->Connection_Handle = htob(Connection_Handle, 2);
1018 index_input += 2;
1019 Osal_MemCpy((void *) &cp0->Random_Number, (const void *) Random_Number, 8);
1020 index_input += 8;
1021 cp0->Encrypted_Diversifier = htob(Encrypted_Diversifier, 2);
1022 index_input += 2;
1023 Osal_MemCpy((void *) &cp0->Long_Term_Key, (const void *) Long_Term_Key, 16);
1024 index_input += 16;
1025 Osal_MemSet(&rq, 0, sizeof(rq));
1026 rq.ogf = 0x08;
1027 rq.ocf = 0x019;
1028 rq.event = 0x0F;
1029 rq.cparam = cmd_buffer;
1030 rq.clen = index_input;
1031 rq.rparam = &status;
1032 rq.rlen = 1;
1033 if (hci_send_req(&rq, FALSE) < 0)
1034 return BLE_STATUS_TIMEOUT;
1035 if (status)
1036 {
1037 return status;
1038 }
1039 return BLE_STATUS_SUCCESS;
1040 }
1041
hci_le_long_term_key_request_reply(uint16_t Connection_Handle,uint8_t Long_Term_Key[16])1042 tBleStatus hci_le_long_term_key_request_reply(uint16_t Connection_Handle,
1043 uint8_t Long_Term_Key[16])
1044 {
1045 struct hci_request rq;
1046 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1047 hci_le_long_term_key_request_reply_cp0 *cp0 = (hci_le_long_term_key_request_reply_cp0*)(cmd_buffer);
1048 hci_le_long_term_key_request_reply_rp0 resp;
1049 Osal_MemSet(&resp, 0, sizeof(resp));
1050 int index_input = 0;
1051 cp0->Connection_Handle = htob(Connection_Handle, 2);
1052 index_input += 2;
1053 Osal_MemCpy((void *) &cp0->Long_Term_Key, (const void *) Long_Term_Key, 16);
1054 index_input += 16;
1055 Osal_MemSet(&rq, 0, sizeof(rq));
1056 rq.ogf = 0x08;
1057 rq.ocf = 0x01a;
1058 rq.cparam = cmd_buffer;
1059 rq.clen = index_input;
1060 rq.rparam = &resp;
1061 rq.rlen = sizeof(resp);
1062 if (hci_send_req(&rq, FALSE) < 0)
1063 return BLE_STATUS_TIMEOUT;
1064 if (resp.Status)
1065 {
1066 return resp.Status;
1067 }
1068 return BLE_STATUS_SUCCESS;
1069 }
1070
hci_le_long_term_key_requested_negative_reply(uint16_t Connection_Handle)1071 tBleStatus hci_le_long_term_key_requested_negative_reply(uint16_t Connection_Handle)
1072 {
1073 struct hci_request rq;
1074 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1075 hci_le_long_term_key_requested_negative_reply_cp0 *cp0 = (hci_le_long_term_key_requested_negative_reply_cp0*)(cmd_buffer);
1076 hci_le_long_term_key_requested_negative_reply_rp0 resp;
1077 Osal_MemSet(&resp, 0, sizeof(resp));
1078 int index_input = 0;
1079 cp0->Connection_Handle = htob(Connection_Handle, 2);
1080 index_input += 2;
1081 Osal_MemSet(&rq, 0, sizeof(rq));
1082 rq.ogf = 0x08;
1083 rq.ocf = 0x01b;
1084 rq.cparam = cmd_buffer;
1085 rq.clen = index_input;
1086 rq.rparam = &resp;
1087 rq.rlen = sizeof(resp);
1088 if (hci_send_req(&rq, FALSE) < 0)
1089 return BLE_STATUS_TIMEOUT;
1090 if (resp.Status)
1091 {
1092 return resp.Status;
1093 }
1094 return BLE_STATUS_SUCCESS;
1095 }
1096
hci_le_read_supported_states(uint8_t LE_States[8])1097 tBleStatus hci_le_read_supported_states(uint8_t LE_States[8])
1098 {
1099 struct hci_request rq;
1100 hci_le_read_supported_states_rp0 resp;
1101 Osal_MemSet(&resp, 0, sizeof(resp));
1102 Osal_MemSet(&rq, 0, sizeof(rq));
1103 rq.ogf = 0x08;
1104 rq.ocf = 0x01c;
1105 rq.rparam = &resp;
1106 rq.rlen = sizeof(resp);
1107 if (hci_send_req(&rq, FALSE) < 0)
1108 return BLE_STATUS_TIMEOUT;
1109 if (resp.Status)
1110 {
1111 return resp.Status;
1112 }
1113 Osal_MemCpy((void *) LE_States, (const void *) resp.LE_States, 8);
1114 return BLE_STATUS_SUCCESS;
1115 }
1116
hci_le_receiver_test(uint8_t RX_Frequency)1117 tBleStatus hci_le_receiver_test(uint8_t RX_Frequency)
1118 {
1119 struct hci_request rq;
1120 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1121 hci_le_receiver_test_cp0 *cp0 = (hci_le_receiver_test_cp0*)(cmd_buffer);
1122 tBleStatus status = 0;
1123 int index_input = 0;
1124 cp0->RX_Frequency = htob(RX_Frequency, 1);
1125 index_input += 1;
1126 Osal_MemSet(&rq, 0, sizeof(rq));
1127 rq.ogf = 0x08;
1128 rq.ocf = 0x01d;
1129 rq.cparam = cmd_buffer;
1130 rq.clen = index_input;
1131 rq.rparam = &status;
1132 rq.rlen = 1;
1133 if (hci_send_req(&rq, FALSE) < 0)
1134 return BLE_STATUS_TIMEOUT;
1135 if (status)
1136 {
1137 return status;
1138 }
1139 return BLE_STATUS_SUCCESS;
1140 }
1141
hci_le_transmitter_test(uint8_t TX_Frequency,uint8_t Length_Of_Test_Data,uint8_t Packet_Payload)1142 tBleStatus hci_le_transmitter_test(uint8_t TX_Frequency,
1143 uint8_t Length_Of_Test_Data,
1144 uint8_t Packet_Payload)
1145 {
1146 struct hci_request rq;
1147 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1148 hci_le_transmitter_test_cp0 *cp0 = (hci_le_transmitter_test_cp0*)(cmd_buffer);
1149 tBleStatus status = 0;
1150 int index_input = 0;
1151 cp0->TX_Frequency = htob(TX_Frequency, 1);
1152 index_input += 1;
1153 cp0->Length_Of_Test_Data = htob(Length_Of_Test_Data, 1);
1154 index_input += 1;
1155 cp0->Packet_Payload = htob(Packet_Payload, 1);
1156 index_input += 1;
1157 Osal_MemSet(&rq, 0, sizeof(rq));
1158 rq.ogf = 0x08;
1159 rq.ocf = 0x01e;
1160 rq.cparam = cmd_buffer;
1161 rq.clen = index_input;
1162 rq.rparam = &status;
1163 rq.rlen = 1;
1164 if (hci_send_req(&rq, FALSE) < 0)
1165 return BLE_STATUS_TIMEOUT;
1166 if (status)
1167 {
1168 return status;
1169 }
1170 return BLE_STATUS_SUCCESS;
1171 }
1172
hci_le_test_end(uint16_t * Number_Of_Packets)1173 tBleStatus hci_le_test_end(uint16_t *Number_Of_Packets)
1174 {
1175 struct hci_request rq;
1176 hci_le_test_end_rp0 resp;
1177 Osal_MemSet(&resp, 0, sizeof(resp));
1178 Osal_MemSet(&rq, 0, sizeof(rq));
1179 rq.ogf = 0x08;
1180 rq.ocf = 0x01f;
1181 rq.rparam = &resp;
1182 rq.rlen = sizeof(resp);
1183 if (hci_send_req(&rq, FALSE) < 0)
1184 return BLE_STATUS_TIMEOUT;
1185 if (resp.Status)
1186 {
1187 return resp.Status;
1188 }
1189 *Number_Of_Packets = btoh(resp.Number_Of_Packets, 2);
1190 return BLE_STATUS_SUCCESS;
1191 }
1192
hci_le_set_data_length(uint16_t Connection_Handle,uint16_t TxOctets,uint16_t TxTime)1193 tBleStatus hci_le_set_data_length(uint16_t Connection_Handle,
1194 uint16_t TxOctets,
1195 uint16_t TxTime)
1196 {
1197 struct hci_request rq;
1198 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1199 hci_le_set_data_length_cp0 *cp0 = (hci_le_set_data_length_cp0*)(cmd_buffer);
1200 hci_le_set_data_length_rp0 resp;
1201 Osal_MemSet(&resp, 0, sizeof(resp));
1202 int index_input = 0;
1203 cp0->Connection_Handle = htob(Connection_Handle, 2);
1204 index_input += 2;
1205 cp0->TxOctets = htob(TxOctets, 2);
1206 index_input += 2;
1207 cp0->TxTime = htob(TxTime, 2);
1208 index_input += 2;
1209 Osal_MemSet(&rq, 0, sizeof(rq));
1210 rq.ogf = 0x08;
1211 rq.ocf = 0x022;
1212 rq.cparam = cmd_buffer;
1213 rq.clen = index_input;
1214 rq.rparam = &resp;
1215 rq.rlen = sizeof(resp);
1216 if (hci_send_req(&rq, FALSE) < 0)
1217 return BLE_STATUS_TIMEOUT;
1218 if (resp.Status)
1219 {
1220 return resp.Status;
1221 }
1222 return BLE_STATUS_SUCCESS;
1223 }
1224
hci_le_read_suggested_default_data_length(uint16_t * SuggestedMaxTxOctets,uint16_t * SuggestedMaxTxTime)1225 tBleStatus hci_le_read_suggested_default_data_length(uint16_t *SuggestedMaxTxOctets,
1226 uint16_t *SuggestedMaxTxTime)
1227 {
1228 struct hci_request rq;
1229 hci_le_read_suggested_default_data_length_rp0 resp;
1230 Osal_MemSet(&resp, 0, sizeof(resp));
1231 Osal_MemSet(&rq, 0, sizeof(rq));
1232 rq.ogf = 0x08;
1233 rq.ocf = 0x023;
1234 rq.rparam = &resp;
1235 rq.rlen = sizeof(resp);
1236 if (hci_send_req(&rq, FALSE) < 0)
1237 return BLE_STATUS_TIMEOUT;
1238 if (resp.Status)
1239 {
1240 return resp.Status;
1241 }
1242 *SuggestedMaxTxOctets = btoh(resp.SuggestedMaxTxOctets, 2);
1243 *SuggestedMaxTxTime = btoh(resp.SuggestedMaxTxTime, 2);
1244 return BLE_STATUS_SUCCESS;
1245 }
1246
hci_le_write_suggested_default_data_length(uint16_t SuggestedMaxTxOctets,uint16_t SuggestedMaxTxTime)1247 tBleStatus hci_le_write_suggested_default_data_length(uint16_t SuggestedMaxTxOctets,
1248 uint16_t SuggestedMaxTxTime)
1249 {
1250 struct hci_request rq;
1251 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1252 hci_le_write_suggested_default_data_length_cp0 *cp0 = (hci_le_write_suggested_default_data_length_cp0*)(cmd_buffer);
1253 tBleStatus status = 0;
1254 int index_input = 0;
1255 cp0->SuggestedMaxTxOctets = htob(SuggestedMaxTxOctets, 2);
1256 index_input += 2;
1257 cp0->SuggestedMaxTxTime = htob(SuggestedMaxTxTime, 2);
1258 index_input += 2;
1259 Osal_MemSet(&rq, 0, sizeof(rq));
1260 rq.ogf = 0x08;
1261 rq.ocf = 0x024;
1262 rq.cparam = cmd_buffer;
1263 rq.clen = index_input;
1264 rq.rparam = &status;
1265 rq.rlen = 1;
1266 if (hci_send_req(&rq, FALSE) < 0)
1267 return BLE_STATUS_TIMEOUT;
1268 if (status)
1269 {
1270 return status;
1271 }
1272 return BLE_STATUS_SUCCESS;
1273 }
1274
hci_le_read_local_p256_public_key(void)1275 tBleStatus hci_le_read_local_p256_public_key(void)
1276 {
1277 struct hci_request rq;
1278 tBleStatus status = 0;
1279 Osal_MemSet(&rq, 0, sizeof(rq));
1280 rq.ogf = 0x08;
1281 rq.ocf = 0x025;
1282 rq.event = 0x0F;
1283 rq.rparam = &status;
1284 rq.rlen = 1;
1285 if (hci_send_req(&rq, FALSE) < 0)
1286 return BLE_STATUS_TIMEOUT;
1287 if (status)
1288 {
1289 return status;
1290 }
1291 return BLE_STATUS_SUCCESS;
1292 }
1293
hci_le_generate_dhkey(uint8_t Remote_P256_Public_Key[64])1294 tBleStatus hci_le_generate_dhkey(uint8_t Remote_P256_Public_Key[64])
1295 {
1296 struct hci_request rq;
1297 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1298 hci_le_generate_dhkey_cp0 *cp0 = (hci_le_generate_dhkey_cp0*)(cmd_buffer);
1299 tBleStatus status = 0;
1300 int index_input = 0;
1301 Osal_MemCpy((void *) &cp0->Remote_P256_Public_Key, (const void *) Remote_P256_Public_Key, 64);
1302 index_input += 64;
1303 Osal_MemSet(&rq, 0, sizeof(rq));
1304 rq.ogf = 0x08;
1305 rq.ocf = 0x026;
1306 rq.event = 0x0F;
1307 rq.cparam = cmd_buffer;
1308 rq.clen = index_input;
1309 rq.rparam = &status;
1310 rq.rlen = 1;
1311 if (hci_send_req(&rq, FALSE) < 0)
1312 return BLE_STATUS_TIMEOUT;
1313 if (status)
1314 {
1315 return status;
1316 }
1317 return BLE_STATUS_SUCCESS;
1318 }
1319
hci_le_add_device_to_resolving_list(uint8_t Peer_Identity_Address_Type,uint8_t Peer_Identity_Address[6],uint8_t Peer_IRK[16],uint8_t Local_IRK[16])1320 tBleStatus hci_le_add_device_to_resolving_list(uint8_t Peer_Identity_Address_Type,
1321 uint8_t Peer_Identity_Address[6],
1322 uint8_t Peer_IRK[16],
1323 uint8_t Local_IRK[16])
1324 {
1325 struct hci_request rq;
1326 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1327 hci_le_add_device_to_resolving_list_cp0 *cp0 = (hci_le_add_device_to_resolving_list_cp0*)(cmd_buffer);
1328 tBleStatus status = 0;
1329 int index_input = 0;
1330 cp0->Peer_Identity_Address_Type = htob(Peer_Identity_Address_Type, 1);
1331 index_input += 1;
1332 Osal_MemCpy((void *) &cp0->Peer_Identity_Address, (const void *) Peer_Identity_Address, 6);
1333 index_input += 6;
1334 Osal_MemCpy((void *) &cp0->Peer_IRK, (const void *) Peer_IRK, 16);
1335 index_input += 16;
1336 Osal_MemCpy((void *) &cp0->Local_IRK, (const void *) Local_IRK, 16);
1337 index_input += 16;
1338 Osal_MemSet(&rq, 0, sizeof(rq));
1339 rq.ogf = 0x08;
1340 rq.ocf = 0x027;
1341 rq.cparam = cmd_buffer;
1342 rq.clen = index_input;
1343 rq.rparam = &status;
1344 rq.rlen = 1;
1345 if (hci_send_req(&rq, FALSE) < 0)
1346 return BLE_STATUS_TIMEOUT;
1347 if (status)
1348 {
1349 return status;
1350 }
1351 return BLE_STATUS_SUCCESS;
1352 }
1353
hci_le_remove_device_from_resolving_list(uint8_t Peer_Identity_Address_Type,uint8_t Peer_Identity_Address[6])1354 tBleStatus hci_le_remove_device_from_resolving_list(uint8_t Peer_Identity_Address_Type,
1355 uint8_t Peer_Identity_Address[6])
1356 {
1357 struct hci_request rq;
1358 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1359 hci_le_remove_device_from_resolving_list_cp0 *cp0 = (hci_le_remove_device_from_resolving_list_cp0*)(cmd_buffer);
1360 tBleStatus status = 0;
1361 int index_input = 0;
1362 cp0->Peer_Identity_Address_Type = htob(Peer_Identity_Address_Type, 1);
1363 index_input += 1;
1364 Osal_MemCpy((void *) &cp0->Peer_Identity_Address, (const void *) Peer_Identity_Address, 6);
1365 index_input += 6;
1366 Osal_MemSet(&rq, 0, sizeof(rq));
1367 rq.ogf = 0x08;
1368 rq.ocf = 0x028;
1369 rq.cparam = cmd_buffer;
1370 rq.clen = index_input;
1371 rq.rparam = &status;
1372 rq.rlen = 1;
1373 if (hci_send_req(&rq, FALSE) < 0)
1374 return BLE_STATUS_TIMEOUT;
1375 if (status)
1376 {
1377 return status;
1378 }
1379 return BLE_STATUS_SUCCESS;
1380 }
1381
hci_le_clear_resolving_list(void)1382 tBleStatus hci_le_clear_resolving_list(void)
1383 {
1384 struct hci_request rq;
1385 tBleStatus status = 0;
1386 Osal_MemSet(&rq, 0, sizeof(rq));
1387 rq.ogf = 0x08;
1388 rq.ocf = 0x029;
1389 rq.rparam = &status;
1390 rq.rlen = 1;
1391 if (hci_send_req(&rq, FALSE) < 0)
1392 return BLE_STATUS_TIMEOUT;
1393 if (status)
1394 {
1395 return status;
1396 }
1397 return BLE_STATUS_SUCCESS;
1398 }
1399
hci_le_read_resolving_list_size(uint8_t * Resolving_List_Size)1400 tBleStatus hci_le_read_resolving_list_size(uint8_t *Resolving_List_Size)
1401 {
1402 struct hci_request rq;
1403 hci_le_read_resolving_list_size_rp0 resp;
1404 Osal_MemSet(&resp, 0, sizeof(resp));
1405 Osal_MemSet(&rq, 0, sizeof(rq));
1406 rq.ogf = 0x08;
1407 rq.ocf = 0x02a;
1408 rq.rparam = &resp;
1409 rq.rlen = sizeof(resp);
1410 if (hci_send_req(&rq, FALSE) < 0)
1411 return BLE_STATUS_TIMEOUT;
1412 if (resp.Status)
1413 {
1414 return resp.Status;
1415 }
1416 *Resolving_List_Size = btoh(resp.Resolving_List_Size, 1);
1417 return BLE_STATUS_SUCCESS;
1418 }
1419
hci_le_read_peer_resolvable_address(uint8_t Peer_Identity_Address_Type,uint8_t Peer_Identity_Address[6],uint8_t Peer_Resolvable_Address[6])1420 tBleStatus hci_le_read_peer_resolvable_address(uint8_t Peer_Identity_Address_Type,
1421 uint8_t Peer_Identity_Address[6],
1422 uint8_t Peer_Resolvable_Address[6])
1423 {
1424 struct hci_request rq;
1425 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1426 hci_le_read_peer_resolvable_address_cp0 *cp0 = (hci_le_read_peer_resolvable_address_cp0*)(cmd_buffer);
1427 hci_le_read_peer_resolvable_address_rp0 resp;
1428 Osal_MemSet(&resp, 0, sizeof(resp));
1429 int index_input = 0;
1430 cp0->Peer_Identity_Address_Type = htob(Peer_Identity_Address_Type, 1);
1431 index_input += 1;
1432 Osal_MemCpy((void *) &cp0->Peer_Identity_Address, (const void *) Peer_Identity_Address, 6);
1433 index_input += 6;
1434 Osal_MemSet(&rq, 0, sizeof(rq));
1435 rq.ogf = 0x08;
1436 rq.ocf = 0x02b;
1437 rq.cparam = cmd_buffer;
1438 rq.clen = index_input;
1439 rq.rparam = &resp;
1440 rq.rlen = sizeof(resp);
1441 if (hci_send_req(&rq, FALSE) < 0)
1442 return BLE_STATUS_TIMEOUT;
1443 if (resp.Status)
1444 {
1445 return resp.Status;
1446 }
1447 Osal_MemCpy((void *) Peer_Resolvable_Address, (const void *) resp.Peer_Resolvable_Address, 6);
1448 return BLE_STATUS_SUCCESS;
1449 }
1450
hci_le_read_local_resolvable_address(uint8_t Peer_Identity_Address_Type,uint8_t Peer_Identity_Address[6],uint8_t Local_Resolvable_Address[6])1451 tBleStatus hci_le_read_local_resolvable_address(uint8_t Peer_Identity_Address_Type,
1452 uint8_t Peer_Identity_Address[6],
1453 uint8_t Local_Resolvable_Address[6])
1454 {
1455 struct hci_request rq;
1456 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1457 hci_le_read_local_resolvable_address_cp0 *cp0 = (hci_le_read_local_resolvable_address_cp0*)(cmd_buffer);
1458 hci_le_read_local_resolvable_address_rp0 resp;
1459 Osal_MemSet(&resp, 0, sizeof(resp));
1460 int index_input = 0;
1461 cp0->Peer_Identity_Address_Type = htob(Peer_Identity_Address_Type, 1);
1462 index_input += 1;
1463 Osal_MemCpy((void *) &cp0->Peer_Identity_Address, (const void *) Peer_Identity_Address, 6);
1464 index_input += 6;
1465 Osal_MemSet(&rq, 0, sizeof(rq));
1466 rq.ogf = 0x08;
1467 rq.ocf = 0x02c;
1468 rq.cparam = cmd_buffer;
1469 rq.clen = index_input;
1470 rq.rparam = &resp;
1471 rq.rlen = sizeof(resp);
1472 if (hci_send_req(&rq, FALSE) < 0)
1473 return BLE_STATUS_TIMEOUT;
1474 if (resp.Status)
1475 {
1476 return resp.Status;
1477 }
1478 Osal_MemCpy((void *) Local_Resolvable_Address, (const void *) resp.Local_Resolvable_Address, 6);
1479 return BLE_STATUS_SUCCESS;
1480 }
1481
hci_le_set_address_resolution_enable(uint8_t Address_Resolution_Enable)1482 tBleStatus hci_le_set_address_resolution_enable(uint8_t Address_Resolution_Enable)
1483 {
1484 struct hci_request rq;
1485 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1486 hci_le_set_address_resolution_enable_cp0 *cp0 = (hci_le_set_address_resolution_enable_cp0*)(cmd_buffer);
1487 tBleStatus status = 0;
1488 int index_input = 0;
1489 cp0->Address_Resolution_Enable = htob(Address_Resolution_Enable, 1);
1490 index_input += 1;
1491 Osal_MemSet(&rq, 0, sizeof(rq));
1492 rq.ogf = 0x08;
1493 rq.ocf = 0x02d;
1494 rq.cparam = cmd_buffer;
1495 rq.clen = index_input;
1496 rq.rparam = &status;
1497 rq.rlen = 1;
1498 if (hci_send_req(&rq, FALSE) < 0)
1499 return BLE_STATUS_TIMEOUT;
1500 if (status)
1501 {
1502 return status;
1503 }
1504 return BLE_STATUS_SUCCESS;
1505 }
1506
hci_le_set_resolvable_private_address_timeout(uint16_t RPA_Timeout)1507 tBleStatus hci_le_set_resolvable_private_address_timeout(uint16_t RPA_Timeout)
1508 {
1509 struct hci_request rq;
1510 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1511 hci_le_set_resolvable_private_address_timeout_cp0 *cp0 = (hci_le_set_resolvable_private_address_timeout_cp0*)(cmd_buffer);
1512 tBleStatus status = 0;
1513 int index_input = 0;
1514 cp0->RPA_Timeout = htob(RPA_Timeout, 2);
1515 index_input += 2;
1516 Osal_MemSet(&rq, 0, sizeof(rq));
1517 rq.ogf = 0x08;
1518 rq.ocf = 0x02e;
1519 rq.cparam = cmd_buffer;
1520 rq.clen = index_input;
1521 rq.rparam = &status;
1522 rq.rlen = 1;
1523 if (hci_send_req(&rq, FALSE) < 0)
1524 return BLE_STATUS_TIMEOUT;
1525 if (status)
1526 {
1527 return status;
1528 }
1529 return BLE_STATUS_SUCCESS;
1530 }
1531
hci_le_read_maximum_data_length(uint16_t * supportedMaxTxOctets,uint16_t * supportedMaxTxTime,uint16_t * supportedMaxRxOctets,uint16_t * supportedMaxRxTime)1532 tBleStatus hci_le_read_maximum_data_length(uint16_t *supportedMaxTxOctets,
1533 uint16_t *supportedMaxTxTime,
1534 uint16_t *supportedMaxRxOctets,
1535 uint16_t *supportedMaxRxTime)
1536 {
1537 struct hci_request rq;
1538 hci_le_read_maximum_data_length_rp0 resp;
1539 Osal_MemSet(&resp, 0, sizeof(resp));
1540 Osal_MemSet(&rq, 0, sizeof(rq));
1541 rq.ogf = 0x08;
1542 rq.ocf = 0x02f;
1543 rq.rparam = &resp;
1544 rq.rlen = sizeof(resp);
1545 if (hci_send_req(&rq, FALSE) < 0)
1546 return BLE_STATUS_TIMEOUT;
1547 if (resp.Status)
1548 {
1549 return resp.Status;
1550 }
1551 *supportedMaxTxOctets = btoh(resp.supportedMaxTxOctets, 2);
1552 *supportedMaxTxTime = btoh(resp.supportedMaxTxTime, 2);
1553 *supportedMaxRxOctets = btoh(resp.supportedMaxRxOctets, 2);
1554 *supportedMaxRxTime = btoh(resp.supportedMaxRxTime, 2);
1555 return BLE_STATUS_SUCCESS;
1556 }
1557
hci_le_read_phy(uint16_t Connection_Handle,uint8_t * TX_PHY,uint8_t * RX_PHY)1558 tBleStatus hci_le_read_phy(uint16_t Connection_Handle,
1559 uint8_t *TX_PHY,
1560 uint8_t *RX_PHY)
1561 {
1562 struct hci_request rq;
1563 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1564 hci_le_read_phy_cp0 *cp0 = (hci_le_read_phy_cp0*)(cmd_buffer);
1565 hci_le_read_phy_rp0 resp;
1566 Osal_MemSet(&resp, 0, sizeof(resp));
1567 int index_input = 0;
1568 cp0->Connection_Handle = htob(Connection_Handle, 2);
1569 index_input += 2;
1570 Osal_MemSet(&rq, 0, sizeof(rq));
1571 rq.ogf = 0x08;
1572 rq.ocf = 0x030;
1573 rq.cparam = cmd_buffer;
1574 rq.clen = index_input;
1575 rq.rparam = &resp;
1576 rq.rlen = sizeof(resp);
1577 if (hci_send_req(&rq, FALSE) < 0)
1578 return BLE_STATUS_TIMEOUT;
1579 if (resp.Status)
1580 {
1581 return resp.Status;
1582 }
1583 *TX_PHY = btoh(resp.TX_PHY, 1);
1584 *RX_PHY = btoh(resp.RX_PHY, 1);
1585 return BLE_STATUS_SUCCESS;
1586 }
1587
hci_le_set_default_phy(uint8_t ALL_PHYS,uint8_t TX_PHYS,uint8_t RX_PHYS)1588 tBleStatus hci_le_set_default_phy(uint8_t ALL_PHYS,
1589 uint8_t TX_PHYS,
1590 uint8_t RX_PHYS)
1591 {
1592 struct hci_request rq;
1593 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1594 hci_le_set_default_phy_cp0 *cp0 = (hci_le_set_default_phy_cp0*)(cmd_buffer);
1595 tBleStatus status = 0;
1596 int index_input = 0;
1597 cp0->ALL_PHYS = htob(ALL_PHYS, 1);
1598 index_input += 1;
1599 cp0->TX_PHYS = htob(TX_PHYS, 1);
1600 index_input += 1;
1601 cp0->RX_PHYS = htob(RX_PHYS, 1);
1602 index_input += 1;
1603 Osal_MemSet(&rq, 0, sizeof(rq));
1604 rq.ogf = 0x08;
1605 rq.ocf = 0x031;
1606 rq.cparam = cmd_buffer;
1607 rq.clen = index_input;
1608 rq.rparam = &status;
1609 rq.rlen = 1;
1610 if (hci_send_req(&rq, FALSE) < 0)
1611 return BLE_STATUS_TIMEOUT;
1612 if (status)
1613 {
1614 return status;
1615 }
1616 return BLE_STATUS_SUCCESS;
1617 }
1618
hci_le_set_phy(uint16_t Connection_Handle,uint8_t ALL_PHYS,uint8_t TX_PHYS,uint8_t RX_PHYS,uint16_t PHY_options)1619 tBleStatus hci_le_set_phy(uint16_t Connection_Handle,
1620 uint8_t ALL_PHYS,
1621 uint8_t TX_PHYS,
1622 uint8_t RX_PHYS,
1623 uint16_t PHY_options)
1624 {
1625 struct hci_request rq;
1626 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1627 hci_le_set_phy_cp0 *cp0 = (hci_le_set_phy_cp0*)(cmd_buffer);
1628 tBleStatus status = 0;
1629 int index_input = 0;
1630 cp0->Connection_Handle = htob(Connection_Handle, 2);
1631 index_input += 2;
1632 cp0->ALL_PHYS = htob(ALL_PHYS, 1);
1633 index_input += 1;
1634 cp0->TX_PHYS = htob(TX_PHYS, 1);
1635 index_input += 1;
1636 cp0->RX_PHYS = htob(RX_PHYS, 1);
1637 index_input += 1;
1638 cp0->PHY_options = htob(PHY_options, 2);
1639 index_input += 2;
1640 Osal_MemSet(&rq, 0, sizeof(rq));
1641 rq.ogf = 0x08;
1642 rq.ocf = 0x032;
1643 rq.event = 0x0F;
1644 rq.cparam = cmd_buffer;
1645 rq.clen = index_input;
1646 rq.rparam = &status;
1647 rq.rlen = 1;
1648 if (hci_send_req(&rq, FALSE) < 0)
1649 return BLE_STATUS_TIMEOUT;
1650 if (status)
1651 {
1652 return status;
1653 }
1654 return BLE_STATUS_SUCCESS;
1655 }
1656
hci_le_enhanced_receiver_test(uint8_t RX_Frequency,uint8_t PHY,uint8_t Modulation_Index)1657 tBleStatus hci_le_enhanced_receiver_test(uint8_t RX_Frequency,
1658 uint8_t PHY,
1659 uint8_t Modulation_Index)
1660 {
1661 struct hci_request rq;
1662 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1663 hci_le_enhanced_receiver_test_cp0 *cp0 = (hci_le_enhanced_receiver_test_cp0*)(cmd_buffer);
1664 tBleStatus status = 0;
1665 int index_input = 0;
1666 cp0->RX_Frequency = htob(RX_Frequency, 1);
1667 index_input += 1;
1668 cp0->PHY = htob(PHY, 1);
1669 index_input += 1;
1670 cp0->Modulation_Index = htob(Modulation_Index, 1);
1671 index_input += 1;
1672 Osal_MemSet(&rq, 0, sizeof(rq));
1673 rq.ogf = 0x08;
1674 rq.ocf = 0x033;
1675 rq.cparam = cmd_buffer;
1676 rq.clen = index_input;
1677 rq.rparam = &status;
1678 rq.rlen = 1;
1679 if (hci_send_req(&rq, FALSE) < 0)
1680 return BLE_STATUS_TIMEOUT;
1681 if (status)
1682 {
1683 return status;
1684 }
1685 return BLE_STATUS_SUCCESS;
1686 }
1687
hci_le_enhanced_transmitter_test(uint8_t TX_Frequency,uint8_t Length_Of_Test_Data,uint8_t Packet_Payload,uint8_t PHY)1688 tBleStatus hci_le_enhanced_transmitter_test(uint8_t TX_Frequency,
1689 uint8_t Length_Of_Test_Data,
1690 uint8_t Packet_Payload,
1691 uint8_t PHY)
1692 {
1693 struct hci_request rq;
1694 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1695 hci_le_enhanced_transmitter_test_cp0 *cp0 = (hci_le_enhanced_transmitter_test_cp0*)(cmd_buffer);
1696 tBleStatus status = 0;
1697 int index_input = 0;
1698 cp0->TX_Frequency = htob(TX_Frequency, 1);
1699 index_input += 1;
1700 cp0->Length_Of_Test_Data = htob(Length_Of_Test_Data, 1);
1701 index_input += 1;
1702 cp0->Packet_Payload = htob(Packet_Payload, 1);
1703 index_input += 1;
1704 cp0->PHY = htob(PHY, 1);
1705 index_input += 1;
1706 Osal_MemSet(&rq, 0, sizeof(rq));
1707 rq.ogf = 0x08;
1708 rq.ocf = 0x034;
1709 rq.cparam = cmd_buffer;
1710 rq.clen = index_input;
1711 rq.rparam = &status;
1712 rq.rlen = 1;
1713 if (hci_send_req(&rq, FALSE) < 0)
1714 return BLE_STATUS_TIMEOUT;
1715 if (status)
1716 {
1717 return status;
1718 }
1719 return BLE_STATUS_SUCCESS;
1720 }
1721
1722