1/*
2 * Copyright (C) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file att.h
18 *
19 * @brief Declares extern interface, including register interface, callback interface etc.
20 *
21 */
22
23#ifndef ATT_H
24#define ATT_H
25
26#include <stdint.h>
27#include "btstack.h"
28#include "buffer.h"
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33// Transport type
34#define BT_TRANSPORT_INVALID 0
35#define BT_TRANSPORT_BR_EDR 1
36#define BT_TRANSPORT_LE 2
37
38// client callback event id
39#define ATT_ERROR_RESPONSE_ID 0x0101
40#define ATT_EXCHANGE_MTU_RESPONSE_ID 0x0103
41#define ATT_FIND_INFORMATION_RESPONSE_ID 0x0105
42#define ATT_FIND_BY_TYPE_VALUE_RESPONSE_ID 0x0107
43#define ATT_READ_BY_TYPE_RESPONSE_ID 0x0109
44#define ATT_READ_RESPONSE_ID 0x010B
45#define ATT_READ_BLOB_RESPONSE_ID 0x010D
46#define ATT_READ_MULTIPLE_RESPONSE_ID 0x010F
47#define ATT_READ_BY_GROUP_TYPE_RESPONSE_ID 0x0202
48#define ATT_WRITE_RESPONSE_ID 0x0204
49#define ATT_PREPARE_WRITE_RESPONSE_ID 0x0208
50#define ATT_EXECUTE_WRITE_RESPONSE_ID 0x020A
51#define ATT_HANDLE_VALUE_NOTIFICATION_ID 0x020B
52#define ATT_HANDLE_VALUE_INDICATION_ID 0x020C
53#define ATT_TRANSACTION_TIME_OUT_ID 0x020E
54
55// server callback event id
56#define ATT_EXCHANGE_MTU_REQUEST_ID 0x0102
57#define ATT_FIND_INFORMATION_REQUEST_ID 0x0104
58#define ATT_FIND_BY_TYPE_VALUE_REQUEST_ID 0x0106
59#define ATT_READ_BY_TYPE_REQUEST_ID 0x0108
60#define ATT_READ_REQUEST_ID 0x010A
61#define ATT_READ_BLOB_REQUEST_ID 0x010C
62#define ATT_READ_MULTIPLE_REQUEST_ID 0x010E
63#define ATT_READ_BY_GROUP_TYPE_REQUEST_ID 0x0201
64#define ATT_WRITE_REQUEST_ID 0x0203
65#define ATT_WRITE_COMMAND_ID 0x0205
66#define ATT_SIGNED_WRITE_COMMAND_ID 0x0206
67#define ATT_PREPARE_WRITE_REQUEST_ID 0x0207
68#define ATT_EXECUTE_WRITE_REQUEST_ID 0x0209
69#define ATT_HANDLE_VALUE_CONFIRMATION_ID 0x020D
70#define ATT_UNKNOW_OPCODE_ID 0x020F
71
72// error response code
73#define ATT_INVALID_HANDLE 0x01
74#define ATT_READ_NOT_PERMITTED 0x02
75#define ATT_WRITE_NOT_PERMITTED 0x03
76#define ATT_INVALID_PDU 0x04
77#define ATT_INSUFFICIENT_AUTHENTICATION 0x05
78#define ATT_REQUEST_NOT_SUPPORTED 0x06
79#define ATT_INVALID_OFFSET 0x07
80#define ATT_INSUFFICIENT_AUTHORIZATION 0x08
81#define ATT_PREPARE_QUEUE_FULL 0x09
82#define ATT_ATTRIBUTE_NOT_FOUND 0x0A
83#define ATT_ATTRIBUTE_NOT_LONG 0x0B
84#define ATT_INSUFFICIENT_ENCRYPTION_KEY_SIZE 0x0C
85#define ATT_INVALID_ATTRIBUTE_VALUE_LENGTH 0x0D
86#define ATT_UNLIKELY_ERROR 0x0E
87#define ATT_INSUFFICIENT_ENCRYPTION 0x0F
88#define ATT_UNSUPPORTED_GROUP_TYPE 0x10
89#define ATT_INSUFFICIENT_RESOURECES 0x11
90#define ATT_WRITE_REQUEST_REJECTED 0xFC
91#define ATT_CLIENT_CHARACTERISTIC_CONFIGURATION_DESCRIPTOR_IMPROPERLY_CONFIGURED 0xFD
92#define ATT_PROCEDURE_ALREADY_IN_PROGRESS 0xFE
93#define ATT_OUT_OF_RANGE 0xFF
94
95// opcode
96#define ERROR_RESPONSE 0x01
97#define EXCHANGE_MTU_REQUEST 0x02
98#define EXCHANGE_MTU_RESPONSE 0x03
99#define FIND_INFORMATION_REQUEST 0x04
100#define FIND_INFORMATION_RESPONSE 0x05
101#define FIND_BY_TYPE_VALUE_REQUEST 0x06
102#define FIND_BY_TYPE_VALUE_RESPONSE 0x07
103#define READ_BY_TYPE_REQUEST 0x08
104#define READ_BY_TYPE_RESPONSE 0x09
105#define READ_REQUEST 0x0A
106#define READ_RESPONSE 0x0B
107#define READ_BLOB_REQUEST 0x0C
108#define READ_BLOB_RESPONSE 0x0D
109#define READ_MULTIPLE_REQUEST 0x0E
110#define READ_MULTIPLE_RESPONSE 0x0F
111#define READ_BY_GROUP_TYPE_REQUEST 0x10
112#define READ_BY_GROUP_TYPE_RESPONSE 0x11
113#define WRITE_REQUEST 0x12
114#define WRITE_RESPONSE 0x13
115#define WRITE_COMMAND 0x52
116#define SIGNED_WRITE_COMMAND 0xD2
117#define PREPARE_WRITE_REQUEST 0x16
118#define PREPARE_WRITE_RESPONSE 0x17
119#define EXECUTE_WRITE_REQUEST 0x18
120#define EXECUTE_WRITE_RESPONSE 0x19
121#define HANDLE_VALUE_NOTIFICATION 0x1B
122#define HANDLE_VALUE_INDICATION 0x1D
123#define HANDLE_VALUE_CONFIRMATION 0x1E
124#define READ_MULTIPLE_VARIABLE_RESPONSE 0x21
125#define MULTIPLE_HANDLE_VALUE_NOTIFICATION 0x23
126
127// gap security authentication result code
128#define SECURITY_AUTHENTICATION_SUCCESS 0x45
129#define SECURITY_AUTHENTICATION_FAIL 0x46
130
131// bredr connect callback result code
132#define BREDR_CONNECT_SUCCESS 0x49
133#define BREDR_CONNECT_FAIL 0x50
134
135// le connect callback result code
136#define LE_CONNECT_SUCCESS 0x51
137#define LE_CONNECT_FAIL 0x52
138
139// le disconnect result code
140#define LE_DISCONNECT_SUCCESS 0x53
141#define LE_DISCONNECT_FAIL 0x54
142
143// bredr disconnect callback result code
144#define INITIATIVECONNECT_DISCONNECT_SUCCESS 0x55
145#define INITIATIVECONNECT_DISCONNECT_FAIL 0x56
146#define PASSIVECONNECT_DISCONNECT_SUCCESS 0x57
147#define PASSIVECONNECT_DISCONNECT_FAIL 0x58
148#define DISCONNECT_ABNORMAL 0x59
149
150// bredr connect response result
151#define BREDR_CONNECT_ACCEPT 0x00
152#define BREDR_CONNECT_REJECTED 0x04
153
154// att connect timeout
155#define ATT_CONNECT_TIMEOUT 0x0060
156
157typedef struct {
158    uint16_t attHandle;
159    BtUuid uuid;
160} AttHandleUuid;
161
162typedef struct {
163    uint16_t attHandle;
164    uint16_t groupEndHandle;
165} AttHandleInfo;
166
167typedef struct {
168    uint8_t properties;
169    uint16_t attributeHandle;
170    BtUuid *uuid;
171} AttSpecificAttributeValue;
172
173typedef struct {
174    uint16_t attHandle;
175} AttHandleValue;
176
177typedef struct {
178    uint16_t attHandle;
179    uint16_t groupEndHandle;
180    uint8_t *attributeValue;
181} AttReadGoupAttributeData;
182
183typedef struct {
184    uint16_t mtuSize;
185} AttExchangeMTUType;
186
187typedef struct {
188    uint16_t startHandle;
189    uint16_t endHandle;
190} AttHandleRange;
191
192typedef struct {
193    uint8_t reqOpcode;
194    uint16_t attHandleInError;
195    uint8_t errorCode;
196} AttError;
197
198typedef struct {
199    AttHandleUuid *handleUuidPairs;
200    uint16_t pairNum;
201    uint8_t format;
202} AttFindInformationRsp;
203
204typedef struct {
205    AttHandleRange handleRange;
206    uint16_t attType;
207} AttFindByTypeValueReq;
208
209typedef struct {
210    AttHandleInfo *handleInfoList;
211    uint16_t listNum;
212} AttFindByTypeValueRsp;
213
214typedef union {
215    AttHandleRange findInformationRequest;
216    AttFindInformationRsp findInforRsponse;
217    AttFindByTypeValueReq findByTypeValueRequest;
218    AttFindByTypeValueRsp findByTypeValueResponse;
219} AttFind;
220
221typedef struct {
222    AttHandleRange handleRange;
223    BtUuid *uuid;
224} AttReadByTypeReq;
225
226typedef struct {
227    AttHandleValue attHandle;
228    uint8_t *attributeValue;
229} AttReadByTypeRspDataList;
230
231typedef struct {
232    AttReadByTypeRspDataList *valueList;
233    uint16_t valueNum;
234    uint8_t len;
235} AttReadByTypeRsp;
236
237typedef struct {
238    uint16_t attHandle;
239} AttReadReq;
240
241typedef struct {
242    uint16_t attHandle;
243    uint16_t offset;
244} AttReadBlobReqPrepareWriteValue;
245
246typedef struct {
247    uint16_t *setHandles;
248} AttReadMultipleReq;
249
250typedef struct {
251    uint8_t *setValues;
252} AttReadMultipleRes;
253
254typedef struct {
255    AttHandleRange handleRange;
256    BtUuid *uuid;
257} AttReadGroupReq;
258
259typedef struct {
260    uint8_t length;
261    uint16_t num;
262    AttReadGoupAttributeData *attributeData;
263} AttReadGroupRes;
264
265typedef union {
266    AttReadByTypeReq readHandleRangeUuid;
267    AttReadByTypeRsp readHandleListNum;
268    AttReadReq readHandle;
269    AttReadBlobReqPrepareWriteValue readBlob;
270    AttReadMultipleReq readMultRequest;
271    AttReadMultipleRes readMultResponse;
272    AttReadGroupReq readGroupRequest;
273    AttReadGroupRes readGroupResponse;
274} AttRead;
275
276typedef enum {
277    SIGNATURE_OK,
278    SIGNATURE_ERR_EXECUTION,
279    SIGNATURE_ERR_COUNTER,
280    SIGNATURE_ERR_ALGORITHM,
281    GAP_REJECT,
282} AttSignedWriteCommandResult;
283
284typedef struct {
285    AttHandleValue attHandleValueObj;
286    uint8_t authSignature[12];
287    uint16_t authSignatureLen;
288    AttSignedWriteCommandResult result;
289} AttSignedWriteComm;
290
291typedef struct {
292    AttHandleValue handleValue;
293    uint16_t offset;
294} AttPrepareWrite;
295
296typedef struct {
297    uint8_t flag;
298} AttExecuteWrite;
299
300typedef union {
301    AttHandleValue writeRequest;
302    AttHandleValue writeCommand;
303    AttHandleValue confirmation;
304    AttSignedWriteComm signedWriteCommand;
305    AttPrepareWrite prepareWrite;
306    AttExecuteWrite excuteWrite;
307} AttWrite;
308
309typedef struct {
310    uint8_t status;
311    uint8_t role;
312    BtAddr addr;
313} AttLeConnectCallback;
314
315typedef struct {
316    uint8_t status;
317    uint8_t reason;
318} AttLeDisconnectCallback;
319
320typedef struct {
321    BtAddr addr;
322    uint8_t status;
323    uint16_t mtu;
324} AttBredrConnectCallback;
325
326typedef struct {
327    uint8_t reason;
328} AttBredrDisconnectCallback;
329
330typedef struct {
331    uint16_t connIntervalMin;
332    uint16_t connIntervalMax;
333    uint16_t connLatency;
334    uint16_t supervisionTimeout;
335} AttLeConnect;
336
337typedef struct {
338    uint16_t mtu;
339    uint16_t flushTimeout;
340    uint8_t mode;
341} AttBredrConnect;
342
343typedef union {
344    AttLeConnect leConnParaVar;
345    AttBredrConnect bredrConnParaVar;
346} AttConnect;
347
348typedef union AttEventData {
349    AttError attErrorResponse;
350    AttExchangeMTUType attExchangeMtuRequest;
351    AttExchangeMTUType attExchangeMtuResponse;
352    AttFind attFindInformationRequest;
353    AttFind attFindInformationResponse;
354    AttFind attFindByTypeValueRequest;
355    AttFind attFindByTypeValueResponse;
356    AttRead attReadByTypeRequest;
357    AttRead attReadByTypeResponse;
358    AttRead attReadRequest;
359    AttRead attReadResponse;
360    AttRead attReadBlobRequest;
361    AttRead attReadBlobResponse;
362    AttRead attReadMultipleRequest;
363    AttRead attReadMultipleResponse;
364    AttRead attReadByGroupTypeRequest;
365    AttRead attReadByGroupTypeResponse;
366    AttWrite attWriteRequest;
367    AttWrite attWriteResponse;
368    AttWrite attWriteCommand;
369    AttWrite attSignedWriteCommand;
370    AttWrite attPreprareWriteRequest;
371    AttWrite attPrepareWriteResponse;
372    AttWrite attExecuteWriteRequest;
373    AttWrite attExecuteWriteResponse;
374    AttHandleValue attNotification;
375    AttHandleValue attIndication;
376    AttHandleValue attHandleValueConfirmation;
377    AttWrite attTimeOut;
378} AttEventData;
379
380typedef struct {
381    void (*attLEConnectCompleted)(uint16_t connectHandle, AttLeConnectCallback *data, void *context);
382    void (*attLEDisconnectCompleted)(uint16_t connectHandle, AttLeDisconnectCallback *data, void *context);
383    void (*attBREDRConnectCompleted)(uint16_t connectHandle, AttBredrConnectCallback *data, void *context);
384    void (*attBREDRDisconnectCompleted)(uint16_t connectHandle, AttBredrDisconnectCallback *data, void *context);
385    void (*attBREDRConnectInd)(uint16_t connectHandle, void *context);
386} AttConnectCallback;
387
388typedef void (*attCallback)(uint16_t connectHandle, uint16_t event, void *eventData, Buffer *buffer, void *context);
389typedef void (*attSendDataCallback)(uint16_t retGattConnectHandle, int result, void *context);
390
391typedef struct {
392    attSendDataCallback attSendDataCB;
393    void *context;
394} AttClientSendDataCallback;
395
396typedef struct {
397    attSendDataCallback attSendDataCB;
398    void *context;
399} AttServerSendDataCallback;
400
401/**
402 * @brief Gatt register the client data callback to att.
403 *
404 * @param1 dataCallback Indicates the pointer to callback.
405 * @param2 context Indicates the pointer to context.
406 */
407void BTSTACK_API ATT_ClientDataRegister(attCallback dataCallback, void *context);
408
409/**
410 * @brief Gatt deregister the client data callback to att.
411 *
412 */
413void BTSTACK_API ATT_ClientDataDeregister();
414
415/**
416 * @brief Gatt register the server data callback to att.
417 *
418 * @param1 dataCallback Indicates the pointer to callback.
419 * @param2 context Indicates the pointer to context.
420 */
421void BTSTACK_API ATT_ServerDataRegister(attCallback dataCallback, void *context);
422
423/**
424 * @brief Gatt deregister the server data callback to att.
425 *
426 */
427void BTSTACK_API ATT_ServerDataDeregister();
428
429/**
430 * @brief Gatt register the connection callback to att.
431 *
432 * @param1 connectBack Indicates the struct to callback.
433 * @param2 context Indicates the pointer to context.
434 */
435void BTSTACK_API ATT_ConnectRegister(AttConnectCallback connectBack, void *context);
436
437/**
438 * @brief Gatt deregister the connection callback to att.
439 *
440 */
441void BTSTACK_API ATT_ConnectDeregister();
442
443/**
444 * @brief Gatt client register the send data callback to att.
445 *
446 * @param1 attSendDataCB Indicates pointer of attSendDataCallback.
447 * @param2 context Indicates the pointer to context.
448 */
449void BTSTACK_API ATT_ClientSendDataRegister(attSendDataCallback attSendDataCB, void *context);
450
451/**
452 * @brief Gatt client deregister the send data callback to att.
453 */
454void BTSTACK_API ATT_ClientSendDataDeRegister();
455
456/**
457 * @brief Gatt server register the send data callback to att.
458 *
459 * @param1 AttSendDataCB Indicates pointer of attSendDataCallback.
460 * @param2 context Indicates the pointer to context.
461 */
462void BTSTACK_API ATT_ServerSendDataRegister(attSendDataCallback AttSendDataCB, void *context);
463
464/**
465 * @brief Gatt server deregister the send data callback to att.
466 */
467void BTSTACK_API ATT_ServerSendDataDeRegister();
468
469/**
470 * @brief Send a connect request.
471 *
472 * @param1 transportType Indicates the connect type.
473 * @param2 connParaPtr Indicates the pointer to const connect parameter.
474 * @param3 btAddress Indicates the pointer to const address.
475 * @param4 bredrconnectHandle Indicates the pointer to connecthandle be outputted.
476 */
477void BTSTACK_API ATT_ConnectReq(
478    uint8_t transportType, const AttConnect *connParaPtr, const BtAddr *btAddress, const uint16_t *bredrconnectHandle);
479
480/**
481 * @brief Send a connect response.
482 *
483 * @param1 connectHandle Indicates the connect handle.
484 * @param2 result Indicates the variable of result.
485 * @param3 status Indicates the result of status.
486 * @param4 cfg Indicates the pointer to const connect parameter.
487 */
488void BTSTACK_API ATT_ConnectRsp(uint16_t connectHandle, uint16_t result, uint16_t status, const AttConnect *cfg);
489
490/**
491 * @brief Send a disconnect request.
492 *
493 * @param connectHandle Indicates the connect handle.
494 */
495void BTSTACK_API ATT_DisconnectReq(uint16_t connectHandle);
496
497/**
498 * @brief Send an error response.
499 *
500 * @param1 connectHandle Indicates the connect handle.
501 * @param2 ATTErrorPtr Indicates the pointer to const error response parameter.
502 */
503void BTSTACK_API ATT_ErrorResponse(uint16_t connectHandle, const AttError *ATTErrorPtr);
504
505/**
506 * @brief Send an exchange MTU request .
507 *
508 * @param1 connectHandle Indicates the connect handle.
509 * @param2 clientRxMTU Indicates the client receive MTU size.
510 */
511void BTSTACK_API ATT_ExchangeMTURequest(uint16_t connectHandle, uint16_t clientRxMTU);
512
513/**
514 * @brief Send an exchange MTU response.
515 *
516 * @param1 connectHandle Indicates the connect handle.
517 * @param2 serverRxMTU Indicates the attribute server receive MTU size.
518 */
519void BTSTACK_API ATT_ExchangeMTUResponse(uint16_t connectHandle, uint16_t serverRxMTU);
520
521/**
522 * @brief Send a find Information request.
523 *
524 * @param1 connectHandle Indicates the connect handle.
525 * @param2 startHandle Indicates the first requested handle number.
526 * @param3 endHandle Indicates the last requested handle number.
527 */
528void BTSTACK_API ATT_FindInformationRequest(uint16_t connectHandle, uint16_t startHandle, uint16_t endHandle);
529
530/**
531 * @brief Send a find Information response.
532 *
533 * @param1 connectHandle Indicates the connect handle.
534 * @param2 format Indicates the format of the information data.
535 * @param3 handleUUIDPairs Indicates the pointer to const information data.
536 * @param4 pairNum Indicates the paris number of the Information Data.
537 */
538void BTSTACK_API ATT_FindInformationResponse(
539    uint16_t connectHandle, uint8_t format, AttHandleUuid *handleUUIDPairs, uint16_t pairNum);
540
541/**
542 * @brief Send a find by type value request.
543 *
544 * @param1 connectHandle Indicates the connect handle.
545 * @param2 attFindByTypePtreve Indicates the pointer to const the parameter of AttFindByTypeValueReq.
546 * @param3 attValue Indicates the pointer to attribute value to find.
547 */
548void BTSTACK_API ATT_FindByTypeValueRequest(
549    uint16_t connectHandle, const AttFindByTypeValueReq *attFindByTypePtreve, const Buffer *attValue);
550
551/**
552 * @brief Send a find by type value response.
553 *
554 * @param1 connectHandle Indicates the connect handle.
555 * @param2 handleInfoList Indicates the pointer to const a list of 1 or more Handle Information.
556 * @param3 listNum Indicates the number of handles information list.
557 */
558void BTSTACK_API ATT_FindByTypeValueResponse(
559    uint16_t connectHandle, const AttHandleInfo *handleInfoList, uint16_t listNum);
560
561/**
562 * @brief Send a read by type request.
563 *
564 * @param1 connectHandle Indicates the connect handle.
565 * @param2 startHandle Indicates the first requested handle number.
566 * @param3 endHandle Indicates the last requested handle number.
567 * @param4 uuid Indicates the pointer to const 2 or 16 octet UUID.
568 */
569void BTSTACK_API ATT_ReadByTypeRequest(
570    uint16_t connectHandle, uint16_t startHandle, uint16_t endHandle, const BtUuid *uuid);
571
572/**
573 * @brief Send a read by type response.
574 *
575 * @param1 connectHandle Indicates the connect handle.
576 * @param2 length Indicates the size of each attribute handlevalue pair.
577 * @param3 valueList Indicates the pointer to const a list of attribute data.
578 * @param4 attrValueNum Indicates the value of attribute value number.
579 */
580void BTSTACK_API ATT_ReadByTypeResponse(
581    uint16_t connectHandle, uint8_t length, const AttReadByTypeRspDataList *valueList, uint16_t attrValueNum);
582
583/**
584 * @brief Send a read request.
585 *
586 * @param1 connectHandle Indicates the connect handle.
587 * @param2 attHandle Indicates the handle of the attribute to be read.
588 */
589void BTSTACK_API ATT_ReadRequest(uint16_t connectHandle, uint16_t attHandle);
590
591/**
592 * @brief Send a read response.
593 *
594 * @param1 connectHandle Indicates the connect handle.
595 * @param2 attValue Indicates the pointer to the value of the attribute with the handle given.
596 */
597void BTSTACK_API ATT_ReadResponse(uint16_t connectHandle, const Buffer *attValue);
598
599/**
600 * @brief Send a read blob request.
601 *
602 * @param1 connectHandle Indicates the connect handle.
603 * @param2 attHandle Indicates the handle of the attribute to be read.
604 * @param3 offset Indicates the offset of the first octet to be read.
605 */
606void BTSTACK_API ATT_ReadBlobRequest(uint16_t connectHandle, uint16_t attHandle, uint16_t offset);
607
608/**
609 * @brief Send a read blob response.
610 *
611 * @param1 connectHandle Indicates the connect handle.
612 * @param2 attReadBlobResObj Indicates the pointer to part of the value of the attribute with the handle given.
613 */
614void BTSTACK_API ATT_ReadBlobResponse(uint16_t connectHandle, const Buffer *attReadBlobResObj);
615
616/**
617 * @brief Send a read multiple request.
618 *
619 * @param1 connectHandle Indicates the connect handle.
620 * @param2 handleList Indicates the pointer to a set of two or more attribute handles.
621 */
622void BTSTACK_API ATT_ReadMultipleRequest(uint16_t connectHandle, const Buffer *handleList);
623
624/**
625 * @brief Send a read multiple response.
626 *
627 * @param1 connectHandle Indicates the connect handle.
628 * @param2 valueList Indicates the pointer to a set of two or more values.
629 */
630void BTSTACK_API ATT_ReadMultipleResponse(uint16_t connectHandle, const Buffer *valueList);
631
632/**
633 * @brief Send a read by group type request.
634 *
635 * @param1 connectHandle Indicates the connect handle.
636 * @param2 startHandle Indicates the first requested handle number.
637 * @param3 endHandle Indicates the last requested handle number.
638 * @param4 uuid Indicates the pointer to 2 or 16 octet UUID.
639 */
640void BTSTACK_API ATT_ReadByGroupTypeRequest(
641    uint16_t connectHandle, uint16_t startHandle, uint16_t endHandle, const BtUuid *uuid);
642
643/**
644 * @brief Send a read by group type response.
645 *
646 * @param1 connectHandle Indicates the connect handle.
647 * @param2 length Indicates the size of each attribute data.
648 * @param3 serviceList Indicates the pointer to const a list of attribute data.
649 * @param4 serviceNum Indicates the number of attribute data.
650 */
651void BTSTACK_API ATT_ReadByGroupTypeResponse(
652    uint16_t connectHandle, uint8_t length, const AttReadGoupAttributeData *serviceList, uint16_t serviceNum);
653
654/**
655 * @brief Send a write request.
656 *
657 * @param1 connectHandle Indicates the connect handle.
658 * @param2 attHandle Indicates the handle of the attribute to be written.
659 * @param3 attValue Indicates the pointer to the value to be written to the attribute.
660 */
661void BTSTACK_API ATT_WriteRequest(uint16_t connectHandle, uint16_t attHandle, const Buffer *attValue);
662
663/**
664 * @brief Send a write response.
665 *
666 * @param connectHandle Indicates the connect handle.
667 */
668void BTSTACK_API ATT_WriteResponse(uint16_t connectHandle);
669
670/**
671 * @brief Send a write command.
672 *
673 * @param1 connectHandle Indicates the connect handle.
674 * @param2 attHandle Indicates the handle of the attribute to be set.
675 * @param3 attValue Indicates the pointer to the value of be written to the attribute.
676 */
677void BTSTACK_API ATT_WriteCommand(uint16_t connectHandle, uint16_t attHandle, const Buffer *attValue);
678
679/**
680 * @brief Send a signed write command.
681 *
682 * @param1 connectHandle Indicates the connect handle.
683 * @param2 attHandle Indicates the the handle of the attribute to be set.
684 * @param3 attValue Indicates the pointer to the value to be written to the attribute.
685 */
686void BTSTACK_API ATT_SignedWriteCommand(uint16_t connectHandle, uint16_t attHandle, const Buffer *attValue);
687
688/**
689 * @brief Send a prepare write request.
690 *
691 * @param1 connectHandle Indicates the connect handle.
692 * @param2 attReadBlobObj Indicates the value of the struct AttReadBlobReqPrepareWriteValue.
693 * @param3 attValue Indicates the pointer to the value of the attribute to be written.
694 */
695void BTSTACK_API ATT_PrepareWriteRequest(
696    uint16_t connectHandle, AttReadBlobReqPrepareWriteValue attReadBlobObj, const Buffer *attValue);
697
698/**
699 * @brief Send a prepare write response.
700 *
701 * @param1 connectHandle Indicates the connect handle.
702 * @param2 attReadBlobObj Indicates the value of the struct AttReadBlobReqPrepareWriteValue.
703 * @param3 attValue Indicates the pointer to the value of the attribute to be written.
704 */
705void BTSTACK_API ATT_PrepareWriteResponse(
706    uint16_t connectHandle, AttReadBlobReqPrepareWriteValue attReadBlobObj, const Buffer *attValue);
707
708/**
709 * @brief Send a execute write request.
710 *
711 * @param1 connectHandle Indicates the connect handle.
712 * @param2 flag Indicates the value of flags.
713 */
714void BTSTACK_API ATT_ExecuteWriteRequest(uint16_t connectHandle, uint8_t flag);
715
716/**
717 * @brief Send a execute write response.
718 *
719 * @param connectHandle Indicates the connect handle.
720 */
721void BTSTACK_API ATT_ExecuteWriteResponse(uint16_t connectHandle);
722
723/**
724 * @brief Send a handle value notification.
725 *
726 * @param1 connectHandle Indicates the connect handle.
727 * @param2 attHandle Indicates the handle of the attribute.
728 * @param3 attValue Indicates the pointer to the current value of the attribute.
729 */
730void BTSTACK_API ATT_HandleValueNotification(uint16_t connectHandle, uint16_t attHandle, const Buffer *attValue);
731
732/**
733 * @brief Send a handle value indication.
734 *
735 * @param1 connectHandle Indicates the connect handle.
736 * @param2 attHandle Indicates the handle of the attribute.
737 * @param3 attValue Indicates the pointer to the current value of the attribute.
738 */
739void BTSTACK_API ATT_HandleValueIndication(uint16_t connectHandle, uint16_t attHandle, const Buffer *attValue);
740
741/**
742 * @brief Send a handle value confirmation.
743 *
744 * @param connectHandle Indicates the connect handle.
745 */
746void BTSTACK_API ATT_HandleValueConfirmation(uint16_t connectHandle);
747
748/**
749 * @brief Cancel Le ACL connection
750 *
751 * @return Returns BT_SUCCESS if the operation is successful, otherwise the operation fails.
752 */
753int BTSTACK_API ATT_LeConnectCancel(const BtAddr *addr);
754
755#ifdef __cplusplus
756}
757#endif
758
759#endif  // ATT_H
760