-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcy_ble_stack_gatt_client.h
1670 lines (1537 loc) · 81.3 KB
/
cy_ble_stack_gatt_client.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
/*******************************************************************************
* \file cy_ble_stack_gatt_client.h
* \version 3.60
*
* \brief
* This file contains declarations of public BLE APIs of Generic Attribute Profile - Client Role.
* Also specifies the defines, constants, and data structures required for the APIs.
*
* Related Document:
* BLE Standard Spec - CoreV4.2, CSS, CSAs, ESR05, ESR06
*
********************************************************************************
* \copyright
* Copyright 2017-2021, Cypress Semiconductor Corporation. All rights reserved.
* You may use this file only in accordance with the license, terms, conditions,
* disclaimers, and limitations in the end user license agreement accompanying
* the software package with which this file was provided.
*******************************************************************************/
#ifndef CY_BLE_STACK_GATT_CLIENT_H_
#define CY_BLE_STACK_GATT_CLIENT_H_
/***************************************
* Common BLE Stack includes
***************************************/
#include "cy_ble_stack_gatt.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/***************************************
** Exported data structures
***************************************/
/**
\addtogroup group_ble_common_api_gatt_definitions
@{
*/
/** Stop command parameter */
typedef struct
{
/**Connection handle*/
cy_stc_ble_conn_handle_t connHandle;
}cy_stc_ble_gattc_stop_cmd_param_t;
/** GATT Discover primary service request parameter */
typedef struct
{
/** Handle Range */
cy_stc_ble_gatt_attr_handle_range_t range;
/**Connection handle*/
cy_stc_ble_conn_handle_t connHandle;
}cy_stc_ble_gattc_read_by_group_req_t;
/** GATT Discover primary service by UUID request parameter */
typedef struct
{
/** Attribute Value to Find */
cy_stc_ble_gatt_value_t value;
/** Handle Range - Start and End Handle */
cy_stc_ble_gatt_attr_handle_range_t range;
/** 16-bit UUID to Find */
cy_ble_uuid16_t uuid;
/**Connection handle*/
cy_stc_ble_conn_handle_t connHandle;
}cy_stc_ble_gattc_find_by_type_value_req_t;
/** GATT read by type request parameter */
typedef struct
{
/** Handle Range */
cy_stc_ble_gatt_attr_handle_range_t range;
/** GATT UUID type */
cy_ble_uuid_t uuid;
/** Format indicating, 16-bit or 128-bit UUIDs
* For 16-bit UUID format - CY_BLE_GATT_16_BIT_UUID_FORMAT (0x01)
* For 128-bit UUID format - CY_BLE_GATT_128_BIT_UUID_FORMAT (0x02)
*/
uint8_t uuidFormat;
/**Connection handle*/
cy_stc_ble_conn_handle_t connHandle;
}cy_stc_ble_gattc_read_by_type_req_t;
/** GATT find info request parameter */
typedef cy_stc_ble_gattc_read_by_group_req_t cy_stc_ble_gattc_find_info_req_t;
/** Read request parameter */
typedef struct
{
/** Handle on which Read Blob is requested */
cy_ble_gatt_db_attr_handle_t attrHandle;
/**Connection handle*/
cy_stc_ble_conn_handle_t connHandle;
}cy_stc_ble_gattc_read_req_t;
/** Handle-offset pair parameter */
typedef struct
{
/** Handle on which Read Blob is requested */
cy_ble_gatt_db_attr_handle_t attrHandle;
/** Value Offset from which the Read is Requested */
uint16_t offset;
}cy_stc_ble_gattc_handle_offset_pair_t;
/** Read blob request parameter */
typedef struct
{
/** Handle-offset pair parameter */
cy_stc_ble_gattc_handle_offset_pair_t handleOffset;
/**Connection handle*/
cy_stc_ble_conn_handle_t connHandle;
}cy_stc_ble_gattc_read_blob_req_t;
/** GATT handle list type */
typedef struct
{
/** Handle list where the UUID with value indicated is found */
uint16_t * handleList;
/** Number of Handles in the list */
uint16_t listCount;
/** Actual Number of Handles Packed. This is a output parameter */
uint16_t actualCount;
}cy_stc_ble_gattc_handle_list_t;
/** Read multiple request parameter */
typedef struct
{
/** GATT handle list type */
cy_stc_ble_gattc_handle_list_t handleListType;
/**Connection handle*/
cy_stc_ble_conn_handle_t connHandle;
}cy_stc_ble_gattc_read_mult_req_t;
/** Write request parameter */
typedef cy_stc_ble_gatt_write_param_t cy_stc_ble_gattc_write_req_t;
/** Prepare Write request parameter */
typedef cy_stc_ble_gatt_prep_write_param_t cy_stc_ble_gattc_prep_write_req_t;
/** Prepare Write request parameter for reliable write request */
typedef struct
{
/** handle value offset pair */
cy_stc_ble_gatt_handle_value_offset_param_t * handleValOffsetPair;
/** Connection handle */
cy_stc_ble_conn_handle_t connHandle;
/** Number of requests. That is, the count of array of structures
of type 'cy_stc_ble_gatt_handle_value_offset_param_t'. Each array element
represents a value and the attribute to which the value has
to be written */
uint8_t numOfRequests;
}cy_stc_ble_gattc_reliable_write_req_t;
/** Execute Write request parameter */
typedef struct
{
/** Connection handle */
cy_stc_ble_conn_handle_t connHandle;
/** Indicates whether Queued Write is to be executed (0x01) or canceled (0x00) */
uint8_t flag;
}cy_stc_ble_gattc_exec_write_req_t;
/** Write command request to be sent to Server */
typedef cy_stc_ble_gattc_write_req_t cy_stc_ble_gattc_write_cmd_req_t;
/** Signed Write command request to be sent to Server */
typedef cy_stc_ble_gattc_write_req_t cy_stc_ble_gattc_signed_write_cmd_req_t;
/** Signed Write command request to be sent to Server */
typedef cy_stc_ble_gattc_stop_cmd_param_t cy_stc_ble_gattc_confirmation_req_t;
/* --------------------------Structure corresponding to events-------------------- */
/** Read response parameter type received from server*/
typedef struct
{
/** Attribute Value */
cy_stc_ble_gatt_value_t value;
/** Connection handle */
cy_stc_ble_conn_handle_t connHandle;
}cy_stc_ble_gattc_read_rsp_param_t;
/** Handle value notification data received from server */
typedef cy_stc_ble_gattc_write_req_t cy_stc_ble_gattc_handle_value_ntf_param_t;
/** GATT handle value indication parameter received from server type */
typedef cy_stc_ble_gattc_write_req_t cy_stc_ble_gattc_handle_value_ind_param_t;
/** Data Element for Group Response */
typedef struct
{
/** attribute handle value pair */
uint8_t * attrValue;
/** Length of each Attribute Data Element including the Handle Range */
uint16_t length;
/** Total Length of Attribute Data */
uint16_t attrLen;
}cy_stc_ble_gattc_grp_attr_data_list_t;
/** Read By Group Response received from Server*/
typedef struct
{
/** Group attribute data list */
cy_stc_ble_gattc_grp_attr_data_list_t attrData;
/** Connection handle */
cy_stc_ble_conn_handle_t connHandle;
}cy_stc_ble_gattc_read_by_grp_rsp_param_t;
/** GATT read by type response received from server*/
typedef cy_stc_ble_gattc_read_by_grp_rsp_param_t cy_stc_ble_gattc_read_by_type_rsp_param_t;
/** GATT find by type value response received from server*/
typedef struct
{
/** Handle Range list */
cy_stc_ble_gatt_attr_handle_range_t * range;
/** Size of list */
uint8_t count;
/** Connection handle */
cy_stc_ble_conn_handle_t connHandle;
}cy_stc_ble_gattc_find_by_type_rsp_param_t;
/** GATT list of Handle UUID pair parameter type */
typedef struct
{
/** Handle - UUID Pair list
This is a packed byte stream, hence it needs to be unpacked and decoded. */
uint8_t *list;
/** Number of elements in the list in bytes */
uint16_t byteCount;
}cy_stc_ble_gattc_handle_uuid_list_param_t;
/** GATT find info response received from Server*/
typedef struct
{
/** Handle Value list */
cy_stc_ble_gattc_handle_uuid_list_param_t handleValueList;
/** Connection handle */
cy_stc_ble_conn_handle_t connHandle;
/** Format indicating, 16-bit (0x01) or 128-bit (0x02) UUIDs */
uint8_t uuidFormat;
}cy_stc_ble_gattc_find_info_rsp_param_t;
/** Execute Write result */
typedef struct
{
/**Connection handle*/
cy_stc_ble_conn_handle_t connHandle;
/** Result of the execute write request */
uint8_t result;
}cy_stc_ble_gattc_exec_write_rsp_param_t;
/** Long procedure end indication event parameter */
typedef struct
{
/**Connection handle*/
cy_stc_ble_conn_handle_t connHandle;
/** Result of the execute write request */
uint8_t opcode;
}cy_stc_ble_gattc_long_procedure_end_param_t;
/** Execute Write response parameter */
typedef cy_stc_ble_gattc_exec_write_req_t cy_stc_ble_gattc_exec_write_rsp_t;
/** @} */
/***************************************
** Exported APIs
***************************************/
/**
\addtogroup group_ble_common_api_gatt_client_functions
@{
*/
/******************************************************************************
* Function Name: Cy_BLE_GATTC_StopCmd
***************************************************************************//**
*
* This function is used by the GATT Client application to stop any of the following ongoing
* GATT procedures:
* 1. Cy_BLE_GATTC_DiscoverPrimaryServices()
* 2. Cy_BLE_GATTC_DiscoverPrimaryServiceByUuid()
* 3. Cy_BLE_GATTC_FindIncludedServices()
* 4. Cy_BLE_GATTC_DiscoverCharacteristics()
* 5. Cy_BLE_GATTC_DiscoverCharacteristicByUuid()
* 6. Cy_BLE_GATTC_DiscoverCharacteristicDescriptors()
* 7. Cy_BLE_GATTC_ReadLongCharacteristicValues()
* 8. Cy_BLE_GATTC_WriteLongCharacteristicValues()
* 9. Cy_BLE_GATTC_ReliableWrites()
* 10. Cy_BLE_GATTC_ReadLongCharacteristicDescriptors()
* 11. Cy_BLE_GATTC_WriteLongCharacteristicDescriptors()
* 12. Cy_BLE_GATTC_ReadByTypeReq()
* .
* If none of the above procedures is ongoing, then this command will be ignored.
* This function has no effect on ATT procedures other than those listed above.
* If the procedure is ongoing, this function will stop it and inform that the operation
* is successful through the event 'CY_BLE_EVT_GATTC_STOP_CMD_COMPLETE'.
* This is a non-blocking function.
*
* If the user intends to start a new GATT procedure including those listed above
* and there is an ongoing GATT procedure (any one from the above list), the user
* needs to call this function to stop the ongoing GATT procedure and then invoke
* the desired GATT procedure.
*
* \param param: parameter is of type cy_stc_ble_gattc_stop_cmd_param_t.
* param->connHandle: Connection handle to identify the peer GATT entity of type
* cy_stc_ble_conn_handle_t.
*
* \return
* cy_en_ble_api_result_t : Return value indicates whether the function succeeded or
* failed. Following are the possible error codes.
*
* Error codes | Description
* ------------ | -----------
* CY_BLE_SUCCESS | On successful operation.
* CY_BLE_ERROR_INVALID_PARAMETER | If 'param' is NULL or 'connHandle' is invalid.
*
******************************************************************************/
cy_en_ble_api_result_t Cy_BLE_GATTC_StopCmd
(
cy_stc_ble_gattc_stop_cmd_param_t * param
);
/******************************************************************************
* Function Name: Cy_BLE_GATTC_ExchangeMtuReq
***************************************************************************//**
*
* This function is used by the GATT Client application to send Exchange MTU Request PDU.
* This function is used to send maximum size of packet (GATT MTU) that cab be received by
* GATT Client application. This is a non-blocking function.
*
* Default GATT MTU size as per Bluetooth 5.0 core specification is 23 bytes. If
* the GATT Client application supports a size greater than the default, it has to invoke
* this function with the desired GATT MTU size. This function should be
* initiated only once during a connection.
*
* Refer to Bluetooth 5.0 core specification, Volume 3, Part G, section 4.3.1
* for more details on GATT MTU exchange operation.
*
* If the peer GATT Server device is a PSoC 6 MCU, Exchange MTU Request PDU results in
* CY_BLE_EVT_GATTS_XCNHG_MTU_REQ event at the GATT Server's end, in response
* to which the GATT Server is expected to send its maximum size of packet (GATT MTU).
*
* The CY_BLE_EVT_GATTC_XCHNG_MTU_RSP event is generated at the
* GATT Client application on receiving GATT MTU response from the GATT Server.
*
* \param param: parameter is of type CY_BLE_GATT_XCHG_MTU_REQ_PARAM_T.
* param->mtu: Size of GATT MTU.
*
* \return
* cy_en_ble_api_result_t : Return value indicates whether the function succeeded or
* failed. Following are the possible error codes.
*
* Error codes | Description
* ------------ | -----------
* CY_BLE_SUCCESS | On successful operation.
* CY_BLE_ERROR_INVALID_PARAMETER | If 'param' is NULL or 'connHandle' is invalid or, 'mtu' value is greater than that set on calling Cy_BLE_StackInit().
* CY_BLE_ERROR_INVALID_OPERATION | This operation is not permitted.
* CY_BLE_ERROR_MEMORY_ALLOCATION_FAILED| Memory allocation failed.
*
******************************************************************************/
cy_en_ble_api_result_t Cy_BLE_GATTC_ExchangeMtuReq
(
cy_stc_ble_gatt_xchg_mtu_param_t * param
);
/******************************************************************************
* Function Name: Cy_BLE_GATTC_DiscoverPrimaryServices
***************************************************************************//**
*
* This function is used by the GATT Client application to discover the primary services as
* per the handle-range provided, on a peer GATT Server.
* This is a non-blocking function.
*
* Internally, this function initiates multiple Read By Group Type Requests to
* the peer device, in response to which it receives Read By Group Type Responses.
* Each Read By Group Type Response results in
* CY_BLE_EVT_GATTC_READ_BY_GROUP_TYPE_RSP event, which is propagated to the
* application layer for handling.
*
* Primary service discovery is complete when Error Response
* (CY_BLE_EVT_GATTC_ERROR_RSP) is received with Error Code set to Attribute
* Not Found or when the End Group Handle in the Read by Group Type Response is
* 0xFFFF. Completion of this operation is notified to the upper layer(s) using
* CY_BLE_EVT_GATTC_ERROR_RSP or CY_BLE_EVT_GATTC_LONG_PROCEDURE_END event.
*
* Application can stop the primary service discovery if the
* desired primary service is found prior to discovering all the primary services
* on the GATT Server. This can be achieved by using the Cy_BLE_GATTC_StopCmd()
* function.
*
* Refer to Bluetooth 5.0 core specification, Volume 3, Part G, section 4.5.0 for
* more details on this sequence of operations.
*
* \param param: parameter is of type cy_stc_ble_gattc_read_by_group_req_t.
* param->connHandle: Connection handle of type cy_stc_ble_conn_handle_t
* to identify the peer GATT entity.
* param->range: Parameter is of type cy_stc_ble_gatt_attr_handle_range_t where,
* 1. 'range.startHandle' can be set to the start handle of the desired
* primary service.
* 2. 'range.endHandle' can be set to the end handle of the desired
* primary service.
* \note
* 'startHandle' & 'endHandle' should not be zero and 'startHandle' shall be less than or equal to the 'endHandle'.
*
* \return
* cy_en_ble_api_result_t : Return value indicates whether the function succeeded or
* failed. Following are the possible error codes.
*
* Error codes | Description
* ------------ | -----------
* CY_BLE_SUCCESS | On successful operation.
* CY_BLE_ERROR_INVALID_PARAMETER | If 'param' is NULL or if any of the input parameters is invalid.
* CY_BLE_ERROR_INVALID_OPERATION | This operation is not permitted.
* CY_BLE_ERROR_MEMORY_ALLOCATION_FAILED| Memory allocation failed.
*
******************************************************************************/
cy_en_ble_api_result_t Cy_BLE_GATTC_DiscoverPrimaryServices
(
cy_stc_ble_gattc_read_by_group_req_t * param
);
/******************************************************************************
* Function Name: Cy_BLE_GATTC_DiscoverPrimaryServiceByUuid
***************************************************************************//**
*
* This function is used by the GATT Client application to discover a specific primary
* service on a peer GATT Server, when only the Service UUID is known.
* This is a non-blocking function.
*
* Internally, this function initiates multiple Find By Type Value Requests with
* the Attribute Type parameter set to the UUID for Primary Service and the
* Attribute Value set to the 16-bit Bluetooth UUID or 128-bit UUID for the
* specific primary service. Each Find By Type Value Response received from the
* peer device is passed to the application as
* CY_BLE_EVT_GATTC_FIND_BY_TYPE_VALUE_RSP event.
*
* The sequence of operations is complete when the Error Response is received
* and the Error Code is set to Attribute Not Found or when the End Group
* Handle in the Find By Type Value Response is 0xFFFF. Completion of this
* function is notified to the upper layer using CY_BLE_EVT_GATTC_ERROR_RSP or
* CY_BLE_EVT_GATTC_LONG_PROCEDURE_END event.
*
* Application can stop this procedure if a desired primary service is found
* prior to the discovery of all the primary services of the specified service UUID supported
* on the GATT Server. This can be achieved by using the Cy_BLE_GATTC_StopCmd()
* function.
*
* Refer to Bluetooth 5.0 core specification, Volume 3, Part G, section 4.4.2
* for more details on this sequence of operations.
*
* \param param: parameter is of type cy_stc_ble_gattc_find_by_type_value_req_t.
* param->connHandle: Connection handle of type cy_stc_ble_conn_handle_t
* to identify the peer GATT entity.
* param->range and param->uuid are ignored in this function.
* param->value: Parameter is of type cy_stc_ble_gatt_value_t, where,
* 1. 'value.val' should point to uint8_t array containing the UUID to
* look for. UUID can be 16 or 128 bit.
* 2. 'value.len' should be set to 2 if the 16-bit UUID is to be found.
* The length should be set to 16 if 128-bit UUID is to be found.
* 3. 'value.actualLen' is an unused parameter and should be ignored.
*
* \return
* cy_en_ble_api_result_t : Return value indicates whether the function succeeded or
* failed. Following are the possible error codes.
*
* Error codes | Description
* ------------ | -----------
* CY_BLE_SUCCESS | On successful operation.
* CY_BLE_ERROR_INVALID_PARAMETER | If 'param' is NULL or 'connHandle' is invalid.
* CY_BLE_ERROR_INVALID_OPERATION | This operation is not permitted.
* CY_BLE_ERROR_MEMORY_ALLOCATION_FAILED| Memory allocation failed.
*
******************************************************************************/
cy_en_ble_api_result_t Cy_BLE_GATTC_DiscoverPrimaryServiceByUuid
(
cy_stc_ble_gattc_find_by_type_value_req_t * param
);
/******************************************************************************
* Function Name: Cy_BLE_GATTC_DiscoverCharacteristics
***************************************************************************//**
*
* This function is used by the GATT Client application to find all characteristic
* declarations within a service definition on a peer GATT Server, when
* only the service handle range is known.
* This is a non-blocking function.
*
* Internally, multiple Read By Type Requests are sent to the GATT Server in
* response to which Read By Type Responses are received. Each response results
* in the event CY_BLE_EVT_GATTC_READ_BY_TYPE_RSP, which is passed to the
* application layer for handling.
*
* The sequence of operations is complete when the Error Response is received and the
* Error Code is set to Attribute Not Found or the Read By Type Response has an
* Attribute Handle that is equal to the Ending Handle of the request.
* Completion of this function is notified to the upper layer using
* CY_BLE_EVT_GATTC_ERROR_RSP or with the CY_BLE_EVT_GATTC_LONG_PROCEDURE_END
* event.
*
* Application can stop this procedure if a desired characteristic is found
* prior to the discovering all the characteristics of the specified service supported
* on the GATT Server. This can be achieved by using the Cy_BLE_GATTC_StopCmd()
* function.
*
* Refer to Bluetooth 5.0 core specification, Volume 3, Part G, section 4.6.1 for
* more details on the sequence of operations.
*
* \param param: Pointer to a variable of type cy_stc_ble_gattc_read_by_type_req_t,
* The following must be set:
* param->range.startHandle <br>
* param->range.endHandle <br>
* param->connHandle <br>
* The following must be ignored:
* param->uuidFormat (CY_BLE_GATT_16_BIT_UUID_FORMAT or
* CY_BLE_GATT_128_BIT_UUID_FORMAT) <br>
* param->uuid.uuid16 or param->uuid.uuid128
* based on the uuidFormat
* \note
* 'startHandle' & 'endHandle' should not be zero, and 'startHandle' shall be less than or equal to the 'endHandle'.
*
* \return
* cy_en_ble_api_result_t : Return value indicates whether the function succeeded or
* failed. Following are the possible error codes.
*
* Error codes | Description
* ------------ | -----------
* CY_BLE_SUCCESS | On successful operation.
* CY_BLE_ERROR_INVALID_PARAMETER | If 'param' is NULL or if any of the input parameters is invalid.
* CY_BLE_ERROR_INVALID_OPERATION | This operation is not permitted.
* CY_BLE_ERROR_MEMORY_ALLOCATION_FAILED| Memory allocation failed.
*
******************************************************************************/
cy_en_ble_api_result_t Cy_BLE_GATTC_DiscoverCharacteristics
(
cy_stc_ble_gattc_read_by_type_req_t * param
);
/******************************************************************************
* Function Name: Cy_BLE_GATTC_DiscoverCharacteristicByUuid
***************************************************************************//**
*
* This function is used by the GATT Client application to discover service characteristics
* on a peer GATT Server, when only the service handle ranges are known and the
* characteristic UUID is known.
* This is a non-blocking function.
*
* Internally, multiple Read By Type Requests are sent to the peer device in
* response to which Read By Type Responses are received. Each of these responses
* results in the event CY_BLE_EVT_GATTC_READ_BY_TYPE_RSP, which is passed to the
* application layer for further processing.
*
* The sequence of operations is complete when the Error Response is received and the
* Error Code is set to Attribute Not Found or the Read By Type Response has an
* Attribute Handle that is equal to the Ending Handle of the request.
* Completion of this function is notified to the upper layer using
* CY_BLE_EVT_GATTC_ERROR_RSP or CY_BLE_EVT_GATTC_LONG_PROCEDURE_END event.
*
* Application can stop this procedure if a desired characteristic is found
* prior to the discovering all the characteristics of the specified service supported
* on the GATT Server. This can be achieved by using the Cy_BLE_GATTC_StopCmd()
* function.
*
* Refer to Bluetooth 5.0 core specification, Volume 3, Part G, section 4.6.2
* for more details on the sequence of operations.
*
* \param param: Pointer to a variable of type cy_stc_ble_gattc_read_by_type_req_t,
* The following must be set:
* param->range.startHandle
* param->range.endHandle
* param->connHandle
* param->uuidFormat (CY_BLE_GATT_16_BIT_UUID_FORMAT or
* CY_BLE_GATT_128_BIT_UUID_FORMAT)
* param->uuid.uuid16 or readByTypeReqParam->uuid.uuid128
* based on the uuidFormat
* \note
* 'startHandle' & 'endHandle' should not be zero, and 'startHandle' shall be less than or equal to the 'endHandle'.
*
* \return
* cy_en_ble_api_result_t : Return value indicates whether the function succeeded or
* failed. Following are the possible error codes.
*
* Error codes | Description
* ------------ | -----------
* CY_BLE_SUCCESS | On successful operation.
* CY_BLE_ERROR_INVALID_PARAMETER | If 'param' is NULL or if any of the input parameters is invalid.
* CY_BLE_ERROR_INVALID_OPERATION | This operation is not permitted.
* CY_BLE_ERROR_MEMORY_ALLOCATION_FAILED| Memory allocation failed.
*
******************************************************************************/
cy_en_ble_api_result_t Cy_BLE_GATTC_DiscoverCharacteristicByUuid
(
cy_stc_ble_gattc_read_by_type_req_t * param
);
/******************************************************************************
* Function Name: Cy_BLE_GATTC_DiscoverCharacteristicDescriptors
***************************************************************************//**
*
* This function is used by the GATT Client application to find all the characteristic
* descriptors on a peer GATT Server. This is a non-blocking function.
*
* Internally, multiple Find Information Requests are sent to the peer device in
* response to which Find Information Responses are received by the GATT Client application.
* Each of these responses generate CY_BLE_EVT_GATTC_FIND_INFO_RSP event at the
* GATT Client application end.
*
* The sequence of operations is complete when the Error Response is received and the
* Error Code is set to Attribute Not Found or the Find Information Response has
* an Attribute Handle that is equal to the Ending Handle of the request.
* Completion of this function is notified to the upper layer using CY_BLE_EVT_GATTC_ERROR_RSP or
* CY_BLE_EVT_GATTC_LONG_PROCEDURE_END event.
*
* Application can stop this procedure if the desired Characteristic Descriptor
* is found prior to the discovering all the characteristic descriptors of the
* specified characteristic. This can be achieved by using the Cy_BLE_GATTC_StopCmd()
* function.
*
*
* Refer to Bluetooth 5.0 core specification, Volume 3, Part G, section 4.7.1 for
* more details on the sequence of operations.
*
* \param param: Pointer to a variable of type cy_stc_ble_gattc_find_info_req_t.
* The following must be set:
* param->range.startHandle <br>
* param->range.endHandle <br>
* param->connHandle <br>
* \note
* 'startHandle' & 'endHandle' should not be zero, and 'startHandle' shall be less than or equal to the 'endHandle'.
*
* \return
* cy_en_ble_api_result_t : Return value indicates whether the function succeeded or
* failed. Following are the possible error codes.
*
* Error codes | Description
* ------------ | -----------
* CY_BLE_SUCCESS | On successful operation.
* CY_BLE_ERROR_INVALID_PARAMETER | If 'param' is NULL or if any of the input parameters is invalid.
* CY_BLE_ERROR_INVALID_OPERATION | This operation is not permitted.
* CY_BLE_ERROR_MEMORY_ALLOCATION_FAILED| Memory allocation failed.
*
******************************************************************************/
cy_en_ble_api_result_t Cy_BLE_GATTC_DiscoverCharacteristicDescriptors
(
cy_stc_ble_gattc_find_info_req_t * param
);
/******************************************************************************
* Function Name: Cy_BLE_GATTC_FindIncludedServices
***************************************************************************//**
*
* This function is used by the GATT Client application to find Included Service
* declarations within a GATT Service on a peer GATT Server. This is a
* non-blocking function.
*
* Internally, multiple Read By Type Requests are sent to the peer device in
* response to which Read By Type Responses are received
* (CY_BLE_EVT_GATTC_READ_BY_TYPE_RSP) and passed to the application layer.
*
* When Read By Type Response data does not contain the service UUID,
* indicating the service uses a 128-bit UUID, the application layer can
* choose to get the service UUID by performing the following steps:
* 1. Stop ongoing GATT operation by invoking Cy_BLE_GATTC_StopCmd()
* 2. Send Read Request by invoking the function
* Cy_BLE_GATTC_ReadCharacteristicValue() with the read request attribute handle set to
* the included service attribute handle. Application should handle CY_BLE_EVT_GATTC_READ_RSP event.
* 3. Include service discovery can further be continued by calling Cy_BLE_GATTC_FindIncludedServices() function with
* start handle (param->range.startHandle) equals to (included service attribute handle + 1).
*
* The sequence of operations is complete when either the Error Response is received
* with the Error Code set to Attribute Not Found or the Read By Type Response
* has an Attribute Handle of the included service declaration that is equal to the
* Ending Handle of the request. Completion of
* this function is notified to the upper layer using CY_BLE_EVT_GATTC_ERROR_RSP
* or CY_BLE_EVT_GATTC_LONG_PROCEDURE_END event.
* Application can stop this procedure if the desired included service is
* found prior to the discovering all the included services of the
* specified service. This can be achieved by using the Cy_BLE_GATTC_StopCmd()
* function.
*
* Refer to Bluetooth 5.0 core specification, Volume 3, Part G, section 4.5.1
* for more details on the sequence of operations.
*
* \param param: Pointer to a variable of type cy_stc_ble_gattc_read_by_type_req_t,
* The following must be set:
* param->range.startHandle <br>
* param->range.endHandle <br>
* param->connHandle <br>
* The following must be ignored:
* param->uuidFormat (CY_BLE_GATT_16_BIT_UUID_FORMAT or
* CY_BLE_GATT_128_BIT_UUID_FORMAT) <br>
* param->uuid.uuid16 or readByTypeReqParam->uuid.uuid128
* based on the uuidFormat
* \note
* 'startHandle' & 'endHandle' should not be zero, and 'startHandle' shall be less than or equal to the 'endHandle'.
*
* \return
* cy_en_ble_api_result_t : Return value indicates whether the function succeeded or
* failed. Following are the possible error codes.
*
* Error codes | Description
* ------------ | -----------
* CY_BLE_SUCCESS | On successful operation.
* CY_BLE_ERROR_INVALID_PARAMETER | If 'param' is NULL or if any of the input parameters is invalid.
* CY_BLE_ERROR_INVALID_OPERATION | This operation is not permitted.
* CY_BLE_ERROR_MEMORY_ALLOCATION_FAILED| Memory allocation failed.
*
******************************************************************************/
cy_en_ble_api_result_t Cy_BLE_GATTC_FindIncludedServices
(
cy_stc_ble_gattc_read_by_type_req_t * param
);
/******************************************************************************
* Function Name: Cy_BLE_GATTC_ReadByTypeReq
***************************************************************************//**
*
* This function allows the user to send Read by type request to a peer GATT server.
* This function results in CY_BLE_EVT_GATTC_READ_BY_TYPE_RSP event or
* CY_BLE_EVT_GATTC_ERROR_RSP event at the GATT client depending on whether the GATT server
* sends read by type response or GATT Error response.
*
* Refer to Bluetooth 5.0 core specification, Volume 3, Part G, section 4.5.1
* for more details on the sequence of operations.
*
* \param param: Pointer to a variable of type cy_stc_ble_gattc_read_by_type_req_t,
* Where, the following needs to be set:
* param->range.startHandle
* param->range.endHandle
* param->connHandle
* param->uuidFormat (CY_BLE_GATT_16_BIT_UUID_FORMAT or
* CY_BLE_GATT_128_BIT_UUID_FORMAT)
* param->uuid.uuid16 or readByTypeReqParam->uuid.uuid128
* based on the uuidFormat
*
* \note
* 'startHandle' & 'endHandle' should not be zero, and 'startHandle' shall be less than or equal to the 'endHandle'.
*
* \return
* cy_en_ble_api_result_t : Return value indicates whether the function succeeded or
* failed. Following are the possible error codes.
*
* Error codes | Description
* ------------ | -----------
* CY_BLE_SUCCESS | On successful operation.
* CY_BLE_ERROR_INVALID_PARAMETER | If 'param' is NULL or if any of the input parameters is invalid.
* CY_BLE_ERROR_INVALID_OPERATION | This operation is not permitted.
* CY_BLE_ERROR_MEMORY_ALLOCATION_FAILED| Memory allocation failed.
*
******************************************************************************/
cy_en_ble_api_result_t Cy_BLE_GATTC_ReadByTypeReq
(
cy_stc_ble_gattc_read_by_type_req_t * param
);
/******************************************************************************
* Function Name: Cy_BLE_GATTC_ReadCharacteristicValue
***************************************************************************//**
*
* This function is used by the GATT Client application to read a Characteristic Value
* from a peer GATT Server, when the GATT Client application knows the Characteristic
* Value Handle. This is a non-blocking function.
*
* Internally, Read Request is sent to the peer GATT Server. If the read operation
* is successful, GATT Server sends a Read Response. This response results in
* CY_BLE_EVT_GATTC_READ_RSP event at the GATT Client's end, and response is passed to the application.
*
*
* In response to the Read Request GATT server shall send an Error Response if
* 1. GATT Client has insufficient authentication to read requested characteristic value OR
* 2. GATT Client has insufficient authorization to read requested characteristic value OR
* 3. GATT Client has used insufficient encryption key size OR
* 4. GATT Client has insufficient encryption to read requested characteristic value OR
* 5. If GATT Client requested handle is invalid OR
* 6. If a read operation is not permitted on the requested Characteristic Value.
* The Error Code parameter is set as specified in the Attribute Protocol.
* This Error response results in CY_BLE_EVT_GATTC_ERROR_RSP event at the GATT client application.
*
* If the peer GATT Server is a PSoC 6 MCU, Read Request PDU results in
* CY_BLE_EVT_GATTS_READ_CHAR_VAL_ACCESS_REQ event at the GATT server's end, if the corresponding
* characteristic's attribute permission is set to CY_BLE_GATT_DB_ATTR_CHAR_VAL_RD_EVENT.
*
*
* Refer to Bluetooth 5.0 core specification, Volume 3, Part G, section 4.8.1
* for more details on the sequence of operations.
*
* \param param: Pointer to a variable of type cy_stc_ble_gattc_read_req_t.
* The following must be set:
* param->attrHandle: Attribute handle to be read <br>
* param->connHandle
*
* \return
* cy_en_ble_api_result_t : Return value indicates whether the function succeeded or
* failed. Following are the possible error codes.
*
* Error codes | Description
* ------------ | -----------
* CY_BLE_SUCCESS | On successful operation.
* CY_BLE_ERROR_INVALID_PARAMETER | If 'param' is NULL or 'connHandle' is invalid, or if 'attrHandle' is zero.
* CY_BLE_ERROR_INVALID_OPERATION | This operation is not permitted.
* CY_BLE_ERROR_MEMORY_ALLOCATION_FAILED| Memory allocation failed.
*
******************************************************************************/
cy_en_ble_api_result_t Cy_BLE_GATTC_ReadCharacteristicValue
(
cy_stc_ble_gattc_read_req_t * param
);
/******************************************************************************
* Function Name: Cy_BLE_GATTC_ReadUsingCharacteristicUuid
***************************************************************************//**
*
* This function is used by the GATT Client application to read a Characteristic Value from a peer
* GATT Server when the application knows only the characteristic UUID and
* does not know the handle of the characteristic. This is a non-blocking function.
*
* Internally, Read By Type Request is sent to the peer GATT server. If the read operation
* is successful, GATT Server sends a Read By Type Response. This response results in
* CY_BLE_EVT_GATTC_READ_RSP event at the GATT Client's end, and response is passed to the application.
*
* In response to this Request GATT server shall send an Error Response if
* 1. GATT Client has insufficient authentication to read the requested characteristic value OR
* 2. GATT Client has insufficient authorization to read the requested characteristic value OR
* 3. GATT Client has insufficient encryption to read the requested characteristic value OR
* 3. GATT Client has used insufficient encryption key size OR
* 4. Read operation is not permitted on the requested Characteristic Value OR
* 5. characteristic does not exist on the GATT server within the handle OR
* range provided OR
* 6. Starting Handle parameter greater than the Ending Handle parameter or the
* Starting Handle parameter is 0x0000
* The Error Code parameter is set as specified in the Attribute Protocol.
* This Error response results in CY_BLE_EVT_GATTC_ERROR_RSP event at the GATT client application.
*
* If the peer GATT Server is a PSoC 6 MCU, Read By Type Request PDU results in the
* CY_BLE_EVT_GATTS_READ_CHAR_VAL_ACCESS_REQ event at the GATT server's end if the
* corresponding characteristic's attribute permission is set to
* CY_BLE_GATT_DB_ATTR_CHAR_VAL_RD_EVENT.
*
*
* Refer to Bluetooth 5.0 core specification, Volume 3, Part G, section 4.8.2 for
* more details on the sequence of operations.
*
* \param param: Pointer to a variable of type cy_stc_ble_gattc_read_by_type_req_t,
* Where, the following needs to be set:
* param->range.startHandle
* param->range.endHandle
* param->connHandle
* param->uuidFormat (CY_BLE_GATT_16_BIT_UUID_FORMAT or
* CY_BLE_GATT_128_BIT_UUID_FORMAT)
* param->uuid.uuid16 or readByTypeReqParam->uuid.uuid128
* based on the uuidFormat
* \note
* 'startHandle' & 'endHandle' should not be zero, and 'startHandle' shall be less than or equal to the 'endHandle'.
*
* \return
* cy_en_ble_api_result_t : Return value indicates whether the function succeeded or
* failed. Following are the possible error codes.
*
* Error codes | Description
* ------------ | -----------
* CY_BLE_SUCCESS | On successful operation.
* CY_BLE_ERROR_INVALID_PARAMETER | If 'param' is NULL or if any of the input parameters is invalid.
* CY_BLE_ERROR_INVALID_OPERATION | This operation is not permitted.
* CY_BLE_ERROR_MEMORY_ALLOCATION_FAILED| Memory allocation failed.
*
******************************************************************************/
cy_en_ble_api_result_t Cy_BLE_GATTC_ReadUsingCharacteristicUuid
(
cy_stc_ble_gattc_read_by_type_req_t * param
);
/******************************************************************************
* Function Name: Cy_BLE_GATTC_ReadLongCharacteristicValues
***************************************************************************//**
*
* This function is used by the GATT Client application to read a Characteristic Value from a peer
* GATT Server when the GATT Client knows the Characteristic Value Handle and the length
* of the Characteristic Value is longer than that can be sent in a single Read Response
* Attribute Protocol message. This is a non-blocking function.
*
* Internally multiple Read Blob Requests are sent to the peer device in response
* to which Read Blob Responses are received. For each Read Blob Request, a Read
* Blob Response event is received (CY_BLE_EVT_GATTC_READ_BLOB_RSP) with a
* portion of the Characteristic Value contained in the Part Attribute Value
* parameter. These events are propagated to the application layer
* for further processing. Each read blob response will return up to (GATT MTU-1) bytes of
* data. If the size of characteristic value field is an integral multiple of (GATT MTU-1)
* then the operation terminates with an error response event, where the error code is
* CY_BLE_GATT_ERR_INVALID_OFFSET. If the size of the characteristic value field is
* not an integral multiple of (GATT MTU-1), the last read blob response will return
* data bytes that are less than (GATT MTU-1). The application must monitor these two
* conditions before proceeding with the initiation of any other GATT operation.
*
* In response to the this Request GATT server shall send an Error Response if
* 1. GATT Client has insufficient authentication to read the requested characteristic value OR
* 2. GATT Client has insufficient authorization to read the requested characteristic value OR
* 3. GATT Client has insufficient encryption to read the requested characteristic value OR
* 4. GATT Client has used insufficient encryption key size OR
* 5. Read operation is not permitted on the requested Characteristic Value OR
* 6. The Characteristic Value is not longer than (GATT MTU - 1) OR
* 7. The requested handle is invalid OR
* 8. Value offset is greater than length attribute value.
* The Error Code parameter is set as specified in the Attribute Protocol.
* This Error response results in CY_BLE_EVT_GATTC_ERROR_RSP event at the GATT client application.
*
* If the peer GATT Server is a PSoC 6 MCU, Read Blob Request PDU results in the
* CY_BLE_EVT_GATTS_READ_CHAR_VAL_ACCESS_REQ event at the GATT server's end if the
* corresponding characteristic's attribute permission is set to
* CY_BLE_GATT_DB_ATTR_CHAR_VAL_RD_EVENT.
*
* Refer to Bluetooth 5.0 core specification, Volume 3, Part G, section 4.8.3
* for more details on the sequence of operations.
*
* \param param: Pointer to a variable of type cy_stc_ble_gattc_read_blob_req_t.
* Where, the following needs to be set:
* param->attrHandle
* param->offset
* param->connHandle
*
* \return
* cy_en_ble_api_result_t : Return value indicates whether the function succeeded or
* failed. Following are the possible error codes.
*
* Error codes | Description
* ------------ | -----------
* CY_BLE_SUCCESS | On successful operation.
* CY_BLE_ERROR_INVALID_PARAMETER | If 'param' is NULL or 'connHandle' is invalid, or if 'attrHandle' is zero.
* CY_BLE_ERROR_INVALID_OPERATION | This operation is not permitted.
* CY_BLE_ERROR_MEMORY_ALLOCATION_FAILED| Memory allocation failed.
*
******************************************************************************/
cy_en_ble_api_result_t Cy_BLE_GATTC_ReadLongCharacteristicValues
(
cy_stc_ble_gattc_read_blob_req_t * param
);
/******************************************************************************
* Function Name: Cy_BLE_GATTC_ReadMultipleCharacteristicValues
***************************************************************************//**
*
* This function is used by the GATT Client application to read multiple Characteristic Values