TI BLE-Stack for Bluetooth 4.2 API Documentation  3.01.00.07
att.h
Go to the documentation of this file.
1 /******************************************************************************
2 
3  Group: WCS, BTS
4  $Target Device: DEVICES $
5 
6  ******************************************************************************
7  $License: TISD 2009 $
8  ******************************************************************************
9  $Release Name: PACKAGE NAME $
10  $Release Date: PACKAGE RELEASE DATE $
11  *****************************************************************************/
12 
27 #ifndef ATT_H
28 #define ATT_H
29 
30 #ifdef __cplusplus
31 extern "C"
32 {
33 #endif
34 
35 /*********************************************************************
36  * INCLUDES
37  */
38 #include "bcomdef.h"
39 #include "osal.h"
40 
41 #include "l2cap.h"
42 
43 /*********************************************************************
44  * CONSTANTS
45  */
46 
59 #define ATT_MTU_SIZE L2CAP_MTU_SIZE
60 #define ATT_MAX_MTU_SIZE (255-L2CAP_HDR_SIZE)
61 
66 #define ATT_ERROR_RSP 0x01
67 #define ATT_EXCHANGE_MTU_REQ 0x02
68 #define ATT_EXCHANGE_MTU_RSP 0x03
69 #define ATT_FIND_INFO_REQ 0x04
70 #define ATT_FIND_INFO_RSP 0x05
71 #define ATT_FIND_BY_TYPE_VALUE_REQ 0x06
72 #define ATT_FIND_BY_TYPE_VALUE_RSP 0x07
73 #define ATT_READ_BY_TYPE_REQ 0x08
74 #define ATT_READ_BY_TYPE_RSP 0x09
75 #define ATT_READ_REQ 0x0a
76 #define ATT_READ_RSP 0x0b
77 #define ATT_READ_BLOB_REQ 0x0c
78 #define ATT_READ_BLOB_RSP 0x0d
79 #define ATT_READ_MULTI_REQ 0x0e
80 #define ATT_READ_MULTI_RSP 0x0f
81 #define ATT_READ_BY_GRP_TYPE_REQ 0x10
82 #define ATT_READ_BY_GRP_TYPE_RSP 0x11
83 #define ATT_WRITE_REQ 0x12
84 #define ATT_WRITE_RSP 0x13
85 #define ATT_PREPARE_WRITE_REQ 0x16
86 #define ATT_PREPARE_WRITE_RSP 0x17
87 #define ATT_EXECUTE_WRITE_REQ 0x18
88 #define ATT_EXECUTE_WRITE_RSP 0x19
89 #define ATT_HANDLE_VALUE_NOTI 0x1b
90 #define ATT_HANDLE_VALUE_IND 0x1d
91 #define ATT_HANDLE_VALUE_CFM 0x1e
92 
93 #define ATT_WRITE_CMD 0x52
94 #define ATT_SIGNED_WRITE_CMD 0xD2
95 
100 #define ATT_FLOW_CTRL_VIOLATED_EVENT 0x7E
101 #define ATT_MTU_UPDATED_EVENT 0x7F
102 
107 #define ATT_METHOD_BITS 0x3f
108 #define ATT_CMD_FLAG_BIT 0x40
109 #define ATT_AUTHEN_SIG_FLAG_BIT 0x80
110 #define ATT_BT_UUID_SIZE 2
111 #define ATT_UUID_SIZE 16
112 #define ATT_MSG_TIMEOUT 30
113 
119 #define ATT_SIG_NOT_INCLUDED 0x00
120 #define ATT_SIG_VALID 0x01
121 #define ATT_SIG_INVALID 0x02
122 
124 /*********************************************************************
125  * Error Response: Error Code
126  */
127 
131 #define ATT_ERR_INVALID_HANDLE 0x01
132 #define ATT_ERR_READ_NOT_PERMITTED 0x02
133 #define ATT_ERR_WRITE_NOT_PERMITTED 0x03
134 #define ATT_ERR_INVALID_PDU 0x04
135 #define ATT_ERR_INSUFFICIENT_AUTHEN 0x05
136 #define ATT_ERR_UNSUPPORTED_REQ 0x06
137 #define ATT_ERR_INVALID_OFFSET 0x07
138 #define ATT_ERR_INSUFFICIENT_AUTHOR 0x08
139 #define ATT_ERR_PREPARE_QUEUE_FULL 0x09
140 #define ATT_ERR_ATTR_NOT_FOUND 0x0a
141 #define ATT_ERR_ATTR_NOT_LONG 0x0b
142 #define ATT_ERR_INSUFFICIENT_KEY_SIZE 0x0c
143 #define ATT_ERR_INVALID_VALUE_SIZE 0x0d
144 #define ATT_ERR_UNLIKELY 0x0e
145 #define ATT_ERR_INSUFFICIENT_ENCRYPT 0x0f
146 #define ATT_ERR_UNSUPPORTED_GRP_TYPE 0x10
147 #define ATT_ERR_INSUFFICIENT_RESOURCES 0x11
148 
149 /*** Reserved for future use: 0x12 - 0x7F ***/
150 
151 /*** Application error code defined by a higher layer specification: 0x80-0x9F ***/
152 
153 #define ATT_ERR_INVALID_VALUE 0x80
154 
156 /*********************************************************************
157  * Find Information Response: UUID Format
158  */
159 #define ATT_HANDLE_BT_UUID_TYPE 0x01
160 #define ATT_HANDLE_UUID_TYPE 0x02
161 
162 /*********************************************************************
163  * Read Multiple Request: Handles
164  */
165 #define ATT_MIN_NUM_HANDLES 2
166 
167 /*********************************************************************
168  * Execute Write Request: Flags
169  */
170 #define ATT_CANCEL_PREPARED_WRITES 0x00
171 #define ATT_WRITE_PREPARED_VALUES 0x01
172 
173 #if defined ( TESTMODES )
174  #define ATT_TESTMODE_OFF 0
176  #define ATT_TESTMODE_UNAUTHEN_SIG 1
177 #endif
178 
182 #define ATT_OPCODE_SIZE 1
183 #define ATT_EXCHANGE_MTU_REQ_SIZE 2
184 #define ATT_EXCHANGE_MTU_RSP_SIZE 2
185 #define ATT_ERROR_RSP_SIZE 4
186 #define ATT_FIND_INFO_REQ_FIXED_SIZE 4
187 #define ATT_FIND_INFO_RSP_FIXED_SIZE 1
188 #define ATT_FIND_INFO_RSP_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_FIND_INFO_RSP_FIXED_SIZE )
189 #define ATT_FIND_BY_TYPE_VALUE_REQ_FIXED_SIZE 6
190 #define ATT_FIND_BY_TYPE_VALUE_REQ_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_FIND_BY_TYPE_VALUE_REQ_FIXED_SIZE )
191 #define ATT_READ_BY_TYPE_REQ_FIXED_SIZE 4
192 #define ATT_READ_BY_TYPE_REQ_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_READ_BY_TYPE_REQ_FIXED_SIZE )
193 #define ATT_READ_BY_TYPE_RSP_FIXED_SIZE 1
194 #define ATT_READ_BY_TYPE_RSP_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_READ_BY_TYPE_RSP_FIXED_SIZE )
195 #define ATT_READ_REQ_SIZE 2
196 #define ATT_READ_BY_GRP_TYPE_RSP_FIXED_SIZE 1
197 #define ATT_READ_BY_GRP_TYPE_RSP_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_READ_BY_GRP_TYPE_RSP_FIXED_SIZE )
198 #define ATT_WRITE_REQ_FIXED_SIZE 2
199 #define ATT_READ_BLOB_REQ_SIZE 4
200 #define ATT_WRITE_REQ_FIXED_SIZE 2
201 #define ATT_WRITE_REQ_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_WRITE_REQ_FIXED_SIZE )
202 #define ATT_PREPARE_WRITE_REQ_FIXED_SIZE 4
203 #define ATT_PREPARE_WRITE_REQ_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_PREPARE_WRITE_REQ_FIXED_SIZE )
204 #define ATT_PREPARE_WRITE_RSP_FIXED_SIZE 4
205 #define ATT_EXECUTE_WRITE_REQ_SIZE 1
206 #define ATT_HANDLE_VALUE_IND_FIXED_SIZE 2
207 #define ATT_HANDLE_VALUE_IND_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_HANDLE_VALUE_IND_FIXED_SIZE )
208 #define ATT_AUTHEN_SIG_LEN 12
209 
211 /*********************************************************************
212  * VARIABLES
213  */
214 
216 extern CONST uint8 btBaseUUID[ATT_UUID_SIZE];
218 
219 /*********************************************************************
220  * MACROS
221  */
223 #define ATT_WRITE_COMMAND( method, cmd ) ( ( (method) == ATT_WRITE_REQ ) && ( (cmd) == TRUE ) )
224 
225 /*********************************************************************
226  * ATT Find Info Response macros
227  */
228 
230 
231 // Handle and 16-bit Bluetooth UUID pair indexes
232 #define ATT_BT_PAIR_HANDLE_IDX( i ) ( (i) * (2 + ATT_BT_UUID_SIZE) )
233 #define ATT_BT_PAIR_UUID_IDX( i ) ( ATT_BT_PAIR_HANDLE_IDX( (i) ) + 2 )
234 
235 #define ATT_BT_PAIR_HANDLE( info, i ) ( BUILD_UINT16( (info)[ATT_BT_PAIR_HANDLE_IDX((i))], \
236  (info)[ATT_BT_PAIR_HANDLE_IDX((i))+1] ) )
237 #define ATT_BT_PAIR_UUID( info, i ) ( BUILD_UINT16( (info)[ATT_BT_PAIR_UUID_IDX((i))], \
238  (info)[ATT_BT_PAIR_UUID_IDX((i))+1] ) )
239 
240 // Handle and 128-bit UUID pair indexes
241 #define ATT_PAIR_HANDLE_IDX( i ) ( (i) * (2 + ATT_UUID_SIZE) )
242 #define ATT_PAIR_UUID_IDX( i ) ( ATT_PAIR_HANDLE_IDX( (i) ) + 2 )
243 
244 #define ATT_PAIR_HANDLE( info, i ) ( BUILD_UINT16( (info)[ATT_PAIR_HANDLE_IDX((i))], \
245  (info)[ATT_PAIR_HANDLE_IDX((i))+1] ) )
246 
247 /*********************************************************************
248  * ATT Find By Type Value Response macros
249  */
250 // Attribute Handle and Group End Handle pair indexes
251 #define ATT_ATTR_HANDLE_IDX( i ) ( (i) * (2 + 2) )
252 #define ATT_GRP_END_HANDLE_IDX( i ) ( ATT_ATTR_HANDLE_IDX( (i) ) + 2 )
253 
254 #define ATT_ATTR_HANDLE( info, i ) ( BUILD_UINT16( (info)[ATT_ATTR_HANDLE_IDX((i))], \
255  (info)[ATT_ATTR_HANDLE_IDX((i))+1] ) )
256 #define ATT_GRP_END_HANDLE( info, i ) ( BUILD_UINT16( (info)[ATT_GRP_END_HANDLE_IDX((i))], \
257  (info)[ATT_GRP_END_HANDLE_IDX((i))+1] ) )
258 
259 /*********************************************************************
260  * ATT Read Multiple Request macros
261  */
262 // Attribute Handle index
263 #define ATT_HANDLE_IDX( i ) ( (i) * 2 )
264 
265 #define ATT_HANDLE( handles, i ) ( BUILD_UINT16( (handles)[ATT_HANDLE_IDX((i))], \
266  (handles)[ATT_HANDLE_IDX((i))+1] ) )
267 
269 
272 /*********************************************************************
273  * TYPEDEFS
274  */
275 
280 typedef struct
282 {
283  uint8 sig;
284  uint8 cmd;
285  uint8 method;
286  uint16 len;
287  uint8 *pParams;
288 } attPacket_t;
289 
291 typedef struct
292 {
293  uint8 len;
294  uint8 uuid[ATT_UUID_SIZE];
295 } attAttrType_t;
296 
298 typedef struct
299 {
300  uint8 len;
301  uint8 uuid[ATT_BT_UUID_SIZE];
303 
313 typedef struct
314 {
315  uint8 reqOpcode;
316  uint16 handle;
317  uint8 errCode;
318 } attErrorRsp_t;
319 
325 typedef struct
326 {
327  uint16 clientRxMTU;
329 
335 typedef struct
336 {
337  uint16 serverRxMTU;
339 
345 typedef struct
346 {
347  uint16 startHandle;
348  uint16 endHandle;
350 
352 typedef struct
353 {
354  uint16 handle;
355  uint8 uuid[ATT_BT_UUID_SIZE];
357 
359 typedef struct
360 {
361  uint16 handle;
362  uint8 uuid[ATT_UUID_SIZE];
364 
370 typedef struct
371 {
372  uint16 numInfo;
373  uint8 format;
374  uint8 *pInfo;
376 
382 typedef struct
383 {
384  uint16 startHandle;
385  uint16 endHandle;
387  uint16 len;
388  uint8 *pValue;
390 
392 typedef struct
393 {
394  uint16 handle;
395  uint16 grpEndHandle;
397 
403 typedef struct
404 {
405  uint16 numInfo;
406  uint8 *pHandlesInfo;
408 
414 typedef struct
415 {
416  uint16 startHandle;
417  uint16 endHandle;
420 
426 typedef struct
427 {
428  uint16 numPairs;
429  uint16 len;
430  uint8 *pDataList;
431  uint16 dataLen;
433 
439 typedef struct
440 {
441  uint16 handle;
442 } attReadReq_t;
443 
449 typedef struct
450 {
451  uint16 len;
452  uint8 *pValue;
453 } attReadRsp_t;
454 
460 typedef struct
461 {
462  uint16 handle;
463  uint16 offset;
465 
471 typedef struct
472 {
473  uint16 len;
474  uint8 *pValue;
476 
482 typedef struct
483 {
484  uint8 *pHandles;
485  uint16 numHandles;
487 
493 typedef struct
494 {
495  uint16 len;
496  uint8 *pValues;
498 
504 typedef struct
505 {
506  uint16 startHandle;
507  uint16 endHandle;
510 
516 typedef struct
517 {
518  uint16 numGrps;
519  uint16 len;
520  uint8 *pDataList;
522 
528 typedef struct
529 {
530  uint16 handle;
531  uint16 len;
532  uint8 *pValue;
533  uint8 sig;
534  uint8 cmd;
535 } attWriteReq_t;
536 
542 typedef struct
543 {
544  uint16 handle;
545  uint16 offset;
546  uint16 len;
547  uint8 *pValue;
549 
555 typedef struct
556 {
557  uint16 handle;
558  uint16 offset;
559  uint16 len;
560  uint8 *pValue;
562 
568 typedef struct
569 {
570  uint8 flags;
573 
579 typedef struct
580 {
581  uint16 handle;
582  uint16 len;
583  uint8 *pValue;
585 
591 typedef struct
592 {
593  uint16 handle;
594  uint16 len;
595  uint8 *pValue;
597 
615 typedef struct
616 {
617  uint8 opcode;
620 
631 typedef struct
632 {
633  uint16 MTU;
635 
645 typedef union
646 {
647  // Request messages
659 
660  // Response messages
671 
672  // Indication and Notification messages
675 
676  // Locally-generated event messages
679 } attMsg_t;
680 
683 
685 // Function prototype to notify GATT Server or Client about an outgoing ATT message.
686 typedef void (*attNotifyTxCB_t)( uint16 connHandle, uint8 opcode );
687 
688 /*********************************************************************
689  * VARIABLES
690  */
691 
692 /*********************************************************************
693  * API FUNCTIONS
694  */
695 
696 /*-------------------------------------------------------------------
697  * General Utility APIs
698  */
699 
700 /*
701  * Parse an attribute protocol message.
702  */
703 extern uint8 ATT_ParsePacket( l2capDataEvent_t *pL2capMsg, attPacket_t *pPkt );
704 
705 /*
706  * Compare two UUIDs. The UUIDs are converted if necessary.
707  */
708 extern uint8 ATT_CompareUUID( const uint8 *pUUID1, uint16 len1,
709  const uint8 *pUUID2, uint16 len2 );
710 /*
711  * Convert a 16-bit UUID to 128-bit UUID.
712  */
713 extern uint8 ATT_ConvertUUIDto128( const uint8 *pUUID16, uint8 *pUUID128 );
714 
715 /*
716  * Convert a 128-bit UUID to 16-bit UUID.
717  */
718 extern uint8 ATT_ConvertUUIDto16( const uint8 *pUUID128, uint8 *pUUID16 );
719 
720 
721 /*-------------------------------------------------------------------
722  * Attribute Client Utility APIs
723  */
724 
725 /*
726  * Build Error Response.
727  */
728 extern uint16 ATT_BuildErrorRsp( uint8 *pBuf, uint8 *pMsg );
729 
730 /*
731  * Parse Error Response.
732  */
733 extern bStatus_t ATT_ParseErrorRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
734 
735 /*
736  * Build Exchange MTU Request.
737  */
738 extern uint16 ATT_BuildExchangeMTUReq( uint8 *pBuf, uint8 *pMsg );
739 
740 /*
741  * Build Exchange MTU Response.
742  */
743 extern uint16 ATT_BuildExchangeMTURsp( uint8 *pBuf, uint8 *pMsg );
744 
745 /*
746  * Parse Exchange MTU Response.
747  */
748 extern bStatus_t ATT_ParseExchangeMTURsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
749 
750 /*
751  * Build Find Information Request.
752  */
753 extern uint16 ATT_BuildFindInfoReq( uint8 *pBuf, uint8 *pMsg );
754 
755 /*
756  * Parse Find Information Response.
757  */
758 extern bStatus_t ATT_ParseFindInfoRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
759 
760 /*
761  * Build Find Information Response.
762  */
763 extern uint16 ATT_BuildFindInfoRsp( uint8 *pBuf, uint8 *pMsg );
764 
765 /*
766  * Build Find By Type Value Request.
767  */
768 extern uint16 ATT_BuildFindByTypeValueReq( uint8 *pBuf, uint8 *pMsg );
769 
770 /*
771  * Build Find By Type Value Response.
772  */
773 extern uint16 ATT_BuildFindByTypeValueRsp( uint8 *pBuf, uint8 *pMsg );
774 
775 /*
776  * Parse Find By Type Value Response.
777  */
778 extern bStatus_t ATT_ParseFindByTypeValueRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
779 
780 /*
781  * Build Read By Type Request.
782  */
783 extern uint16 ATT_BuildReadByTypeReq( uint8 *pBuf, uint8 *pMsg );
784 
785 /*
786  * Build Read By Type Response.
787  */
788 extern uint16 ATT_BuildReadByTypeRsp( uint8 *pBuf, uint8 *pMsg );
789 
790 /*
791  * Parse Read By Type Response.
792  */
793 extern bStatus_t ATT_ParseReadByTypeRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
794 
795 /*
796  * Build Read Request.
797  */
798 extern uint16 ATT_BuildReadReq( uint8 *pBuf, uint8 *pMsg );
799 
800 /*
801  * Build Read Response.
802  */
803 extern uint16 ATT_BuildReadRsp( uint8 *pBuf, uint8 *pMsg );
804 
805 /*
806  * Parse Read Response.
807  */
808 extern bStatus_t ATT_ParseReadRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
809 
810 /*
811  * Build Read Blob Request.
812  */
813 extern uint16 ATT_BuildReadBlobReq( uint8 *pBuf, uint8 *pMsg );
814 
815 /*
816  * Build Read Blob Response.
817  */
818 extern uint16 ATT_BuildReadBlobRsp( uint8 *pBuf, uint8 *pMsg );
819 
820 /*
821  * Parse Read Blob Response.
822  */
823 extern bStatus_t ATT_ParseReadBlobRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
824 
825 /*
826  * Build Read Multiple Request.
827  */
828 extern uint16 ATT_BuildReadMultiReq( uint8 *pBuf, uint8 *pMsg );
829 
830 /*
831  * Build Read Multiple Response.
832  */
833 extern uint16 ATT_BuildReadMultiRsp( uint8 *pBuf, uint8 *pMsg );
834 
835 /*
836  * Parse Read Multiple Response.
837  */
838 extern bStatus_t ATT_ParseReadMultiRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
839 
840 /*
841  * Build Read By Group Type Response.
842  */
843 extern uint16 ATT_BuildReadByGrpTypeRsp( uint8 *pBuf, uint8 *pMsg );
844 
845 /*
846  * Parse Read By Group Type Response.
847  */
848 extern bStatus_t ATT_ParseReadByGrpTypeRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
849 
850 /*
851  * Build Write Request.
852  */
853 extern uint16 ATT_BuildWriteReq( uint8 *pBuf, uint8 *pMsg );
854 
855 /*
856  * Parse Write Response.
857  */
858 extern bStatus_t ATT_ParseWriteRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
859 
860 /*
861  * Build Prepare Write Request.
862  */
863 extern uint16 ATT_BuildPrepareWriteReq( uint8 *pBuf, uint8 *pMsg );
864 
865 /*
866  * Build Prepare Write Response.
867  */
868 extern uint16 ATT_BuildPrepareWriteRsp( uint8 *pBuf, uint8 *pMsg );
869 
870 /*
871  * Parse Prepare Write Response.
872  */
873 extern bStatus_t ATT_ParsePrepareWriteRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
874 
875 /*
876  * Build Execute Write Request.
877  */
878 extern uint16 ATT_BuildExecuteWriteReq( uint8 *pBuf, uint8 *pMsg );
879 
880 /*
881  * Parse Execute Write Response.
882  */
883 extern bStatus_t ATT_ParseExecuteWriteRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
884 
885 /*
886  * Build Handle Value Indication.
887  */
888 extern uint16 ATT_BuildHandleValueInd( uint8 *pBuf, uint8 *pMsg );
889 
890 /*
891  * Parse Handle Value Indication.
892  */
893 extern bStatus_t ATT_ParseHandleValueInd( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
894 
895 
896 /*-------------------------------------------------------------------
897  * Attribute Server Utility APIs
898  */
899 
900 /*
901  * Parse Exchange MTU Request.
902  */
903 extern bStatus_t ATT_ParseExchangeMTUReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
904 
905 /*
906  * Parse Find Information Request.
907  */
908 extern bStatus_t ATT_ParseFindInfoReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
909 
910 /*
911  * Parse Find By Type Value Request.
912  */
913 extern bStatus_t ATT_ParseFindByTypeValueReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
914 
915 /*
916  * Parse Read By Type Request.
917  */
918 extern bStatus_t ATT_ParseReadByTypeReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
919 
920 /*
921  * Parse Read Request.
922  */
923 extern bStatus_t ATT_ParseReadReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
924 
925 /*
926  * Parse Write Blob Request.
927  */
928 extern bStatus_t ATT_ParseReadBlobReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
929 
930 /*
931  * Parse Read Multiple Request.
932  */
933 extern bStatus_t ATT_ParseReadMultiReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
934 
935 /*
936  * Parse Write Request.
937  */
938 extern bStatus_t ATT_ParseWriteReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
939 
940 /*
941  * Parse Execute Write Request.
942  */
943 extern bStatus_t ATT_ParseExecuteWriteReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
944 
945 /*
946  * Parse Prepare Write Request.
947  */
948 extern bStatus_t ATT_ParsePrepareWriteReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
949 
950 /*
951  * Parse Handle Value Confirmation.
952  */
953 extern bStatus_t ATT_ParseHandleValueCfm( uint8 *pParams, uint16 len, attMsg_t *pMsg );
954 
956 
957 /*-------------------------------------------------------------------
958  * Attribute Client Public APIs
959  */
960 
979 extern bStatus_t ATT_ExchangeMTUReq( uint16 connHandle, attExchangeMTUReq_t *pReq );
980 
993 extern bStatus_t ATT_FindInfoReq( uint16 connHandle, attFindInfoReq_t *pReq );
994 
1007 extern bStatus_t ATT_FindByTypeValueReq( uint16 connHandle, attFindByTypeValueReq_t *pReq );
1008 
1021 extern bStatus_t ATT_ReadByTypeReq( uint16 connHandle, attReadByTypeReq_t *pReq );
1022 
1035 extern bStatus_t ATT_ReadReq( uint16 connHandle, attReadReq_t *pReq );
1036 
1049 extern bStatus_t ATT_ReadBlobReq( uint16 connHandle, attReadBlobReq_t *pReq );
1050 
1063 extern bStatus_t ATT_ReadMultiReq( uint16 connHandle, attReadMultiReq_t *pReq );
1064 
1077 extern bStatus_t ATT_ReadByGrpTypeReq( uint16 connHandle, attReadByGrpTypeReq_t *pReq );
1078 
1092 extern bStatus_t ATT_WriteReq( uint16 connHandle, attWriteReq_t *pReq );
1093 
1106 extern bStatus_t ATT_PrepareWriteReq( uint16 connHandle, attPrepareWriteReq_t *pReq );
1107 
1120 extern bStatus_t ATT_ExecuteWriteReq( uint16 connHandle, attExecuteWriteReq_t *pReq );
1121 
1133 extern bStatus_t ATT_HandleValueCfm( uint16 connHandle );
1134 
1135 
1136 /*-------------------------------------------------------------------
1137  * Attribute Server Public APIs
1138  */
1139 
1152 extern bStatus_t ATT_ErrorRsp( uint16 connHandle, attErrorRsp_t *pRsp );
1153 
1166 extern bStatus_t ATT_ExchangeMTURsp( uint16 connHandle, attExchangeMTURsp_t *pRsp );
1167 
1180 extern bStatus_t ATT_FindInfoRsp( uint16 connHandle, attFindInfoRsp_t *pRsp );
1181 
1194 extern bStatus_t ATT_FindByTypeValueRsp( uint16 connHandle, attFindByTypeValueRsp_t *pRsp );
1195 
1208 extern bStatus_t ATT_ReadByTypeRsp( uint16 connHandle, attReadByTypeRsp_t *pRsp );
1209 
1222 extern bStatus_t ATT_ReadRsp( uint16 connHandle, attReadRsp_t *pRsp );
1223 
1236 extern bStatus_t ATT_ReadBlobRsp( uint16 connHandle, attReadBlobRsp_t *pRsp );
1237 
1250 extern bStatus_t ATT_ReadMultiRsp( uint16 connHandle, attReadMultiRsp_t *pRsp ) ;
1251 
1264 extern bStatus_t ATT_ReadByGrpTypeRsp( uint16 connHandle, attReadByGrpTypeRsp_t *pRsp );
1265 
1277 extern bStatus_t ATT_WriteRsp( uint16 connHandle );
1278 
1291 extern bStatus_t ATT_PrepareWriteRsp( uint16 connHandle, attPrepareWriteRsp_t *pRsp );
1292 
1304 extern bStatus_t ATT_ExecuteWriteRsp( uint16 connHandle );
1305 
1318 extern bStatus_t ATT_HandleValueNoti( uint16 connHandle, attHandleValueNoti_t *pNoti );
1319 
1332 extern bStatus_t ATT_HandleValueInd( uint16 connHandle, attHandleValueInd_t *pInd );
1333 
1334 /*-------------------------------------------------------------------
1335  * Attribute Common Public APIs
1336  */
1337 
1347 extern uint8 ATT_UpdateMTU( uint16 connHandle, uint16 MTU );
1348 
1356 extern uint16 ATT_GetMTU( uint16 connHandle );
1357 
1364 extern void ATT_SetParamValue( uint16 value );
1365 
1371 extern uint16 ATT_GetParamValue( void );
1372 
1378 extern void ATT_RegisterServer( attNotifyTxCB_t pfnNotifyTx );
1379 
1385 extern void ATT_RegisterClient( attNotifyTxCB_t pfnNotifyTx );
1386 
1389 /*********************************************************************
1390 *********************************************************************/
1391 
1392 #ifdef __cplusplus
1393 }
1394 #endif
1395 
1396 #endif /* ATT_H */
1397 
uint16 endHandle
Last requested handle number.
Definition: att.h:348
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:441
uint16 len
Length of each attribute handle, end group handle and value set.
Definition: att.h:519
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:663
uint16 numInfo
Number of attribute handle-UUID pairs found.
Definition: att.h:372
attPrepareWriteRsp_t prepareWriteRsp
ATT Prepare Write Response.
Definition: att.h:670
L2CAP layer interface.
Exchange MTU Response format.
Definition: att.h:335
bStatus_t ATT_FindByTypeValueRsp(uint16 connHandle, attFindByTypeValueRsp_t *pRsp)
Send Find By Type Value Response.
Read Request.
Definition: att.h:439
uint16 numGrps
Number of attribute handle, end group handle and value sets found.
Definition: att.h:518
Find Information Response format.
Definition: att.h:370
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:406
bStatus_t ATT_ExchangeMTUReq(uint16 connHandle, attExchangeMTUReq_t *pReq)
Send Exchange MTU Request.
uint16 MTU
new MTU size
Definition: att.h:633
attReadByGrpTypeReq_t readByGrpTypeReq
ATT Read By Group Type Request.
Definition: att.h:655
uint16 numHandles
Number of attribute handles.
Definition: att.h:485
attPrepareWriteReq_t prepareWriteReq
ATT Prepare Write Request.
Definition: att.h:657
attAttrBtType_t type
2-octet UUID to find
Definition: att.h:386
uint8 reqOpcode
Request that generated this error response.
Definition: att.h:315
bStatus_t ATT_FindInfoRsp(uint16 connHandle, attFindInfoRsp_t *pRsp)
Send Find Information Response.
attMtuUpdatedEvt_t mtuEvt
ATT MTU Updated Event.
Definition: att.h:678
Find Information Request format.
Definition: att.h:345
Read Response.
Definition: att.h:449
Handle and its 128-bit UUID.
Definition: att.h:359
attErrorRsp_t errorRsp
ATT Error Response.
Definition: att.h:661
bStatus_t ATT_ExchangeMTURsp(uint16 connHandle, attExchangeMTURsp_t *pRsp)
Send Exchange MTU Response.
attHandleValueNoti_t handleValueNoti
ATT Handle Value Notification.
Definition: att.h:673
Error Response format.
Definition: att.h:313
attAttrType_t type
Requested group type (2 or 16 octet UUID)
Definition: att.h:508
Find By Type Value Request format.
Definition: att.h:382
uint8 sig
Authentication Signature status (not included (0), valid (1), invalid (2))
Definition: att.h:283
uint8 * pHandles
Set of two or more attribute handles (4 to ATT_MTU_SIZE-1) - must be first field. ...
Definition: att.h:484
#define ATT_BT_UUID_SIZE
Size of 16-bit Bluetooth UUID.
Definition: att.h:110
uint16 offset
Offset of the first octet to be written.
Definition: att.h:545
#define ATT_UUID_SIZE
Size of 128-bit UUID.
Definition: att.h:111
Write Request format.
Definition: att.h:528
uint8 flags
Definition: att.h:570
void ATT_RegisterClient(attNotifyTxCB_t pfnNotifyTx)
Register the client's notify Tx function with the ATT layer.
uint8 cmd
Command Flag.
Definition: att.h:534
uint16 len
Length of value.
Definition: att.h:473
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:559
uint8 * pDataList
List of 1 or more attribute handle-value pairs (2 to ATT_MTU_SIZE-2)
Definition: att.h:430
attReadMultiReq_t readMultiReq
ATT Read Multiple Request.
Definition: att.h:654
uint8 * pValue
Part of the value of the attribute to be written (0 to ATT_MTU_SIZE-5) - must be allocated.
Definition: att.h:547
uint16 len
Length of value.
Definition: att.h:451
uint16 startHandle
First requested handle number (must be first field)
Definition: att.h:384
uint16 handle
Handle of the attribute that has been read.
Definition: att.h:557
uint8 opcode
opcode of message that caused flow control violation
Definition: att.h:617
attFindInfoReq_t findInfoReq
ATT Find Information Request.
Definition: att.h:649
uint16 numPairs
Number of attribute handle-UUID pairs found.
Definition: att.h:428
attReadRsp_t readRsp
ATT Read Response.
Definition: att.h:666
bStatus_t ATT_PrepareWriteReq(uint16 connHandle, attPrepareWriteReq_t *pReq)
Send Prepare Write Request.
attHandleValueInd_t handleValueInd
ATT Handle Value Indication.
Definition: att.h:674
uint16 clientRxMTU
Client receive MTU size.
Definition: att.h:327
uint8 format
Format of information data.
Definition: att.h:373
uint16 offset
Offset of the first octet to be read.
Definition: att.h:463
uint16 startHandle
First requested handle number (must be first field)
Definition: att.h:347
uint16 len
Length of Attribute Parameters.
Definition: att.h:286
uint8 sig
Authentication Signature status (not included (0), valid (1), invalid (2))
Definition: att.h:533
Read By Group Type Response format.
Definition: att.h:516
attReadByTypeRsp_t readByTypeRsp
ATT Read By Type Response.
Definition: att.h:665
uint16 ATT_GetParamValue(void)
Get a ATT Parameter value.
ATT MTU Updated Event message format.
Definition: att.h:631
bStatus_t ATT_FindByTypeValueReq(uint16 connHandle, attFindByTypeValueReq_t *pReq)
Send Find By Type Value Request.
uint16 len
Length of values.
Definition: att.h:495
attExchangeMTUReq_t exchangeMTUReq
ATT Exchange MTU Request.
Definition: att.h:648
uint16 endHandle
Last requested handle number.
Definition: att.h:385
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:291
Read Multiple Response format.
Definition: att.h:493
bStatus_t ATT_HandleValueInd(uint16 connHandle, attHandleValueInd_t *pInd)
Send Handle Value Indication.
Read Blob Response format.
Definition: att.h:471
bStatus_t ATT_ReadByTypeRsp(uint16 connHandle, attReadByTypeRsp_t *pRsp)
Send Read By Type Respond.
attReadBlobReq_t readBlobReq
ATT Read Blob Request.
Definition: att.h:653
bStatus_t ATT_WriteRsp(uint16 connHandle)
Send Write Response.
uint16 endHandle
Last requested handle number.
Definition: att.h:417
Attribute Type format (2-octet Bluetooth UUID).
Definition: att.h:298
uint16 serverRxMTU
Server receive MTU size.
Definition: att.h:337
uint8 method
Method.
Definition: att.h:285
uint8 * pParams
Attribute Parameters.
Definition: att.h:287
uint16 offset
Offset of the first octet to be written.
Definition: att.h:558
uint8 * pValue
Value of the attribute to be written (0 to ATT_MTU_SIZE-3)
Definition: att.h:532
uint16 len
Length of value.
Definition: att.h:582
Read Blob Request format.
Definition: att.h:460
uint8 cmd
Command Flag.
Definition: att.h:284
uint8 * pValue
Part of the value of the attribute to be written (0 to ATT_MTU_SIZE-5)
Definition: att.h:560
Find By Type Value Response format.
Definition: att.h:403
bStatus_t ATT_PrepareWriteRsp(uint16 connHandle, attPrepareWriteRsp_t *pRsp)
Send Prepare Write Response.
ATT Flow Control Violated Event message format.
Definition: att.h:615
Read By Type Request format.
Definition: att.h:414
uint8 * pValue
Attribute value to find (0 to ATT_MTU_SIZE-7)
Definition: att.h:388
Read Multiple Request format.
Definition: att.h:482
uint8 * pValue
Current value of the attribute (0 to ATT_MTU_SIZE-3)
Definition: att.h:595
uint8 len
Length of UUID (2 or 16)
Definition: att.h:293
uint16 len
Length of value.
Definition: att.h:546
uint16 handle
Attribute handle that generated error response.
Definition: att.h:316
uint8 * pInfo
Information data whose format is determined by format field (4 to ATT_MTU_SIZE-2) ...
Definition: att.h:374
Handle Value Indication format.
Definition: att.h:591
uint16 handle
Handle of the attribute to be read (must be first field)
Definition: att.h:462
attExecuteWriteReq_t executeWriteReq
ATT Execute Write Request.
Definition: att.h:658
Type definitions and macros for BLE stack.
Handle Value Notification format.
Definition: att.h:579
uint16 startHandle
First requested handle number (must be first field)
Definition: att.h:416
uint16 handle
Handle of the attribute to be written (must be first field)
Definition: att.h:544
uint16 endHandle
Last requested handle number.
Definition: att.h:507
bStatus_t ATT_ReadBlobReq(uint16 connHandle, attReadBlobReq_t *pReq)
Send Read Blob Request.
ATT Message format.
Definition: att.h:645
attReadBlobRsp_t readBlobRsp
ATT Read Blob Response.
Definition: att.h:667
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:520
uint16 handle
Handle of the attribute to be written (must be first field)
Definition: att.h:530
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:594
bStatus_t ATT_ExecuteWriteRsp(uint16 connHandle)
Send Execute Write Response.
attFlowCtrlViolatedEvt_t flowCtrlEvt
ATT Flow Control Violated Event.
Definition: att.h:677
uint16 handle
Handle of the attribute that has been changed (must be first field)
Definition: att.h:593
bStatus_t ATT_ReadReq(uint16 connHandle, attReadReq_t *pReq)
Send Read Request.
Exchange MTU Request format.
Definition: att.h:325
uint16 grpEndHandle
Group end handle.
Definition: att.h:395
uint16 len
Size of each attribute handle-value pair.
Definition: att.h:429
Attribute Protocol PDU format.
Definition: att.h:281
uint8 * pValue
Value of the attribute with the handle given (0 to ATT_MTU_SIZE-1)
Definition: att.h:452
uint8 * pValue
Part of the value of the attribute with the handle given (0 to ATT_MTU_SIZE-1)
Definition: att.h:474
uint16 dataLen
Length of data written into pDataList. Not part of actual ATT Response.
Definition: att.h:431
attAttrType_t type
Requested type (2 or 16 octet UUID)
Definition: att.h:418
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:504
uint16 handle
Handle.
Definition: att.h:354
attReadByTypeReq_t readByTypeReq
ATT Read By Type Request.
Definition: att.h:651
Handle and its 16-bit Bluetooth UUIDs.
Definition: att.h:352
uint16 len
Length of value.
Definition: att.h:531
attReadByGrpTypeRsp_t readByGrpTypeRsp
ATT Read By Group Type Response.
Definition: att.h:669
bStatus_t ATT_ReadBlobRsp(uint16 connHandle, attReadBlobRsp_t *pRsp)
Send Read Blob Response.
Status_t bStatus_t
BLE Generic Status return.
Definition: bcomdef.h:227
uint8 pendingOpcode
opcode of pending message
Definition: att.h:618
uint8 len
Length of UUID (2)
Definition: att.h:300
Read By Type Response format.
Definition: att.h:426
Prepare Write Response format.
Definition: att.h:555
uint16 handle
Handle.
Definition: att.h:361
uint16 numInfo
Number of handles information found.
Definition: att.h:405
Prepare Write Request format.
Definition: att.h:542
attExchangeMTURsp_t exchangeMTURsp
ATT Exchange MTU Response.
Definition: att.h:662
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:650
bStatus_t ATT_WriteReq(uint16 connHandle, attWriteReq_t *pReq)
Send Write Request.
attReadReq_t readReq
ATT Read Request.
Definition: att.h:652
bStatus_t ATT_HandleValueNoti(uint16 connHandle, attHandleValueNoti_t *pNoti)
Send Handle Value Notification.
attReadMultiRsp_t readMultiRsp
ATT Read Multiple Response.
Definition: att.h:668
attWriteReq_t writeReq
ATT Write Request.
Definition: att.h:656
uint8 * pValues
Set of two or more values (0 to ATT_MTU_SIZE-1)
Definition: att.h:496
uint16 len
Length of value.
Definition: att.h:387
attFindByTypeValueRsp_t findByTypeValueRsp
ATT Find By Type Value Response.
Definition: att.h:664
uint8 * pValue
Current value of the attribute (0 to ATT_MTU_SIZE-3)
Definition: att.h:583
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:394
uint16 startHandle
First requested handle number (must be first field)
Definition: att.h:506
uint8 errCode
Reason why the request has generated error response.
Definition: att.h:317
OSAL L2CAP_DATA_EVENT message format.
Definition: l2cap.h:561
bStatus_t ATT_HandleValueCfm(uint16 connHandle)
Send Handle Value Confirmation.
Execute Write Request format.
Definition: att.h:568
uint16 handle
Handle of the attribute that has been changed (must be first field)
Definition: att.h:581
bStatus_t ATT_ErrorRsp(uint16 connHandle, attErrorRsp_t *pRsp)
Send Error Response.
Handles Information format.
Definition: att.h:392
Copyright 2017, Texas Instruments Incorporated