1 /******************************************************************************
2 * @file ble_gatt_aci.c
3 * @author MCD Application Team
4 * @date 23 May 2019
5 * @brief Source file for ble api STM32WB (gatt_aci)
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_gatt_aci.h"
22
aci_gatt_init(void)23 tBleStatus aci_gatt_init(void)
24 {
25 struct hci_request rq;
26 tBleStatus status = 0;
27 Osal_MemSet(&rq, 0, sizeof(rq));
28 rq.ogf = 0x3f;
29 rq.ocf = 0x101;
30 rq.rparam = &status;
31 rq.rlen = 1;
32 if (hci_send_req(&rq, FALSE) < 0)
33 return BLE_STATUS_TIMEOUT;
34 if (status)
35 {
36 return status;
37 }
38 return BLE_STATUS_SUCCESS;
39 }
40
aci_gatt_add_service(uint8_t Service_UUID_Type,Service_UUID_t * Service_UUID,uint8_t Service_Type,uint8_t Max_Attribute_Records,uint16_t * Service_Handle)41 tBleStatus aci_gatt_add_service(uint8_t Service_UUID_Type,
42 Service_UUID_t *Service_UUID,
43 uint8_t Service_Type,
44 uint8_t Max_Attribute_Records,
45 uint16_t *Service_Handle)
46 {
47 struct hci_request rq;
48 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
49 aci_gatt_add_service_cp0 *cp0 = (aci_gatt_add_service_cp0*)(cmd_buffer);
50 aci_gatt_add_service_cp1 *cp1 = (aci_gatt_add_service_cp1*)(cmd_buffer + 1 + (Service_UUID_Type == 1 ? 2 : (Service_UUID_Type == 2 ? 16 : 0)));
51 aci_gatt_add_service_rp0 resp;
52 Osal_MemSet(&resp, 0, sizeof(resp));
53 int index_input = 0;
54 cp0->Service_UUID_Type = htob(Service_UUID_Type, 1);
55 index_input += 1;
56 /* var_len_data input */
57 {
58 uint8_t size;
59 switch (Service_UUID_Type) {
60 case 1: size = 2; break;
61 case 2: size = 16; break;
62 default: return BLE_STATUS_ERROR;
63 }
64 Osal_MemCpy((void *) &cp0->Service_UUID, (const void *) Service_UUID, size);
65 index_input += size;
66 {
67 cp1->Service_Type = htob(Service_Type, 1);
68 }
69 index_input += 1;
70 {
71 cp1->Max_Attribute_Records = htob(Max_Attribute_Records, 1);
72 }
73 index_input += 1;
74 }
75 Osal_MemSet(&rq, 0, sizeof(rq));
76 rq.ogf = 0x3f;
77 rq.ocf = 0x102;
78 rq.cparam = cmd_buffer;
79 rq.clen = index_input;
80 rq.rparam = &resp;
81 rq.rlen = sizeof(resp);
82 if (hci_send_req(&rq, FALSE) < 0)
83 return BLE_STATUS_TIMEOUT;
84 if (resp.Status)
85 {
86 return resp.Status;
87 }
88 *Service_Handle = btoh(resp.Service_Handle, 2);
89 return BLE_STATUS_SUCCESS;
90 }
91
aci_gatt_include_service(uint16_t Service_Handle,uint16_t Include_Start_Handle,uint16_t Include_End_Handle,uint8_t Include_UUID_Type,Include_UUID_t * Include_UUID,uint16_t * Include_Handle)92 tBleStatus aci_gatt_include_service(uint16_t Service_Handle,
93 uint16_t Include_Start_Handle,
94 uint16_t Include_End_Handle,
95 uint8_t Include_UUID_Type,
96 Include_UUID_t *Include_UUID,
97 uint16_t *Include_Handle)
98 {
99 struct hci_request rq;
100 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
101 aci_gatt_include_service_cp0 *cp0 = (aci_gatt_include_service_cp0*)(cmd_buffer);
102 aci_gatt_include_service_rp0 resp;
103 Osal_MemSet(&resp, 0, sizeof(resp));
104 int index_input = 0;
105 int uuid_size = (Include_UUID_Type == 2) ? 16 : 2;
106 cp0->Service_Handle = htob(Service_Handle, 2);
107 index_input += 2;
108 cp0->Include_Start_Handle = htob(Include_Start_Handle, 2);
109 index_input += 2;
110 cp0->Include_End_Handle = htob(Include_End_Handle, 2);
111 index_input += 2;
112 cp0->Include_UUID_Type = htob(Include_UUID_Type, 1);
113 index_input += 1;
114 Osal_MemCpy((void *) &cp0->Include_UUID, (const void *) Include_UUID, uuid_size);
115 index_input += uuid_size;
116 Osal_MemSet(&rq, 0, sizeof(rq));
117 rq.ogf = 0x3f;
118 rq.ocf = 0x103;
119 rq.cparam = cmd_buffer;
120 rq.clen = index_input;
121 rq.rparam = &resp;
122 rq.rlen = sizeof(resp);
123 if (hci_send_req(&rq, FALSE) < 0)
124 return BLE_STATUS_TIMEOUT;
125 if (resp.Status)
126 {
127 return resp.Status;
128 }
129 *Include_Handle = btoh(resp.Include_Handle, 2);
130 return BLE_STATUS_SUCCESS;
131 }
132
aci_gatt_add_char(uint16_t Service_Handle,uint8_t Char_UUID_Type,Char_UUID_t * Char_UUID,uint16_t Char_Value_Length,uint8_t Char_Properties,uint8_t Security_Permissions,uint8_t GATT_Evt_Mask,uint8_t Enc_Key_Size,uint8_t Is_Variable,uint16_t * Char_Handle)133 tBleStatus aci_gatt_add_char(uint16_t Service_Handle,
134 uint8_t Char_UUID_Type,
135 Char_UUID_t *Char_UUID,
136 uint16_t Char_Value_Length,
137 uint8_t Char_Properties,
138 uint8_t Security_Permissions,
139 uint8_t GATT_Evt_Mask,
140 uint8_t Enc_Key_Size,
141 uint8_t Is_Variable,
142 uint16_t *Char_Handle)
143 {
144 struct hci_request rq;
145 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
146 aci_gatt_add_char_cp0 *cp0 = (aci_gatt_add_char_cp0*)(cmd_buffer);
147 aci_gatt_add_char_cp1 *cp1 = (aci_gatt_add_char_cp1*)(cmd_buffer + 2 + 1 + (Char_UUID_Type == 1 ? 2 : (Char_UUID_Type == 2 ? 16 : 0)));
148 aci_gatt_add_char_rp0 resp;
149 Osal_MemSet(&resp, 0, sizeof(resp));
150 int index_input = 0;
151 cp0->Service_Handle = htob(Service_Handle, 2);
152 index_input += 2;
153 cp0->Char_UUID_Type = htob(Char_UUID_Type, 1);
154 index_input += 1;
155 /* var_len_data input */
156 {
157 uint8_t size;
158 switch (Char_UUID_Type) {
159 case 1: size = 2; break;
160 case 2: size = 16; break;
161 default: return BLE_STATUS_ERROR;
162 }
163 Osal_MemCpy((void *) &cp0->Char_UUID, (const void *) Char_UUID, size);
164 index_input += size;
165 {
166 cp1->Char_Value_Length = htob(Char_Value_Length, 2);
167 }
168 index_input += 2;
169 {
170 cp1->Char_Properties = htob(Char_Properties, 1);
171 }
172 index_input += 1;
173 {
174 cp1->Security_Permissions = htob(Security_Permissions, 1);
175 }
176 index_input += 1;
177 {
178 cp1->GATT_Evt_Mask = htob(GATT_Evt_Mask, 1);
179 }
180 index_input += 1;
181 {
182 cp1->Enc_Key_Size = htob(Enc_Key_Size, 1);
183 }
184 index_input += 1;
185 {
186 cp1->Is_Variable = htob(Is_Variable, 1);
187 }
188 index_input += 1;
189 }
190 Osal_MemSet(&rq, 0, sizeof(rq));
191 rq.ogf = 0x3f;
192 rq.ocf = 0x104;
193 rq.cparam = cmd_buffer;
194 rq.clen = index_input;
195 rq.rparam = &resp;
196 rq.rlen = sizeof(resp);
197 if (hci_send_req(&rq, FALSE) < 0)
198 return BLE_STATUS_TIMEOUT;
199 if (resp.Status)
200 {
201 return resp.Status;
202 }
203 *Char_Handle = btoh(resp.Char_Handle, 2);
204 return BLE_STATUS_SUCCESS;
205 }
206
aci_gatt_add_char_desc(uint16_t Service_Handle,uint16_t Char_Handle,uint8_t Char_Desc_Uuid_Type,Char_Desc_Uuid_t * Char_Desc_Uuid,uint8_t Char_Desc_Value_Max_Len,uint8_t Char_Desc_Value_Length,uint8_t Char_Desc_Value[],uint8_t Security_Permissions,uint8_t Access_Permissions,uint8_t GATT_Evt_Mask,uint8_t Enc_Key_Size,uint8_t Is_Variable,uint16_t * Char_Desc_Handle)207 tBleStatus aci_gatt_add_char_desc(uint16_t Service_Handle,
208 uint16_t Char_Handle,
209 uint8_t Char_Desc_Uuid_Type,
210 Char_Desc_Uuid_t *Char_Desc_Uuid,
211 uint8_t Char_Desc_Value_Max_Len,
212 uint8_t Char_Desc_Value_Length,
213 uint8_t Char_Desc_Value[],
214 uint8_t Security_Permissions,
215 uint8_t Access_Permissions,
216 uint8_t GATT_Evt_Mask,
217 uint8_t Enc_Key_Size,
218 uint8_t Is_Variable,
219 uint16_t *Char_Desc_Handle)
220 {
221 struct hci_request rq;
222 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
223 aci_gatt_add_char_desc_cp0 *cp0 = (aci_gatt_add_char_desc_cp0*)(cmd_buffer);
224 aci_gatt_add_char_desc_cp1 *cp1 = (aci_gatt_add_char_desc_cp1*)(cmd_buffer + 2 + 2 + 1 + (Char_Desc_Uuid_Type == 1 ? 2 : (Char_Desc_Uuid_Type == 2 ? 16 : 0)));
225 aci_gatt_add_char_desc_cp2 *cp2 = (aci_gatt_add_char_desc_cp2*)(cmd_buffer + 2 + 2 + 1 + (Char_Desc_Uuid_Type == 1 ? 2 : (Char_Desc_Uuid_Type == 2 ? 16 : 0)) + 1 + 1 + Char_Desc_Value_Length * (sizeof(uint8_t)));
226 aci_gatt_add_char_desc_rp0 resp;
227 Osal_MemSet(&resp, 0, sizeof(resp));
228 int index_input = 0;
229 cp0->Service_Handle = htob(Service_Handle, 2);
230 index_input += 2;
231 cp0->Char_Handle = htob(Char_Handle, 2);
232 index_input += 2;
233 cp0->Char_Desc_Uuid_Type = htob(Char_Desc_Uuid_Type, 1);
234 index_input += 1;
235 /* var_len_data input */
236 {
237 uint8_t size;
238 switch (Char_Desc_Uuid_Type) {
239 case 1: size = 2; break;
240 case 2: size = 16; break;
241 default: return BLE_STATUS_ERROR;
242 }
243 Osal_MemCpy((void *) &cp0->Char_Desc_Uuid, (const void *) Char_Desc_Uuid, size);
244 index_input += size;
245 {
246 cp1->Char_Desc_Value_Max_Len = htob(Char_Desc_Value_Max_Len, 1);
247 }
248 index_input += 1;
249 {
250 cp1->Char_Desc_Value_Length = htob(Char_Desc_Value_Length, 1);
251 }
252 index_input += 1;
253 Osal_MemCpy((void *) &cp1->Char_Desc_Value, (const void *) Char_Desc_Value, Char_Desc_Value_Length);
254 index_input += Char_Desc_Value_Length;
255 {
256 cp2->Security_Permissions = htob(Security_Permissions, 1);
257 }
258 index_input += 1;
259 {
260 cp2->Access_Permissions = htob(Access_Permissions, 1);
261 }
262 index_input += 1;
263 {
264 cp2->GATT_Evt_Mask = htob(GATT_Evt_Mask, 1);
265 }
266 index_input += 1;
267 {
268 cp2->Enc_Key_Size = htob(Enc_Key_Size, 1);
269 }
270 index_input += 1;
271 {
272 cp2->Is_Variable = htob(Is_Variable, 1);
273 }
274 index_input += 1;
275 }
276 Osal_MemSet(&rq, 0, sizeof(rq));
277 rq.ogf = 0x3f;
278 rq.ocf = 0x105;
279 rq.cparam = cmd_buffer;
280 rq.clen = index_input;
281 rq.rparam = &resp;
282 rq.rlen = sizeof(resp);
283 if (hci_send_req(&rq, FALSE) < 0)
284 return BLE_STATUS_TIMEOUT;
285 if (resp.Status)
286 {
287 return resp.Status;
288 }
289 *Char_Desc_Handle = btoh(resp.Char_Desc_Handle, 2);
290 return BLE_STATUS_SUCCESS;
291 }
292
aci_gatt_update_char_value(uint16_t Service_Handle,uint16_t Char_Handle,uint8_t Val_Offset,uint8_t Char_Value_Length,uint8_t Char_Value[])293 tBleStatus aci_gatt_update_char_value(uint16_t Service_Handle,
294 uint16_t Char_Handle,
295 uint8_t Val_Offset,
296 uint8_t Char_Value_Length,
297 uint8_t Char_Value[])
298 {
299 struct hci_request rq;
300 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
301 aci_gatt_update_char_value_cp0 *cp0 = (aci_gatt_update_char_value_cp0*)(cmd_buffer);
302 tBleStatus status = 0;
303 int index_input = 0;
304 cp0->Service_Handle = htob(Service_Handle, 2);
305 index_input += 2;
306 cp0->Char_Handle = htob(Char_Handle, 2);
307 index_input += 2;
308 cp0->Val_Offset = htob(Val_Offset, 1);
309 index_input += 1;
310 cp0->Char_Value_Length = htob(Char_Value_Length, 1);
311 index_input += 1;
312 Osal_MemCpy((void *) &cp0->Char_Value, (const void *) Char_Value, Char_Value_Length);
313 index_input += Char_Value_Length;
314 Osal_MemSet(&rq, 0, sizeof(rq));
315 rq.ogf = 0x3f;
316 rq.ocf = 0x106;
317 rq.cparam = cmd_buffer;
318 rq.clen = index_input;
319 rq.rparam = &status;
320 rq.rlen = 1;
321 if (hci_send_req(&rq, FALSE) < 0)
322 return BLE_STATUS_TIMEOUT;
323 if (status)
324 {
325 return status;
326 }
327 return BLE_STATUS_SUCCESS;
328 }
329
aci_gatt_del_char(uint16_t Serv_Handle,uint16_t Char_Handle)330 tBleStatus aci_gatt_del_char(uint16_t Serv_Handle,
331 uint16_t Char_Handle)
332 {
333 struct hci_request rq;
334 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
335 aci_gatt_del_char_cp0 *cp0 = (aci_gatt_del_char_cp0*)(cmd_buffer);
336 tBleStatus status = 0;
337 int index_input = 0;
338 cp0->Serv_Handle = htob(Serv_Handle, 2);
339 index_input += 2;
340 cp0->Char_Handle = htob(Char_Handle, 2);
341 index_input += 2;
342 Osal_MemSet(&rq, 0, sizeof(rq));
343 rq.ogf = 0x3f;
344 rq.ocf = 0x107;
345 rq.cparam = cmd_buffer;
346 rq.clen = index_input;
347 rq.rparam = &status;
348 rq.rlen = 1;
349 if (hci_send_req(&rq, FALSE) < 0)
350 return BLE_STATUS_TIMEOUT;
351 if (status)
352 {
353 return status;
354 }
355 return BLE_STATUS_SUCCESS;
356 }
357
aci_gatt_del_service(uint16_t Serv_Handle)358 tBleStatus aci_gatt_del_service(uint16_t Serv_Handle)
359 {
360 struct hci_request rq;
361 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
362 aci_gatt_del_service_cp0 *cp0 = (aci_gatt_del_service_cp0*)(cmd_buffer);
363 tBleStatus status = 0;
364 int index_input = 0;
365 cp0->Serv_Handle = htob(Serv_Handle, 2);
366 index_input += 2;
367 Osal_MemSet(&rq, 0, sizeof(rq));
368 rq.ogf = 0x3f;
369 rq.ocf = 0x108;
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
aci_gatt_del_include_service(uint16_t Serv_Handle,uint16_t Include_Handle)383 tBleStatus aci_gatt_del_include_service(uint16_t Serv_Handle,
384 uint16_t Include_Handle)
385 {
386 struct hci_request rq;
387 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
388 aci_gatt_del_include_service_cp0 *cp0 = (aci_gatt_del_include_service_cp0*)(cmd_buffer);
389 tBleStatus status = 0;
390 int index_input = 0;
391 cp0->Serv_Handle = htob(Serv_Handle, 2);
392 index_input += 2;
393 cp0->Include_Handle = htob(Include_Handle, 2);
394 index_input += 2;
395 Osal_MemSet(&rq, 0, sizeof(rq));
396 rq.ogf = 0x3f;
397 rq.ocf = 0x109;
398 rq.cparam = cmd_buffer;
399 rq.clen = index_input;
400 rq.rparam = &status;
401 rq.rlen = 1;
402 if (hci_send_req(&rq, FALSE) < 0)
403 return BLE_STATUS_TIMEOUT;
404 if (status)
405 {
406 return status;
407 }
408 return BLE_STATUS_SUCCESS;
409 }
410
aci_gatt_set_event_mask(uint32_t GATT_Evt_Mask)411 tBleStatus aci_gatt_set_event_mask(uint32_t GATT_Evt_Mask)
412 {
413 struct hci_request rq;
414 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
415 aci_gatt_set_event_mask_cp0 *cp0 = (aci_gatt_set_event_mask_cp0*)(cmd_buffer);
416 tBleStatus status = 0;
417 int index_input = 0;
418 cp0->GATT_Evt_Mask = htob(GATT_Evt_Mask, 4);
419 index_input += 4;
420 Osal_MemSet(&rq, 0, sizeof(rq));
421 rq.ogf = 0x3f;
422 rq.ocf = 0x10a;
423 rq.cparam = cmd_buffer;
424 rq.clen = index_input;
425 rq.rparam = &status;
426 rq.rlen = 1;
427 if (hci_send_req(&rq, FALSE) < 0)
428 return BLE_STATUS_TIMEOUT;
429 if (status)
430 {
431 return status;
432 }
433 return BLE_STATUS_SUCCESS;
434 }
435
aci_gatt_exchange_config(uint16_t Connection_Handle)436 tBleStatus aci_gatt_exchange_config(uint16_t Connection_Handle)
437 {
438 struct hci_request rq;
439 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
440 aci_gatt_exchange_config_cp0 *cp0 = (aci_gatt_exchange_config_cp0*)(cmd_buffer);
441 tBleStatus status = 0;
442 int index_input = 0;
443 cp0->Connection_Handle = htob(Connection_Handle, 2);
444 index_input += 2;
445 Osal_MemSet(&rq, 0, sizeof(rq));
446 rq.ogf = 0x3f;
447 rq.ocf = 0x10b;
448 rq.event = 0x0F;
449 rq.cparam = cmd_buffer;
450 rq.clen = index_input;
451 rq.rparam = &status;
452 rq.rlen = 1;
453 if (hci_send_req(&rq, FALSE) < 0)
454 return BLE_STATUS_TIMEOUT;
455 if (status)
456 {
457 return status;
458 }
459 return BLE_STATUS_SUCCESS;
460 }
461
aci_att_find_info_req(uint16_t Connection_Handle,uint16_t Start_Handle,uint16_t End_Handle)462 tBleStatus aci_att_find_info_req(uint16_t Connection_Handle,
463 uint16_t Start_Handle,
464 uint16_t End_Handle)
465 {
466 struct hci_request rq;
467 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
468 aci_att_find_info_req_cp0 *cp0 = (aci_att_find_info_req_cp0*)(cmd_buffer);
469 tBleStatus status = 0;
470 int index_input = 0;
471 cp0->Connection_Handle = htob(Connection_Handle, 2);
472 index_input += 2;
473 cp0->Start_Handle = htob(Start_Handle, 2);
474 index_input += 2;
475 cp0->End_Handle = htob(End_Handle, 2);
476 index_input += 2;
477 Osal_MemSet(&rq, 0, sizeof(rq));
478 rq.ogf = 0x3f;
479 rq.ocf = 0x10c;
480 rq.event = 0x0F;
481 rq.cparam = cmd_buffer;
482 rq.clen = index_input;
483 rq.rparam = &status;
484 rq.rlen = 1;
485 if (hci_send_req(&rq, FALSE) < 0)
486 return BLE_STATUS_TIMEOUT;
487 if (status)
488 {
489 return status;
490 }
491 return BLE_STATUS_SUCCESS;
492 }
493
aci_att_find_by_type_value_req(uint16_t Connection_Handle,uint16_t Start_Handle,uint16_t End_Handle,uint16_t UUID,uint8_t Attribute_Val_Length,uint8_t Attribute_Val[])494 tBleStatus aci_att_find_by_type_value_req(uint16_t Connection_Handle,
495 uint16_t Start_Handle,
496 uint16_t End_Handle,
497 uint16_t UUID,
498 uint8_t Attribute_Val_Length,
499 uint8_t Attribute_Val[])
500 {
501 struct hci_request rq;
502 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
503 aci_att_find_by_type_value_req_cp0 *cp0 = (aci_att_find_by_type_value_req_cp0*)(cmd_buffer);
504 tBleStatus status = 0;
505 int index_input = 0;
506 cp0->Connection_Handle = htob(Connection_Handle, 2);
507 index_input += 2;
508 cp0->Start_Handle = htob(Start_Handle, 2);
509 index_input += 2;
510 cp0->End_Handle = htob(End_Handle, 2);
511 index_input += 2;
512 cp0->UUID = htob(UUID, 2);
513 index_input += 2;
514 cp0->Attribute_Val_Length = htob(Attribute_Val_Length, 1);
515 index_input += 1;
516 Osal_MemCpy((void *) &cp0->Attribute_Val, (const void *) Attribute_Val, Attribute_Val_Length);
517 index_input += Attribute_Val_Length;
518 Osal_MemSet(&rq, 0, sizeof(rq));
519 rq.ogf = 0x3f;
520 rq.ocf = 0x10d;
521 rq.event = 0x0F;
522 rq.cparam = cmd_buffer;
523 rq.clen = index_input;
524 rq.rparam = &status;
525 rq.rlen = 1;
526 if (hci_send_req(&rq, FALSE) < 0)
527 return BLE_STATUS_TIMEOUT;
528 if (status)
529 {
530 return status;
531 }
532 return BLE_STATUS_SUCCESS;
533 }
534
aci_att_read_by_type_req(uint16_t Connection_Handle,uint16_t Start_Handle,uint16_t End_Handle,uint8_t UUID_Type,UUID_t * UUID)535 tBleStatus aci_att_read_by_type_req(uint16_t Connection_Handle,
536 uint16_t Start_Handle,
537 uint16_t End_Handle,
538 uint8_t UUID_Type,
539 UUID_t *UUID)
540 {
541 struct hci_request rq;
542 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
543 aci_att_read_by_type_req_cp0 *cp0 = (aci_att_read_by_type_req_cp0*)(cmd_buffer);
544 tBleStatus status = 0;
545 int index_input = 0;
546 int uuid_size = (UUID_Type == 2) ? 16 : 2;
547 cp0->Connection_Handle = htob(Connection_Handle, 2);
548 index_input += 2;
549 cp0->Start_Handle = htob(Start_Handle, 2);
550 index_input += 2;
551 cp0->End_Handle = htob(End_Handle, 2);
552 index_input += 2;
553 cp0->UUID_Type = htob(UUID_Type, 1);
554 index_input += 1;
555 Osal_MemCpy((void *) &cp0->UUID, (const void *) UUID, uuid_size);
556 index_input += uuid_size;
557 Osal_MemSet(&rq, 0, sizeof(rq));
558 rq.ogf = 0x3f;
559 rq.ocf = 0x10e;
560 rq.event = 0x0F;
561 rq.cparam = cmd_buffer;
562 rq.clen = index_input;
563 rq.rparam = &status;
564 rq.rlen = 1;
565 if (hci_send_req(&rq, FALSE) < 0)
566 return BLE_STATUS_TIMEOUT;
567 if (status)
568 {
569 return status;
570 }
571 return BLE_STATUS_SUCCESS;
572 }
573
aci_att_read_by_group_type_req(uint16_t Connection_Handle,uint16_t Start_Handle,uint16_t End_Handle,uint8_t UUID_Type,UUID_t * UUID)574 tBleStatus aci_att_read_by_group_type_req(uint16_t Connection_Handle,
575 uint16_t Start_Handle,
576 uint16_t End_Handle,
577 uint8_t UUID_Type,
578 UUID_t *UUID)
579 {
580 struct hci_request rq;
581 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
582 aci_att_read_by_group_type_req_cp0 *cp0 = (aci_att_read_by_group_type_req_cp0*)(cmd_buffer);
583 tBleStatus status = 0;
584 int index_input = 0;
585 int uuid_size = (UUID_Type == 2) ? 16 : 2;
586 cp0->Connection_Handle = htob(Connection_Handle, 2);
587 index_input += 2;
588 cp0->Start_Handle = htob(Start_Handle, 2);
589 index_input += 2;
590 cp0->End_Handle = htob(End_Handle, 2);
591 index_input += 2;
592 cp0->UUID_Type = htob(UUID_Type, 1);
593 index_input += 1;
594 Osal_MemCpy((void *) &cp0->UUID, (const void *) UUID, uuid_size);
595 index_input += uuid_size;
596 Osal_MemSet(&rq, 0, sizeof(rq));
597 rq.ogf = 0x3f;
598 rq.ocf = 0x10f;
599 rq.event = 0x0F;
600 rq.cparam = cmd_buffer;
601 rq.clen = index_input;
602 rq.rparam = &status;
603 rq.rlen = 1;
604 if (hci_send_req(&rq, FALSE) < 0)
605 return BLE_STATUS_TIMEOUT;
606 if (status)
607 {
608 return status;
609 }
610 return BLE_STATUS_SUCCESS;
611 }
612
aci_att_prepare_write_req(uint16_t Connection_Handle,uint16_t Attr_Handle,uint16_t Val_Offset,uint8_t Attribute_Val_Length,uint8_t Attribute_Val[])613 tBleStatus aci_att_prepare_write_req(uint16_t Connection_Handle,
614 uint16_t Attr_Handle,
615 uint16_t Val_Offset,
616 uint8_t Attribute_Val_Length,
617 uint8_t Attribute_Val[])
618 {
619 struct hci_request rq;
620 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
621 aci_att_prepare_write_req_cp0 *cp0 = (aci_att_prepare_write_req_cp0*)(cmd_buffer);
622 tBleStatus status = 0;
623 int index_input = 0;
624 cp0->Connection_Handle = htob(Connection_Handle, 2);
625 index_input += 2;
626 cp0->Attr_Handle = htob(Attr_Handle, 2);
627 index_input += 2;
628 cp0->Val_Offset = htob(Val_Offset, 2);
629 index_input += 2;
630 cp0->Attribute_Val_Length = htob(Attribute_Val_Length, 1);
631 index_input += 1;
632 Osal_MemCpy((void *) &cp0->Attribute_Val, (const void *) Attribute_Val, Attribute_Val_Length);
633 index_input += Attribute_Val_Length;
634 Osal_MemSet(&rq, 0, sizeof(rq));
635 rq.ogf = 0x3f;
636 rq.ocf = 0x110;
637 rq.event = 0x0F;
638 rq.cparam = cmd_buffer;
639 rq.clen = index_input;
640 rq.rparam = &status;
641 rq.rlen = 1;
642 if (hci_send_req(&rq, FALSE) < 0)
643 return BLE_STATUS_TIMEOUT;
644 if (status)
645 {
646 return status;
647 }
648 return BLE_STATUS_SUCCESS;
649 }
650
aci_att_execute_write_req(uint16_t Connection_Handle,uint8_t Execute)651 tBleStatus aci_att_execute_write_req(uint16_t Connection_Handle,
652 uint8_t Execute)
653 {
654 struct hci_request rq;
655 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
656 aci_att_execute_write_req_cp0 *cp0 = (aci_att_execute_write_req_cp0*)(cmd_buffer);
657 tBleStatus status = 0;
658 int index_input = 0;
659 cp0->Connection_Handle = htob(Connection_Handle, 2);
660 index_input += 2;
661 cp0->Execute = htob(Execute, 1);
662 index_input += 1;
663 Osal_MemSet(&rq, 0, sizeof(rq));
664 rq.ogf = 0x3f;
665 rq.ocf = 0x111;
666 rq.event = 0x0F;
667 rq.cparam = cmd_buffer;
668 rq.clen = index_input;
669 rq.rparam = &status;
670 rq.rlen = 1;
671 if (hci_send_req(&rq, FALSE) < 0)
672 return BLE_STATUS_TIMEOUT;
673 if (status)
674 {
675 return status;
676 }
677 return BLE_STATUS_SUCCESS;
678 }
679
aci_gatt_disc_all_primary_services(uint16_t Connection_Handle)680 tBleStatus aci_gatt_disc_all_primary_services(uint16_t Connection_Handle)
681 {
682 struct hci_request rq;
683 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
684 aci_gatt_disc_all_primary_services_cp0 *cp0 = (aci_gatt_disc_all_primary_services_cp0*)(cmd_buffer);
685 tBleStatus status = 0;
686 int index_input = 0;
687 cp0->Connection_Handle = htob(Connection_Handle, 2);
688 index_input += 2;
689 Osal_MemSet(&rq, 0, sizeof(rq));
690 rq.ogf = 0x3f;
691 rq.ocf = 0x112;
692 rq.event = 0x0F;
693 rq.cparam = cmd_buffer;
694 rq.clen = index_input;
695 rq.rparam = &status;
696 rq.rlen = 1;
697 if (hci_send_req(&rq, FALSE) < 0)
698 return BLE_STATUS_TIMEOUT;
699 if (status)
700 {
701 return status;
702 }
703 return BLE_STATUS_SUCCESS;
704 }
705
aci_gatt_disc_primary_service_by_uuid(uint16_t Connection_Handle,uint8_t UUID_Type,UUID_t * UUID)706 tBleStatus aci_gatt_disc_primary_service_by_uuid(uint16_t Connection_Handle,
707 uint8_t UUID_Type,
708 UUID_t *UUID)
709 {
710 struct hci_request rq;
711 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
712 aci_gatt_disc_primary_service_by_uuid_cp0 *cp0 = (aci_gatt_disc_primary_service_by_uuid_cp0*)(cmd_buffer);
713 tBleStatus status = 0;
714 int index_input = 0;
715 int uuid_size = (UUID_Type == 2) ? 16 : 2;
716 cp0->Connection_Handle = htob(Connection_Handle, 2);
717 index_input += 2;
718 cp0->UUID_Type = htob(UUID_Type, 1);
719 index_input += 1;
720 Osal_MemCpy((void *) &cp0->UUID, (const void *) UUID, uuid_size);
721 index_input += uuid_size;
722 Osal_MemSet(&rq, 0, sizeof(rq));
723 rq.ogf = 0x3f;
724 rq.ocf = 0x113;
725 rq.event = 0x0F;
726 rq.cparam = cmd_buffer;
727 rq.clen = index_input;
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
aci_gatt_find_included_services(uint16_t Connection_Handle,uint16_t Start_Handle,uint16_t End_Handle)739 tBleStatus aci_gatt_find_included_services(uint16_t Connection_Handle,
740 uint16_t Start_Handle,
741 uint16_t End_Handle)
742 {
743 struct hci_request rq;
744 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
745 aci_gatt_find_included_services_cp0 *cp0 = (aci_gatt_find_included_services_cp0*)(cmd_buffer);
746 tBleStatus status = 0;
747 int index_input = 0;
748 cp0->Connection_Handle = htob(Connection_Handle, 2);
749 index_input += 2;
750 cp0->Start_Handle = htob(Start_Handle, 2);
751 index_input += 2;
752 cp0->End_Handle = htob(End_Handle, 2);
753 index_input += 2;
754 Osal_MemSet(&rq, 0, sizeof(rq));
755 rq.ogf = 0x3f;
756 rq.ocf = 0x114;
757 rq.event = 0x0F;
758 rq.cparam = cmd_buffer;
759 rq.clen = index_input;
760 rq.rparam = &status;
761 rq.rlen = 1;
762 if (hci_send_req(&rq, FALSE) < 0)
763 return BLE_STATUS_TIMEOUT;
764 if (status)
765 {
766 return status;
767 }
768 return BLE_STATUS_SUCCESS;
769 }
770
aci_gatt_disc_all_char_of_service(uint16_t Connection_Handle,uint16_t Start_Handle,uint16_t End_Handle)771 tBleStatus aci_gatt_disc_all_char_of_service(uint16_t Connection_Handle,
772 uint16_t Start_Handle,
773 uint16_t End_Handle)
774 {
775 struct hci_request rq;
776 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
777 aci_gatt_disc_all_char_of_service_cp0 *cp0 = (aci_gatt_disc_all_char_of_service_cp0*)(cmd_buffer);
778 tBleStatus status = 0;
779 int index_input = 0;
780 cp0->Connection_Handle = htob(Connection_Handle, 2);
781 index_input += 2;
782 cp0->Start_Handle = htob(Start_Handle, 2);
783 index_input += 2;
784 cp0->End_Handle = htob(End_Handle, 2);
785 index_input += 2;
786 Osal_MemSet(&rq, 0, sizeof(rq));
787 rq.ogf = 0x3f;
788 rq.ocf = 0x115;
789 rq.event = 0x0F;
790 rq.cparam = cmd_buffer;
791 rq.clen = index_input;
792 rq.rparam = &status;
793 rq.rlen = 1;
794 if (hci_send_req(&rq, FALSE) < 0)
795 return BLE_STATUS_TIMEOUT;
796 if (status)
797 {
798 return status;
799 }
800 return BLE_STATUS_SUCCESS;
801 }
802
aci_gatt_disc_char_by_uuid(uint16_t Connection_Handle,uint16_t Start_Handle,uint16_t End_Handle,uint8_t UUID_Type,UUID_t * UUID)803 tBleStatus aci_gatt_disc_char_by_uuid(uint16_t Connection_Handle,
804 uint16_t Start_Handle,
805 uint16_t End_Handle,
806 uint8_t UUID_Type,
807 UUID_t *UUID)
808 {
809 struct hci_request rq;
810 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
811 aci_gatt_disc_char_by_uuid_cp0 *cp0 = (aci_gatt_disc_char_by_uuid_cp0*)(cmd_buffer);
812 tBleStatus status = 0;
813 int index_input = 0;
814 int uuid_size = (UUID_Type == 2) ? 16 : 2;
815 cp0->Connection_Handle = htob(Connection_Handle, 2);
816 index_input += 2;
817 cp0->Start_Handle = htob(Start_Handle, 2);
818 index_input += 2;
819 cp0->End_Handle = htob(End_Handle, 2);
820 index_input += 2;
821 cp0->UUID_Type = htob(UUID_Type, 1);
822 index_input += 1;
823 Osal_MemCpy((void *) &cp0->UUID, (const void *) UUID, uuid_size);
824 index_input += uuid_size;
825 Osal_MemSet(&rq, 0, sizeof(rq));
826 rq.ogf = 0x3f;
827 rq.ocf = 0x116;
828 rq.event = 0x0F;
829 rq.cparam = cmd_buffer;
830 rq.clen = index_input;
831 rq.rparam = &status;
832 rq.rlen = 1;
833 if (hci_send_req(&rq, FALSE) < 0)
834 return BLE_STATUS_TIMEOUT;
835 if (status)
836 {
837 return status;
838 }
839 return BLE_STATUS_SUCCESS;
840 }
841
aci_gatt_disc_all_char_desc(uint16_t Connection_Handle,uint16_t Char_Handle,uint16_t End_Handle)842 tBleStatus aci_gatt_disc_all_char_desc(uint16_t Connection_Handle,
843 uint16_t Char_Handle,
844 uint16_t End_Handle)
845 {
846 struct hci_request rq;
847 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
848 aci_gatt_disc_all_char_desc_cp0 *cp0 = (aci_gatt_disc_all_char_desc_cp0*)(cmd_buffer);
849 tBleStatus status = 0;
850 int index_input = 0;
851 cp0->Connection_Handle = htob(Connection_Handle, 2);
852 index_input += 2;
853 cp0->Char_Handle = htob(Char_Handle, 2);
854 index_input += 2;
855 cp0->End_Handle = htob(End_Handle, 2);
856 index_input += 2;
857 Osal_MemSet(&rq, 0, sizeof(rq));
858 rq.ogf = 0x3f;
859 rq.ocf = 0x117;
860 rq.event = 0x0F;
861 rq.cparam = cmd_buffer;
862 rq.clen = index_input;
863 rq.rparam = &status;
864 rq.rlen = 1;
865 if (hci_send_req(&rq, FALSE) < 0)
866 return BLE_STATUS_TIMEOUT;
867 if (status)
868 {
869 return status;
870 }
871 return BLE_STATUS_SUCCESS;
872 }
873
aci_gatt_read_char_value(uint16_t Connection_Handle,uint16_t Attr_Handle)874 tBleStatus aci_gatt_read_char_value(uint16_t Connection_Handle,
875 uint16_t Attr_Handle)
876 {
877 struct hci_request rq;
878 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
879 aci_gatt_read_char_value_cp0 *cp0 = (aci_gatt_read_char_value_cp0*)(cmd_buffer);
880 tBleStatus status = 0;
881 int index_input = 0;
882 cp0->Connection_Handle = htob(Connection_Handle, 2);
883 index_input += 2;
884 cp0->Attr_Handle = htob(Attr_Handle, 2);
885 index_input += 2;
886 Osal_MemSet(&rq, 0, sizeof(rq));
887 rq.ogf = 0x3f;
888 rq.ocf = 0x118;
889 rq.event = 0x0F;
890 rq.cparam = cmd_buffer;
891 rq.clen = index_input;
892 rq.rparam = &status;
893 rq.rlen = 1;
894 if (hci_send_req(&rq, FALSE) < 0)
895 return BLE_STATUS_TIMEOUT;
896 if (status)
897 {
898 return status;
899 }
900 return BLE_STATUS_SUCCESS;
901 }
902
aci_gatt_read_using_char_uuid(uint16_t Connection_Handle,uint16_t Start_Handle,uint16_t End_Handle,uint8_t UUID_Type,UUID_t * UUID)903 tBleStatus aci_gatt_read_using_char_uuid(uint16_t Connection_Handle,
904 uint16_t Start_Handle,
905 uint16_t End_Handle,
906 uint8_t UUID_Type,
907 UUID_t *UUID)
908 {
909 struct hci_request rq;
910 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
911 aci_gatt_read_using_char_uuid_cp0 *cp0 = (aci_gatt_read_using_char_uuid_cp0*)(cmd_buffer);
912 tBleStatus status = 0;
913 int index_input = 0;
914 int uuid_size = (UUID_Type == 2) ? 16 : 2;
915 cp0->Connection_Handle = htob(Connection_Handle, 2);
916 index_input += 2;
917 cp0->Start_Handle = htob(Start_Handle, 2);
918 index_input += 2;
919 cp0->End_Handle = htob(End_Handle, 2);
920 index_input += 2;
921 cp0->UUID_Type = htob(UUID_Type, 1);
922 index_input += 1;
923 Osal_MemCpy((void *) &cp0->UUID, (const void *) UUID, uuid_size);
924 index_input += uuid_size;
925 Osal_MemSet(&rq, 0, sizeof(rq));
926 rq.ogf = 0x3f;
927 rq.ocf = 0x119;
928 rq.event = 0x0F;
929 rq.cparam = cmd_buffer;
930 rq.clen = index_input;
931 rq.rparam = &status;
932 rq.rlen = 1;
933 if (hci_send_req(&rq, FALSE) < 0)
934 return BLE_STATUS_TIMEOUT;
935 if (status)
936 {
937 return status;
938 }
939 return BLE_STATUS_SUCCESS;
940 }
941
aci_gatt_read_long_char_value(uint16_t Connection_Handle,uint16_t Attr_Handle,uint16_t Val_Offset)942 tBleStatus aci_gatt_read_long_char_value(uint16_t Connection_Handle,
943 uint16_t Attr_Handle,
944 uint16_t Val_Offset)
945 {
946 struct hci_request rq;
947 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
948 aci_gatt_read_long_char_value_cp0 *cp0 = (aci_gatt_read_long_char_value_cp0*)(cmd_buffer);
949 tBleStatus status = 0;
950 int index_input = 0;
951 cp0->Connection_Handle = htob(Connection_Handle, 2);
952 index_input += 2;
953 cp0->Attr_Handle = htob(Attr_Handle, 2);
954 index_input += 2;
955 cp0->Val_Offset = htob(Val_Offset, 2);
956 index_input += 2;
957 Osal_MemSet(&rq, 0, sizeof(rq));
958 rq.ogf = 0x3f;
959 rq.ocf = 0x11a;
960 rq.event = 0x0F;
961 rq.cparam = cmd_buffer;
962 rq.clen = index_input;
963 rq.rparam = &status;
964 rq.rlen = 1;
965 if (hci_send_req(&rq, FALSE) < 0)
966 return BLE_STATUS_TIMEOUT;
967 if (status)
968 {
969 return status;
970 }
971 return BLE_STATUS_SUCCESS;
972 }
973
aci_gatt_read_multiple_char_value(uint16_t Connection_Handle,uint8_t Number_of_Handles,Handle_Entry_t Handle_Entry[])974 tBleStatus aci_gatt_read_multiple_char_value(uint16_t Connection_Handle,
975 uint8_t Number_of_Handles,
976 Handle_Entry_t Handle_Entry[])
977 {
978 struct hci_request rq;
979 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
980 aci_gatt_read_multiple_char_value_cp0 *cp0 = (aci_gatt_read_multiple_char_value_cp0*)(cmd_buffer);
981 tBleStatus status = 0;
982 int index_input = 0;
983 cp0->Connection_Handle = htob(Connection_Handle, 2);
984 index_input += 2;
985 cp0->Number_of_Handles = htob(Number_of_Handles, 1);
986 index_input += 1;
987 Osal_MemCpy((void*) &cp0->Handle_Entry, (const void *) Handle_Entry, Number_of_Handles * (sizeof(Handle_Entry_t)));
988 index_input += Number_of_Handles * (sizeof(Handle_Entry_t));
989 Osal_MemSet(&rq, 0, sizeof(rq));
990 rq.ogf = 0x3f;
991 rq.ocf = 0x11b;
992 rq.event = 0x0F;
993 rq.cparam = cmd_buffer;
994 rq.clen = index_input;
995 rq.rparam = &status;
996 rq.rlen = 1;
997 if (hci_send_req(&rq, FALSE) < 0)
998 return BLE_STATUS_TIMEOUT;
999 if (status)
1000 {
1001 return status;
1002 }
1003 return BLE_STATUS_SUCCESS;
1004 }
1005
aci_gatt_write_char_value(uint16_t Connection_Handle,uint16_t Attr_Handle,uint8_t Attribute_Val_Length,uint8_t Attribute_Val[])1006 tBleStatus aci_gatt_write_char_value(uint16_t Connection_Handle,
1007 uint16_t Attr_Handle,
1008 uint8_t Attribute_Val_Length,
1009 uint8_t Attribute_Val[])
1010 {
1011 struct hci_request rq;
1012 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1013 aci_gatt_write_char_value_cp0 *cp0 = (aci_gatt_write_char_value_cp0*)(cmd_buffer);
1014 tBleStatus status = 0;
1015 int index_input = 0;
1016 cp0->Connection_Handle = htob(Connection_Handle, 2);
1017 index_input += 2;
1018 cp0->Attr_Handle = htob(Attr_Handle, 2);
1019 index_input += 2;
1020 cp0->Attribute_Val_Length = htob(Attribute_Val_Length, 1);
1021 index_input += 1;
1022 Osal_MemCpy((void *) &cp0->Attribute_Val, (const void *) Attribute_Val, Attribute_Val_Length);
1023 index_input += Attribute_Val_Length;
1024 Osal_MemSet(&rq, 0, sizeof(rq));
1025 rq.ogf = 0x3f;
1026 rq.ocf = 0x11c;
1027 rq.event = 0x0F;
1028 rq.cparam = cmd_buffer;
1029 rq.clen = index_input;
1030 rq.rparam = &status;
1031 rq.rlen = 1;
1032 if (hci_send_req(&rq, FALSE) < 0)
1033 return BLE_STATUS_TIMEOUT;
1034 if (status)
1035 {
1036 return status;
1037 }
1038 return BLE_STATUS_SUCCESS;
1039 }
1040
aci_gatt_write_long_char_value(uint16_t Connection_Handle,uint16_t Attr_Handle,uint16_t Val_Offset,uint8_t Attribute_Val_Length,uint8_t Attribute_Val[])1041 tBleStatus aci_gatt_write_long_char_value(uint16_t Connection_Handle,
1042 uint16_t Attr_Handle,
1043 uint16_t Val_Offset,
1044 uint8_t Attribute_Val_Length,
1045 uint8_t Attribute_Val[])
1046 {
1047 struct hci_request rq;
1048 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1049 aci_gatt_write_long_char_value_cp0 *cp0 = (aci_gatt_write_long_char_value_cp0*)(cmd_buffer);
1050 tBleStatus status = 0;
1051 int index_input = 0;
1052 cp0->Connection_Handle = htob(Connection_Handle, 2);
1053 index_input += 2;
1054 cp0->Attr_Handle = htob(Attr_Handle, 2);
1055 index_input += 2;
1056 cp0->Val_Offset = htob(Val_Offset, 2);
1057 index_input += 2;
1058 cp0->Attribute_Val_Length = htob(Attribute_Val_Length, 1);
1059 index_input += 1;
1060 Osal_MemCpy((void *) &cp0->Attribute_Val, (const void *) Attribute_Val, Attribute_Val_Length);
1061 index_input += Attribute_Val_Length;
1062 Osal_MemSet(&rq, 0, sizeof(rq));
1063 rq.ogf = 0x3f;
1064 rq.ocf = 0x11d;
1065 rq.event = 0x0F;
1066 rq.cparam = cmd_buffer;
1067 rq.clen = index_input;
1068 rq.rparam = &status;
1069 rq.rlen = 1;
1070 if (hci_send_req(&rq, FALSE) < 0)
1071 return BLE_STATUS_TIMEOUT;
1072 if (status)
1073 {
1074 return status;
1075 }
1076 return BLE_STATUS_SUCCESS;
1077 }
1078
aci_gatt_write_char_reliable(uint16_t Connection_Handle,uint16_t Attr_Handle,uint16_t Val_Offset,uint8_t Attribute_Val_Length,uint8_t Attribute_Val[])1079 tBleStatus aci_gatt_write_char_reliable(uint16_t Connection_Handle,
1080 uint16_t Attr_Handle,
1081 uint16_t Val_Offset,
1082 uint8_t Attribute_Val_Length,
1083 uint8_t Attribute_Val[])
1084 {
1085 struct hci_request rq;
1086 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1087 aci_gatt_write_char_reliable_cp0 *cp0 = (aci_gatt_write_char_reliable_cp0*)(cmd_buffer);
1088 tBleStatus status = 0;
1089 int index_input = 0;
1090 cp0->Connection_Handle = htob(Connection_Handle, 2);
1091 index_input += 2;
1092 cp0->Attr_Handle = htob(Attr_Handle, 2);
1093 index_input += 2;
1094 cp0->Val_Offset = htob(Val_Offset, 2);
1095 index_input += 2;
1096 cp0->Attribute_Val_Length = htob(Attribute_Val_Length, 1);
1097 index_input += 1;
1098 Osal_MemCpy((void *) &cp0->Attribute_Val, (const void *) Attribute_Val, Attribute_Val_Length);
1099 index_input += Attribute_Val_Length;
1100 Osal_MemSet(&rq, 0, sizeof(rq));
1101 rq.ogf = 0x3f;
1102 rq.ocf = 0x11e;
1103 rq.event = 0x0F;
1104 rq.cparam = cmd_buffer;
1105 rq.clen = index_input;
1106 rq.rparam = &status;
1107 rq.rlen = 1;
1108 if (hci_send_req(&rq, FALSE) < 0)
1109 return BLE_STATUS_TIMEOUT;
1110 if (status)
1111 {
1112 return status;
1113 }
1114 return BLE_STATUS_SUCCESS;
1115 }
1116
aci_gatt_write_long_char_desc(uint16_t Connection_Handle,uint16_t Attr_Handle,uint16_t Val_Offset,uint8_t Attribute_Val_Length,uint8_t Attribute_Val[])1117 tBleStatus aci_gatt_write_long_char_desc(uint16_t Connection_Handle,
1118 uint16_t Attr_Handle,
1119 uint16_t Val_Offset,
1120 uint8_t Attribute_Val_Length,
1121 uint8_t Attribute_Val[])
1122 {
1123 struct hci_request rq;
1124 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1125 aci_gatt_write_long_char_desc_cp0 *cp0 = (aci_gatt_write_long_char_desc_cp0*)(cmd_buffer);
1126 tBleStatus status = 0;
1127 int index_input = 0;
1128 cp0->Connection_Handle = htob(Connection_Handle, 2);
1129 index_input += 2;
1130 cp0->Attr_Handle = htob(Attr_Handle, 2);
1131 index_input += 2;
1132 cp0->Val_Offset = htob(Val_Offset, 2);
1133 index_input += 2;
1134 cp0->Attribute_Val_Length = htob(Attribute_Val_Length, 1);
1135 index_input += 1;
1136 Osal_MemCpy((void *) &cp0->Attribute_Val, (const void *) Attribute_Val, Attribute_Val_Length);
1137 index_input += Attribute_Val_Length;
1138 Osal_MemSet(&rq, 0, sizeof(rq));
1139 rq.ogf = 0x3f;
1140 rq.ocf = 0x11f;
1141 rq.event = 0x0F;
1142 rq.cparam = cmd_buffer;
1143 rq.clen = index_input;
1144 rq.rparam = &status;
1145 rq.rlen = 1;
1146 if (hci_send_req(&rq, FALSE) < 0)
1147 return BLE_STATUS_TIMEOUT;
1148 if (status)
1149 {
1150 return status;
1151 }
1152 return BLE_STATUS_SUCCESS;
1153 }
1154
aci_gatt_read_long_char_desc(uint16_t Connection_Handle,uint16_t Attr_Handle,uint16_t Val_Offset)1155 tBleStatus aci_gatt_read_long_char_desc(uint16_t Connection_Handle,
1156 uint16_t Attr_Handle,
1157 uint16_t Val_Offset)
1158 {
1159 struct hci_request rq;
1160 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1161 aci_gatt_read_long_char_desc_cp0 *cp0 = (aci_gatt_read_long_char_desc_cp0*)(cmd_buffer);
1162 tBleStatus status = 0;
1163 int index_input = 0;
1164 cp0->Connection_Handle = htob(Connection_Handle, 2);
1165 index_input += 2;
1166 cp0->Attr_Handle = htob(Attr_Handle, 2);
1167 index_input += 2;
1168 cp0->Val_Offset = htob(Val_Offset, 2);
1169 index_input += 2;
1170 Osal_MemSet(&rq, 0, sizeof(rq));
1171 rq.ogf = 0x3f;
1172 rq.ocf = 0x120;
1173 rq.event = 0x0F;
1174 rq.cparam = cmd_buffer;
1175 rq.clen = index_input;
1176 rq.rparam = &status;
1177 rq.rlen = 1;
1178 if (hci_send_req(&rq, FALSE) < 0)
1179 return BLE_STATUS_TIMEOUT;
1180 if (status)
1181 {
1182 return status;
1183 }
1184 return BLE_STATUS_SUCCESS;
1185 }
1186
aci_gatt_write_char_desc(uint16_t Connection_Handle,uint16_t Attr_Handle,uint8_t Attribute_Val_Length,uint8_t Attribute_Val[])1187 tBleStatus aci_gatt_write_char_desc(uint16_t Connection_Handle,
1188 uint16_t Attr_Handle,
1189 uint8_t Attribute_Val_Length,
1190 uint8_t Attribute_Val[])
1191 {
1192 struct hci_request rq;
1193 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1194 aci_gatt_write_char_desc_cp0 *cp0 = (aci_gatt_write_char_desc_cp0*)(cmd_buffer);
1195 tBleStatus status = 0;
1196 int index_input = 0;
1197 cp0->Connection_Handle = htob(Connection_Handle, 2);
1198 index_input += 2;
1199 cp0->Attr_Handle = htob(Attr_Handle, 2);
1200 index_input += 2;
1201 cp0->Attribute_Val_Length = htob(Attribute_Val_Length, 1);
1202 index_input += 1;
1203 Osal_MemCpy((void *) &cp0->Attribute_Val, (const void *) Attribute_Val, Attribute_Val_Length);
1204 index_input += Attribute_Val_Length;
1205 Osal_MemSet(&rq, 0, sizeof(rq));
1206 rq.ogf = 0x3f;
1207 rq.ocf = 0x121;
1208 rq.event = 0x0F;
1209 rq.cparam = cmd_buffer;
1210 rq.clen = index_input;
1211 rq.rparam = &status;
1212 rq.rlen = 1;
1213 if (hci_send_req(&rq, FALSE) < 0)
1214 return BLE_STATUS_TIMEOUT;
1215 if (status)
1216 {
1217 return status;
1218 }
1219 return BLE_STATUS_SUCCESS;
1220 }
1221
aci_gatt_read_char_desc(uint16_t Connection_Handle,uint16_t Attr_Handle)1222 tBleStatus aci_gatt_read_char_desc(uint16_t Connection_Handle,
1223 uint16_t Attr_Handle)
1224 {
1225 struct hci_request rq;
1226 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1227 aci_gatt_read_char_desc_cp0 *cp0 = (aci_gatt_read_char_desc_cp0*)(cmd_buffer);
1228 tBleStatus status = 0;
1229 int index_input = 0;
1230 cp0->Connection_Handle = htob(Connection_Handle, 2);
1231 index_input += 2;
1232 cp0->Attr_Handle = htob(Attr_Handle, 2);
1233 index_input += 2;
1234 Osal_MemSet(&rq, 0, sizeof(rq));
1235 rq.ogf = 0x3f;
1236 rq.ocf = 0x122;
1237 rq.event = 0x0F;
1238 rq.cparam = cmd_buffer;
1239 rq.clen = index_input;
1240 rq.rparam = &status;
1241 rq.rlen = 1;
1242 if (hci_send_req(&rq, FALSE) < 0)
1243 return BLE_STATUS_TIMEOUT;
1244 if (status)
1245 {
1246 return status;
1247 }
1248 return BLE_STATUS_SUCCESS;
1249 }
1250
aci_gatt_write_without_resp(uint16_t Connection_Handle,uint16_t Attr_Handle,uint8_t Attribute_Val_Length,uint8_t Attribute_Val[])1251 tBleStatus aci_gatt_write_without_resp(uint16_t Connection_Handle,
1252 uint16_t Attr_Handle,
1253 uint8_t Attribute_Val_Length,
1254 uint8_t Attribute_Val[])
1255 {
1256 struct hci_request rq;
1257 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1258 aci_gatt_write_without_resp_cp0 *cp0 = (aci_gatt_write_without_resp_cp0*)(cmd_buffer);
1259 tBleStatus status = 0;
1260 int index_input = 0;
1261 cp0->Connection_Handle = htob(Connection_Handle, 2);
1262 index_input += 2;
1263 cp0->Attr_Handle = htob(Attr_Handle, 2);
1264 index_input += 2;
1265 cp0->Attribute_Val_Length = htob(Attribute_Val_Length, 1);
1266 index_input += 1;
1267 Osal_MemCpy((void *) &cp0->Attribute_Val, (const void *) Attribute_Val, Attribute_Val_Length);
1268 index_input += Attribute_Val_Length;
1269 Osal_MemSet(&rq, 0, sizeof(rq));
1270 rq.ogf = 0x3f;
1271 rq.ocf = 0x123;
1272 rq.cparam = cmd_buffer;
1273 rq.clen = index_input;
1274 rq.rparam = &status;
1275 rq.rlen = 1;
1276 if (hci_send_req(&rq, FALSE) < 0)
1277 return BLE_STATUS_TIMEOUT;
1278 if (status)
1279 {
1280 return status;
1281 }
1282 return BLE_STATUS_SUCCESS;
1283 }
1284
aci_gatt_signed_write_without_resp(uint16_t Connection_Handle,uint16_t Attr_Handle,uint8_t Attribute_Val_Length,uint8_t Attribute_Val[])1285 tBleStatus aci_gatt_signed_write_without_resp(uint16_t Connection_Handle,
1286 uint16_t Attr_Handle,
1287 uint8_t Attribute_Val_Length,
1288 uint8_t Attribute_Val[])
1289 {
1290 struct hci_request rq;
1291 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1292 aci_gatt_signed_write_without_resp_cp0 *cp0 = (aci_gatt_signed_write_without_resp_cp0*)(cmd_buffer);
1293 tBleStatus status = 0;
1294 int index_input = 0;
1295 cp0->Connection_Handle = htob(Connection_Handle, 2);
1296 index_input += 2;
1297 cp0->Attr_Handle = htob(Attr_Handle, 2);
1298 index_input += 2;
1299 cp0->Attribute_Val_Length = htob(Attribute_Val_Length, 1);
1300 index_input += 1;
1301 Osal_MemCpy((void *) &cp0->Attribute_Val, (const void *) Attribute_Val, Attribute_Val_Length);
1302 index_input += Attribute_Val_Length;
1303 Osal_MemSet(&rq, 0, sizeof(rq));
1304 rq.ogf = 0x3f;
1305 rq.ocf = 0x124;
1306 rq.cparam = cmd_buffer;
1307 rq.clen = index_input;
1308 rq.rparam = &status;
1309 rq.rlen = 1;
1310 if (hci_send_req(&rq, FALSE) < 0)
1311 return BLE_STATUS_TIMEOUT;
1312 if (status)
1313 {
1314 return status;
1315 }
1316 return BLE_STATUS_SUCCESS;
1317 }
1318
aci_gatt_confirm_indication(uint16_t Connection_Handle)1319 tBleStatus aci_gatt_confirm_indication(uint16_t Connection_Handle)
1320 {
1321 struct hci_request rq;
1322 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1323 aci_gatt_confirm_indication_cp0 *cp0 = (aci_gatt_confirm_indication_cp0*)(cmd_buffer);
1324 tBleStatus status = 0;
1325 int index_input = 0;
1326 cp0->Connection_Handle = htob(Connection_Handle, 2);
1327 index_input += 2;
1328 Osal_MemSet(&rq, 0, sizeof(rq));
1329 rq.ogf = 0x3f;
1330 rq.ocf = 0x125;
1331 rq.cparam = cmd_buffer;
1332 rq.clen = index_input;
1333 rq.rparam = &status;
1334 rq.rlen = 1;
1335 if (hci_send_req(&rq, FALSE) < 0)
1336 return BLE_STATUS_TIMEOUT;
1337 if (status)
1338 {
1339 return status;
1340 }
1341 return BLE_STATUS_SUCCESS;
1342 }
1343
aci_gatt_write_resp(uint16_t Connection_Handle,uint16_t Attr_Handle,uint8_t Write_status,uint8_t Error_Code,uint8_t Attribute_Val_Length,uint8_t Attribute_Val[])1344 tBleStatus aci_gatt_write_resp(uint16_t Connection_Handle,
1345 uint16_t Attr_Handle,
1346 uint8_t Write_status,
1347 uint8_t Error_Code,
1348 uint8_t Attribute_Val_Length,
1349 uint8_t Attribute_Val[])
1350 {
1351 struct hci_request rq;
1352 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1353 aci_gatt_write_resp_cp0 *cp0 = (aci_gatt_write_resp_cp0*)(cmd_buffer);
1354 tBleStatus status = 0;
1355 int index_input = 0;
1356 cp0->Connection_Handle = htob(Connection_Handle, 2);
1357 index_input += 2;
1358 cp0->Attr_Handle = htob(Attr_Handle, 2);
1359 index_input += 2;
1360 cp0->Write_status = htob(Write_status, 1);
1361 index_input += 1;
1362 cp0->Error_Code = htob(Error_Code, 1);
1363 index_input += 1;
1364 cp0->Attribute_Val_Length = htob(Attribute_Val_Length, 1);
1365 index_input += 1;
1366 Osal_MemCpy((void *) &cp0->Attribute_Val, (const void *) Attribute_Val, Attribute_Val_Length);
1367 index_input += Attribute_Val_Length;
1368 Osal_MemSet(&rq, 0, sizeof(rq));
1369 rq.ogf = 0x3f;
1370 rq.ocf = 0x126;
1371 rq.cparam = cmd_buffer;
1372 rq.clen = index_input;
1373 rq.rparam = &status;
1374 rq.rlen = 1;
1375 if (hci_send_req(&rq, FALSE) < 0)
1376 return BLE_STATUS_TIMEOUT;
1377 if (status)
1378 {
1379 return status;
1380 }
1381 return BLE_STATUS_SUCCESS;
1382 }
1383
aci_gatt_allow_read(uint16_t Connection_Handle)1384 tBleStatus aci_gatt_allow_read(uint16_t Connection_Handle)
1385 {
1386 struct hci_request rq;
1387 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1388 aci_gatt_allow_read_cp0 *cp0 = (aci_gatt_allow_read_cp0*)(cmd_buffer);
1389 tBleStatus status = 0;
1390 int index_input = 0;
1391 cp0->Connection_Handle = htob(Connection_Handle, 2);
1392 index_input += 2;
1393 Osal_MemSet(&rq, 0, sizeof(rq));
1394 rq.ogf = 0x3f;
1395 rq.ocf = 0x127;
1396 rq.cparam = cmd_buffer;
1397 rq.clen = index_input;
1398 rq.rparam = &status;
1399 rq.rlen = 1;
1400 if (hci_send_req(&rq, FALSE) < 0)
1401 return BLE_STATUS_TIMEOUT;
1402 if (status)
1403 {
1404 return status;
1405 }
1406 return BLE_STATUS_SUCCESS;
1407 }
1408
aci_gatt_set_security_permission(uint16_t Serv_Handle,uint16_t Attr_Handle,uint8_t Security_Permissions)1409 tBleStatus aci_gatt_set_security_permission(uint16_t Serv_Handle,
1410 uint16_t Attr_Handle,
1411 uint8_t Security_Permissions)
1412 {
1413 struct hci_request rq;
1414 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1415 aci_gatt_set_security_permission_cp0 *cp0 = (aci_gatt_set_security_permission_cp0*)(cmd_buffer);
1416 tBleStatus status = 0;
1417 int index_input = 0;
1418 cp0->Serv_Handle = htob(Serv_Handle, 2);
1419 index_input += 2;
1420 cp0->Attr_Handle = htob(Attr_Handle, 2);
1421 index_input += 2;
1422 cp0->Security_Permissions = htob(Security_Permissions, 1);
1423 index_input += 1;
1424 Osal_MemSet(&rq, 0, sizeof(rq));
1425 rq.ogf = 0x3f;
1426 rq.ocf = 0x128;
1427 rq.cparam = cmd_buffer;
1428 rq.clen = index_input;
1429 rq.rparam = &status;
1430 rq.rlen = 1;
1431 if (hci_send_req(&rq, FALSE) < 0)
1432 return BLE_STATUS_TIMEOUT;
1433 if (status)
1434 {
1435 return status;
1436 }
1437 return BLE_STATUS_SUCCESS;
1438 }
1439
aci_gatt_set_desc_value(uint16_t Serv_Handle,uint16_t Char_Handle,uint16_t Char_Desc_Handle,uint16_t Val_Offset,uint8_t Char_Desc_Value_Length,uint8_t Char_Desc_Value[])1440 tBleStatus aci_gatt_set_desc_value(uint16_t Serv_Handle,
1441 uint16_t Char_Handle,
1442 uint16_t Char_Desc_Handle,
1443 uint16_t Val_Offset,
1444 uint8_t Char_Desc_Value_Length,
1445 uint8_t Char_Desc_Value[])
1446 {
1447 struct hci_request rq;
1448 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1449 aci_gatt_set_desc_value_cp0 *cp0 = (aci_gatt_set_desc_value_cp0*)(cmd_buffer);
1450 tBleStatus status = 0;
1451 int index_input = 0;
1452 cp0->Serv_Handle = htob(Serv_Handle, 2);
1453 index_input += 2;
1454 cp0->Char_Handle = htob(Char_Handle, 2);
1455 index_input += 2;
1456 cp0->Char_Desc_Handle = htob(Char_Desc_Handle, 2);
1457 index_input += 2;
1458 cp0->Val_Offset = htob(Val_Offset, 2);
1459 index_input += 2;
1460 cp0->Char_Desc_Value_Length = htob(Char_Desc_Value_Length, 1);
1461 index_input += 1;
1462 Osal_MemCpy((void *) &cp0->Char_Desc_Value, (const void *) Char_Desc_Value, Char_Desc_Value_Length);
1463 index_input += Char_Desc_Value_Length;
1464 Osal_MemSet(&rq, 0, sizeof(rq));
1465 rq.ogf = 0x3f;
1466 rq.ocf = 0x129;
1467 rq.cparam = cmd_buffer;
1468 rq.clen = index_input;
1469 rq.rparam = &status;
1470 rq.rlen = 1;
1471 if (hci_send_req(&rq, FALSE) < 0)
1472 return BLE_STATUS_TIMEOUT;
1473 if (status)
1474 {
1475 return status;
1476 }
1477 return BLE_STATUS_SUCCESS;
1478 }
1479
aci_gatt_read_handle_value(uint16_t Attr_Handle,uint16_t Offset,uint16_t Value_Length_Requested,uint16_t * Length,uint16_t * Value_Length,uint8_t Value[])1480 tBleStatus aci_gatt_read_handle_value(uint16_t Attr_Handle,
1481 uint16_t Offset,
1482 uint16_t Value_Length_Requested,
1483 uint16_t *Length,
1484 uint16_t *Value_Length,
1485 uint8_t Value[])
1486 {
1487 struct hci_request rq;
1488 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1489 aci_gatt_read_handle_value_cp0 *cp0 = (aci_gatt_read_handle_value_cp0*)(cmd_buffer);
1490 aci_gatt_read_handle_value_rp0 resp;
1491 Osal_MemSet(&resp, 0, sizeof(resp));
1492 int index_input = 0;
1493 cp0->Attr_Handle = htob(Attr_Handle, 2);
1494 index_input += 2;
1495 cp0->Offset = htob(Offset, 2);
1496 index_input += 2;
1497 cp0->Value_Length_Requested = htob(Value_Length_Requested, 2);
1498 index_input += 2;
1499 Osal_MemSet(&rq, 0, sizeof(rq));
1500 rq.ogf = 0x3f;
1501 rq.ocf = 0x12a;
1502 rq.cparam = cmd_buffer;
1503 rq.clen = index_input;
1504 rq.rparam = &resp;
1505 rq.rlen = sizeof(resp);
1506 if (hci_send_req(&rq, FALSE) < 0)
1507 return BLE_STATUS_TIMEOUT;
1508 if (resp.Status)
1509 {
1510 return resp.Status;
1511 }
1512 *Length = btoh(resp.Length, 2);
1513 *Value_Length = btoh(resp.Value_Length, 2);
1514 Osal_MemCpy((void *) Value, (const void *) resp.Value, *Value_Length);
1515 return BLE_STATUS_SUCCESS;
1516 }
1517
aci_gatt_update_char_value_ext(uint16_t Conn_Handle_To_Notify,uint16_t Service_Handle,uint16_t Char_Handle,uint8_t Update_Type,uint16_t Char_Length,uint16_t Value_Offset,uint8_t Value_Length,uint8_t Value[])1518 tBleStatus aci_gatt_update_char_value_ext(uint16_t Conn_Handle_To_Notify,
1519 uint16_t Service_Handle,
1520 uint16_t Char_Handle,
1521 uint8_t Update_Type,
1522 uint16_t Char_Length,
1523 uint16_t Value_Offset,
1524 uint8_t Value_Length,
1525 uint8_t Value[])
1526 {
1527 struct hci_request rq;
1528 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1529 aci_gatt_update_char_value_ext_cp0 *cp0 = (aci_gatt_update_char_value_ext_cp0*)(cmd_buffer);
1530 tBleStatus status = 0;
1531 int index_input = 0;
1532 cp0->Conn_Handle_To_Notify = htob(Conn_Handle_To_Notify, 2);
1533 index_input += 2;
1534 cp0->Service_Handle = htob(Service_Handle, 2);
1535 index_input += 2;
1536 cp0->Char_Handle = htob(Char_Handle, 2);
1537 index_input += 2;
1538 cp0->Update_Type = htob(Update_Type, 1);
1539 index_input += 1;
1540 cp0->Char_Length = htob(Char_Length, 2);
1541 index_input += 2;
1542 cp0->Value_Offset = htob(Value_Offset, 2);
1543 index_input += 2;
1544 cp0->Value_Length = htob(Value_Length, 1);
1545 index_input += 1;
1546 Osal_MemCpy((void *) &cp0->Value, (const void *) Value, Value_Length);
1547 index_input += Value_Length;
1548 Osal_MemSet(&rq, 0, sizeof(rq));
1549 rq.ogf = 0x3f;
1550 rq.ocf = 0x12c;
1551 rq.cparam = cmd_buffer;
1552 rq.clen = index_input;
1553 rq.rparam = &status;
1554 rq.rlen = 1;
1555 if (hci_send_req(&rq, FALSE) < 0)
1556 return BLE_STATUS_TIMEOUT;
1557 if (status)
1558 {
1559 return status;
1560 }
1561 return BLE_STATUS_SUCCESS;
1562 }
1563
aci_gatt_deny_read(uint16_t Connection_Handle,uint8_t Error_Code)1564 tBleStatus aci_gatt_deny_read(uint16_t Connection_Handle,
1565 uint8_t Error_Code)
1566 {
1567 struct hci_request rq;
1568 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1569 aci_gatt_deny_read_cp0 *cp0 = (aci_gatt_deny_read_cp0*)(cmd_buffer);
1570 tBleStatus status = 0;
1571 int index_input = 0;
1572 cp0->Connection_Handle = htob(Connection_Handle, 2);
1573 index_input += 2;
1574 cp0->Error_Code = htob(Error_Code, 1);
1575 index_input += 1;
1576 Osal_MemSet(&rq, 0, sizeof(rq));
1577 rq.ogf = 0x3f;
1578 rq.ocf = 0x12d;
1579 rq.cparam = cmd_buffer;
1580 rq.clen = index_input;
1581 rq.rparam = &status;
1582 rq.rlen = 1;
1583 if (hci_send_req(&rq, FALSE) < 0)
1584 return BLE_STATUS_TIMEOUT;
1585 if (status)
1586 {
1587 return status;
1588 }
1589 return BLE_STATUS_SUCCESS;
1590 }
1591
aci_gatt_set_access_permission(uint16_t Serv_Handle,uint16_t Attr_Handle,uint8_t Access_Permissions)1592 tBleStatus aci_gatt_set_access_permission(uint16_t Serv_Handle,
1593 uint16_t Attr_Handle,
1594 uint8_t Access_Permissions)
1595 {
1596 struct hci_request rq;
1597 uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
1598 aci_gatt_set_access_permission_cp0 *cp0 = (aci_gatt_set_access_permission_cp0*)(cmd_buffer);
1599 tBleStatus status = 0;
1600 int index_input = 0;
1601 cp0->Serv_Handle = htob(Serv_Handle, 2);
1602 index_input += 2;
1603 cp0->Attr_Handle = htob(Attr_Handle, 2);
1604 index_input += 2;
1605 cp0->Access_Permissions = htob(Access_Permissions, 1);
1606 index_input += 1;
1607 Osal_MemSet(&rq, 0, sizeof(rq));
1608 rq.ogf = 0x3f;
1609 rq.ocf = 0x12e;
1610 rq.cparam = cmd_buffer;
1611 rq.clen = index_input;
1612 rq.rparam = &status;
1613 rq.rlen = 1;
1614 if (hci_send_req(&rq, FALSE) < 0)
1615 return BLE_STATUS_TIMEOUT;
1616 if (status)
1617 {
1618 return status;
1619 }
1620 return BLE_STATUS_SUCCESS;
1621 }
1622
1623