forked from dsouzahansenfrancis/STBTLE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbluenrg_gatt_aci.h
1072 lines (999 loc) · 55.5 KB
/
bluenrg_gatt_aci.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/******************** (C) COPYRIGHT 2014 STMicroelectronics ********************
* File Name : bluenrg_gatt_aci.h
* Author : AMS - AAS
* Version : V1.0.0
* Date : 26-Jun-2014
* Description : Header file with GATT commands for BlueNRG FW6.3.
********************************************************************************
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
#ifndef __BLUENRG_GATT_ACI_H__
#define __BLUENRG_GATT_ACI_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "bluenrg_gatt_server.h"
/**
*@addtogroup GATT GATT
*@brief GATT layer.
*@{
*/
/**
*@defgroup GATT_Functions GATT functions
*@brief API for GATT layer.
*@{
*/
/**
* @brief Initialize the GATT layer for server and client roles.
* @note It adds also the GATT service with Service Changed Characteristic.
* Until this command is issued the GATT channel will not process any commands
* even if the connection is opened. This command has to be given
* before using any of the GAP features.
* @return Value indicating success or error code.
*/
tBleStatus aci_gatt_init(void);
/**
* @brief Add a service to the GATT Server. When a service is created in the server, the Host needs
* to reserve the handle ranges for this service using max_attr_records parameter. This
* parameter specifies the maximum number of attribute records that can be added to this
* service (including the service attribute, include attribute, characteristic attribute,
* characteristic value attribute and characteristic descriptor attribute). Handle of the
* created service is returned.
* @note Service declaration is taken from the service pool. The attributes for characteristics and descriptors
* are allocated from the attribute pool.
* @param service_uuid_type Type of service UUID (16-bit or 128-bit). See @ref UUID_Types "UUID Types".
* @param[in] service_uuid 16-bit or 128-bit UUID based on the UUID Type field
* @param service_type Primary or secondary service. See @ref Service_type "Service Type".
* @param max_attr_records Maximum number of attribute records that can be added to this service
* (including the service declaration itself)
* @param[out] serviceHandle Handle of the Service. When this service is added to the service,
* a handle is allocated by the server to this service. Server also
* allocates a range of handles for this service from serviceHandle to
* <serviceHandle + max_attr_records>.
* @return Value indicating success or error code.
*/
tBleStatus aci_gatt_add_serv(uint8_t service_uuid_type,
const uint8_t* service_uuid,
uint8_t service_type,
uint8_t max_attr_records,
uint16_t *serviceHandle);
/**
* @brief Include a service given by included_start_handle and included_end_handle to another service
* given by service_handle. Attribute server creates an INCLUDE definition attribute and return
* the handle of this attribute in included_handle.
* @param service_handle Handle of the service to which another service has to be included
* @param included_start_handle Start Handle of the service which has to be included in service
* @param included_end_handle End Handle of the service which has to be included in service
* @param included_uuid_type Type of UUID for included service (16-bit or 128-bit). See @ref Well-Known_UUIDs "Well-Known UUIDs".
* @param[in] included_uuid 16-bit or 128-bit UUID.
* @param[out] included_handle Handle of the include declaration.
* @return Value indicating success or error code.
*/
tBleStatus aci_gatt_include_service(uint16_t service_handle, uint16_t included_start_handle,
uint16_t included_end_handle, uint8_t included_uuid_type,
const uint8_t* included_uuid, uint16_t *included_handle);
/**
* @brief Add a characteristic to a service.
* @param serviceHandle Handle of the service to which the characteristic has to be added.
* @param charUuidType Type of characteristic UUID (16-bit or 128-bit). See @ref UUID_Types "UUID Types".
* @arg @ref UUID_TYPE_16
* @arg @ref UUID_TYPE_128
* @param charUuid 16-bit or 128-bit UUID.
* @param charValueLen Maximum length of the characteristic value.
* @param charProperties Bitwise OR values of Characteristic Properties (defined in Volume 3,
* Section 3.3.3.1 of Bluetooth Specification 4.0). See @ref Char_properties "Characteristic properties".
* @param secPermissions Security permissions for the added characteristic. See @ref Security_permissions "Security permissions".
* @arg ATTR_PERMISSION_NONE
* @arg ATTR_PERMISSION_AUTHEN_READ
* @arg ATTR_PERMISSION_AUTHOR_READ
* @arg ATTR_PERMISSION_ENCRY_READ
* @arg ATTR_PERMISSION_AUTHEN_WRITE
* @arg ATTR_PERMISSION_AUTHOR_WRITE
* @arg ATTR_PERMISSION_ENCRY_WRITE
* @param gattEvtMask Bit mask that enables events that will be sent to the application by the GATT server
* on certain ATT requests. See @ref Gatt_Event_Mask "Gatt Event Mask".
* @arg GATT_DONT_NOTIFY_EVENTS
* @arg GATT_NOTIFY_ATTRIBUTE_WRITE
* @arg GATT_NOTIFY_WRITE_REQ_AND_WAIT_FOR_APPL_RESP
* @arg GATT_NOTIFY_READ_REQ_AND_WAIT_FOR_APPL_RESP
* @param encryKeySize The minimum encryption key size requirement for this attribute. Valid Range: 7 to 16.
* @param isVariable If the attribute has a variable length value field (1) or not (0).
* @param charHandle Handle of the Characteristic that has been added. It is the handle of the characteristic declaration.
* The attribute that holds the characteristic value is allocated at the next handle, followed by the Client
* Characteristic Configuration descriptor if the characteristic has @ref CHAR_PROP_NOTIFY or @ref CHAR_PROP_INDICATE
* properties.
* @return Value indicating success or error code.
*/
tBleStatus aci_gatt_add_char(uint16_t serviceHandle,
uint8_t charUuidType,
const uint8_t* charUuid,
uint8_t charValueLen,
uint8_t charProperties,
uint8_t secPermissions,
uint8_t gattEvtMask,
uint8_t encryKeySize,
uint8_t isVariable,
uint16_t* charHandle);
/**
* Add a characteristic descriptor to a service.
* @param serviceHandle Handle of the service to which the characteristic belongs
* @param charHandle Handle of the characteristic to which description has to be added.
* @param descUuidType 16-bit or 128-bit UUID. See @ref UUID_Types "UUID Types".
* @arg @ref UUID_TYPE_16
* @arg @ref UUID_TYPE_128
* @param[in] uuid UUID of the Characteristic descriptor. It can be one of the UUID assigned by Bluetooth SIG
* (Well_known_UUIDs) or a user-defined one.
* @param descValueMaxLen The maximum length of the descriptor value
* @param descValueLen Current Length of the characteristic descriptor value
* @param[in] descValue Value of the characteristic description
* @param secPermissions Security permissions for the added descriptor. See @ref Security_permissions "Security permissions".
* @arg ATTR_PERMISSION_NONE
* @arg ATTR_PERMISSION_AUTHEN_READ
* @arg ATTR_PERMISSION_AUTHOR_READ
* @arg ATTR_PERMISSION_ENCRY_READ
* @arg ATTR_PERMISSION_AUTHEN_WRITE
* @arg ATTR_PERMISSION_AUTHOR_WRITE
* @arg ATTR_PERMISSION_ENCRY_WRITE
* @param accPermissions Access permissions for the added descriptor. See @ref Access_permissions "Access permissions".
* @arg ATTR_NO_ACCESS
* @arg ATTR_ACCESS_READ_ONLY
* @arg ATTR_ACCESS_WRITE_REQ_ONLY
* @arg ATTR_ACCESS_READ_WRITE
* @arg ATTR_ACCESS_WRITE_WITHOUT_RESPONSE
* @arg ATTR_ACCESS_SIGNED_WRITE_ALLOWED
* @param gattEvtMask Bit mask that enables events that will be sent to the application by the GATT server
* on certain ATT requests. See @ref Gatt_Event_Mask "Gatt Event Mask".
* @param encryKeySize The minimum encryption key size requirement for this attribute. Valid Range: 7 to 16.
* @param isVariable If the attribute has a variable length value field (1) or not (0).
* @param[out] descHandle Handle of the Characteristic Descriptor.
* @return Value indicating success or error code.
*/
tBleStatus aci_gatt_add_char_desc(uint16_t serviceHandle,
uint16_t charHandle,
uint8_t descUuidType,
const uint8_t* uuid,
uint8_t descValueMaxLen,
uint8_t descValueLen,
const void* descValue,
uint8_t secPermissions,
uint8_t accPermissions,
uint8_t gattEvtMask,
uint8_t encryKeySize,
uint8_t isVariable,
uint16_t* descHandle);
/**
* @brief Update a characteristic value in a service.
* @note If notifications (or indications) are enabled on that characteristic, a notification (or indication)
* will be sent to the client after sending this command to the BlueNRG. The command is queued into the
* BlueNRG command queue. If the buffer is full, because previous commands could not be still processed,
* the function will return @ref BLE_STATUS_INSUFFICIENT_RESOURCES. This will happen if notifications (or
* indications) are enabled and the application calls aci_gatt_update_char_value() at an higher rate
* than what is allowed by the link. Throughput on BLE link depends on connection interval and
* connection length parameters (decided by the master, see aci_l2cap_connection_parameter_update_request()
* for more info on how to suggest new connection parameters from a slave). If the application does not
* want to lose notifications because BlueNRG buffer becomes full, it has to retry again till the function
* returns @ref BLE_STATUS_SUCCESS or any other error code.\n
* Example:\n
* Here if BlueNRG buffer become full because BlueNRG was not able to send packets for a while, some
* notifications will be lost.
* @code
* tBleStatus Free_Fall_Notify(void)
* {
* uint8_t val;
* tBleStatus ret;
*
* val = 0x01;
* ret = aci_gatt_update_char_value(accServHandle, freeFallCharHandle, 0, 1, &val);
*
* if (ret != BLE_STATUS_SUCCESS){
* PRINTF("Error while updating ACC characteristic.\n") ;
* return BLE_STATUS_ERROR ;
* }
* return BLE_STATUS_SUCCESS;
* }
* @endcode
* Here if BlueNRG buffer become full, the application try again to send the notification.
* @code
* struct timer t;
* Timer_Set(&t, CLOCK_SECOND*10);
* while(aci_gatt_update_char_value(chatServHandle,TXCharHandle,0,len,array_val)==BLE_STATUS_INSUFFICIENT_RESOURCES){
* // Radio is busy (buffer full).
* if(Timer_Expired(&t))
* break;
* }
* @endcode
*
* @param servHandle Handle of the service to which characteristic belongs
* @param charHandle Handle of the characteristic
* @param charValOffset The offset from which the attribute value has to be updated. If this is set to 0,
* and the attribute value is of variable length, then the length of the attribute will
* be set to the charValueLen. If the charValOffset is set to a value greater than 0,
* then the length of the attribute will be set to the maximum length as specified for
* the attribute while adding the characteristic.
* @param charValueLen Length of the characteristic value in octets
* @param[in] charValue Characteristic value
* @return Value indicating success or error code.
*/
tBleStatus aci_gatt_update_char_value(uint16_t servHandle,
uint16_t charHandle,
uint8_t charValOffset,
uint8_t charValueLen,
const uint8_t *charValue);
/**
* @brief Delete the specified characteristic from the service.
* @param servHandle Handle of the service to which characteristic belongs
* @param charHandle Handle of the characteristic to be deleted
* @return Value indicating success or error code.
*/
tBleStatus aci_gatt_del_char(uint16_t servHandle, uint16_t charHandle);
/**
* @brief Delete the specified service from the GATT server database.
* @param servHandle Handle of the service to be deleted
* @return Value indicating success or error code.
*/
tBleStatus aci_gatt_del_service(uint16_t servHandle);
/**
* @brief Delete the Include definition from the service.
* @param servHandle Handle of the service to which Include definition belongs
* @param includeServHandle Handle of the Included definition to be deleted
* @return Value indicating success or error code.
*/
tBleStatus aci_gatt_del_include_service(uint16_t servHandle, uint16_t includeServHandle);
/**
* @brief Perform an ATT MTU exchange procedure.
* @note When the ATT MTU exchange procedure is completed, a @ref EVT_BLUE_ATT_EXCHANGE_MTU_RESP
* event is generated. A @ref EVT_BLUE_GATT_PROCEDURE_COMPLETE event is also generated
* to indicate the end of the procedure.
* @param conn_handle Connection handle for which the command is given.
* @return Value indicating success or error code.
*/
tBleStatus aci_gatt_exchange_configuration(uint16_t conn_handle);
/**
* @brief Send a @a Find @a Information @a Request.
* @note This command is used to obtain the mapping of attribute handles with their associated
* types. The responses of the procedure are given through the
* @ref EVT_BLUE_ATT_FIND_INFORMATION_RESP event. The end of the procedure is indicated by
* a @ref EVT_BLUE_GATT_PROCEDURE_COMPLETE event.
* @param conn_handle Connection handle for which the command is given
* @param start_handle Starting handle of the range of attributes to be discovered on the server
* @param end_handle Ending handle of the range of attributes to be discovered on the server
* @return Value indicating success or error code.
*/
tBleStatus aci_att_find_information_req(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle);
/**
* @brief Send a @a Find @a By @a Type @a Value @a Request
* @note The Find By Type Value Request is used to obtain the handles of attributes that
* have a given 16-bit UUID attribute type and a given attribute value.
* The responses of the procedure are given through the @ref EVT_BLUE_ATT_FIND_BY_TYPE_VAL_RESP event.
* The end of the procedure is indicated by a @ref EVT_BLUE_GATT_PROCEDURE_COMPLETE event.
* @param conn_handle Connection handle for which the command is given.
* @param start_handle First requested handle number
* @param end_handle Last requested handle number
* @param uuid 2 octet UUID to find (little-endian)
* @param attr_val_len Length of attribute value (maximum value is ATT_MTU - 7).
* @param attr_val Attribute value to find
* @return Value indicating success or error code.
*/
tBleStatus aci_att_find_by_type_value_req(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle,
uint8_t* uuid, uint8_t attr_val_len, uint8_t* attr_val);
/**
* @brief Send a @a Read @a By @a Type @a Request
* @note The Read By Type Request is used to obtain the values of attributes where the attribute type
* is known but the handle is not known.
* The responses of the procedure are given through the @ref EVT_BLUE_ATT_READ_BY_TYPE_RESP event.
* The end of the procedure is indicated by a @ref EVT_BLUE_GATT_PROCEDURE_COMPLETE event.
* @param conn_handle Connection handle for which the command is given.
* @param start_handle First requested handle number
* @param end_handle Last requested handle number
* @param uuid_type @arg @ref UUID_TYPE_16
* @arg @ref UUID_TYPE_128
* @param uuid 2 or 16 octet UUID
* @return Value indicating success or error code.
*/
tBleStatus aci_att_read_by_type_req(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle,
uint8_t uuid_type, uint8_t* uuid);
/**
* @brief Send a @a Read @a By @a Group @a Type @a Request
* @note The Read By Group Type Request is used to obtain the values of grouping attributes where the attribute
* type is known but the handle is not known. Grouping attributes are defined at GATT layer. The grouping
* attribute types are: «Primary Service», «Secondary Service» and «Characteristic».
* The responses of the procedure are given through the @ref EVT_BLUE_ATT_READ_BY_GROUP_TYPE_RESP event.
* The end of the procedure is indicated by a @ref EVT_BLUE_GATT_PROCEDURE_COMPLETE.
* @param conn_handle Connection handle for which the command is given.
* @param start_handle First requested handle number
* @param end_handle Last requested handle number
* @param uuid_type @arg @ref UUID_TYPE_16
* @arg @ref UUID_TYPE_128
* @param uuid 2 or 16 octet UUID
* @return Value indicating success or error code.
*/
tBleStatus aci_att_read_by_group_type_req(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle,
uint8_t uuid_type, uint8_t* uuid);
/**
* @brief Send a @a Prepare @a Write @a Request
* @note The Prepare Write Request is used to request the server to prepare to write the value of an attribute.
* The responses of the procedure are given through the @ref EVT_BLUE_ATT_PREPARE_WRITE_RESP event.
* The end of the procedure is indicated by a @ref EVT_BLUE_GATT_PROCEDURE_COMPLETE.
* @param conn_handle Connection handle for which the command is given.
* @param attr_handle The handle of the attribute to be written
* @param value_offset The offset of the first octet to be written
* @param attr_val_len Length of attribute value (maximum value is ATT_MTU - 5).
* @param attr_val The value of the attribute to be written
* @return Value indicating success or error code.
*/
tBleStatus aci_att_prepare_write_req(uint16_t conn_handle, uint16_t attr_handle, uint16_t value_offset,
uint8_t attr_val_len, uint8_t* attr_val);
/**
* @brief Send an @a Execute @a Write @a Request
* @note The Execute Write Request is used to request the server to write or cancel the write of all the
* prepared values currently held in the prepare queue from this client.
* The result of the procedure is given through the @ref EVT_BLUE_ATT_EXEC_WRITE_RESP event.
* The end of the procedure is indicated by a @ref EVT_BLUE_GATT_PROCEDURE_COMPLETE event.
* @param conn_handle Connection handle for which the command is given.
* @param execute @arg 0x00 Cancel all prepared writes
* @arg 0x01 Immediately write all pending prepared values.
* @return Value indicating success or error code.
*/
tBleStatus aci_att_execute_write_req(uint16_t conn_handle, uint8_t execute);
/**
* @brief This command will start the GATT client procedure to discover all primary services on the server.
* @note The responses of the procedure are given through the @ref EVT_BLUE_ATT_READ_BY_GROUP_TYPE_RESP event.
* The end of the procedure is indicated by a @ref EVT_BLUE_GATT_PROCEDURE_COMPLETE event.
* @param conn_handle Connection handle for which the command is given.
* @return Value indicating success or error code.
*/
tBleStatus aci_gatt_disc_all_prim_services(uint16_t conn_handle);
/**
* @brief Start the procedure to discover the primary services of the specified UUID on the server.
* @note The responses of the procedure are given through the @ref EVT_BLUE_ATT_FIND_BY_TYPE_VAL_RESP event.
* The end of the procedure is indicated by a @ref EVT_BLUE_GATT_PROCEDURE_COMPLETE event.
* @param conn_handle Connection handle for which the command is given.
* @param uuid_type @arg @ref UUID_TYPE_16
* @arg @ref UUID_TYPE_128
* @param uuid 2 or 16 octet UUID
* @return Value indicating success or error code.
*/
tBleStatus aci_gatt_disc_prim_service_by_uuid(uint16_t conn_handle, uint8_t uuid_type, uint8_t* uuid);
/**
* @brief Start the procedure to find all included services.
* @note The responses of the procedure are given through the @ref EVT_BLUE_ATT_READ_BY_TYPE_RESP event.
* The end of the procedure is indicated by a @ref EVT_BLUE_GATT_PROCEDURE_COMPLETE event.
* @param conn_handle Connection handle for which the command is given.
* @param start_handle Start handle of the service
* @param end_handle End handle of the service
* @return Value indicating success or error code.
*/
tBleStatus aci_gatt_find_included_services(uint16_t conn_handle, uint16_t start_handle,
uint16_t end_handle);
/**
* @brief Start the procedure to discover all the characteristics of a given service.
* @note When the procedure is completed, a @ref EVT_BLUE_GATT_PROCEDURE_COMPLETE event is generated.
* Before procedure completion the response packets are given through @ref EVT_BLUE_ATT_READ_BY_TYPE_RESP event.
* @param conn_handle Connection handle for which the command is given
* @param start_attr_handle Start attribute handle of the service
* @param end_attr_handle End attribute handle of the service
* @return Value indicating success or error code.
*/
tBleStatus aci_gatt_disc_all_charac_of_serv(uint16_t conn_handle, uint16_t start_attr_handle,
uint16_t end_attr_handle);
/**
* @brief Start the procedure to discover all the characteristics specified by a UUID.
* @note When the procedure is completed, a @ref EVT_BLUE_GATT_PROCEDURE_COMPLETE event is generated.
* Before procedure completion the response packets are given through
* @ref EVT_BLUE_GATT_DISC_READ_CHAR_BY_UUID_RESP event.
* @param conn_handle Connection handle for which the command is given
* @param start_handle Start attribute handle of the service
* @param end_handle End attribute handle of the service
* @param uuid_type @arg @ref UUID_TYPE_16
* @arg @ref UUID_TYPE_128
* @param uuid 2 or 16 octet UUID
* @return Value indicating success or error code.
*/
tBleStatus aci_gatt_disc_charac_by_uuid(uint16_t conn_handle, uint16_t start_handle,
uint16_t end_handle, uint8_t uuid_type, const uint8_t* uuid);
/**
* @brief Start the procedure to discover all characteristic descriptors on the server.
* @note When the procedure is completed, a @ref EVT_BLUE_GATT_PROCEDURE_COMPLETE event is generated.
* Before procedure completion the response packets are given through @ref EVT_BLUE_ATT_FIND_INFORMATION_RESP event.
* @param conn_handle Connection handle for which the command is given.
* @param char_val_handle Starting handle of the characteristic
* @param char_end_handle End handle of the characteristic
* @return Value indicating success or error code.
*/
tBleStatus aci_gatt_disc_all_charac_descriptors(uint16_t conn_handle, uint16_t char_val_handle,
uint16_t char_end_handle);
/**
* @brief Start the procedure to read the attribute value.
* @note When the procedure is completed, a @ref EVT_BLUE_GATT_PROCEDURE_COMPLETE event is generated.
* Before procedure completion the response packet is given through @ref EVT_BLUE_ATT_READ_RESP event.
* @param conn_handle Connection handle for which the command is given
* @param attr_handle Handle of the characteristic to be read
* @return Value indicating success or error code.\n
* It can be @ref BLE_STATUS_NOT_ALLOWED in the following cases:\n
* - If the exchange has already taken place\n
* - If GATT is expecting response for previous request\n
* - Already a request is in the queue to be sent\n
* - Channel not open\n
* - Already one GATT procedure is started
*/
tBleStatus aci_gatt_read_charac_val(uint16_t conn_handle, uint16_t attr_handle);
/**
* @brief Start the procedure to read all the characteristics specified by the UUID.
* @note When the procedure is completed, a @ref EVT_BLUE_GATT_PROCEDURE_COMPLETE event is generated.
* Before procedure completion the response packets are given through
* @ref EVT_BLUE_GATT_DISC_READ_CHAR_BY_UUID_RESP event.
* @param conn_handle Connection handle for which the command is given
* @param start_handle Starting handle of the range to be searched
* @param end_handle End handle of the range to be searched
* @param uuid_type @arg @ref UUID_TYPE_16
* @arg @ref UUID_TYPE_128
* @param uuid 2 or 16 octet UUID
* @return Value indicating success or error code.
*/
tBleStatus aci_gatt_read_using_charac_uuid(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle,
uint8_t uuid_type, uint8_t* uuid);
/**
* @brief Start the procedure to read a long characteristic value.
* @note When the procedure is completed, a @ref EVT_BLUE_GATT_PROCEDURE_COMPLETE event is generated.
* Before procedure completion the response packets are given through @ref EVT_BLUE_ATT_READ_BLOB_RESP event.
* @param conn_handle Connection handle for which the command is given
* @param attr_handle Handle of the characteristic to be read
* @param val_offset Offset from which the value needs to be read
* @return Value indicating success or error code.\n
* It can be @ref BLE_STATUS_NOT_ALLOWED in the following cases:\n
* - If the exchange has already taken place\n
* - If GATT is expecting response for previous request\n
* - Already a request is in the queue to be sent\n
* - Channel not open\n
* - Already one GATT procedure is started
*/
tBleStatus aci_gatt_read_long_charac_val(uint16_t conn_handle, uint16_t attr_handle,
uint16_t val_offset);
/**
* @brief Start a procedure to read multiple characteristic values from a server.
* @note This sub-procedure is used to read multiple Characteristic Values from a server when the
* client knows the Characteristic Value Handles.
* When the procedure is completed, a @ref EVT_BLUE_GATT_PROCEDURE_COMPLETE event is generated.
* Before procedure completion the response packets are given through
* @ref EVT_BLUE_ATT_READ_MULTIPLE_RESP event.
* @param conn_handle Connection handle for which the command is given
* @param num_handles The number of handles for which the value has to be read
* @param set_of_handles The handles for which the attribute value has to be read
* @return Value indicating success or error code.
*/
tBleStatus aci_gatt_read_multiple_charac_val(uint16_t conn_handle, uint8_t num_handles,
uint8_t* set_of_handles);
/**
* @brief Start the procedure to write a characteristic value.
* @note When the procedure is completed, a @ref EVT_BLUE_GATT_PROCEDURE_COMPLETE event is generated.
* @param conn_handle Connection handle for which the command is given
* @param attr_handle Handle of the characteristic to be written
* @param value_len Length of the value to be written
* @param[in] attr_value Value to be written
* @return Value indicating success or error code.\n
* It can be @ref BLE_STATUS_NOT_ALLOWED in the following cases:\n
* - If the exchange has already taken place\n
* - If GATT is expecting response for previous request\n
* - Already a request is in the queue to be sent\n
* - Channel not open\n
* - Already one GATT procedure is started
*/
tBleStatus aci_gatt_write_charac_value(uint16_t conn_handle, uint16_t attr_handle,
uint8_t value_len, uint8_t *attr_value);
/**
* @brief Start the procedure to write a long characteristic value.
* @note When the procedure is completed, a @ref EVT_BLUE_GATT_PROCEDURE_COMPLETE event is generated.
* During the procedure, @ref EVT_BLUE_ATT_PREPARE_WRITE_RESP and @ref EVT_BLUE_ATT_EXEC_WRITE_RESP
* events are raised.
* @param conn_handle Connection handle for which the command is given
* @param attr_handle Handle of the attribute to be written
* @param val_offset Offset at which the attribute has to be written
* @param val_len Length of the value to be written
* @param attr_val Value to be written
* @return Value indicating success or error code.
*/
tBleStatus aci_gatt_write_long_charac_val(uint16_t conn_handle, uint16_t attr_handle,
uint16_t val_offset, uint8_t val_len, const uint8_t* attr_val);
/**
* @brief Start the procedure to write a characteristic reliably.
* @note When the procedure is completed, a @ref EVT_BLUE_GATT_PROCEDURE_COMPLETE event is generated.
* During the procedure, @ref EVT_BLUE_ATT_PREPARE_WRITE_RESP and @ref EVT_BLUE_ATT_EXEC_WRITE_RESP
* events are raised.
* @param conn_handle Connection handle for which the command is given
* @param attr_handle Handle of the attribute to be written
* @param val_offset Offset at which the attribute has to be written
* @param val_len Length of the value to be written
* @param attr_val Value to be written
* @return Value indicating success or error code.
*/
tBleStatus aci_gatt_write_charac_reliable(uint16_t conn_handle, uint16_t attr_handle,
uint16_t val_offset, uint8_t val_len, uint8_t* attr_val);
/**
* @brief Start the procedure to write a long characteristic descriptor.
* @note When the procedure is completed, a @ref EVT_BLUE_GATT_PROCEDURE_COMPLETE event is generated.
* During the procedure, @ref EVT_BLUE_ATT_PREPARE_WRITE_RESP and @ref EVT_BLUE_ATT_EXEC_WRITE_RESP
* events are raised.
* @param conn_handle Connection handle for which the command is given
* @param attr_handle Handle of the attribute to be written
* @param val_offset Offset at which the attribute has to be written
* @param val_len Length of the value to be written
* @param attr_val Value to be written
* @return Value indicating success or error code.
*/
tBleStatus aci_gatt_write_long_charac_desc(uint16_t conn_handle, uint16_t attr_handle,
uint16_t val_offset, uint8_t val_len, uint8_t* attr_val);
/**
* @brief Start the procedure to read a long characteristic value.
* @note When the procedure is completed, a @ref EVT_BLUE_GATT_PROCEDURE_COMPLETE event is generated.
* Before procedure completion the response packets are given through @ref EVT_BLUE_ATT_READ_BLOB_RESP
* event.
* @param conn_handle Connection handle for which the command is given
* @param attr_handle Handle of the characteristic descriptor
* @param val_offset Offset from which the value needs to be read
* @return Value indicating success or error code.
*/
tBleStatus aci_gatt_read_long_charac_desc(uint16_t conn_handle, uint16_t attr_handle,
uint16_t val_offset);
/**
* @brief Start the procedure to write a characteristic descriptor.
* @note When the procedure is completed, a @ref EVT_BLUE_GATT_PROCEDURE_COMPLETE event is generated.
* @param conn_handle Connection handle for which the command is given
* @param attr_handle Handle of the attribute to be written
* @param value_len Length of the value to be written
* @param[in] attr_value Value to be written
* @return Value indicating success or error code.\n
* It can be @ref BLE_STATUS_NOT_ALLOWED in the following cases:\n
* - If the exchange has already taken place\n
* - If GATT is expecting response for previous request\n
* - Already a request is in the queue to be sent\n
* - Channel not open\n
* - Already one GATT procedure is started
*/
tBleStatus aci_gatt_write_charac_descriptor(uint16_t conn_handle, uint16_t attr_handle,
uint8_t value_len, uint8_t *attr_value);
/**
* @brief Start the procedure to read the descriptor specified.
* @note When the procedure is completed, a @ref EVT_BLUE_GATT_PROCEDURE_COMPLETE event is generated.
* Before procedure completion the response packet is given through @ref EVT_BLUE_ATT_READ_RESP event.
* @param conn_handle Connection handle for which the command is given
* @param attr_handle Handle of the descriptor to be read
* @return Value indicating success or error code.
*/
tBleStatus aci_gatt_read_charac_desc(uint16_t conn_handle, uint16_t attr_handle);
/**
* @brief Start the procedure to write a characteristic value without waiting for any response from the server.
* @note No events are generated after this command is executed.
* @param conn_handle Connection handle for which the command is given
* @param attr_handle Handle of the attribute to be written
* @param val_len Length of the value to be written (up to ATT_MTU - 3)
* @param[in] attr_val Value to be written
* @return Value indicating success or error code.\n
* It can be @ref BLE_STATUS_NOT_ALLOWED in the following cases:\n
* - If the exchange has already taken place\n
* - If GATT is expecting response for previous request\n
* - Already a request is in the queue to be sent\n
* - Channel not open\n
* - Already one GATT procedure is started
*/
tBleStatus aci_gatt_write_without_response(uint16_t conn_handle, uint16_t attr_handle,
uint8_t val_len, const uint8_t* attr_val);
/**
* @brief Start a signed write without response from the server.
* @note The procedure i used to write a characteristic value with an authentication signature without waiting
* for any response from the server. It cannot be used when the link is encrypted.
* @param conn_handle Connection handle for which the command is given
* @param attr_handle Handle of the attribute to be written
* @param val_len Length of the value to be written (up to ATT_MTU - 13).
* @param attr_val Value to be written
* @return Value indicating success or error code
*/
tBleStatus aci_gatt_signed_write_without_resp(uint16_t conn_handle, uint16_t attr_handle,
uint8_t val_len, uint8_t* attr_val);
/**
* @brief Confirm an indication
* @note This command has to be sent when the application receives the event @ref EVT_BLUE_GATT_INDICATION.
* @param conn_handle Connection handle for which the command is given.
* @return Value indicating success or error code.
*/
tBleStatus aci_gatt_confirm_indication(uint16_t conn_handle);
/**
* @brief Allow or reject a write request from a client.
* @note This command has to be sent by the application when it receives the @ref EVT_BLUE_GATT_WRITE_PERMIT_REQ.
* If the write is allowed, then the status and error code has to be set to 0. If the write is not allowed,
* then the status has to be set to 1 and the error code has to be set to the error code that has to be
* passed to the client.
* @param conn_handle Connection handle for which the command is given
* @param attr_handle Handle of the attribute that was passed in the event @ref EVT_BLUE_GATT_WRITE_PERMIT_REQ.
* @param write_status 0x00: The value can be written to the attribute specified by attr_handle\n
* 0x01: The value cannot be written to the attribute specified by the attr_handle.
* @param err_code The error code that has to be passed to the client in case the write has to be rejected.
* @param att_val_len Length of the value to be written as passed in the event @ref EVT_BLUE_GATT_WRITE_PERMIT_REQ.
* @param att_val Value as passed in the event @ref EVT_BLUE_GATT_WRITE_PERMIT_REQ.
* @return Value indicating success or error code.
*/
tBleStatus aci_gatt_write_response(uint16_t conn_handle,
uint16_t attr_handle,
uint8_t write_status,
uint8_t err_code,
uint8_t att_val_len,
uint8_t *att_val);
/**
* @brief Allow the GATT server to send a response to a read request from a client.
* @note The application has to send this command when it receives the @ref EVT_BLUE_GATT_READ_PERMIT_REQ
* or @ref EVT_BLUE_GATT_READ_MULTI_PERMIT_REQ. This command indicates to the stack that the response
* can be sent to the client. So if the application wishes to update any of the attributes before
* they are read by the client, it has to update the characteristic values using the aci_gatt_update_char_value
* and then give this command. The application should perform the required operations within 30 seconds,
* otherwise the GATT procedure will go to timeout.
* @param conn_handle Connection handle for which the command is given.
* @return Value indicating success or error code.
*/
tBleStatus aci_gatt_allow_read(uint16_t conn_handle);
/**
* @brief Set the security permission for the attribute handle specified.
* @note Currently the setting of security permission is allowed only for client configuration descriptor.
* @param service_handle Handle of the service which contains the attribute whose security
* permission has to be modified.
* @param attr_handle Handle of the attribute whose security permission has to be modified.
* @param security_permission Security permissions for the descriptor. See @ref Security_permissions "Security permissions".
* @arg ATTR_PERMISSION_NONE
* @arg ATTR_PERMISSION_AUTHEN_READ
* @arg ATTR_PERMISSION_AUTHOR_READ
* @arg ATTR_PERMISSION_ENCRY_READ
* @arg ATTR_PERMISSION_AUTHEN_WRITE
* @arg ATTR_PERMISSION_AUTHOR_WRITE
* @arg ATTR_PERMISSION_ENCRY_WRITE
* @return Value indicating success or error code.
*/
tBleStatus aci_gatt_set_security_permission(uint16_t service_handle, uint16_t attr_handle,
uint8_t security_permission);
/**
* @brief This command sets the value of the descriptor specified by charDescHandle.
* @param servHandle Handle of the service which contains the descriptor.
* @param charHandle Handle of the characteristic which contains the descriptor.
* @param charDescHandle Handle of the descriptor whose value has to be set.
* @param charDescValOffset Offset from which the descriptor value has to be updated.
* @param charDescValueLen Length of the descriptor value
* @param[in] charDescValue descriptor value
* @return Value indicating success or error code.
*/
tBleStatus aci_gatt_set_desc_value(uint16_t servHandle,
uint16_t charHandle,
uint16_t charDescHandle,
uint16_t charDescValOffset,
uint8_t charDescValueLen,
const uint8_t *charDescValue);
/**
* @brief Reads the value of the attribute handle specified from the local GATT database.
* @param attr_handle Handle of the attribute to read
* @param data_len Length of the data buffer.
* @param[in] data_len_out_p Length of the read attribute.
* @param[in] data Pointer to the buffer that will contain the read value.
* The buffer will be filled with the attribute value.
* The length will be the minimum between the provided data_len and the actual length of the
* attribute (in data_len_out_p).
* @return Value indicating success or error code.
*/
tBleStatus aci_gatt_read_handle_value(uint16_t attr_handle, uint16_t data_len, uint16_t *data_len_out_p, uint8_t *data);
#if BLUENRG_MS
///@cond BLUENRG_MS
/**
* @brief Reads the value of the attribute handle specified from the local GATT database, starting from a given offset.
* @param attr_handle Handle of the attribute to read
* @param offset Offset from which the value needs to be read
* @param data_len Length of the data buffer.
* @param[in] data_len_out_p Length of the read attribute.
* @param[in] data Pointer to the buffer that will contain the read value.
* The buffer will be filled with the attribute value.
* The length will be the minimum between the provided data_len and the actual length of the
* attribute (in data_len_out_p).
* @return Value indicating success or error code.
*/
tBleStatus aci_gatt_read_handle_value_offset(uint16_t attr_handle, uint8_t offset, uint16_t data_len, uint16_t *data_len_out_p, uint8_t *data);
///@endcond
#endif
/**
* @}
*/
/**
* @defgroup GATT_Events GATT events
* The structures are the data field of @ref evt_blue_aci.
* @{
*/
/**
* This event is raised to the application by the GATT server when a client modifies any attribute on the server,
* if event is enabled (see @ref Gatt_Event_Mask "Gatt Event Mask"). See @ref _evt_gatt_attr_modified.
*/
#define EVT_BLUE_GATT_ATTRIBUTE_MODIFIED (0x0C01)
typedef __packed struct _evt_gatt_attr_modified{
uint16_t conn_handle; /**< The connection handle which modified the attribute. */
uint16_t attr_handle; /**< Handle of the attribute that was modified. */
uint8_t data_length; /**< The length of the data */
#if BLUENRG_MS
///@cond BLUENRG_MS
uint16_t offset; /**< Offset from which the write has been performed by the peer device */
///@endcond
#endif
uint8_t att_data[VARIABLE_SIZE]; /**< The new value (length is data_length) */
} PACKED evt_gatt_attr_modified;
/**
* This event is generated by the client/server to the application on a GATT timeout (30 seconds).
* See @ref _evt_gatt_procedure_timeout.
*/
#define EVT_BLUE_GATT_PROCEDURE_TIMEOUT (0x0C02)
typedef __packed struct _evt_gatt_procedure_timeout{
uint16_t conn_handle; /**< The connection handle on which the GATT procedure has timed out */
} PACKED evt_gatt_procedure_timeout;
/**
* This event is generated in response to an Exchange MTU request. See aci_gatt_exchange_configuration().
* See @ref _evt_att_exchange_mtu_resp.
*/
#define EVT_BLUE_ATT_EXCHANGE_MTU_RESP (0x0C03)
typedef __packed struct _evt_att_exchange_mtu_resp{
uint16_t conn_handle; /**< The connection handle related to the response */
uint8_t event_data_length; /**< Length of following data (always 1). */
uint16_t server_rx_mtu; /**< Attribute server receive MTU size */
} PACKED evt_att_exchange_mtu_resp;
/**
* This event is generated in response to a @a Find @a Information @a Request. See aci_att_find_information_req() and
* Find Information Response in Bluetooth Core v4.0 spec. See @ref _evt_att_find_information_resp.
*/
#define EVT_BLUE_ATT_FIND_INFORMATION_RESP (0x0C04)
typedef __packed struct _evt_att_find_information_resp{
uint16_t conn_handle; /**< The connection handle related to the response */
uint8_t event_data_length; /**< Length of following data. */
uint8_t format; /**< The format of the handle_uuid_pair. @arg 1: 16-bit UUIDs @arg 2: 128-bit UUIDs */
/**
* A sequence of handle-uuid pairs.\n
* @li if format=1, each pair is:\n
* [2 octets for handle, 2 octets for UUIDs] \n
* @li if format=2, each pair is:\n
* [2 octets for handle, 16 octets for UUIDs]
*/
uint8_t handle_uuid_pair[VARIABLE_SIZE];
} PACKED evt_att_find_information_resp;
/**
* This event is generated in response to a @a Find @a By @a Type @a Value @a Request. See
* Find By Type Value Response in Bluetooth Core v4.0 spec. See @ref _evt_att_find_by_type_val_resp.
*/
#define EVT_BLUE_ATT_FIND_BY_TYPE_VAL_RESP (0x0C05)
typedef __packed struct _evt_att_find_by_type_val_resp{
uint16_t conn_handle; /**< The connection handle related to the response */
uint8_t event_data_length; /**< Length of following data. */
/**
* Handles Information List as defined in Bluetooth Core v4.0 spec.
* A sequence of handle pairs: [2 octets for Found Attribute Handle, 2 octets for Group End Handle]
*/
uint8_t handles_info_list[VARIABLE_SIZE];
} PACKED evt_att_find_by_type_val_resp;
/**
* This event is generated in response to a @a Read @a By @a Type @a Request. See aci_gatt_find_included_services() and
* aci_gatt_disc_all_charac_of_serv().
* For more info see Read By Type Response in Bluetooth Core v4.0 spec. See @ref _evt_att_read_by_type_resp.
*/
#define EVT_BLUE_ATT_READ_BY_TYPE_RESP (0x0C06)
typedef __packed struct _evt_att_read_by_type_resp{
uint16_t conn_handle; /**< The connection handle related to the response */
uint8_t event_data_length; /**< Length of following data. */
uint8_t handle_value_pair_length; /**< The size of each attribute handle-value pair */
/**
* Attribute Data List as defined in Bluetooth Core v4.0 spec.
* A sequence of handle-value pairs: [2 octets for Attribute Handle, (handle_value_pair_length - 2 octets) for Attribute Value]
*/
uint8_t handle_value_pair[VARIABLE_SIZE];
} PACKED evt_att_read_by_type_resp;
/**
* This event is generated in response to a @a Read @a Request. See aci_gatt_read_charac_val().
* For more info see Read Response in Bluetooth Core v4.0 spec. See @ref _evt_att_read_resp.
*/
#define EVT_BLUE_ATT_READ_RESP (0x0C07)
typedef __packed struct _evt_att_read_resp{
uint16_t conn_handle; /**< The connection handle related to the response. */
uint8_t event_data_length; /**< Length of following data. */
uint8_t attribute_value[VARIABLE_SIZE]; /**< The value of the attribute. */
} PACKED evt_att_read_resp;
/**
* This event is generated in response to a @a Read @a Blob @a Request. See aci_gatt_read_long_charac_val().
* For more info see Read Blob Response in Bluetooth Core v4.0 spec. See @ref _evt_att_read_blob_resp.
*/
#define EVT_BLUE_ATT_READ_BLOB_RESP (0x0C08)
typedef __packed struct _evt_att_read_blob_resp{
uint16_t conn_handle; /**< The connection handle related to the response. */
uint8_t event_data_length; /**< Length of following data. */
uint8_t part_attribute_value[VARIABLE_SIZE]; /**< Part of the attribute value. */
} PACKED evt_att_read_blob_resp;
/**
* This event is generated in response to a @a Read @a Multiple @a Request.
* For more info see Read Multiple Response in Bluetooth Core v4.0 spec. See @ref _evt_att_read_mult_resp.
*/
#define EVT_BLUE_ATT_READ_MULTIPLE_RESP (0x0C09)
typedef __packed struct _evt_att_read_mult_resp{
uint16_t conn_handle; /**< The connection handle related to the response. */
uint8_t event_data_length; /**< Length of following data. */
uint8_t set_of_values[VARIABLE_SIZE]; /**< A set of two or more values.*/
} PACKED evt_att_read_mult_resp;
/**
* This event is generated in response to a @a Read @a By @a Group @a Type @a Request. See aci_gatt_disc_all_prim_services().
* For more info see Read By Group type Response in Bluetooth Core v4.0 spec. See @ref _evt_att_read_by_group_resp.
*/
#define EVT_BLUE_ATT_READ_BY_GROUP_TYPE_RESP (0x0C0A)
typedef __packed struct _evt_att_read_by_group_resp{
uint16_t conn_handle; /**< The connection handle related to the response. */
uint8_t event_data_length; /**< Length of following data. */
uint8_t attribute_data_length; /**< The size of each Attribute Data. */
/**
* A list of Attribute Data where the attribute data is composed by:
* @li 2 octets for Attribute Handle
* @li 2 octets for End Group Handle
* @li (attribute_data_length - 4) octets for Attribute Value
*/
uint8_t attribute_data_list[VARIABLE_SIZE];
} PACKED evt_att_read_by_group_resp;
/**
* This event is generated in response to a @a Prepare @a Write @a Request.
* For more info see Prepare Write Response in Bluetooth Core v4.0 spec. See @ref _evt_att_prepare_write_resp.
*/
#define EVT_BLUE_ATT_PREPARE_WRITE_RESP (0x0C0C)
typedef __packed struct _evt_att_prepare_write_resp{
uint16_t conn_handle; /**< The connection handle related to the response. */
uint8_t event_data_length; /**< Length of following data. */
uint16_t attribute_handle; /**< The handle of the attribute to be written. */
uint16_t offset; /**< The offset of the first octet to be written. */
uint8_t part_attr_value[VARIABLE_SIZE]; /**< The value of the attribute to be written. */
} PACKED evt_att_prepare_write_resp;
/**
* This event is generated in response to an @a Execute @a Write @a Request.
* For more info see Execute Write Response in Bluetooth Core v4.0 spec. See @ref _evt_att_exec_write_resp.
*/
#define EVT_BLUE_ATT_EXEC_WRITE_RESP (0x0C0D)
typedef __packed struct _evt_att_exec_write_resp{
uint16_t conn_handle; /**< The connection handle related to the response. */
uint8_t event_data_length; /**< Always 0. */
} PACKED evt_att_exec_write_resp;
/**
* This event is generated when an indication is received from the server.
* For more info see Handle Value Indication in Bluetooth Core v4.0 spec. See @ref _evt_gatt_indication.
*/
#define EVT_BLUE_GATT_INDICATION (0x0C0E)
typedef __packed struct _evt_gatt_indication{
uint16_t conn_handle; /**< The connection handle related to the event. */
uint8_t event_data_length; /**< Length of following data. */
uint16_t attr_handle; /**< The handle of the attribute. */
uint8_t attr_value[VARIABLE_SIZE]; /**< The current value of the attribute. */
} PACKED evt_gatt_indication;
/**
* This event is generated when a notification is received from the server.
* For more info see Handle Value Notification in Bluetooth Core v4.0 spec. See @ref _evt_gatt_notification.
*/
#define EVT_BLUE_GATT_NOTIFICATION (0x0C0F)
typedef __packed struct _evt_gatt_notification{
uint16_t conn_handle; /**< The connection handle related to the event. */
uint8_t event_data_length; /**< Length of following data. */
uint16_t attr_handle; /**< The handle of the attribute. */
uint8_t attr_value[VARIABLE_SIZE]; /**< The current value of the attribute. */
} PACKED evt_gatt_attr_notification;
/**
* This event is generated when a GATT client procedure completes either with error or successfully.
* See @ref _evt_gatt_procedure_complete.
*/
#define EVT_BLUE_GATT_PROCEDURE_COMPLETE (0x0C10)
typedef __packed struct _evt_gatt_procedure_complete{
uint16_t conn_handle; /**< The connection handle on which the GATT procedure has completed */
uint8_t data_length; /**< Length of error_code field (always 1). */
/**
* Indicates whether the procedure completed with error (BLE_STATUS_FAILED) or was successful (BLE_STATUS_SUCCESS).
*/
uint8_t error_code;
} PACKED evt_gatt_procedure_complete;
/**
* This event is generated when an Error Response is received from the server. The error response can be given
* by the server at the end of one of the GATT discovery procedures. This does not mean that the procedure ended
* with an error, but this error event is part of the procedure itself. See @ref _evt_gatt_error_resp.
*/
#define EVT_BLUE_GATT_ERROR_RESP (0x0C11)
typedef __packed struct _evt_gatt_error_resp{
uint16_t conn_handle; /**< The connection handle related to the event. */
uint8_t event_data_length; /**< Length of following data. */
uint8_t req_opcode; /**< The request that generated this error response. */
uint16_t attr_handle; /**< The attribute handle that generated this error response. */
uint8_t error_code; /**< The reason why the request has generated an error response. See Error Response in Bluetooth Core v4.0 spec. */
} PACKED evt_gatt_error_resp;
/**
* This event can be generated during a "Discover Characteristics By UUID" procedure or a "Read using
* Characteristic UUID" procedure.
* The attribute value will be a service declaration as defined in Bluetooth Core v4.0 spec (vol.3, Part G, ch. 3.3.1),
* when a "Discover Characteristics By UUID" has been started. It will be the value of the Characteristic if a
* "Read using Characteristic UUID" has been performed. See @ref _evt_gatt_disc_read_char_by_uuid_resp.
*/
#define EVT_BLUE_GATT_DISC_READ_CHAR_BY_UUID_RESP (0x0C12)
typedef __packed struct _evt_gatt_disc_read_char_by_uuid_resp{
uint16_t conn_handle; /**< The connection handle related to the event. */
uint8_t event_data_length; /**< Length of following data. */
uint16_t attr_handle; /**< The handle of the attribute. */
/**
* The attribute value will be a service declaration as defined in Bluetooth Core v4.0 spec (vol.3, Part G, ch. 3.3.1),
* when a "Discover Characteristics By UUID" has been started. It will be the value of the Characteristic if a
* "Read using Characteristic UUID" has been performed.
*/
uint8_t attr_value[VARIABLE_SIZE];
} PACKED evt_gatt_disc_read_char_by_uuid_resp;
/**
* This event is given to the application when a write request, write command or signed write command
* is received by the server from the client. This event will be given to the application only if the
* event bit for this event generation is set when the characteristic was added.
* When this event is received, the application has to check whether the value being requested for write
* is allowed to be written and respond with the command aci_gatt_write_response().
* If the write is rejected by the application, then the value of the attribute will not be modified.
* In case of a write request, an error response will be sent to the client, with the error code as specified by the application.
* In case of write/signed write commands, no response is sent to the client but the attribute is not modified.