TI BLE5-Stack API Documentation  9.12.00
att.h
Go to the documentation of this file.
1 /******************************************************************************
2 
3  Group: WCS, BTS
4  $Target Device: DEVICES $
5 
6  ******************************************************************************
7  $License: TI_TEXT 2009 $
8  ******************************************************************************
9  $Release Name: PACKAGE NAME $
10  $Release Date: PACKAGE RELEASE DATE $
11  *****************************************************************************/
12 
24 #ifndef ATT_H
25 #define ATT_H
26 
27 #ifdef __cplusplus
28 extern "C"
29 {
30 #endif
31 
32 /*********************************************************************
33  * INCLUDES
34  */
37 
39 
40 /*********************************************************************
41  * CONSTANTS
42  */
43 
58 #define ATT_MTU_SIZE L2CAP_MTU_SIZE
59 #define ATT_MAX_MTU_SIZE (255-L2CAP_HDR_SIZE)
60 
66 #define ATT_NUM_SUPPORTED_METHODS 0x20U
67 
68 #define ATT_ERROR_RSP 0x01
69 #define ATT_EXCHANGE_MTU_REQ 0x02
70 #define ATT_EXCHANGE_MTU_RSP 0x03
71 #define ATT_FIND_INFO_REQ 0x04
72 #define ATT_FIND_INFO_RSP 0x05
73 #define ATT_FIND_BY_TYPE_VALUE_REQ 0x06
74 #define ATT_FIND_BY_TYPE_VALUE_RSP 0x07
75 #define ATT_READ_BY_TYPE_REQ 0x08
76 #define ATT_READ_BY_TYPE_RSP 0x09
77 #define ATT_READ_REQ 0x0a
78 #define ATT_READ_RSP 0x0b
79 #define ATT_READ_BLOB_REQ 0x0c
80 #define ATT_READ_BLOB_RSP 0x0d
81 #define ATT_READ_MULTI_REQ 0x0e
82 #define ATT_READ_MULTI_RSP 0x0f
83 #define ATT_READ_BY_GRP_TYPE_REQ 0x10
84 #define ATT_READ_BY_GRP_TYPE_RSP 0x11
85 #define ATT_WRITE_REQ 0x12
86 #define ATT_WRITE_RSP 0x13
87 #define ATT_PREPARE_WRITE_REQ 0x16
88 #define ATT_PREPARE_WRITE_RSP 0x17
89 #define ATT_EXECUTE_WRITE_REQ 0x18
90 #define ATT_EXECUTE_WRITE_RSP 0x19
91 #define ATT_HANDLE_VALUE_NOTI 0x1b
92 #define ATT_HANDLE_VALUE_IND 0x1d
93 #define ATT_HANDLE_VALUE_CFM 0x1e
94 #define ATT_UNSUPPORTED_METHOD 0x20
95 
96 #define ATT_WRITE_CMD 0x52
97 #define ATT_SIGNED_WRITE_CMD 0xD2
98 
104 #define ATT_TRANSACTION_READY_EVENT 0x7D
105 #define ATT_FLOW_CTRL_VIOLATED_EVENT 0x7E
106 #define ATT_MTU_UPDATED_EVENT 0x7F
107 
114 #define ATT_METHOD_BITS 0x3f
115 #define ATT_CMD_FLAG_BIT 0x40
116 #define ATT_AUTHEN_SIG_FLAG_BIT 0x80
117 #define ATT_BT_UUID_SIZE 2
118 #define ATT_UUID_SIZE 16
119 #define ATT_MSG_TIMEOUT 30
120 
127 #define ATT_SIG_NOT_INCLUDED 0x00U
128 #define ATT_SIG_VALID 0x01U
129 #define ATT_SIG_INVALID 0x02U
130 
132 /*********************************************************************
133  * Error Response: Error Code
134  */
135 
140 #define ATT_ERR_INVALID_HANDLE 0x01
141 #define ATT_ERR_READ_NOT_PERMITTED 0x02
142 #define ATT_ERR_WRITE_NOT_PERMITTED 0x03
143 #define ATT_ERR_INVALID_PDU 0x04
144 #define ATT_ERR_INSUFFICIENT_AUTHEN 0x05
145 #define ATT_ERR_UNSUPPORTED_REQ 0x06
146 #define ATT_ERR_INVALID_OFFSET 0x07
147 #define ATT_ERR_INSUFFICIENT_AUTHOR 0x08
148 #define ATT_ERR_PREPARE_QUEUE_FULL 0x09
149 #define ATT_ERR_ATTR_NOT_FOUND 0x0a
150 #define ATT_ERR_ATTR_NOT_LONG 0x0b
151 #define ATT_ERR_INSUFFICIENT_KEY_SIZE 0x0c
152 #define ATT_ERR_INVALID_VALUE_SIZE 0x0d
153 #define ATT_ERR_UNLIKELY 0x0e
154 #define ATT_ERR_INSUFFICIENT_ENCRYPT 0x0f
155 #define ATT_ERR_UNSUPPORTED_GRP_TYPE 0x10
156 #define ATT_ERR_INSUFFICIENT_RESOURCES 0x11
157 
158 /*** Reserved for future use: 0x12 - 0x7F ***/
159 
160 /*** Application error code defined by a higher layer specification: 0x80-0x9F ***/
161 
162 #define ATT_ERR_INVALID_VALUE 0x80
163 
165 /*********************************************************************
166  * Find Information Response: UUID Format
167  */
168 #define ATT_HANDLE_BT_UUID_TYPE 0x01
169 #define ATT_HANDLE_UUID_TYPE 0x02
170 
171 /*********************************************************************
172  * Read Multiple Request: Handles
173  */
174 #define ATT_MIN_NUM_HANDLES 2
175 
176 /*********************************************************************
177  * Execute Write Request: Flags
178  */
179 #define ATT_CANCEL_PREPARED_WRITES 0x00
180 #define ATT_WRITE_PREPARED_VALUES 0x01
181 
182 #if defined ( TESTMODES )
183  #define ATT_TESTMODE_OFF 0
185  #define ATT_TESTMODE_UNAUTHEN_SIG 1
186  #define ATT_TESTMODE_SEND_UNS_REQ 2
187  #define ATT_TESTMODE_SEND_UNS_CMD 3
188 #endif
189 
194 #define ATT_UNSUPPORTED_OPCODE_SIZE 0U
195 #define ATT_OPCODE_SIZE 1
196 #define ATT_EXCHANGE_MTU_REQ_SIZE 2
197 #define ATT_EXCHANGE_MTU_RSP_SIZE 2
198 #define ATT_ERROR_RSP_SIZE 4
199 #define ATT_FIND_INFO_REQ_FIXED_SIZE 4
200 #define ATT_FIND_INFO_RSP_FIXED_SIZE 1
201 #define ATT_FIND_INFO_RSP_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_FIND_INFO_RSP_FIXED_SIZE )
202 #define ATT_FIND_BY_TYPE_VALUE_REQ_FIXED_SIZE 6
203 #define ATT_FIND_BY_TYPE_VALUE_RSP_FIXED_SIZE 2
204 #define ATT_FIND_BY_TYPE_VALUE_REQ_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_FIND_BY_TYPE_VALUE_REQ_FIXED_SIZE )
205 #define ATT_READ_BY_TYPE_REQ_FIXED_SIZE 4
206 #define ATT_READ_BY_TYPE_REQ_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_READ_BY_TYPE_REQ_FIXED_SIZE )
207 #define ATT_READ_BY_TYPE_RSP_FIXED_SIZE 1
208 #define ATT_READ_BY_TYPE_RSP_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_READ_BY_TYPE_RSP_FIXED_SIZE )
209 #define ATT_READ_REQ_SIZE 2
210 #define ATT_READ_RSP_SIZE 3
211 #define ATT_READ_BY_GRP_TYPE_REQ_FIXED_SIZE 4
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_READ_BLOB_RSP_SIZE 3
217 #define ATT_READ_MULTI_REQ_SIZE 3
218 #define ATT_WRITE_MULTI_REQ_SIZE 3
219 #define ATT_WRITE_MULTI_RSP_SIZE 3
220 #define ATT_WRITE_REQ_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_WRITE_REQ_FIXED_SIZE )
221 #define ATT_PREPARE_WRITE_REQ_FIXED_SIZE 4
222 #define ATT_PREPARE_WRITE_REQ_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_PREPARE_WRITE_REQ_FIXED_SIZE )
223 #define ATT_PREPARE_WRITE_RSP_FIXED_SIZE 4
224 #define ATT_EXECUTE_WRITE_REQ_SIZE 1
225 #define ATT_HANDLE_VALUE_IND_FIXED_SIZE 2
226 #define ATT_HANDLE_VALUE_IND_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_HANDLE_VALUE_IND_FIXED_SIZE )
227 #define ATT_HANDLE_VALUE_NOTI_FIXED_SIZE 4
228 #define ATT_AUTHEN_SIG_LEN 12
229 
231 /*********************************************************************
232  * VARIABLES
233  */
234 
236 extern const uint8 btBaseUUID[ATT_UUID_SIZE];
238 
239 extern const uint8_t attPktLenTable[ATT_NUM_SUPPORTED_METHODS+1U];
240 
241 /*********************************************************************
242  * MACROS
243  */
245 #define ATT_WRITE_COMMAND( method, cmd ) ( ( (method) == ATT_WRITE_REQ ) && ( (cmd) == TRUE ) )
246 
247 /*********************************************************************
248  * ATT Find Info Response macros
249  */
250 
252 
253 // Handle and 16-bit Bluetooth UUID pair indexes
254 #define ATT_BT_PAIR_HANDLE_IDX( i ) ( (i) * (2 + ATT_BT_UUID_SIZE) )
255 #define ATT_BT_PAIR_UUID_IDX( i ) ( ATT_BT_PAIR_HANDLE_IDX( (i) ) + 2 )
256 
257 #define ATT_BT_PAIR_HANDLE( info, i ) ( BUILD_UINT16( (info)[ATT_BT_PAIR_HANDLE_IDX((i))], \
258  (info)[ATT_BT_PAIR_HANDLE_IDX((i))+1] ) )
259 #define ATT_BT_PAIR_UUID( info, i ) ( BUILD_UINT16( (info)[ATT_BT_PAIR_UUID_IDX((i))], \
260  (info)[ATT_BT_PAIR_UUID_IDX((i))+1] ) )
261 
262 // Handle and 128-bit UUID pair indexes
263 #define ATT_PAIR_HANDLE_IDX( i ) ( (i) * (2 + ATT_UUID_SIZE) )
264 #define ATT_PAIR_UUID_IDX( i ) ( ATT_PAIR_HANDLE_IDX( (i) ) + 2 )
265 
266 #define ATT_PAIR_HANDLE( info, i ) ( BUILD_UINT16( (info)[ATT_PAIR_HANDLE_IDX((i))], \
267  (info)[ATT_PAIR_HANDLE_IDX((i))+1] ) )
268 
269 /*********************************************************************
270  * ATT Find By Type Value Response macros
271  */
272 // Attribute Handle and Group End Handle pair indexes
273 #define ATT_ATTR_HANDLE_IDX( i ) ( (i) * (2 + 2) )
274 #define ATT_GRP_END_HANDLE_IDX( i ) ( ATT_ATTR_HANDLE_IDX( (i) ) + 2 )
275 
276 #define ATT_ATTR_HANDLE( info, i ) ( BUILD_UINT16( (info)[ATT_ATTR_HANDLE_IDX((i))], \
277  (info)[ATT_ATTR_HANDLE_IDX((i))+1] ) )
278 #define ATT_GRP_END_HANDLE( info, i ) ( BUILD_UINT16( (info)[ATT_GRP_END_HANDLE_IDX((i))], \
279  (info)[ATT_GRP_END_HANDLE_IDX((i))+1] ) )
280 
281 /*********************************************************************
282  * ATT Read Multiple Request macros
283  */
284 // Attribute Handle index
285 #define ATT_HANDLE_IDX( i ) ( (i) * 2 )
286 
287 #define ATT_HANDLE( handles, i ) ( BUILD_UINT16( (handles)[ATT_HANDLE_IDX((i))], \
288  (handles)[ATT_HANDLE_IDX((i))+1] ) )
289 
291 
294 /*********************************************************************
295  * TYPEDEFS
296  */
297 
303 typedef struct
305 {
306  uint8 sig;
307  uint8 cmd;
308  uint8 method;
309  uint16 len;
310  uint8 *pParams;
311 } attPacket_t;
312 
314 typedef struct
315 {
316  uint8 len;
317  uint8 uuid[ATT_UUID_SIZE];
318 } attAttrType_t;
319 
321 typedef struct
322 {
323  uint8 len;
324  uint8 uuid[ATT_BT_UUID_SIZE];
326 
337 typedef struct
338 {
339  uint8 reqOpcode;
340  uint16 handle;
341  uint8 errCode;
342 } attErrorRsp_t;
343 
349 typedef struct
350 {
351  uint16 clientRxMTU;
353 
359 typedef struct
360 {
361  uint16 serverRxMTU;
363 
369 typedef struct
370 {
371  uint16 startHandle;
372  uint16 endHandle;
374 
376 typedef struct
377 {
378  uint16 handle;
379  uint8 uuid[ATT_BT_UUID_SIZE];
381 
383 typedef struct
384 {
385  uint16 handle;
386  uint8 uuid[ATT_UUID_SIZE];
388 
394 typedef struct
395 {
396  uint16 numInfo;
397  uint8 format;
398  uint8 *pInfo;
400 
406 typedef struct
407 {
408  uint16 startHandle;
409  uint16 endHandle;
411  uint16 len;
412  uint8 *pValue;
414 
416 typedef struct
417 {
418  uint16 handle;
419  uint16 grpEndHandle;
421 
427 typedef struct
428 {
429  uint16 numInfo;
430  uint8 *pHandlesInfo;
432 
438 typedef struct
439 {
440  uint16 startHandle;
441  uint16 endHandle;
444 
450 typedef struct
451 {
452  uint16 numPairs;
453  uint16 len;
454  uint8 *pDataList;
455  uint16 dataLen;
457 
463 typedef struct
464 {
465  uint16 handle;
466 } attReadReq_t;
467 
473 typedef struct
474 {
475  uint16 len;
476  uint8 *pValue;
477 } attReadRsp_t;
478 
484 typedef struct
485 {
486  uint16 handle;
487  uint16 offset;
489 
495 typedef struct
496 {
497  uint16 len;
498  uint8 *pValue;
500 
506 typedef struct
507 {
508  uint8 *pHandles;
509  uint16 numHandles;
511 
517 typedef struct
518 {
519  uint16 len;
520  uint8 *pValues;
522 
528 typedef struct
529 {
530  uint16 startHandle;
531  uint16 endHandle;
534 
540 typedef struct
541 {
542  uint16 numGrps;
543  uint16 len;
544  uint8 *pDataList;
546 
552 typedef struct
553 {
554  uint16 handle;
555  uint16 len;
556  uint8 *pValue;
557  uint8 sig;
558  uint8 cmd;
559 } attWriteReq_t;
560 
566 typedef struct
567 {
568  uint16 handle;
569  uint16 offset;
570  uint16 len;
571  uint8 *pValue;
573 
579 typedef struct
580 {
581  uint16 handle;
582  uint16 offset;
583  uint16 len;
584  uint8 *pValue;
586 
592 typedef struct
593 {
594  uint8 flags;
597 
603 typedef struct
604 {
605  uint16 handle;
606  uint16 len;
607  uint8 *pValue;
609 
615 typedef struct
616 {
617  uint16 handle;
618  uint16 len;
619  uint8 *pValue;
621 
639 typedef struct
640 {
641  uint8 opcode;
644 
655 typedef struct
656 {
657  uint16 MTU;
659 
669 typedef union
670 {
671  // Request messages
683 
684  // Response messages
695 
696  // Indication and Notification messages
699 
700  // Locally-generated event messages
703 } attMsg_t;
704 
707 
709 // Function prototype to notify GATT Server or Client about an outgoing ATT message.
710 typedef void (*attNotifyTxCB_t)( uint16 connHandle, uint8 opcode );
711 
712 /*********************************************************************
713  * VARIABLES
714  */
715 
716 /*********************************************************************
717  * API FUNCTIONS
718  */
719 
720 /*-------------------------------------------------------------------
721  * General Utility APIs
722  */
723 
724 /*
725  * Parse an attribute protocol message.
726  */
727 extern uint8 ATT_ParsePacket( l2capDataEvent_t *pL2capMsg, attPacket_t *pPkt );
728 
729 /*
730  * Compare two UUIDs. The UUIDs are converted if necessary.
731  */
732 extern uint8 ATT_CompareUUID( const uint8 *pUUID1, uint16 len1,
733  const uint8 *pUUID2, uint16 len2 );
734 /*
735  * Convert a 16-bit UUID to 128-bit UUID.
736  */
737 extern uint8 ATT_ConvertUUIDto128( const uint8 *pUUID16, uint8 *pUUID128 );
738 
739 /*
740  * Convert a 128-bit UUID to 16-bit UUID.
741  */
742 extern uint8 ATT_ConvertUUIDto16( const uint8 *pUUID128, uint8 *pUUID16 );
743 
744 
745 /*-------------------------------------------------------------------
746  * Attribute Client Utility APIs
747  */
748 
749 /*
750  * Build Error Response.
751  */
752 extern uint16 ATT_BuildErrorRsp( uint8 *pBuf, uint8 *pMsg );
753 
754 /*
755  * Parse Error Response.
756  */
757 extern bStatus_t ATT_ParseErrorRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
758 
759 /*
760  * Build Exchange MTU Request.
761  */
762 extern uint16 ATT_BuildExchangeMTUReq( uint8 *pBuf, uint8 *pMsg );
763 
764 /*
765  * Build Exchange MTU Response.
766  */
767 extern uint16 ATT_BuildExchangeMTURsp( uint8 *pBuf, uint8 *pMsg );
768 
769 /*
770  * Parse Exchange MTU Response.
771  */
772 extern bStatus_t ATT_ParseExchangeMTURsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
773 
774 /*
775  * Build Find Information Request.
776  */
777 extern uint16 ATT_BuildFindInfoReq( uint8 *pBuf, uint8 *pMsg );
778 
779 /*
780  * Parse Find Information Response.
781  */
782 extern bStatus_t ATT_ParseFindInfoRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
783 
784 /*
785  * Build Find Information Response.
786  */
787 extern uint16 ATT_BuildFindInfoRsp( uint8 *pBuf, uint8 *pMsg );
788 
789 /*
790  * Build Find By Type Value Request.
791  */
792 extern uint16 ATT_BuildFindByTypeValueReq( uint8 *pBuf, uint8 *pMsg );
793 
794 /*
795  * Build Find By Type Value Response.
796  */
797 extern uint16 ATT_BuildFindByTypeValueRsp( uint8 *pBuf, uint8 *pMsg );
798 
799 /*
800  * Parse Find By Type Value Response.
801  */
802 extern bStatus_t ATT_ParseFindByTypeValueRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
803 
804 /*
805  * Build Read By Type Request.
806  */
807 extern uint16 ATT_BuildReadByTypeReq( uint8 *pBuf, uint8 *pMsg );
808 
809 /*
810  * Build Read By Type Response.
811  */
812 extern uint16 ATT_BuildReadByTypeRsp( uint8 *pBuf, uint8 *pMsg );
813 
814 /*
815  * Parse Read By Type Response.
816  */
817 extern bStatus_t ATT_ParseReadByTypeRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
818 
819 /*
820  * Build Read Request.
821  */
822 extern uint16 ATT_BuildReadReq( uint8 *pBuf, uint8 *pMsg );
823 
824 /*
825  * Build Read Response.
826  */
827 extern uint16 ATT_BuildReadRsp( uint8 *pBuf, uint8 *pMsg );
828 
829 /*
830  * Parse Read Response.
831  */
832 extern bStatus_t ATT_ParseReadRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
833 
834 /*
835  * Build Read Blob Request.
836  */
837 extern uint16 ATT_BuildReadBlobReq( uint8 *pBuf, uint8 *pMsg );
838 
839 /*
840  * Build Read Blob Response.
841  */
842 extern uint16 ATT_BuildReadBlobRsp( uint8 *pBuf, uint8 *pMsg );
843 
844 /*
845  * Parse Read Blob Response.
846  */
847 extern bStatus_t ATT_ParseReadBlobRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
848 
849 /*
850  * Build Read Multiple Request.
851  */
852 extern uint16 ATT_BuildReadMultiReq( uint8 *pBuf, uint8 *pMsg );
853 
854 /*
855  * Build Read Multiple Response.
856  */
857 extern uint16 ATT_BuildReadMultiRsp( uint8 *pBuf, uint8 *pMsg );
858 
859 /*
860  * Parse Read Multiple Response.
861  */
862 extern bStatus_t ATT_ParseReadMultiRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
863 
864 /*
865  * Build Read By Group Type Response.
866  */
867 extern uint16 ATT_BuildReadByGrpTypeRsp( uint8 *pBuf, uint8 *pMsg );
868 
869 /*
870  * Parse Read By Group Type Response.
871  */
872 extern bStatus_t ATT_ParseReadByGrpTypeRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
873 
874 /*
875  * Build Write Request.
876  */
877 extern uint16 ATT_BuildWriteReq( uint8 *pBuf, uint8 *pMsg );
878 
879 /*
880  * Parse Write Response.
881  */
882 extern bStatus_t ATT_ParseWriteRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
883 
884 /*
885  * Build Prepare Write Request.
886  */
887 extern uint16 ATT_BuildPrepareWriteReq( uint8 *pBuf, uint8 *pMsg );
888 
889 /*
890  * Build Prepare Write Response.
891  */
892 extern uint16 ATT_BuildPrepareWriteRsp( uint8 *pBuf, uint8 *pMsg );
893 
894 /*
895  * Parse Prepare Write Response.
896  */
897 extern bStatus_t ATT_ParsePrepareWriteRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
898 
899 /*
900  * Build Execute Write Request.
901  */
902 extern uint16 ATT_BuildExecuteWriteReq( uint8 *pBuf, uint8 *pMsg );
903 
904 /*
905  * Parse Execute Write Response.
906  */
907 extern bStatus_t ATT_ParseExecuteWriteRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
908 
909 /*
910  * Build Handle Value Indication.
911  */
912 extern uint16 ATT_BuildHandleValueInd( uint8 *pBuf, uint8 *pMsg );
913 
914 /*
915  * Parse Handle Value Indication.
916  */
917 extern bStatus_t ATT_ParseHandleValueInd( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
918 
919 
920 /*-------------------------------------------------------------------
921  * Attribute Server Utility APIs
922  */
923 
924 /*
925  * Parse Exchange MTU Request.
926  */
927 extern bStatus_t ATT_ParseExchangeMTUReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
928 
929 /*
930  * Parse Find Information Request.
931  */
932 extern bStatus_t ATT_ParseFindInfoReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
933 
934 /*
935  * Parse Find By Type Value Request.
936  */
937 extern bStatus_t ATT_ParseFindByTypeValueReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
938 
939 /*
940  * Parse Read By Type Request.
941  */
942 extern bStatus_t ATT_ParseReadByTypeReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
943 
944 /*
945  * Parse Read Request.
946  */
947 extern bStatus_t ATT_ParseReadReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
948 
949 /*
950  * Parse Write Blob Request.
951  */
952 extern bStatus_t ATT_ParseReadBlobReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
953 
954 /*
955  * Parse Read Multiple Request.
956  */
957 extern bStatus_t ATT_ParseReadMultiReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
958 
959 /*
960  * Parse Write Request.
961  */
962 extern bStatus_t ATT_ParseWriteReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
963 
964 /*
965  * Parse Execute Write Request.
966  */
967 extern bStatus_t ATT_ParseExecuteWriteReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
968 
969 /*
970  * Parse Prepare Write Request.
971  */
972 extern bStatus_t ATT_ParsePrepareWriteReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
973 
974 /*
975  * Parse Handle Value Confirmation.
976  */
977 extern bStatus_t ATT_ParseHandleValueCfm( uint8 *pParams, uint16 len, attMsg_t *pMsg );
978 
980 
981 /*-------------------------------------------------------------------
982  * Attribute Client Public APIs
983  */
984 
1003 extern bStatus_t ATT_ExchangeMTUReq( uint16 connHandle, attExchangeMTUReq_t *pReq );
1004 
1017 extern bStatus_t ATT_FindInfoReq( uint16 connHandle, attFindInfoReq_t *pReq );
1018 
1031 extern bStatus_t ATT_FindByTypeValueReq( uint16 connHandle, attFindByTypeValueReq_t *pReq );
1032 
1045 extern bStatus_t ATT_ReadByTypeReq( uint16 connHandle, attReadByTypeReq_t *pReq );
1046 
1059 extern bStatus_t ATT_ReadReq( uint16 connHandle, attReadReq_t *pReq );
1060 
1073 extern bStatus_t ATT_ReadBlobReq( uint16 connHandle, attReadBlobReq_t *pReq );
1074 
1087 extern bStatus_t ATT_ReadMultiReq( uint16 connHandle, attReadMultiReq_t *pReq );
1088 
1101 extern bStatus_t ATT_ReadByGrpTypeReq( uint16 connHandle, attReadByGrpTypeReq_t *pReq );
1102 
1116 extern bStatus_t ATT_WriteReq( uint16 connHandle, attWriteReq_t *pReq );
1117 
1130 extern bStatus_t ATT_PrepareWriteReq( uint16 connHandle, attPrepareWriteReq_t *pReq );
1131 
1144 extern bStatus_t ATT_ExecuteWriteReq( uint16 connHandle, attExecuteWriteReq_t *pReq );
1145 
1157 extern bStatus_t ATT_HandleValueCfm( uint16 connHandle );
1158 
1159 
1160 /*-------------------------------------------------------------------
1161  * Attribute Server Public APIs
1162  */
1163 
1176 extern bStatus_t ATT_ErrorRsp( uint16 connHandle, attErrorRsp_t *pRsp );
1177 
1190 extern bStatus_t ATT_ExchangeMTURsp( uint16 connHandle, attExchangeMTURsp_t *pRsp );
1191 
1204 extern bStatus_t ATT_FindInfoRsp( uint16 connHandle, attFindInfoRsp_t *pRsp );
1205 
1218 extern bStatus_t ATT_FindByTypeValueRsp( uint16 connHandle, attFindByTypeValueRsp_t *pRsp );
1219 
1232 extern bStatus_t ATT_ReadByTypeRsp( uint16 connHandle, attReadByTypeRsp_t *pRsp );
1233 
1246 extern bStatus_t ATT_ReadRsp( uint16 connHandle, attReadRsp_t *pRsp );
1247 
1260 extern bStatus_t ATT_ReadBlobRsp( uint16 connHandle, attReadBlobRsp_t *pRsp );
1261 
1274 extern bStatus_t ATT_ReadMultiRsp( uint16 connHandle, attReadMultiRsp_t *pRsp ) ;
1275 
1288 extern bStatus_t ATT_ReadByGrpTypeRsp( uint16 connHandle, attReadByGrpTypeRsp_t *pRsp );
1289 
1301 extern bStatus_t ATT_WriteRsp( uint16 connHandle );
1302 
1315 extern bStatus_t ATT_PrepareWriteRsp( uint16 connHandle, attPrepareWriteRsp_t *pRsp );
1316 
1328 extern bStatus_t ATT_ExecuteWriteRsp( uint16 connHandle );
1329 
1342 extern bStatus_t ATT_HandleValueNoti( uint16 connHandle, attHandleValueNoti_t *pNoti );
1343 
1356 extern bStatus_t ATT_HandleValueInd( uint16 connHandle, attHandleValueInd_t *pInd );
1357 
1358 /*-------------------------------------------------------------------
1359  * Attribute Common Public APIs
1360  */
1361 
1371 extern uint8 ATT_UpdateMTU( uint16 connHandle, uint16 MTU );
1372 
1380 extern uint16 ATT_GetMTU( uint16 connHandle );
1381 
1388 extern void ATT_SetParamValue( uint16 value );
1389 
1395 extern uint16 ATT_GetParamValue( void );
1396 
1402 extern void ATT_RegisterServer( attNotifyTxCB_t pfnNotifyTx );
1403 
1409 extern void ATT_RegisterClient( attNotifyTxCB_t pfnNotifyTx );
1410 
1413 /*********************************************************************
1414 *********************************************************************/
1415 
1416 #ifdef __cplusplus
1417 }
1418 #endif
1419 
1420 #endif /* ATT_H */
1421 
uint16 endHandle
Last requested handle number.
Definition: att.h:372
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:465
uint16 len
Length of each attribute handle, end group handle and value set.
Definition: att.h:543
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:687
uint16 numInfo
Number of attribute handle-UUID pairs found.
Definition: att.h:396
attPrepareWriteRsp_t prepareWriteRsp
ATT Prepare Write Response.
Definition: att.h:694
L2CAP layer interface.
Exchange MTU Response format.
Definition: att.h:359
bStatus_t ATT_FindByTypeValueRsp(uint16 connHandle, attFindByTypeValueRsp_t *pRsp)
Send Find By Type Value Response.
Read Request.
Definition: att.h:463
uint16 numGrps
Number of attribute handle, end group handle and value sets found.
Definition: att.h:542
Find Information Response format.
Definition: att.h:394
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:430
bStatus_t ATT_ExchangeMTUReq(uint16 connHandle, attExchangeMTUReq_t *pReq)
Send Exchange MTU Request.
uint16 MTU
new MTU size
Definition: att.h:657
attReadByGrpTypeReq_t readByGrpTypeReq
ATT Read By Group Type Request.
Definition: att.h:679
uint16 numHandles
Number of attribute handles.
Definition: att.h:509
attPrepareWriteReq_t prepareWriteReq
ATT Prepare Write Request.
Definition: att.h:681
attAttrBtType_t type
2-octet UUID to find
Definition: att.h:410
uint8 reqOpcode
Request that generated this error response.
Definition: att.h:339
bStatus_t ATT_FindInfoRsp(uint16 connHandle, attFindInfoRsp_t *pRsp)
Send Find Information Response.
attMtuUpdatedEvt_t mtuEvt
ATT MTU Updated Event.
Definition: att.h:702
Find Information Request format.
Definition: att.h:369
Read Response.
Definition: att.h:473
Handle and its 128-bit UUID.
Definition: att.h:383
attErrorRsp_t errorRsp
ATT Error Response.
Definition: att.h:685
bStatus_t ATT_ExchangeMTURsp(uint16 connHandle, attExchangeMTURsp_t *pRsp)
Send Exchange MTU Response.
attHandleValueNoti_t handleValueNoti
ATT Handle Value Notification.
Definition: att.h:697
Error Response format.
Definition: att.h:337
const uint8_t attPktLenTable[ATT_NUM_SUPPORTED_METHODS+1U]
attAttrType_t type
Requested group type (2 or 16 octet UUID)
Definition: att.h:532
Find By Type Value Request format.
Definition: att.h:406
uint8 sig
Authentication Signature status (not included (0), valid (1), invalid (2))
Definition: att.h:306
uint8 * pHandles
Set of two or more attribute handles (4 to ATT_MTU_SIZE-1) - must be first field. ...
Definition: att.h:508
#define ATT_BT_UUID_SIZE
Size of 16-bit Bluetooth UUID.
Definition: att.h:117
uint16 offset
Offset of the first octet to be written.
Definition: att.h:569
#define ATT_UUID_SIZE
Size of 128-bit UUID.
Definition: att.h:118
Write Request format.
Definition: att.h:552
uint8 flags
Definition: att.h:594
void ATT_RegisterClient(attNotifyTxCB_t pfnNotifyTx)
Register the client's notify Tx function with the ATT layer.
uint8 cmd
Command Flag.
Definition: att.h:558
uint16 len
Length of value.
Definition: att.h:497
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:583
uint8 * pDataList
List of 1 or more attribute handle-value pairs (2 to ATT_MTU_SIZE-2)
Definition: att.h:454
attReadMultiReq_t readMultiReq
ATT Read Multiple Request.
Definition: att.h:678
uint8 * pValue
Part of the value of the attribute to be written (0 to ATT_MTU_SIZE-5) - must be allocated.
Definition: att.h:571
uint16 len
Length of value.
Definition: att.h:475
uint16 startHandle
First requested handle number (must be first field)
Definition: att.h:408
uint16 handle
Handle of the attribute that has been read.
Definition: att.h:581
uint8 opcode
opcode of message that caused flow control violation
Definition: att.h:641
attFindInfoReq_t findInfoReq
ATT Find Information Request.
Definition: att.h:673
uint16 numPairs
Number of attribute handle-UUID pairs found.
Definition: att.h:452
attReadRsp_t readRsp
ATT Read Response.
Definition: att.h:690
bStatus_t ATT_PrepareWriteReq(uint16 connHandle, attPrepareWriteReq_t *pReq)
Send Prepare Write Request.
attHandleValueInd_t handleValueInd
ATT Handle Value Indication.
Definition: att.h:698
uint16 clientRxMTU
Client receive MTU size.
Definition: att.h:351
uint8 format
Format of information data.
Definition: att.h:397
uint16 offset
Offset of the first octet to be read.
Definition: att.h:487
uint16 startHandle
First requested handle number (must be first field)
Definition: att.h:371
uint16 len
Length of Attribute Parameters.
Definition: att.h:309
uint8 sig
Authentication Signature status (not included (0), valid (1), invalid (2))
Definition: att.h:557
Read By Group Type Response format.
Definition: att.h:540
attReadByTypeRsp_t readByTypeRsp
ATT Read By Type Response.
Definition: att.h:689
uint16 ATT_GetParamValue(void)
Get a ATT Parameter value.
ATT MTU Updated Event message format.
Definition: att.h:655
bStatus_t ATT_FindByTypeValueReq(uint16 connHandle, attFindByTypeValueReq_t *pReq)
Send Find By Type Value Request.
uint16 len
Length of values.
Definition: att.h:519
attExchangeMTUReq_t exchangeMTUReq
ATT Exchange MTU Request.
Definition: att.h:672
uint16 endHandle
Last requested handle number.
Definition: att.h:409
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:314
Read Multiple Response format.
Definition: att.h:517
bStatus_t ATT_HandleValueInd(uint16 connHandle, attHandleValueInd_t *pInd)
Send Handle Value Indication.
Read Blob Response format.
Definition: att.h:495
bStatus_t ATT_ReadByTypeRsp(uint16 connHandle, attReadByTypeRsp_t *pRsp)
Send Read By Type Respond.
attReadBlobReq_t readBlobReq
ATT Read Blob Request.
Definition: att.h:677
bStatus_t ATT_WriteRsp(uint16 connHandle)
Send Write Response.
uint16 endHandle
Last requested handle number.
Definition: att.h:441
Attribute Type format (2-octet Bluetooth UUID).
Definition: att.h:321
uint16 serverRxMTU
Server receive MTU size.
Definition: att.h:361
uint8 method
Method.
Definition: att.h:308
uint8 * pParams
Attribute Parameters.
Definition: att.h:310
uint16 offset
Offset of the first octet to be written.
Definition: att.h:582
uint8 * pValue
Value of the attribute to be written (0 to ATT_MTU_SIZE-3)
Definition: att.h:556
uint16 len
Length of value.
Definition: att.h:606
Read Blob Request format.
Definition: att.h:484
uint8 cmd
Command Flag.
Definition: att.h:307
uint8 * pValue
Part of the value of the attribute to be written (0 to ATT_MTU_SIZE-5)
Definition: att.h:584
Find By Type Value Response format.
Definition: att.h:427
bStatus_t ATT_PrepareWriteRsp(uint16 connHandle, attPrepareWriteRsp_t *pRsp)
Send Prepare Write Response.
ATT Flow Control Violated Event message format.
Definition: att.h:639
Read By Type Request format.
Definition: att.h:438
uint8 * pValue
Attribute value to find (0 to ATT_MTU_SIZE-7)
Definition: att.h:412
Read Multiple Request format.
Definition: att.h:506
uint8 * pValue
Current value of the attribute (0 to ATT_MTU_SIZE-3)
Definition: att.h:619
uint8 len
Length of UUID (2 or 16)
Definition: att.h:316
uint16 len
Length of value.
Definition: att.h:570
uint16 handle
Attribute handle that generated error response.
Definition: att.h:340
uint8 * pInfo
Information data whose format is determined by format field (4 to ATT_MTU_SIZE-2) ...
Definition: att.h:398
Handle Value Indication format.
Definition: att.h:615
uint16 handle
Handle of the attribute to be read (must be first field)
Definition: att.h:486
attExecuteWriteReq_t executeWriteReq
ATT Execute Write Request.
Definition: att.h:682
#define ATT_NUM_SUPPORTED_METHODS
Number of supported ATT methods.
Definition: att.h:66
Type definitions and macros for BLE stack.
Handle Value Notification format.
Definition: att.h:603
uint16 startHandle
First requested handle number (must be first field)
Definition: att.h:440
uint16 handle
Handle of the attribute to be written (must be first field)
Definition: att.h:568
uint16 endHandle
Last requested handle number.
Definition: att.h:531
bStatus_t ATT_ReadBlobReq(uint16 connHandle, attReadBlobReq_t *pReq)
Send Read Blob Request.
ATT Message format.
Definition: att.h:669
attReadBlobRsp_t readBlobRsp
ATT Read Blob Response.
Definition: att.h:691
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:544
uint16 handle
Handle of the attribute to be written (must be first field)
Definition: att.h:554
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:618
bStatus_t ATT_ExecuteWriteRsp(uint16 connHandle)
Send Execute Write Response.
attFlowCtrlViolatedEvt_t flowCtrlEvt
ATT Flow Control Violated Event.
Definition: att.h:701
uint16 handle
Handle of the attribute that has been changed (must be first field)
Definition: att.h:617
bStatus_t ATT_ReadReq(uint16 connHandle, attReadReq_t *pReq)
Send Read Request.
Exchange MTU Request format.
Definition: att.h:349
uint16 grpEndHandle
Group end handle.
Definition: att.h:419
uint16 len
Size of each attribute handle-value pair.
Definition: att.h:453
Attribute Protocol PDU format.
Definition: att.h:304
uint8 * pValue
Value of the attribute with the handle given (0 to ATT_MTU_SIZE-1)
Definition: att.h:476
uint8 * pValue
Part of the value of the attribute with the handle given (0 to ATT_MTU_SIZE-1)
Definition: att.h:498
uint16 dataLen
Length of data written into pDataList. Not part of actual ATT Response.
Definition: att.h:455
attAttrType_t type
Requested type (2 or 16 octet UUID)
Definition: att.h:442
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:528
uint16 handle
Handle.
Definition: att.h:378
attReadByTypeReq_t readByTypeReq
ATT Read By Type Request.
Definition: att.h:675
Handle and its 16-bit Bluetooth UUIDs.
Definition: att.h:376
uint16 len
Length of value.
Definition: att.h:555
attReadByGrpTypeRsp_t readByGrpTypeRsp
ATT Read By Group Type Response.
Definition: att.h:693
bStatus_t ATT_ReadBlobRsp(uint16 connHandle, attReadBlobRsp_t *pRsp)
Send Read Blob Response.
uint8 pendingOpcode
opcode of pending message
Definition: att.h:642
uint8 len
Length of UUID (2)
Definition: att.h:323
Read By Type Response format.
Definition: att.h:450
Prepare Write Response format.
Definition: att.h:579
uint16 handle
Handle.
Definition: att.h:385
uint16 numInfo
Number of handles information found.
Definition: att.h:429
Prepare Write Request format.
Definition: att.h:566
attExchangeMTURsp_t exchangeMTURsp
ATT Exchange MTU Response.
Definition: att.h:686
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:674
bStatus_t ATT_WriteReq(uint16 connHandle, attWriteReq_t *pReq)
Send Write Request.
attReadReq_t readReq
ATT Read Request.
Definition: att.h:676
uint8_t bStatus_t
BLE Generic Status return.
Definition: bcomdef.h:246
bStatus_t ATT_HandleValueNoti(uint16 connHandle, attHandleValueNoti_t *pNoti)
Send Handle Value Notification.
attReadMultiRsp_t readMultiRsp
ATT Read Multiple Response.
Definition: att.h:692
attWriteReq_t writeReq
ATT Write Request.
Definition: att.h:680
uint8 * pValues
Set of two or more values (0 to ATT_MTU_SIZE-1)
Definition: att.h:520
uint16 len
Length of value.
Definition: att.h:411
attFindByTypeValueRsp_t findByTypeValueRsp
ATT Find By Type Value Response.
Definition: att.h:688
uint8 * pValue
Current value of the attribute (0 to ATT_MTU_SIZE-3)
Definition: att.h:607
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:418
uint16 startHandle
First requested handle number (must be first field)
Definition: att.h:530
uint8 errCode
Reason why the request has generated error response.
Definition: att.h:341
OSAL L2CAP_DATA_EVENT message format.
Definition: l2cap.h:599
bStatus_t ATT_HandleValueCfm(uint16 connHandle)
Send Handle Value Confirmation.
Execute Write Request format.
Definition: att.h:592
uint16 handle
Handle of the attribute that has been changed (must be first field)
Definition: att.h:605
bStatus_t ATT_ErrorRsp(uint16 connHandle, attErrorRsp_t *pRsp)
Send Error Response.
Handles Information format.
Definition: att.h:416
© Copyright 1995-2025, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale