BLE-Stack APIs  3.00.01
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 
24 #ifndef ATT_H
25 #define ATT_H
26 
27 #ifdef __cplusplus
28 extern "C"
29 {
30 #endif
31 
32 /*********************************************************************
33  * INCLUDES
34  */
35 #include "bcomdef.h"
36 #include "osal.h"
37 
38 #include "l2cap.h"
39 
40 /*********************************************************************
41  * CONSTANTS
42  */
43 
56 #define ATT_MTU_SIZE L2CAP_MTU_SIZE
57 #define ATT_MAX_MTU_SIZE (255-L2CAP_HDR_SIZE)
58 
63 #define ATT_ERROR_RSP 0x01
64 #define ATT_EXCHANGE_MTU_REQ 0x02
65 #define ATT_EXCHANGE_MTU_RSP 0x03
66 #define ATT_FIND_INFO_REQ 0x04
67 #define ATT_FIND_INFO_RSP 0x05
68 #define ATT_FIND_BY_TYPE_VALUE_REQ 0x06
69 #define ATT_FIND_BY_TYPE_VALUE_RSP 0x07
70 #define ATT_READ_BY_TYPE_REQ 0x08
71 #define ATT_READ_BY_TYPE_RSP 0x09
72 #define ATT_READ_REQ 0x0a
73 #define ATT_READ_RSP 0x0b
74 #define ATT_READ_BLOB_REQ 0x0c
75 #define ATT_READ_BLOB_RSP 0x0d
76 #define ATT_READ_MULTI_REQ 0x0e
77 #define ATT_READ_MULTI_RSP 0x0f
78 #define ATT_READ_BY_GRP_TYPE_REQ 0x10
79 #define ATT_READ_BY_GRP_TYPE_RSP 0x11
80 #define ATT_WRITE_REQ 0x12
81 #define ATT_WRITE_RSP 0x13
82 #define ATT_PREPARE_WRITE_REQ 0x16
83 #define ATT_PREPARE_WRITE_RSP 0x17
84 #define ATT_EXECUTE_WRITE_REQ 0x18
85 #define ATT_EXECUTE_WRITE_RSP 0x19
86 #define ATT_HANDLE_VALUE_NOTI 0x1b
87 #define ATT_HANDLE_VALUE_IND 0x1d
88 #define ATT_HANDLE_VALUE_CFM 0x1e
89 
90 #define ATT_WRITE_CMD 0x52
91 #define ATT_SIGNED_WRITE_CMD 0xD2
92 
97 #define ATT_FLOW_CTRL_VIOLATED_EVENT 0x7E
98 #define ATT_MTU_UPDATED_EVENT 0x7F
99 
104 #define ATT_METHOD_BITS 0x3f
105 #define ATT_CMD_FLAG_BIT 0x40
106 #define ATT_AUTHEN_SIG_FLAG_BIT 0x80
107 #define ATT_BT_UUID_SIZE 2
108 #define ATT_UUID_SIZE 16
109 #define ATT_MSG_TIMEOUT 30
110 
116 #define ATT_SIG_NOT_INCLUDED 0x00
117 #define ATT_SIG_VALID 0x01
118 #define ATT_SIG_INVALID 0x02
119 
121 /*********************************************************************
122  * Error Response: Error Code
123  */
124 
128 #define ATT_ERR_INVALID_HANDLE 0x01
129 #define ATT_ERR_READ_NOT_PERMITTED 0x02
130 #define ATT_ERR_WRITE_NOT_PERMITTED 0x03
131 #define ATT_ERR_INVALID_PDU 0x04
132 #define ATT_ERR_INSUFFICIENT_AUTHEN 0x05
133 #define ATT_ERR_UNSUPPORTED_REQ 0x06
134 #define ATT_ERR_INVALID_OFFSET 0x07
135 #define ATT_ERR_INSUFFICIENT_AUTHOR 0x08
136 #define ATT_ERR_PREPARE_QUEUE_FULL 0x09
137 #define ATT_ERR_ATTR_NOT_FOUND 0x0a
138 #define ATT_ERR_ATTR_NOT_LONG 0x0b
139 #define ATT_ERR_INSUFFICIENT_KEY_SIZE 0x0c
140 #define ATT_ERR_INVALID_VALUE_SIZE 0x0d
141 #define ATT_ERR_UNLIKELY 0x0e
142 #define ATT_ERR_INSUFFICIENT_ENCRYPT 0x0f
143 #define ATT_ERR_UNSUPPORTED_GRP_TYPE 0x10
144 #define ATT_ERR_INSUFFICIENT_RESOURCES 0x11
145 
146 /*** Reserved for future use: 0x12 - 0x7F ***/
147 
148 /*** Application error code defined by a higher layer specification: 0x80-0x9F ***/
149 
150 #define ATT_ERR_INVALID_VALUE 0x80
151 
153 /*********************************************************************
154  * Find Information Response: UUID Format
155  */
156 #define ATT_HANDLE_BT_UUID_TYPE 0x01
157 #define ATT_HANDLE_UUID_TYPE 0x02
158 
159 /*********************************************************************
160  * Read Multiple Request: Handles
161  */
162 #define ATT_MIN_NUM_HANDLES 2
163 
164 /*********************************************************************
165  * Execute Write Request: Flags
166  */
167 #define ATT_CANCEL_PREPARED_WRITES 0x00
168 #define ATT_WRITE_PREPARED_VALUES 0x01
169 
170 #if defined ( TESTMODES )
171  #define ATT_TESTMODE_OFF 0
173  #define ATT_TESTMODE_UNAUTHEN_SIG 1
174 #endif
175 
179 #define ATT_OPCODE_SIZE 1
180 #define ATT_EXCHANGE_MTU_REQ_SIZE 2
181 #define ATT_EXCHANGE_MTU_RSP_SIZE 2
182 #define ATT_ERROR_RSP_SIZE 4
183 #define ATT_FIND_INFO_REQ_FIXED_SIZE 4
184 #define ATT_FIND_INFO_RSP_FIXED_SIZE 1
185 #define ATT_FIND_INFO_RSP_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_FIND_INFO_RSP_FIXED_SIZE )
186 #define ATT_FIND_BY_TYPE_VALUE_REQ_FIXED_SIZE 6
187 #define ATT_FIND_BY_TYPE_VALUE_REQ_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_FIND_BY_TYPE_VALUE_REQ_FIXED_SIZE )
188 #define ATT_READ_BY_TYPE_REQ_FIXED_SIZE 4
189 #define ATT_READ_BY_TYPE_REQ_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_READ_BY_TYPE_REQ_FIXED_SIZE )
190 #define ATT_READ_BY_TYPE_RSP_FIXED_SIZE 1
191 #define ATT_READ_BY_TYPE_RSP_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_READ_BY_TYPE_RSP_FIXED_SIZE )
192 #define ATT_READ_REQ_SIZE 2
193 #define ATT_READ_BY_GRP_TYPE_RSP_FIXED_SIZE 1
194 #define ATT_READ_BY_GRP_TYPE_RSP_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_READ_BY_GRP_TYPE_RSP_FIXED_SIZE )
195 #define ATT_WRITE_REQ_FIXED_SIZE 2
196 #define ATT_READ_BLOB_REQ_SIZE 4
197 #define ATT_WRITE_REQ_FIXED_SIZE 2
198 #define ATT_WRITE_REQ_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_WRITE_REQ_FIXED_SIZE )
199 #define ATT_PREPARE_WRITE_REQ_FIXED_SIZE 4
200 #define ATT_PREPARE_WRITE_REQ_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_PREPARE_WRITE_REQ_FIXED_SIZE )
201 #define ATT_PREPARE_WRITE_RSP_FIXED_SIZE 4
202 #define ATT_EXECUTE_WRITE_REQ_SIZE 1
203 #define ATT_HANDLE_VALUE_IND_FIXED_SIZE 2
204 #define ATT_HANDLE_VALUE_IND_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_HANDLE_VALUE_IND_FIXED_SIZE )
205 #define ATT_AUTHEN_SIG_LEN 12
206 
208 /*********************************************************************
209  * VARIABLES
210  */
211 
213 extern CONST uint8 btBaseUUID[ATT_UUID_SIZE];
215 
216 /*********************************************************************
217  * MACROS
218  */
220 #define ATT_WRITE_COMMAND( method, cmd ) ( ( (method) == ATT_WRITE_REQ ) && ( (cmd) == TRUE ) )
221 
222 /*********************************************************************
223  * ATT Find Info Response macros
224  */
225 
227 
228 // Handle and 16-bit Bluetooth UUID pair indexes
229 #define ATT_BT_PAIR_HANDLE_IDX( i ) ( (i) * (2 + ATT_BT_UUID_SIZE) )
230 #define ATT_BT_PAIR_UUID_IDX( i ) ( ATT_BT_PAIR_HANDLE_IDX( (i) ) + 2 )
231 
232 #define ATT_BT_PAIR_HANDLE( info, i ) ( BUILD_UINT16( (info)[ATT_BT_PAIR_HANDLE_IDX((i))], \
233  (info)[ATT_BT_PAIR_HANDLE_IDX((i))+1] ) )
234 #define ATT_BT_PAIR_UUID( info, i ) ( BUILD_UINT16( (info)[ATT_BT_PAIR_UUID_IDX((i))], \
235  (info)[ATT_BT_PAIR_UUID_IDX((i))+1] ) )
236 
237 // Handle and 128-bit UUID pair indexes
238 #define ATT_PAIR_HANDLE_IDX( i ) ( (i) * (2 + ATT_UUID_SIZE) )
239 #define ATT_PAIR_UUID_IDX( i ) ( ATT_PAIR_HANDLE_IDX( (i) ) + 2 )
240 
241 #define ATT_PAIR_HANDLE( info, i ) ( BUILD_UINT16( (info)[ATT_PAIR_HANDLE_IDX((i))], \
242  (info)[ATT_PAIR_HANDLE_IDX((i))+1] ) )
243 
244 /*********************************************************************
245  * ATT Find By Type Value Response macros
246  */
247 // Attribute Handle and Group End Handle pair indexes
248 #define ATT_ATTR_HANDLE_IDX( i ) ( (i) * (2 + 2) )
249 #define ATT_GRP_END_HANDLE_IDX( i ) ( ATT_ATTR_HANDLE_IDX( (i) ) + 2 )
250 
251 #define ATT_ATTR_HANDLE( info, i ) ( BUILD_UINT16( (info)[ATT_ATTR_HANDLE_IDX((i))], \
252  (info)[ATT_ATTR_HANDLE_IDX((i))+1] ) )
253 #define ATT_GRP_END_HANDLE( info, i ) ( BUILD_UINT16( (info)[ATT_GRP_END_HANDLE_IDX((i))], \
254  (info)[ATT_GRP_END_HANDLE_IDX((i))+1] ) )
255 
256 /*********************************************************************
257  * ATT Read Multiple Request macros
258  */
259 // Attribute Handle index
260 #define ATT_HANDLE_IDX( i ) ( (i) * 2 )
261 
262 #define ATT_HANDLE( handles, i ) ( BUILD_UINT16( (handles)[ATT_HANDLE_IDX((i))], \
263  (handles)[ATT_HANDLE_IDX((i))+1] ) )
264 
266 
269 /*********************************************************************
270  * TYPEDEFS
271  */
272 
277 typedef struct
279 {
280  uint8 sig;
281  uint8 cmd;
282  uint8 method;
283  uint16 len;
284  uint8 *pParams;
285 } attPacket_t;
286 
288 typedef struct
289 {
290  uint8 len;
291  uint8 uuid[ATT_UUID_SIZE];
292 } attAttrType_t;
293 
295 typedef struct
296 {
297  uint8 len;
298  uint8 uuid[ATT_BT_UUID_SIZE];
300 
310 typedef struct
311 {
312  uint8 reqOpcode;
313  uint16 handle;
314  uint8 errCode;
315 } attErrorRsp_t;
316 
322 typedef struct
323 {
324  uint16 clientRxMTU;
326 
332 typedef struct
333 {
334  uint16 serverRxMTU;
336 
342 typedef struct
343 {
344  uint16 startHandle;
345  uint16 endHandle;
347 
349 typedef struct
350 {
351  uint16 handle;
352  uint8 uuid[ATT_BT_UUID_SIZE];
354 
356 typedef struct
357 {
358  uint16 handle;
359  uint8 uuid[ATT_UUID_SIZE];
361 
367 typedef struct
368 {
369  uint16 numInfo;
370  uint8 format;
371  uint8 *pInfo;
373 
379 typedef struct
380 {
381  uint16 startHandle;
382  uint16 endHandle;
384  uint16 len;
385  uint8 *pValue;
387 
389 typedef struct
390 {
391  uint16 handle;
392  uint16 grpEndHandle;
394 
400 typedef struct
401 {
402  uint16 numInfo;
403  uint8 *pHandlesInfo;
405 
411 typedef struct
412 {
413  uint16 startHandle;
414  uint16 endHandle;
417 
423 typedef struct
424 {
425  uint16 numPairs;
426  uint16 len;
427  uint8 *pDataList;
428  uint16 dataLen;
430 
436 typedef struct
437 {
438  uint16 handle;
439 } attReadReq_t;
440 
446 typedef struct
447 {
448  uint16 len;
449  uint8 *pValue;
450 } attReadRsp_t;
451 
457 typedef struct
458 {
459  uint16 handle;
460  uint16 offset;
462 
468 typedef struct
469 {
470  uint16 len;
471  uint8 *pValue;
473 
479 typedef struct
480 {
481  uint8 *pHandles;
482  uint16 numHandles;
484 
490 typedef struct
491 {
492  uint16 len;
493  uint8 *pValues;
495 
501 typedef struct
502 {
503  uint16 startHandle;
504  uint16 endHandle;
507 
513 typedef struct
514 {
515  uint16 numGrps;
516  uint16 len;
517  uint8 *pDataList;
519 
525 typedef struct
526 {
527  uint16 handle;
528  uint16 len;
529  uint8 *pValue;
530  uint8 sig;
531  uint8 cmd;
532 } attWriteReq_t;
533 
539 typedef struct
540 {
541  uint16 handle;
542  uint16 offset;
543  uint16 len;
544  uint8 *pValue;
546 
552 typedef struct
553 {
554  uint16 handle;
555  uint16 offset;
556  uint16 len;
557  uint8 *pValue;
559 
565 typedef struct
566 {
567  uint8 flags;
570 
576 typedef struct
577 {
578  uint16 handle;
579  uint16 len;
580  uint8 *pValue;
582 
588 typedef struct
589 {
590  uint16 handle;
591  uint16 len;
592  uint8 *pValue;
594 
612 typedef struct
613 {
614  uint8 opcode;
617 
628 typedef struct
629 {
630  uint16 MTU;
632 
642 typedef union
643 {
644  // Request messages
656 
657  // Response messages
668 
669  // Indication and Notification messages
672 
673  // Locally-generated event messages
676 } attMsg_t;
677 
680 
682 // Function prototype to notify GATT Server or Client about an outgoing ATT message.
683 typedef void (*attNotifyTxCB_t)( uint16 connHandle, uint8 opcode );
684 
685 /*********************************************************************
686  * VARIABLES
687  */
688 
689 /*********************************************************************
690  * API FUNCTIONS
691  */
692 
693 /*-------------------------------------------------------------------
694  * General Utility APIs
695  */
696 
697 /*
698  * Parse an attribute protocol message.
699  */
700 extern uint8 ATT_ParsePacket( l2capDataEvent_t *pL2capMsg, attPacket_t *pPkt );
701 
702 /*
703  * Compare two UUIDs. The UUIDs are converted if necessary.
704  */
705 extern uint8 ATT_CompareUUID( const uint8 *pUUID1, uint16 len1,
706  const uint8 *pUUID2, uint16 len2 );
707 /*
708  * Convert a 16-bit UUID to 128-bit UUID.
709  */
710 extern uint8 ATT_ConvertUUIDto128( const uint8 *pUUID16, uint8 *pUUID128 );
711 
712 /*
713  * Convert a 128-bit UUID to 16-bit UUID.
714  */
715 extern uint8 ATT_ConvertUUIDto16( const uint8 *pUUID128, uint8 *pUUID16 );
716 
717 
718 /*-------------------------------------------------------------------
719  * Attribute Client Utility APIs
720  */
721 
722 /*
723  * Build Error Response.
724  */
725 extern uint16 ATT_BuildErrorRsp( uint8 *pBuf, uint8 *pMsg );
726 
727 /*
728  * Parse Error Response.
729  */
730 extern bStatus_t ATT_ParseErrorRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
731 
732 /*
733  * Build Exchange MTU Request.
734  */
735 extern uint16 ATT_BuildExchangeMTUReq( uint8 *pBuf, uint8 *pMsg );
736 
737 /*
738  * Build Exchange MTU Response.
739  */
740 extern uint16 ATT_BuildExchangeMTURsp( uint8 *pBuf, uint8 *pMsg );
741 
742 /*
743  * Parse Exchange MTU Response.
744  */
745 extern bStatus_t ATT_ParseExchangeMTURsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
746 
747 /*
748  * Build Find Information Request.
749  */
750 extern uint16 ATT_BuildFindInfoReq( uint8 *pBuf, uint8 *pMsg );
751 
752 /*
753  * Parse Find Information Response.
754  */
755 extern bStatus_t ATT_ParseFindInfoRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
756 
757 /*
758  * Build Find Information Response.
759  */
760 extern uint16 ATT_BuildFindInfoRsp( uint8 *pBuf, uint8 *pMsg );
761 
762 /*
763  * Build Find By Type Value Request.
764  */
765 extern uint16 ATT_BuildFindByTypeValueReq( uint8 *pBuf, uint8 *pMsg );
766 
767 /*
768  * Build Find By Type Value Response.
769  */
770 extern uint16 ATT_BuildFindByTypeValueRsp( uint8 *pBuf, uint8 *pMsg );
771 
772 /*
773  * Parse Find By Type Value Response.
774  */
775 extern bStatus_t ATT_ParseFindByTypeValueRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
776 
777 /*
778  * Build Read By Type Request.
779  */
780 extern uint16 ATT_BuildReadByTypeReq( uint8 *pBuf, uint8 *pMsg );
781 
782 /*
783  * Build Read By Type Response.
784  */
785 extern uint16 ATT_BuildReadByTypeRsp( uint8 *pBuf, uint8 *pMsg );
786 
787 /*
788  * Parse Read By Type Response.
789  */
790 extern bStatus_t ATT_ParseReadByTypeRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
791 
792 /*
793  * Build Read Request.
794  */
795 extern uint16 ATT_BuildReadReq( uint8 *pBuf, uint8 *pMsg );
796 
797 /*
798  * Build Read Response.
799  */
800 extern uint16 ATT_BuildReadRsp( uint8 *pBuf, uint8 *pMsg );
801 
802 /*
803  * Parse Read Response.
804  */
805 extern bStatus_t ATT_ParseReadRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
806 
807 /*
808  * Build Read Blob Request.
809  */
810 extern uint16 ATT_BuildReadBlobReq( uint8 *pBuf, uint8 *pMsg );
811 
812 /*
813  * Build Read Blob Response.
814  */
815 extern uint16 ATT_BuildReadBlobRsp( uint8 *pBuf, uint8 *pMsg );
816 
817 /*
818  * Parse Read Blob Response.
819  */
820 extern bStatus_t ATT_ParseReadBlobRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
821 
822 /*
823  * Build Read Multiple Request.
824  */
825 extern uint16 ATT_BuildReadMultiReq( uint8 *pBuf, uint8 *pMsg );
826 
827 /*
828  * Build Read Multiple Response.
829  */
830 extern uint16 ATT_BuildReadMultiRsp( uint8 *pBuf, uint8 *pMsg );
831 
832 /*
833  * Parse Read Multiple Response.
834  */
835 extern bStatus_t ATT_ParseReadMultiRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
836 
837 /*
838  * Build Read By Group Type Response.
839  */
840 extern uint16 ATT_BuildReadByGrpTypeRsp( uint8 *pBuf, uint8 *pMsg );
841 
842 /*
843  * Parse Read By Group Type Response.
844  */
845 extern bStatus_t ATT_ParseReadByGrpTypeRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
846 
847 /*
848  * Build Write Request.
849  */
850 extern uint16 ATT_BuildWriteReq( uint8 *pBuf, uint8 *pMsg );
851 
852 /*
853  * Parse Write Response.
854  */
855 extern bStatus_t ATT_ParseWriteRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
856 
857 /*
858  * Build Prepare Write Request.
859  */
860 extern uint16 ATT_BuildPrepareWriteReq( uint8 *pBuf, uint8 *pMsg );
861 
862 /*
863  * Build Prepare Write Response.
864  */
865 extern uint16 ATT_BuildPrepareWriteRsp( uint8 *pBuf, uint8 *pMsg );
866 
867 /*
868  * Parse Prepare Write Response.
869  */
870 extern bStatus_t ATT_ParsePrepareWriteRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
871 
872 /*
873  * Build Execute Write Request.
874  */
875 extern uint16 ATT_BuildExecuteWriteReq( uint8 *pBuf, uint8 *pMsg );
876 
877 /*
878  * Parse Execute Write Response.
879  */
880 extern bStatus_t ATT_ParseExecuteWriteRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
881 
882 /*
883  * Build Handle Value Indication.
884  */
885 extern uint16 ATT_BuildHandleValueInd( uint8 *pBuf, uint8 *pMsg );
886 
887 /*
888  * Parse Handle Value Indication.
889  */
890 extern bStatus_t ATT_ParseHandleValueInd( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
891 
892 
893 /*-------------------------------------------------------------------
894  * Attribute Server Utility APIs
895  */
896 
897 /*
898  * Parse Exchange MTU Request.
899  */
900 extern bStatus_t ATT_ParseExchangeMTUReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
901 
902 /*
903  * Parse Find Information Request.
904  */
905 extern bStatus_t ATT_ParseFindInfoReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
906 
907 /*
908  * Parse Find By Type Value Request.
909  */
910 extern bStatus_t ATT_ParseFindByTypeValueReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
911 
912 /*
913  * Parse Read By Type Request.
914  */
915 extern bStatus_t ATT_ParseReadByTypeReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
916 
917 /*
918  * Parse Read Request.
919  */
920 extern bStatus_t ATT_ParseReadReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
921 
922 /*
923  * Parse Write Blob Request.
924  */
925 extern bStatus_t ATT_ParseReadBlobReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
926 
927 /*
928  * Parse Read Multiple Request.
929  */
930 extern bStatus_t ATT_ParseReadMultiReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
931 
932 /*
933  * Parse Write Request.
934  */
935 extern bStatus_t ATT_ParseWriteReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
936 
937 /*
938  * Parse Execute Write Request.
939  */
940 extern bStatus_t ATT_ParseExecuteWriteReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
941 
942 /*
943  * Parse Prepare Write Request.
944  */
945 extern bStatus_t ATT_ParsePrepareWriteReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
946 
947 /*
948  * Parse Handle Value Confirmation.
949  */
950 extern bStatus_t ATT_ParseHandleValueCfm( uint8 *pParams, uint16 len, attMsg_t *pMsg );
951 
953 
954 /*-------------------------------------------------------------------
955  * Attribute Client Public APIs
956  */
957 
976 extern bStatus_t ATT_ExchangeMTUReq( uint16 connHandle, attExchangeMTUReq_t *pReq );
977 
990 extern bStatus_t ATT_FindInfoReq( uint16 connHandle, attFindInfoReq_t *pReq );
991 
1004 extern bStatus_t ATT_FindByTypeValueReq( uint16 connHandle, attFindByTypeValueReq_t *pReq );
1005 
1018 extern bStatus_t ATT_ReadByTypeReq( uint16 connHandle, attReadByTypeReq_t *pReq );
1019 
1032 extern bStatus_t ATT_ReadReq( uint16 connHandle, attReadReq_t *pReq );
1033 
1046 extern bStatus_t ATT_ReadBlobReq( uint16 connHandle, attReadBlobReq_t *pReq );
1047 
1060 extern bStatus_t ATT_ReadMultiReq( uint16 connHandle, attReadMultiReq_t *pReq );
1061 
1074 extern bStatus_t ATT_ReadByGrpTypeReq( uint16 connHandle, attReadByGrpTypeReq_t *pReq );
1075 
1089 extern bStatus_t ATT_WriteReq( uint16 connHandle, attWriteReq_t *pReq );
1090 
1103 extern bStatus_t ATT_PrepareWriteReq( uint16 connHandle, attPrepareWriteReq_t *pReq );
1104 
1117 extern bStatus_t ATT_ExecuteWriteReq( uint16 connHandle, attExecuteWriteReq_t *pReq );
1118 
1130 extern bStatus_t ATT_HandleValueCfm( uint16 connHandle );
1131 
1132 
1133 /*-------------------------------------------------------------------
1134  * Attribute Server Public APIs
1135  */
1136 
1149 extern bStatus_t ATT_ErrorRsp( uint16 connHandle, attErrorRsp_t *pRsp );
1150 
1163 extern bStatus_t ATT_ExchangeMTURsp( uint16 connHandle, attExchangeMTURsp_t *pRsp );
1164 
1177 extern bStatus_t ATT_FindInfoRsp( uint16 connHandle, attFindInfoRsp_t *pRsp );
1178 
1191 extern bStatus_t ATT_FindByTypeValueRsp( uint16 connHandle, attFindByTypeValueRsp_t *pRsp );
1192 
1205 extern bStatus_t ATT_ReadByTypeRsp( uint16 connHandle, attReadByTypeRsp_t *pRsp );
1206 
1219 extern bStatus_t ATT_ReadRsp( uint16 connHandle, attReadRsp_t *pRsp );
1220 
1233 extern bStatus_t ATT_ReadBlobRsp( uint16 connHandle, attReadBlobRsp_t *pRsp );
1234 
1247 extern bStatus_t ATT_ReadMultiRsp( uint16 connHandle, attReadMultiRsp_t *pRsp ) ;
1248 
1261 extern bStatus_t ATT_ReadByGrpTypeRsp( uint16 connHandle, attReadByGrpTypeRsp_t *pRsp );
1262 
1274 extern bStatus_t ATT_WriteRsp( uint16 connHandle );
1275 
1288 extern bStatus_t ATT_PrepareWriteRsp( uint16 connHandle, attPrepareWriteRsp_t *pRsp );
1289 
1301 extern bStatus_t ATT_ExecuteWriteRsp( uint16 connHandle );
1302 
1315 extern bStatus_t ATT_HandleValueNoti( uint16 connHandle, attHandleValueNoti_t *pNoti );
1316 
1329 extern bStatus_t ATT_HandleValueInd( uint16 connHandle, attHandleValueInd_t *pInd );
1330 
1331 /*-------------------------------------------------------------------
1332  * Attribute Common Public APIs
1333  */
1334 
1344 extern uint8 ATT_UpdateMTU( uint16 connHandle, uint16 MTU );
1345 
1353 extern uint16 ATT_GetMTU( uint16 connHandle );
1354 
1361 extern void ATT_SetParamValue( uint16 value );
1362 
1368 extern uint16 ATT_GetParamValue( void );
1369 
1375 extern void ATT_RegisterServer( attNotifyTxCB_t pfnNotifyTx );
1376 
1382 extern void ATT_RegisterClient( attNotifyTxCB_t pfnNotifyTx );
1383 
1386 /*********************************************************************
1387 *********************************************************************/
1388 
1389 #ifdef __cplusplus
1390 }
1391 #endif
1392 
1393 #endif /* ATT_H */
1394 
uint16 endHandle
Last requested handle number.
Definition: att.h:345
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:438
uint16 len
Length of each attribute handle, end group handle and value set.
Definition: att.h:516
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:660
uint16 numInfo
Number of attribute handle-UUID pairs found.
Definition: att.h:369
attPrepareWriteRsp_t prepareWriteRsp
ATT Prepare Write Response.
Definition: att.h:667
L2CAP layer interface.
Exchange MTU Response format.
Definition: att.h:332
bStatus_t ATT_FindByTypeValueRsp(uint16 connHandle, attFindByTypeValueRsp_t *pRsp)
Send Find By Type Value Response.
Read Request.
Definition: att.h:436
uint16 numGrps
Number of attribute handle, end group handle and value sets found.
Definition: att.h:515
Find Information Response format.
Definition: att.h:367
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:403
bStatus_t ATT_ExchangeMTUReq(uint16 connHandle, attExchangeMTUReq_t *pReq)
Send Exchange MTU Request.
uint16 MTU
new MTU size
Definition: att.h:630
attReadByGrpTypeReq_t readByGrpTypeReq
ATT Read By Group Type Request.
Definition: att.h:652
uint16 numHandles
Number of attribute handles.
Definition: att.h:482
attPrepareWriteReq_t prepareWriteReq
ATT Prepare Write Request.
Definition: att.h:654
attAttrBtType_t type
2-octet UUID to find
Definition: att.h:383
uint8 reqOpcode
Request that generated this error response.
Definition: att.h:312
bStatus_t ATT_FindInfoRsp(uint16 connHandle, attFindInfoRsp_t *pRsp)
Send Find Information Response.
attMtuUpdatedEvt_t mtuEvt
ATT MTU Updated Event.
Definition: att.h:675
Find Information Request format.
Definition: att.h:342
Read Response.
Definition: att.h:446
Handle and its 128-bit UUID.
Definition: att.h:356
attErrorRsp_t errorRsp
ATT Error Response.
Definition: att.h:658
bStatus_t ATT_ExchangeMTURsp(uint16 connHandle, attExchangeMTURsp_t *pRsp)
Send Exchange MTU Response.
attHandleValueNoti_t handleValueNoti
ATT Handle Value Notification.
Definition: att.h:670
Error Response format.
Definition: att.h:310
attAttrType_t type
Requested group type (2 or 16 octet UUID)
Definition: att.h:505
Find By Type Value Request format.
Definition: att.h:379
uint8 sig
Authentication Signature status (not included (0), valid (1), invalid (2))
Definition: att.h:280
uint8 * pHandles
Set of two or more attribute handles (4 to ATT_MTU_SIZE-1) - must be first field. ...
Definition: att.h:481
#define ATT_BT_UUID_SIZE
Size of 16-bit Bluetooth UUID.
Definition: att.h:107
uint16 offset
Offset of the first octet to be written.
Definition: att.h:542
#define ATT_UUID_SIZE
Size of 128-bit UUID.
Definition: att.h:108
Write Request format.
Definition: att.h:525
uint8 flags
Definition: att.h:567
void ATT_RegisterClient(attNotifyTxCB_t pfnNotifyTx)
Register the client's notify Tx function with the ATT layer.
uint8 cmd
Command Flag.
Definition: att.h:531
uint16 len
Length of value.
Definition: att.h:470
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:556
uint8 * pDataList
List of 1 or more attribute handle-value pairs (2 to ATT_MTU_SIZE-2)
Definition: att.h:427
attReadMultiReq_t readMultiReq
ATT Read Multiple Request.
Definition: att.h:651
uint8 * pValue
Part of the value of the attribute to be written (0 to ATT_MTU_SIZE-5) - must be allocated.
Definition: att.h:544
uint16 len
Length of value.
Definition: att.h:448
uint16 startHandle
First requested handle number (must be first field)
Definition: att.h:381
uint16 handle
Handle of the attribute that has been read.
Definition: att.h:554
uint8 opcode
opcode of message that caused flow control violation
Definition: att.h:614
attFindInfoReq_t findInfoReq
ATT Find Information Request.
Definition: att.h:646
uint16 numPairs
Number of attribute handle-UUID pairs found.
Definition: att.h:425
attReadRsp_t readRsp
ATT Read Response.
Definition: att.h:663
bStatus_t ATT_PrepareWriteReq(uint16 connHandle, attPrepareWriteReq_t *pReq)
Send Prepare Write Request.
attHandleValueInd_t handleValueInd
ATT Handle Value Indication.
Definition: att.h:671
uint16 clientRxMTU
Client receive MTU size.
Definition: att.h:324
uint8 format
Format of information data.
Definition: att.h:370
uint16 offset
Offset of the first octet to be read.
Definition: att.h:460
uint16 startHandle
First requested handle number (must be first field)
Definition: att.h:344
uint16 len
Length of Attribute Parameters.
Definition: att.h:283
uint8 sig
Authentication Signature status (not included (0), valid (1), invalid (2))
Definition: att.h:530
Read By Group Type Response format.
Definition: att.h:513
attReadByTypeRsp_t readByTypeRsp
ATT Read By Type Response.
Definition: att.h:662
uint16 ATT_GetParamValue(void)
Get a ATT Parameter value.
ATT MTU Updated Event message format.
Definition: att.h:628
bStatus_t ATT_FindByTypeValueReq(uint16 connHandle, attFindByTypeValueReq_t *pReq)
Send Find By Type Value Request.
uint16 len
Length of values.
Definition: att.h:492
attExchangeMTUReq_t exchangeMTUReq
ATT Exchange MTU Request.
Definition: att.h:645
uint16 endHandle
Last requested handle number.
Definition: att.h:382
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:288
Read Multiple Response format.
Definition: att.h:490
bStatus_t ATT_HandleValueInd(uint16 connHandle, attHandleValueInd_t *pInd)
Send Handle Value Indication.
Read Blob Response format.
Definition: att.h:468
bStatus_t ATT_ReadByTypeRsp(uint16 connHandle, attReadByTypeRsp_t *pRsp)
Send Read By Type Respond.
attReadBlobReq_t readBlobReq
ATT Read Blob Request.
Definition: att.h:650
bStatus_t ATT_WriteRsp(uint16 connHandle)
Send Write Response.
uint16 endHandle
Last requested handle number.
Definition: att.h:414
Attribute Type format (2-octet Bluetooth UUID).
Definition: att.h:295
uint16 serverRxMTU
Server receive MTU size.
Definition: att.h:334
uint8 method
Method.
Definition: att.h:282
uint8 * pParams
Attribute Parameters.
Definition: att.h:284
uint16 offset
Offset of the first octet to be written.
Definition: att.h:555
uint8 * pValue
Value of the attribute to be written (0 to ATT_MTU_SIZE-3)
Definition: att.h:529
uint16 len
Length of value.
Definition: att.h:579
Read Blob Request format.
Definition: att.h:457
uint8 cmd
Command Flag.
Definition: att.h:281
uint8 * pValue
Part of the value of the attribute to be written (0 to ATT_MTU_SIZE-5)
Definition: att.h:557
Find By Type Value Response format.
Definition: att.h:400
bStatus_t ATT_PrepareWriteRsp(uint16 connHandle, attPrepareWriteRsp_t *pRsp)
Send Prepare Write Response.
ATT Flow Control Violated Event message format.
Definition: att.h:612
Read By Type Request format.
Definition: att.h:411
uint8 * pValue
Attribute value to find (0 to ATT_MTU_SIZE-7)
Definition: att.h:385
Read Multiple Request format.
Definition: att.h:479
uint8 * pValue
Current value of the attribute (0 to ATT_MTU_SIZE-3)
Definition: att.h:592
uint8 len
Length of UUID (2 or 16)
Definition: att.h:290
uint16 len
Length of value.
Definition: att.h:543
uint16 handle
Attribute handle that generated error response.
Definition: att.h:313
uint8 * pInfo
Information data whose format is determined by format field (4 to ATT_MTU_SIZE-2) ...
Definition: att.h:371
Handle Value Indication format.
Definition: att.h:588
uint16 handle
Handle of the attribute to be read (must be first field)
Definition: att.h:459
attExecuteWriteReq_t executeWriteReq
ATT Execute Write Request.
Definition: att.h:655
Type definitions and macros for BLE stack.
Handle Value Notification format.
Definition: att.h:576
uint16 startHandle
First requested handle number (must be first field)
Definition: att.h:413
uint16 handle
Handle of the attribute to be written (must be first field)
Definition: att.h:541
uint16 endHandle
Last requested handle number.
Definition: att.h:504
bStatus_t ATT_ReadBlobReq(uint16 connHandle, attReadBlobReq_t *pReq)
Send Read Blob Request.
ATT Message format.
Definition: att.h:642
attReadBlobRsp_t readBlobRsp
ATT Read Blob Response.
Definition: att.h:664
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:517
uint16 handle
Handle of the attribute to be written (must be first field)
Definition: att.h:527
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:591
bStatus_t ATT_ExecuteWriteRsp(uint16 connHandle)
Send Execute Write Response.
attFlowCtrlViolatedEvt_t flowCtrlEvt
ATT Flow Control Violated Event.
Definition: att.h:674
uint16 handle
Handle of the attribute that has been changed (must be first field)
Definition: att.h:590
bStatus_t ATT_ReadReq(uint16 connHandle, attReadReq_t *pReq)
Send Read Request.
Exchange MTU Request format.
Definition: att.h:322
uint16 grpEndHandle
Group end handle.
Definition: att.h:392
uint16 len
Size of each attribute handle-value pair.
Definition: att.h:426
Attribute Protocol PDU format.
Definition: att.h:278
uint8 * pValue
Value of the attribute with the handle given (0 to ATT_MTU_SIZE-1)
Definition: att.h:449
uint8 * pValue
Part of the value of the attribute with the handle given (0 to ATT_MTU_SIZE-1)
Definition: att.h:471
uint16 dataLen
Length of data written into pDataList. Not part of actual ATT Response.
Definition: att.h:428
attAttrType_t type
Requested type (2 or 16 octet UUID)
Definition: att.h:415
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:501
uint16 handle
Handle.
Definition: att.h:351
attReadByTypeReq_t readByTypeReq
ATT Read By Type Request.
Definition: att.h:648
Handle and its 16-bit Bluetooth UUIDs.
Definition: att.h:349
uint16 len
Length of value.
Definition: att.h:528
attReadByGrpTypeRsp_t readByGrpTypeRsp
ATT Read By Group Type Response.
Definition: att.h:666
bStatus_t ATT_ReadBlobRsp(uint16 connHandle, attReadBlobRsp_t *pRsp)
Send Read Blob Response.
Status_t bStatus_t
BLE Generic Status return.
Definition: bcomdef.h:224
uint8 pendingOpcode
opcode of pending message
Definition: att.h:615
uint8 len
Length of UUID (2)
Definition: att.h:297
Read By Type Response format.
Definition: att.h:423
Prepare Write Response format.
Definition: att.h:552
uint16 handle
Handle.
Definition: att.h:358
uint16 numInfo
Number of handles information found.
Definition: att.h:402
Prepare Write Request format.
Definition: att.h:539
attExchangeMTURsp_t exchangeMTURsp
ATT Exchange MTU Response.
Definition: att.h:659
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:647
bStatus_t ATT_WriteReq(uint16 connHandle, attWriteReq_t *pReq)
Send Write Request.
attReadReq_t readReq
ATT Read Request.
Definition: att.h:649
bStatus_t ATT_HandleValueNoti(uint16 connHandle, attHandleValueNoti_t *pNoti)
Send Handle Value Notification.
attReadMultiRsp_t readMultiRsp
ATT Read Multiple Response.
Definition: att.h:665
attWriteReq_t writeReq
ATT Write Request.
Definition: att.h:653
uint8 * pValues
Set of two or more values (0 to ATT_MTU_SIZE-1)
Definition: att.h:493
uint16 len
Length of value.
Definition: att.h:384
attFindByTypeValueRsp_t findByTypeValueRsp
ATT Find By Type Value Response.
Definition: att.h:661
uint8 * pValue
Current value of the attribute (0 to ATT_MTU_SIZE-3)
Definition: att.h:580
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:391
uint16 startHandle
First requested handle number (must be first field)
Definition: att.h:503
uint8 errCode
Reason why the request has generated error response.
Definition: att.h:314
OSAL L2CAP_DATA_EVENT message format.
Definition: l2cap.h:558
bStatus_t ATT_HandleValueCfm(uint16 connHandle)
Send Handle Value Confirmation.
Execute Write Request format.
Definition: att.h:565
uint16 handle
Handle of the attribute that has been changed (must be first field)
Definition: att.h:578
bStatus_t ATT_ErrorRsp(uint16 connHandle, attErrorRsp_t *pRsp)
Send Error Response.
Handles Information format.
Definition: att.h:389
Copyright 2017, Texas Instruments Incorporated