BLE-Stack APIs  3.00.00
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
att.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2016, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 /*!*****************************************************************************
33  * @defgroup ATT_GATT ATT / GATT
34  * @brief This module implements the Attribute Protocol and Generic Attribute Protocol
35  * @{
36  *
37  * @file att.h
38  * @brief ATT layer interface
39  *
40  * @ref ATT_METHOD_DEFINES
41  */
42 
43 #ifndef ATT_H
44 #define ATT_H
45 
46 #ifdef __cplusplus
47 extern "C"
48 {
49 #endif
50 
51 /*********************************************************************
52  * INCLUDES
53  */
54 #include "bcomdef.h"
55 #include "osal.h"
56 
57 #include "l2cap.h"
58 
59 /*********************************************************************
60  * CONSTANTS
61  */
62 
75 #define ATT_MTU_SIZE L2CAP_MTU_SIZE
76 #define ATT_MAX_MTU_SIZE 517
77 
82 #define ATT_ERROR_RSP 0x01
83 #define ATT_EXCHANGE_MTU_REQ 0x02
84 #define ATT_EXCHANGE_MTU_RSP 0x03
85 #define ATT_FIND_INFO_REQ 0x04
86 #define ATT_FIND_INFO_RSP 0x05
87 #define ATT_FIND_BY_TYPE_VALUE_REQ 0x06
88 #define ATT_FIND_BY_TYPE_VALUE_RSP 0x07
89 #define ATT_READ_BY_TYPE_REQ 0x08
90 #define ATT_READ_BY_TYPE_RSP 0x09
91 #define ATT_READ_REQ 0x0a
92 #define ATT_READ_RSP 0x0b
93 #define ATT_READ_BLOB_REQ 0x0c
94 #define ATT_READ_BLOB_RSP 0x0d
95 #define ATT_READ_MULTI_REQ 0x0e
96 #define ATT_READ_MULTI_RSP 0x0f
97 #define ATT_READ_BY_GRP_TYPE_REQ 0x10
98 #define ATT_READ_BY_GRP_TYPE_RSP 0x11
99 #define ATT_WRITE_REQ 0x12
100 #define ATT_WRITE_RSP 0x13
101 #define ATT_PREPARE_WRITE_REQ 0x16
102 #define ATT_PREPARE_WRITE_RSP 0x17
103 #define ATT_EXECUTE_WRITE_REQ 0x18
104 #define ATT_EXECUTE_WRITE_RSP 0x19
105 #define ATT_HANDLE_VALUE_NOTI 0x1b
106 #define ATT_HANDLE_VALUE_IND 0x1d
107 #define ATT_HANDLE_VALUE_CFM 0x1e
108 
109 #define ATT_WRITE_CMD 0x52
110 #define ATT_SIGNED_WRITE_CMD 0xD2
111 
116 #define ATT_FLOW_CTRL_VIOLATED_EVENT 0x7E
117 #define ATT_MTU_UPDATED_EVENT 0x7F
118 
123 #define ATT_METHOD_BITS 0x3f
124 #define ATT_CMD_FLAG_BIT 0x40
125 #define ATT_AUTHEN_SIG_FLAG_BIT 0x80
126 #define ATT_BT_UUID_SIZE 2
127 #define ATT_UUID_SIZE 16
128 #define ATT_MSG_TIMEOUT 30
129 
135 #define ATT_SIG_NOT_INCLUDED 0x00
136 #define ATT_SIG_VALID 0x01
137 #define ATT_SIG_INVALID 0x02
138 
140 /*********************************************************************
141  * Error Response: Error Code
142  */
143 
147 #define ATT_ERR_INVALID_HANDLE 0x01
148 #define ATT_ERR_READ_NOT_PERMITTED 0x02
149 #define ATT_ERR_WRITE_NOT_PERMITTED 0x03
150 #define ATT_ERR_INVALID_PDU 0x04
151 #define ATT_ERR_INSUFFICIENT_AUTHEN 0x05
152 #define ATT_ERR_UNSUPPORTED_REQ 0x06
153 #define ATT_ERR_INVALID_OFFSET 0x07
154 #define ATT_ERR_INSUFFICIENT_AUTHOR 0x08
155 #define ATT_ERR_PREPARE_QUEUE_FULL 0x09
156 #define ATT_ERR_ATTR_NOT_FOUND 0x0a
157 #define ATT_ERR_ATTR_NOT_LONG 0x0b
158 #define ATT_ERR_INSUFFICIENT_KEY_SIZE 0x0c
159 #define ATT_ERR_INVALID_VALUE_SIZE 0x0d
160 #define ATT_ERR_UNLIKELY 0x0e
161 #define ATT_ERR_INSUFFICIENT_ENCRYPT 0x0f
162 #define ATT_ERR_UNSUPPORTED_GRP_TYPE 0x10
163 #define ATT_ERR_INSUFFICIENT_RESOURCES 0x11
164 
165 /*** Reserved for future use: 0x12 - 0x7F ***/
166 
167 /*** Application error code defined by a higher layer specification: 0x80-0x9F ***/
168 
169 #define ATT_ERR_INVALID_VALUE 0x80
170 
172 /*********************************************************************
173  * Find Information Response: UUID Format
174  */
175 #define ATT_HANDLE_BT_UUID_TYPE 0x01
176 #define ATT_HANDLE_UUID_TYPE 0x02
177 
178 /*********************************************************************
179  * Read Multiple Request: Handles
180  */
181 #define ATT_MIN_NUM_HANDLES 2
182 
183 /*********************************************************************
184  * Execute Write Request: Flags
185  */
186 #define ATT_CANCEL_PREPARED_WRITES 0x00
187 #define ATT_WRITE_PREPARED_VALUES 0x01
188 
189 #if defined ( TESTMODES )
190  #define ATT_TESTMODE_OFF 0
192  #define ATT_TESTMODE_UNAUTHEN_SIG 1
193 #endif
194 
198 #define ATT_OPCODE_SIZE 1
199 #define ATT_EXCHANGE_MTU_REQ_SIZE 2
200 #define ATT_EXCHANGE_MTU_RSP_SIZE 2
201 #define ATT_ERROR_RSP_SIZE 4
202 #define ATT_FIND_INFO_REQ_FIXED_SIZE 4
203 #define ATT_FIND_INFO_RSP_FIXED_SIZE 1
204 #define ATT_FIND_INFO_RSP_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_FIND_INFO_RSP_FIXED_SIZE )
205 #define ATT_FIND_BY_TYPE_VALUE_REQ_FIXED_SIZE 6
206 #define ATT_FIND_BY_TYPE_VALUE_REQ_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_FIND_BY_TYPE_VALUE_REQ_FIXED_SIZE )
207 #define ATT_READ_BY_TYPE_REQ_FIXED_SIZE 4
208 #define ATT_READ_BY_TYPE_REQ_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_READ_BY_TYPE_REQ_FIXED_SIZE )
209 #define ATT_READ_BY_TYPE_RSP_FIXED_SIZE 1
210 #define ATT_READ_BY_TYPE_RSP_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_READ_BY_TYPE_RSP_FIXED_SIZE )
211 #define ATT_READ_REQ_SIZE 2
212 #define ATT_READ_BY_GRP_TYPE_RSP_FIXED_SIZE 1
213 #define ATT_READ_BY_GRP_TYPE_RSP_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_READ_BY_GRP_TYPE_RSP_FIXED_SIZE )
214 #define ATT_WRITE_REQ_FIXED_SIZE 2
215 #define ATT_READ_BLOB_REQ_SIZE 4
216 #define ATT_WRITE_REQ_FIXED_SIZE 2
217 #define ATT_WRITE_REQ_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_WRITE_REQ_FIXED_SIZE )
218 #define ATT_PREPARE_WRITE_REQ_FIXED_SIZE 4
219 #define ATT_PREPARE_WRITE_REQ_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_PREPARE_WRITE_REQ_FIXED_SIZE )
220 #define ATT_PREPARE_WRITE_RSP_FIXED_SIZE 4
221 #define ATT_EXECUTE_WRITE_REQ_SIZE 1
222 #define ATT_HANDLE_VALUE_IND_FIXED_SIZE 2
223 #define ATT_HANDLE_VALUE_IND_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_HANDLE_VALUE_IND_FIXED_SIZE )
224 #define ATT_AUTHEN_SIG_LEN 12
225 
227 /*********************************************************************
228  * VARIABLES
229  */
230 
232 extern CONST uint8 btBaseUUID[ATT_UUID_SIZE];
233 // @endcond // NODOC
234 
235 /*********************************************************************
236  * MACROS
237  */
239 #define ATT_WRITE_COMMAND( method, cmd ) ( ( (method) == ATT_WRITE_REQ ) && ( (cmd) == TRUE ) )
240 
241 /*********************************************************************
242  * ATT Find Info Response macros
243  */
244 // Handle and 16-bit Bluetooth UUID pair indexes
245 #define ATT_BT_PAIR_HANDLE_IDX( i ) ( (i) * (2 + ATT_BT_UUID_SIZE) )
246 #define ATT_BT_PAIR_UUID_IDX( i ) ( ATT_BT_PAIR_HANDLE_IDX( (i) ) + 2 )
247 
248 #define ATT_BT_PAIR_HANDLE( info, i ) ( BUILD_UINT16( (info)[ATT_BT_PAIR_HANDLE_IDX((i))], \
249  (info)[ATT_BT_PAIR_HANDLE_IDX((i))+1] ) )
250 #define ATT_BT_PAIR_UUID( info, i ) ( BUILD_UINT16( (info)[ATT_BT_PAIR_UUID_IDX((i))], \
251  (info)[ATT_BT_PAIR_UUID_IDX((i))+1] ) )
252 
253 // Handle and 128-bit UUID pair indexes
254 #define ATT_PAIR_HANDLE_IDX( i ) ( (i) * (2 + ATT_UUID_SIZE) )
255 #define ATT_PAIR_UUID_IDX( i ) ( ATT_PAIR_HANDLE_IDX( (i) ) + 2 )
256 
257 #define ATT_PAIR_HANDLE( info, i ) ( BUILD_UINT16( (info)[ATT_PAIR_HANDLE_IDX((i))], \
258  (info)[ATT_PAIR_HANDLE_IDX((i))+1] ) )
259 
260 /*********************************************************************
261  * ATT Find By Type Value Response macros
262  */
263 // Attribute Handle and Group End Handle pair indexes
264 #define ATT_ATTR_HANDLE_IDX( i ) ( (i) * (2 + 2) )
265 #define ATT_GRP_END_HANDLE_IDX( i ) ( ATT_ATTR_HANDLE_IDX( (i) ) + 2 )
266 
267 #define ATT_ATTR_HANDLE( info, i ) ( BUILD_UINT16( (info)[ATT_ATTR_HANDLE_IDX((i))], \
268  (info)[ATT_ATTR_HANDLE_IDX((i))+1] ) )
269 #define ATT_GRP_END_HANDLE( info, i ) ( BUILD_UINT16( (info)[ATT_GRP_END_HANDLE_IDX((i))], \
270  (info)[ATT_GRP_END_HANDLE_IDX((i))+1] ) )
271 
272 /*********************************************************************
273  * ATT Read Multiple Request macros
274  */
275 // Attribute Handle index
276 #define ATT_HANDLE_IDX( i ) ( (i) * 2 )
277 
278 #define ATT_HANDLE( handles, i ) ( BUILD_UINT16( (handles)[ATT_HANDLE_IDX((i))], \
279  (handles)[ATT_HANDLE_IDX((i))+1] ) )
280 
283 /*********************************************************************
284  * TYPEDEFS
285  */
286 
291 typedef struct
293 {
294  uint8 sig;
295  uint8 cmd;
296  uint8 method;
297  uint16 len;
298  uint8 *pParams;
299 } attPacket_t;
300 
302 typedef struct
303 {
304  uint8 len;
305  uint8 uuid[ATT_UUID_SIZE];
306 } attAttrType_t;
307 
309 typedef struct
310 {
311  uint8 len;
312  uint8 uuid[ATT_BT_UUID_SIZE];
314 
324 typedef struct
325 {
326  uint8 reqOpcode;
327  uint16 handle;
328  uint8 errCode;
329 } attErrorRsp_t;
330 
336 typedef struct
337 {
338  uint16 clientRxMTU;
340 
346 typedef struct
347 {
348  uint16 serverRxMTU;
350 
356 typedef struct
357 {
358  uint16 startHandle;
359  uint16 endHandle;
361 
363 typedef struct
364 {
365  uint16 handle;
366  uint8 uuid[ATT_BT_UUID_SIZE];
368 
370 typedef struct
371 {
372  uint16 handle;
373  uint8 uuid[ATT_UUID_SIZE];
375 
381 typedef struct
382 {
383  uint16 numInfo;
384  uint8 format;
385  uint8 *pInfo;
387 
393 typedef struct
394 {
395  uint16 startHandle;
396  uint16 endHandle;
398  uint16 len;
399  uint8 *pValue;
401 
403 typedef struct
404 {
405  uint16 handle;
406  uint16 grpEndHandle;
408 
414 typedef struct
415 {
416  uint16 numInfo;
417  uint8 *pHandlesInfo;
419 
425 typedef struct
426 {
427  uint16 startHandle;
428  uint16 endHandle;
431 
437 typedef struct
438 {
439  uint16 numPairs;
440  uint16 len;
441  uint8 *pDataList;
442  uint16 dataLen;
444 
450 typedef struct
451 {
452  uint16 handle;
453 } attReadReq_t;
454 
460 typedef struct
461 {
462  uint16 len;
463  uint8 *pValue;
464 } attReadRsp_t;
465 
471 typedef struct
472 {
473  uint16 handle;
474  uint16 offset;
476 
482 typedef struct
483 {
484  uint16 len;
485  uint8 *pValue;
487 
493 typedef struct
494 {
495  uint8 *pHandles;
496  uint16 numHandles;
498 
504 typedef struct
505 {
506  uint16 len;
507  uint8 *pValues;
509 
515 typedef struct
516 {
517  uint16 startHandle;
518  uint16 endHandle;
521 
527 typedef struct
528 {
529  uint16 numGrps;
530  uint16 len;
531  uint8 *pDataList;
533 
539 typedef struct
540 {
541  uint16 handle;
542  uint16 len;
543  uint8 *pValue;
544  uint8 sig;
545  uint8 cmd;
546 } attWriteReq_t;
547 
553 typedef struct
554 {
555  uint16 handle;
556  uint16 offset;
557  uint16 len;
558  uint8 *pValue;
560 
566 typedef struct
567 {
568  uint16 handle;
569  uint16 offset;
570  uint16 len;
571  uint8 *pValue;
573 
579 typedef struct
580 {
581  uint8 flags;
584 
590 typedef struct
591 {
592  uint16 handle;
593  uint16 len;
594  uint8 *pValue;
596 
602 typedef struct
603 {
604  uint16 handle;
605  uint16 len;
606  uint8 *pValue;
608 
626 typedef struct
627 {
628  uint8 opcode;
631 
642 typedef struct
643 {
644  uint16 MTU;
646 
656 typedef union
657 {
658  // Request messages
670 
671  // Response messages
682 
683  // Indication and Notification messages
686 
687  // Locally-generated event messages
690 } attMsg_t;
691 
694 
696 // Function prototype to notify GATT Server or Client about an outgoing ATT message.
697 typedef void (*attNotifyTxCB_t)( uint16 connHandle, uint8 opcode );
698 
699 /*********************************************************************
700  * VARIABLES
701  */
702 
703 /*********************************************************************
704  * API FUNCTIONS
705  */
706 
707 /*-------------------------------------------------------------------
708  * General Utility APIs
709  */
710 
711 /*
712  * Parse an attribute protocol message.
713  */
714 extern uint8 ATT_ParsePacket( l2capDataEvent_t *pL2capMsg, attPacket_t *pPkt );
715 
716 /*
717  * Compare two UUIDs. The UUIDs are converted if necessary.
718  */
719 extern uint8 ATT_CompareUUID( const uint8 *pUUID1, uint16 len1,
720  const uint8 *pUUID2, uint16 len2 );
721 /*
722  * Convert a 16-bit UUID to 128-bit UUID.
723  */
724 extern uint8 ATT_ConvertUUIDto128( const uint8 *pUUID16, uint8 *pUUID128 );
725 
726 /*
727  * Convert a 128-bit UUID to 16-bit UUID.
728  */
729 extern uint8 ATT_ConvertUUIDto16( const uint8 *pUUID128, uint8 *pUUID16 );
730 
731 
732 /*-------------------------------------------------------------------
733  * Attribute Client Utility APIs
734  */
735 
736 /*
737  * Build Error Response.
738  */
739 extern uint16 ATT_BuildErrorRsp( uint8 *pBuf, uint8 *pMsg );
740 
741 /*
742  * Parse Error Response.
743  */
744 extern bStatus_t ATT_ParseErrorRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
745 
746 /*
747  * Build Exchange MTU Request.
748  */
749 extern uint16 ATT_BuildExchangeMTUReq( uint8 *pBuf, uint8 *pMsg );
750 
751 /*
752  * Build Exchange MTU Response.
753  */
754 extern uint16 ATT_BuildExchangeMTURsp( uint8 *pBuf, uint8 *pMsg );
755 
756 /*
757  * Parse Exchange MTU Response.
758  */
759 extern bStatus_t ATT_ParseExchangeMTURsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
760 
761 /*
762  * Build Find Information Request.
763  */
764 extern uint16 ATT_BuildFindInfoReq( uint8 *pBuf, uint8 *pMsg );
765 
766 /*
767  * Parse Find Information Response.
768  */
769 extern bStatus_t ATT_ParseFindInfoRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
770 
771 /*
772  * Build Find Information Response.
773  */
774 extern uint16 ATT_BuildFindInfoRsp( uint8 *pBuf, uint8 *pMsg );
775 
776 /*
777  * Build Find By Type Value Request.
778  */
779 extern uint16 ATT_BuildFindByTypeValueReq( uint8 *pBuf, uint8 *pMsg );
780 
781 /*
782  * Build Find By Type Value Response.
783  */
784 extern uint16 ATT_BuildFindByTypeValueRsp( uint8 *pBuf, uint8 *pMsg );
785 
786 /*
787  * Parse Find By Type Value Response.
788  */
789 extern bStatus_t ATT_ParseFindByTypeValueRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
790 
791 /*
792  * Build Read By Type Request.
793  */
794 extern uint16 ATT_BuildReadByTypeReq( uint8 *pBuf, uint8 *pMsg );
795 
796 /*
797  * Build Read By Type Response.
798  */
799 extern uint16 ATT_BuildReadByTypeRsp( uint8 *pBuf, uint8 *pMsg );
800 
801 /*
802  * Parse Read By Type Response.
803  */
804 extern bStatus_t ATT_ParseReadByTypeRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
805 
806 /*
807  * Build Read Request.
808  */
809 extern uint16 ATT_BuildReadReq( uint8 *pBuf, uint8 *pMsg );
810 
811 /*
812  * Build Read Response.
813  */
814 extern uint16 ATT_BuildReadRsp( uint8 *pBuf, uint8 *pMsg );
815 
816 /*
817  * Parse Read Response.
818  */
819 extern bStatus_t ATT_ParseReadRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
820 
821 /*
822  * Build Read Blob Request.
823  */
824 extern uint16 ATT_BuildReadBlobReq( uint8 *pBuf, uint8 *pMsg );
825 
826 /*
827  * Build Read Blob Response.
828  */
829 extern uint16 ATT_BuildReadBlobRsp( uint8 *pBuf, uint8 *pMsg );
830 
831 /*
832  * Parse Read Blob Response.
833  */
834 extern bStatus_t ATT_ParseReadBlobRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
835 
836 /*
837  * Build Read Multiple Request.
838  */
839 extern uint16 ATT_BuildReadMultiReq( uint8 *pBuf, uint8 *pMsg );
840 
841 /*
842  * Build Read Multiple Response.
843  */
844 extern uint16 ATT_BuildReadMultiRsp( uint8 *pBuf, uint8 *pMsg );
845 
846 /*
847  * Parse Read Multiple Response.
848  */
849 extern bStatus_t ATT_ParseReadMultiRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
850 
851 /*
852  * Build Read By Group Type Response.
853  */
854 extern uint16 ATT_BuildReadByGrpTypeRsp( uint8 *pBuf, uint8 *pMsg );
855 
856 /*
857  * Parse Read By Group Type Response.
858  */
859 extern bStatus_t ATT_ParseReadByGrpTypeRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
860 
861 /*
862  * Build Write Request.
863  */
864 extern uint16 ATT_BuildWriteReq( uint8 *pBuf, uint8 *pMsg );
865 
866 /*
867  * Parse Write Response.
868  */
869 extern bStatus_t ATT_ParseWriteRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
870 
871 /*
872  * Build Prepare Write Request.
873  */
874 extern uint16 ATT_BuildPrepareWriteReq( uint8 *pBuf, uint8 *pMsg );
875 
876 /*
877  * Build Prepare Write Response.
878  */
879 extern uint16 ATT_BuildPrepareWriteRsp( uint8 *pBuf, uint8 *pMsg );
880 
881 /*
882  * Parse Prepare Write Response.
883  */
884 extern bStatus_t ATT_ParsePrepareWriteRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
885 
886 /*
887  * Build Execute Write Request.
888  */
889 extern uint16 ATT_BuildExecuteWriteReq( uint8 *pBuf, uint8 *pMsg );
890 
891 /*
892  * Parse Execute Write Response.
893  */
894 extern bStatus_t ATT_ParseExecuteWriteRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
895 
896 /*
897  * Build Handle Value Indication.
898  */
899 extern uint16 ATT_BuildHandleValueInd( uint8 *pBuf, uint8 *pMsg );
900 
901 /*
902  * Parse Handle Value Indication.
903  */
904 extern bStatus_t ATT_ParseHandleValueInd( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
905 
906 
907 /*-------------------------------------------------------------------
908  * Attribute Server Utility APIs
909  */
910 
911 /*
912  * Parse Exchange MTU Request.
913  */
914 extern bStatus_t ATT_ParseExchangeMTUReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
915 
916 /*
917  * Parse Find Information Request.
918  */
919 extern bStatus_t ATT_ParseFindInfoReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
920 
921 /*
922  * Parse Find By Type Value Request.
923  */
924 extern bStatus_t ATT_ParseFindByTypeValueReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
925 
926 /*
927  * Parse Read By Type Request.
928  */
929 extern bStatus_t ATT_ParseReadByTypeReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
930 
931 /*
932  * Parse Read Request.
933  */
934 extern bStatus_t ATT_ParseReadReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
935 
936 /*
937  * Parse Write Blob Request.
938  */
939 extern bStatus_t ATT_ParseReadBlobReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
940 
941 /*
942  * Parse Read Multiple Request.
943  */
944 extern bStatus_t ATT_ParseReadMultiReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
945 
946 /*
947  * Parse Write Request.
948  */
949 extern bStatus_t ATT_ParseWriteReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
950 
951 /*
952  * Parse Execute Write Request.
953  */
954 extern bStatus_t ATT_ParseExecuteWriteReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
955 
956 /*
957  * Parse Prepare Write Request.
958  */
959 extern bStatus_t ATT_ParsePrepareWriteReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
960 
961 /*
962  * Parse Handle Value Confirmation.
963  */
964 extern bStatus_t ATT_ParseHandleValueCfm( uint8 *pParams, uint16 len, attMsg_t *pMsg );
965 
967 
968 /*-------------------------------------------------------------------
969  * Attribute Client Public APIs
970  */
971 
990 extern bStatus_t ATT_ExchangeMTUReq( uint16 connHandle, attExchangeMTUReq_t *pReq );
991 
1004 extern bStatus_t ATT_FindInfoReq( uint16 connHandle, attFindInfoReq_t *pReq );
1005 
1018 extern bStatus_t ATT_FindByTypeValueReq( uint16 connHandle, attFindByTypeValueReq_t *pReq );
1019 
1032 extern bStatus_t ATT_ReadByTypeReq( uint16 connHandle, attReadByTypeReq_t *pReq );
1033 
1046 extern bStatus_t ATT_ReadReq( uint16 connHandle, attReadReq_t *pReq );
1047 
1060 extern bStatus_t ATT_ReadBlobReq( uint16 connHandle, attReadBlobReq_t *pReq );
1061 
1074 extern bStatus_t ATT_ReadMultiReq( uint16 connHandle, attReadMultiReq_t *pReq );
1075 
1088 extern bStatus_t ATT_ReadByGrpTypeReq( uint16 connHandle, attReadByGrpTypeReq_t *pReq );
1089 
1103 extern bStatus_t ATT_WriteReq( uint16 connHandle, attWriteReq_t *pReq );
1104 
1117 extern bStatus_t ATT_PrepareWriteReq( uint16 connHandle, attPrepareWriteReq_t *pReq );
1118 
1131 extern bStatus_t ATT_ExecuteWriteReq( uint16 connHandle, attExecuteWriteReq_t *pReq );
1132 
1144 extern bStatus_t ATT_HandleValueCfm( uint16 connHandle );
1145 
1146 
1147 /*-------------------------------------------------------------------
1148  * Attribute Server Public APIs
1149  */
1150 
1163 extern bStatus_t ATT_ErrorRsp( uint16 connHandle, attErrorRsp_t *pRsp );
1164 
1177 extern bStatus_t ATT_ExchangeMTURsp( uint16 connHandle, attExchangeMTURsp_t *pRsp );
1178 
1191 extern bStatus_t ATT_FindInfoRsp( uint16 connHandle, attFindInfoRsp_t *pRsp );
1192 
1205 extern bStatus_t ATT_FindByTypeValueRsp( uint16 connHandle, attFindByTypeValueRsp_t *pRsp );
1206 
1219 extern bStatus_t ATT_ReadByTypeRsp( uint16 connHandle, attReadByTypeRsp_t *pRsp );
1220 
1233 extern bStatus_t ATT_ReadRsp( uint16 connHandle, attReadRsp_t *pRsp );
1234 
1247 extern bStatus_t ATT_ReadBlobRsp( uint16 connHandle, attReadBlobRsp_t *pRsp );
1248 
1261 extern bStatus_t ATT_ReadMultiRsp( uint16 connHandle, attReadMultiRsp_t *pRsp ) ;
1262 
1275 extern bStatus_t ATT_ReadByGrpTypeRsp( uint16 connHandle, attReadByGrpTypeRsp_t *pRsp );
1276 
1288 extern bStatus_t ATT_WriteRsp( uint16 connHandle );
1289 
1302 extern bStatus_t ATT_PrepareWriteRsp( uint16 connHandle, attPrepareWriteRsp_t *pRsp );
1303 
1315 extern bStatus_t ATT_ExecuteWriteRsp( uint16 connHandle );
1316 
1329 extern bStatus_t ATT_HandleValueNoti( uint16 connHandle, attHandleValueNoti_t *pNoti );
1330 
1343 extern bStatus_t ATT_HandleValueInd( uint16 connHandle, attHandleValueInd_t *pInd );
1344 
1345 /*-------------------------------------------------------------------
1346  * Attribute Common Public APIs
1347  */
1348 
1358 extern uint8 ATT_UpdateMTU( uint16 connHandle, uint16 MTU );
1359 
1367 extern uint16 ATT_GetMTU( uint16 connHandle );
1368 
1375 extern void ATT_SetParamValue( uint16 value );
1376 
1382 extern uint16 ATT_GetParamValue( void );
1383 
1389 extern void ATT_RegisterServer( attNotifyTxCB_t pfnNotifyTx );
1390 
1396 extern void ATT_RegisterClient( attNotifyTxCB_t pfnNotifyTx );
1397 
1400 /*********************************************************************
1401 *********************************************************************/
1402 
1403 #ifdef __cplusplus
1404 }
1405 #endif
1406 
1407 #endif /* ATT_H */
1408 
uint16 endHandle
Last requested handle number.
Definition: att.h:359
void ATT_RegisterServer(attNotifyTxCB_t pfnNotifyTx)
Register the server's notify Tx function with the ATT layer.
bStatus_t ATT_ReadRsp(uint16 connHandle, attReadRsp_t *pRsp)
Send Read Response.
uint16 handle
Handle of the attribute to be read (must be first field)
Definition: att.h:452
uint16 len
Length of each attribute handle, end group handle and value set.
Definition: att.h:530
This API allows the software components in the Z-Stack to be written independently of the specifics o...
attFindInfoRsp_t findInfoRsp
ATT Find Information Response.
Definition: att.h:674
uint16 numInfo
Number of attribute handle-UUID pairs found.
Definition: att.h:383
attPrepareWriteRsp_t prepareWriteRsp
ATT Prepare Write Response.
Definition: att.h:681
L2CAP layer interface.
Exchange MTU Response format.
Definition: att.h:346
bStatus_t ATT_FindByTypeValueRsp(uint16 connHandle, attFindByTypeValueRsp_t *pRsp)
Send Find By Type Value Response.
Read Request.
Definition: att.h:450
uint16 numGrps
Number of attribute handle, end group handle and value sets found.
Definition: att.h:529
Find Information Response format.
Definition: att.h:381
bStatus_t ATT_ExecuteWriteReq(uint16 connHandle, attExecuteWriteReq_t *pReq)
Send Execute Write Request.
bStatus_t ATT_FindInfoReq(uint16 connHandle, attFindInfoReq_t *pReq)
Send Find Information Request.
uint8 * pHandlesInfo
List of 1 or more handles information (4 to ATT_MTU_SIZE-1)
Definition: att.h:417
bStatus_t ATT_ExchangeMTUReq(uint16 connHandle, attExchangeMTUReq_t *pReq)
Send Exchange MTU Request.
uint16 MTU
new MTU size
Definition: att.h:644
attReadByGrpTypeReq_t readByGrpTypeReq
ATT Read By Group Type Request.
Definition: att.h:666
uint16 numHandles
Number of attribute handles.
Definition: att.h:496
attPrepareWriteReq_t prepareWriteReq
ATT Prepare Write Request.
Definition: att.h:668
attAttrBtType_t type
2-octet UUID to find
Definition: att.h:397
uint8 reqOpcode
Request that generated this error response.
Definition: att.h:326
bStatus_t ATT_FindInfoRsp(uint16 connHandle, attFindInfoRsp_t *pRsp)
Send Find Information Response.
attMtuUpdatedEvt_t mtuEvt
ATT MTU Updated Event.
Definition: att.h:689
Find Information Request format.
Definition: att.h:356
Read Response.
Definition: att.h:460
Handle and its 128-bit UUID.
Definition: att.h:370
attErrorRsp_t errorRsp
ATT Error Response.
Definition: att.h:672
bStatus_t ATT_ExchangeMTURsp(uint16 connHandle, attExchangeMTURsp_t *pRsp)
Send Exchange MTU Response.
attHandleValueNoti_t handleValueNoti
ATT Handle Value Notification.
Definition: att.h:684
Error Response format.
Definition: att.h:324
attAttrType_t type
Requested group type (2 or 16 octet UUID)
Definition: att.h:519
Find By Type Value Request format.
Definition: att.h:393
uint8 sig
Authentication Signature status (not included (0), valid (1), invalid (2))
Definition: att.h:294
uint8 * pHandles
Set of two or more attribute handles (4 to ATT_MTU_SIZE-1) - must be first field. ...
Definition: att.h:495
#define ATT_BT_UUID_SIZE
Size of 16-bit Bluetooth UUID.
Definition: att.h:126
uint16 offset
Offset of the first octet to be written.
Definition: att.h:556
#define ATT_UUID_SIZE
Size of 128-bit UUID.
Definition: att.h:127
Write Request format.
Definition: att.h:539
uint8 flags
Definition: att.h:581
void ATT_RegisterClient(attNotifyTxCB_t pfnNotifyTx)
Register the client's notify Tx function with the ATT layer.
uint8 cmd
Command Flag.
Definition: att.h:545
uint16 len
Length of value.
Definition: att.h:484
bStatus_t ATT_ReadByTypeReq(uint16 connHandle, attReadByTypeReq_t *pReq)
Send Read By Type Request.
bStatus_t ATT_ReadByGrpTypeRsp(uint16 connHandle, attReadByGrpTypeRsp_t *pRsp)
Send Read By Group Type Respond.
uint16 len
Length of value.
Definition: att.h:570
uint8 * pDataList
List of 1 or more attribute handle-value pairs (2 to ATT_MTU_SIZE-2)
Definition: att.h:441
attReadMultiReq_t readMultiReq
ATT Read Multiple Request.
Definition: att.h:665
uint8 * pValue
Part of the value of the attribute to be written (0 to ATT_MTU_SIZE-5) - must be allocated.
Definition: att.h:558
uint16 len
Length of value.
Definition: att.h:462
uint16 startHandle
First requested handle number (must be first field)
Definition: att.h:395
uint16 handle
Handle of the attribute that has been read.
Definition: att.h:568
uint8 opcode
opcode of message that caused flow control violation
Definition: att.h:628
attFindInfoReq_t findInfoReq
ATT Find Information Request.
Definition: att.h:660
uint16 numPairs
Number of attribute handle-UUID pairs found.
Definition: att.h:439
attReadRsp_t readRsp
ATT Read Response.
Definition: att.h:677
bStatus_t ATT_PrepareWriteReq(uint16 connHandle, attPrepareWriteReq_t *pReq)
Send Prepare Write Request.
attHandleValueInd_t handleValueInd
ATT Handle Value Indication.
Definition: att.h:685
uint16 clientRxMTU
Client receive MTU size.
Definition: att.h:338
uint8 format
Format of information data.
Definition: att.h:384
uint16 offset
Offset of the first octet to be read.
Definition: att.h:474
uint16 startHandle
First requested handle number (must be first field)
Definition: att.h:358
uint16 len
Length of Attribute Parameters.
Definition: att.h:297
uint8 sig
Authentication Signature status (not included (0), valid (1), invalid (2))
Definition: att.h:544
Read By Group Type Response format.
Definition: att.h:527
attReadByTypeRsp_t readByTypeRsp
ATT Read By Type Response.
Definition: att.h:676
uint16 ATT_GetParamValue(void)
Get a ATT Parameter value.
ATT MTU Updated Event message format.
Definition: att.h:642
bStatus_t ATT_FindByTypeValueReq(uint16 connHandle, attFindByTypeValueReq_t *pReq)
Send Find By Type Value Request.
uint16 len
Length of values.
Definition: att.h:506
attExchangeMTUReq_t exchangeMTUReq
ATT Exchange MTU Request.
Definition: att.h:659
uint16 endHandle
Last requested handle number.
Definition: att.h:396
bStatus_t ATT_ReadByGrpTypeReq(uint16 connHandle, attReadByGrpTypeReq_t *pReq)
Send Read By Group Type Request.
Attribute Type format (2 or 16 octet UUID).
Definition: att.h:302
Read Multiple Response format.
Definition: att.h:504
bStatus_t ATT_HandleValueInd(uint16 connHandle, attHandleValueInd_t *pInd)
Send Handle Value Indication.
Read Blob Response format.
Definition: att.h:482
bStatus_t ATT_ReadByTypeRsp(uint16 connHandle, attReadByTypeRsp_t *pRsp)
Send Read By Type Respond.
attReadBlobReq_t readBlobReq
ATT Read Blob Request.
Definition: att.h:664
bStatus_t ATT_WriteRsp(uint16 connHandle)
Send Write Response.
uint16 endHandle
Last requested handle number.
Definition: att.h:428
Attribute Type format (2-octet Bluetooth UUID).
Definition: att.h:309
uint16 serverRxMTU
Server receive MTU size.
Definition: att.h:348
uint8 method
Method.
Definition: att.h:296
uint8 * pParams
Attribute Parameters.
Definition: att.h:298
uint16 offset
Offset of the first octet to be written.
Definition: att.h:569
uint8 * pValue
Value of the attribute to be written (0 to ATT_MTU_SIZE-3)
Definition: att.h:543
uint16 len
Length of value.
Definition: att.h:593
Read Blob Request format.
Definition: att.h:471
uint8 cmd
Command Flag.
Definition: att.h:295
uint8 * pValue
Part of the value of the attribute to be written (0 to ATT_MTU_SIZE-5)
Definition: att.h:571
Find By Type Value Response format.
Definition: att.h:414
bStatus_t ATT_PrepareWriteRsp(uint16 connHandle, attPrepareWriteRsp_t *pRsp)
Send Prepare Write Response.
ATT Flow Control Violated Event message format.
Definition: att.h:626
Read By Type Request format.
Definition: att.h:425
uint8 * pValue
Attribute value to find (0 to ATT_MTU_SIZE-7)
Definition: att.h:399
Read Multiple Request format.
Definition: att.h:493
uint8 * pValue
Current value of the attribute (0 to ATT_MTU_SIZE-3)
Definition: att.h:606
uint8 len
Length of UUID (2 or 16)
Definition: att.h:304
uint16 len
Length of value.
Definition: att.h:557
uint16 handle
Attribute handle that generated error response.
Definition: att.h:327
uint8 * pInfo
Information data whose format is determined by format field (4 to ATT_MTU_SIZE-2) ...
Definition: att.h:385
Handle Value Indication format.
Definition: att.h:602
uint16 handle
Handle of the attribute to be read (must be first field)
Definition: att.h:473
attExecuteWriteReq_t executeWriteReq
ATT Execute Write Request.
Definition: att.h:669
Type definitions and macros for BLE stack.
Handle Value Notification format.
Definition: att.h:590
uint16 startHandle
First requested handle number (must be first field)
Definition: att.h:427
uint16 handle
Handle of the attribute to be written (must be first field)
Definition: att.h:555
uint16 endHandle
Last requested handle number.
Definition: att.h:518
bStatus_t ATT_ReadBlobReq(uint16 connHandle, attReadBlobReq_t *pReq)
Send Read Blob Request.
ATT Message format.
Definition: att.h:656
attReadBlobRsp_t readBlobRsp
ATT Read Blob Response.
Definition: att.h:678
bStatus_t ATT_ReadMultiReq(uint16 connHandle, attReadMultiReq_t *pReq)
Send Read Multiple Request.
uint8 * pDataList
List of 1 or more attribute handle, end group handle and value (4 to ATT_MTU_SIZE-2) ...
Definition: att.h:531
uint16 handle
Handle of the attribute to be written (must be first field)
Definition: att.h:541
void ATT_SetParamValue(uint16 value)
Set a ATT Parameter value. Use this function to change the default ATT parameter values.
uint16 len
Length of value.
Definition: att.h:605
bStatus_t ATT_ExecuteWriteRsp(uint16 connHandle)
Send Execute Write Response.
attFlowCtrlViolatedEvt_t flowCtrlEvt
ATT Flow Control Violated Event.
Definition: att.h:688
uint16 handle
Handle of the attribute that has been changed (must be first field)
Definition: att.h:604
bStatus_t ATT_ReadReq(uint16 connHandle, attReadReq_t *pReq)
Send Read Request.
Exchange MTU Request format.
Definition: att.h:336
uint16 grpEndHandle
Group end handle.
Definition: att.h:406
uint16 len
Size of each attribute handle-value pair.
Definition: att.h:440
Attribute Protocol PDU format.
Definition: att.h:292
uint8 * pValue
Value of the attribute with the handle given (0 to ATT_MTU_SIZE-1)
Definition: att.h:463
uint8 * pValue
Part of the value of the attribute with the handle given (0 to ATT_MTU_SIZE-1)
Definition: att.h:485
uint16 dataLen
Length of data written into pDataList. Not part of actual ATT Response.
Definition: att.h:442
attAttrType_t type
Requested type (2 or 16 octet UUID)
Definition: att.h:429
uint8 ATT_UpdateMTU(uint16 connHandle, uint16 MTU)
This function is used to update the MTU size of a connection.
Read By Group Type Request format.
Definition: att.h:515
uint16 handle
Handle.
Definition: att.h:365
attReadByTypeReq_t readByTypeReq
ATT Read By Type Request.
Definition: att.h:662
Handle and its 16-bit Bluetooth UUIDs.
Definition: att.h:363
uint16 len
Length of value.
Definition: att.h:542
attReadByGrpTypeRsp_t readByGrpTypeRsp
ATT Read By Group Type Response.
Definition: att.h:680
bStatus_t ATT_ReadBlobRsp(uint16 connHandle, attReadBlobRsp_t *pRsp)
Send Read Blob Response.
Status_t bStatus_t
BLE Generic Status return.
Definition: bcomdef.h:243
uint8 pendingOpcode
opcode of pending message
Definition: att.h:629
uint8 len
Length of UUID (2)
Definition: att.h:311
Read By Type Response format.
Definition: att.h:437
Prepare Write Response format.
Definition: att.h:566
uint16 handle
Handle.
Definition: att.h:372
uint16 numInfo
Number of handles information found.
Definition: att.h:416
Prepare Write Request format.
Definition: att.h:553
attExchangeMTURsp_t exchangeMTURsp
ATT Exchange MTU Response.
Definition: att.h:673
bStatus_t ATT_ReadMultiRsp(uint16 connHandle, attReadMultiRsp_t *pRsp)
Send Read Multiple Response.
attFindByTypeValueReq_t findByTypeValueReq
ATT Find By Type Value Request.
Definition: att.h:661
bStatus_t ATT_WriteReq(uint16 connHandle, attWriteReq_t *pReq)
Send Write Request.
attReadReq_t readReq
ATT Read Request.
Definition: att.h:663
bStatus_t ATT_HandleValueNoti(uint16 connHandle, attHandleValueNoti_t *pNoti)
Send Handle Value Notification.
attReadMultiRsp_t readMultiRsp
ATT Read Multiple Response.
Definition: att.h:679
attWriteReq_t writeReq
ATT Write Request.
Definition: att.h:667
uint8 * pValues
Set of two or more values (0 to ATT_MTU_SIZE-1)
Definition: att.h:507
uint16 len
Length of value.
Definition: att.h:398
attFindByTypeValueRsp_t findByTypeValueRsp
ATT Find By Type Value Response.
Definition: att.h:675
uint8 * pValue
Current value of the attribute (0 to ATT_MTU_SIZE-3)
Definition: att.h:594
uint16 ATT_GetMTU(uint16 connHandle)
This function is used to get the MTU size of a connection.
uint16 handle
Found attribute handle.
Definition: att.h:405
uint16 startHandle
First requested handle number (must be first field)
Definition: att.h:517
uint8 errCode
Reason why the request has generated error response.
Definition: att.h:328
OSAL L2CAP_DATA_EVENT message format.
Definition: l2cap.h:575
bStatus_t ATT_HandleValueCfm(uint16 connHandle)
Send Handle Value Confirmation.
Execute Write Request format.
Definition: att.h:579
uint16 handle
Handle of the attribute that has been changed (must be first field)
Definition: att.h:592
bStatus_t ATT_ErrorRsp(uint16 connHandle, attErrorRsp_t *pRsp)
Send Error Response.
Handles Information format.
Definition: att.h:403
Copyright 2016, Texas Instruments Incorporated