TI BLE Stack API Documentation  2.03.06
att.h
1 /******************************************************************************
2 
3  @file att.h
4 
5  @brief This file contains Attribute Protocol (ATT) definitions and prototypes
6  prototypes.
7 
8  Group: WCS, BTS
9  $Target Device: DEVICES $
10 
11  ******************************************************************************
12  $License: TISD 2009 $
13  ******************************************************************************
14  $Release Name: PACKAGE NAME $
15  $Release Date: PACKAGE RELEASE DATE $
16  *****************************************************************************/
17 
18 #ifndef ATT_H
19 #define ATT_H
20 
21 #ifdef __cplusplus
22 extern "C"
23 {
24 #endif
25 
26 /*********************************************************************
27  * INCLUDES
28  */
29 #include "bcomdef.h"
30 #include "osal.h"
31 
32 #include "l2cap.h"
33 
34 /*********************************************************************
35  * CONSTANTS
36  */
37 
38 // The Exchanging MTU Size is defined as the maximum size of any packet
39 // transmitted between a client and a server. A higher layer specification
40 // defines the default ATT MTU value. The ATT MTU value should be within
41 // the range 23 to 517 inclusive.
42 // Refer to ble_user_config.h for the device-specific maximum MTU value.
43 #define ATT_MTU_SIZE L2CAP_MTU_SIZE
44 #define ATT_MAX_MTU_SIZE 517
45 
46 
50 #define ATT_ERROR_RSP 0x01
51 #define ATT_EXCHANGE_MTU_REQ 0x02
52 #define ATT_EXCHANGE_MTU_RSP 0x03
53 #define ATT_FIND_INFO_REQ 0x04
54 #define ATT_FIND_INFO_RSP 0x05
55 #define ATT_FIND_BY_TYPE_VALUE_REQ 0x06
56 #define ATT_FIND_BY_TYPE_VALUE_RSP 0x07
57 #define ATT_READ_BY_TYPE_REQ 0x08
58 #define ATT_READ_BY_TYPE_RSP 0x09
59 #define ATT_READ_REQ 0x0a
60 #define ATT_READ_RSP 0x0b
61 #define ATT_READ_BLOB_REQ 0x0c
62 #define ATT_READ_BLOB_RSP 0x0d
63 #define ATT_READ_MULTI_REQ 0x0e
64 #define ATT_READ_MULTI_RSP 0x0f
65 #define ATT_READ_BY_GRP_TYPE_REQ 0x10
66 #define ATT_READ_BY_GRP_TYPE_RSP 0x11
67 #define ATT_WRITE_REQ 0x12
68 #define ATT_WRITE_RSP 0x13
69 #define ATT_PREPARE_WRITE_REQ 0x16
70 #define ATT_PREPARE_WRITE_RSP 0x17
71 #define ATT_EXECUTE_WRITE_REQ 0x18
72 #define ATT_EXECUTE_WRITE_RSP 0x19
73 #define ATT_HANDLE_VALUE_NOTI 0x1b
74 #define ATT_HANDLE_VALUE_IND 0x1d
75 #define ATT_HANDLE_VALUE_CFM 0x1e
76 
77 #define ATT_WRITE_CMD 0x52
78 #define ATT_SIGNED_WRITE_CMD 0xD2
79 
80 
85 #define ATT_FLOW_CTRL_VIOLATED_EVENT 0x7E
86 #define ATT_MTU_UPDATED_EVENT 0x7F
87 
88 
90 /*** Opcode fields: bitmasks ***/
91 // Method (bits 5-0)
92 #define ATT_METHOD_BITS 0x3f
93 
94 // Command Flag (bit 6)
95 #define ATT_CMD_FLAG_BIT 0x40
96 
97 // Authentication Signature Flag (bit 7)
98 #define ATT_AUTHEN_SIG_FLAG_BIT 0x80
99 
100 // Size of 16-bit Bluetooth UUID
101 #define ATT_BT_UUID_SIZE 2
102 
103 // Size of 128-bit UUID
104 #define ATT_UUID_SIZE 16
105 
106 // ATT Response or Confirmation timeout
107 #define ATT_MSG_TIMEOUT 30
108 
109 // Authentication Signature status for received PDU; it's TRUE or FALSE for PDU to be sent
110 #define ATT_SIG_NOT_INCLUDED 0x00 // Signature not included
111 #define ATT_SIG_VALID 0x01 // Included signature valid
112 #define ATT_SIG_INVALID 0x02 // Included signature not valid
113 
114 /*********************************************************************
115  * Error Response: Error Code
116  */
117 
122 #define ATT_ERR_INVALID_HANDLE 0x01
123 #define ATT_ERR_READ_NOT_PERMITTED 0x02
124 #define ATT_ERR_WRITE_NOT_PERMITTED 0x03
125 #define ATT_ERR_INVALID_PDU 0x04
126 #define ATT_ERR_INSUFFICIENT_AUTHEN 0x05
127 #define ATT_ERR_UNSUPPORTED_REQ 0x06
128 #define ATT_ERR_INVALID_OFFSET 0x07
129 #define ATT_ERR_INSUFFICIENT_AUTHOR 0x08
130 #define ATT_ERR_PREPARE_QUEUE_FULL 0x09
131 #define ATT_ERR_ATTR_NOT_FOUND 0x0a
132 #define ATT_ERR_ATTR_NOT_LONG 0x0b
133 #define ATT_ERR_INSUFFICIENT_KEY_SIZE 0x0c
134 #define ATT_ERR_INVALID_VALUE_SIZE 0x0d
135 #define ATT_ERR_UNLIKELY 0x0e
136 #define ATT_ERR_INSUFFICIENT_ENCRYPT 0x0f
137 #define ATT_ERR_UNSUPPORTED_GRP_TYPE 0x10
138 #define ATT_ERR_INSUFFICIENT_RESOURCES 0x11
139 
140 /*** Reserved for future use: 0x12 - 0x7F ***/
141 
142 /*** Application error code defined by a higher layer specification: 0x80-0x9F ***/
143 
144 #define ATT_ERR_INVALID_VALUE 0x80
145 
146 
148 /*********************************************************************
149  * Find Information Response: UUID Format
150  */
151  // Handle and 16-bit Bluetooth UUID
152 #define ATT_HANDLE_BT_UUID_TYPE 0x01
153 
154  // Handle and 128-bit UUID
155 #define ATT_HANDLE_UUID_TYPE 0x02
156 
157 /*********************************************************************
158  * Read Multiple Request: Handles
159  */
160  // Minimum number of handles in a single Read Multiple Request
161 #define ATT_MIN_NUM_HANDLES 2
162 
163 /*********************************************************************
164  * Execute Write Request: Flags
165  */
166  // Cancel all prepared writes
167 #define ATT_CANCEL_PREPARED_WRITES 0x00
168 
169  // Immediately write all pending prepared values
170 #define ATT_WRITE_PREPARED_VALUES 0x01
171 
172 #if defined ( TESTMODES )
173  // ATT Test Modes
174  #define ATT_TESTMODE_OFF 0 // Test mode off
175  #define ATT_TESTMODE_UNAUTHEN_SIG 1 // Do not authenticate incoming signature
176 #endif
177 
178 /*********************************************************************
179  * Size of mandatory fields of ATT requests
180  */
181 
182 // Length of opcode field: Opcode (1)
183 #define ATT_OPCODE_SIZE 1
184 
185 // Length of Exchange MTU Request: client receive MTU size (2)
186 #define ATT_EXCHANGE_MTU_REQ_SIZE 2
187 
188 // Length of Exchange MTU Response: server receive MTU size (2)
189 #define ATT_EXCHANGE_MTU_RSP_SIZE 2
190 
191 // Length of Error Response: Command opcode in error (1) + Attribute handle in error (2) + Status code (1)
192 #define ATT_ERROR_RSP_SIZE 4
193 
194 // Length of Find Information Request's fixed fields: First handle number (2) + Last handle number (2)
195 #define ATT_FIND_INFO_REQ_FIXED_SIZE 4
196 
197 // Length of Find Information Response's fixed field: Format (1)
198 #define ATT_FIND_INFO_RSP_FIXED_SIZE 1
199 #define ATT_FIND_INFO_RSP_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_FIND_INFO_RSP_FIXED_SIZE )
200 
201 // Length of Find By Type Value Request's fixed fields: Start handle (2) + End handle (2) + Type (2)
202 #define ATT_FIND_BY_TYPE_VALUE_REQ_FIXED_SIZE 6
203 #define ATT_FIND_BY_TYPE_VALUE_REQ_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_FIND_BY_TYPE_VALUE_REQ_FIXED_SIZE )
204 
205 // Length of Read By Type Request's fixed fields: First handle number (2) + Last handle number (2)
206 #define ATT_READ_BY_TYPE_REQ_FIXED_SIZE 4
207 #define ATT_READ_BY_TYPE_REQ_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_READ_BY_TYPE_REQ_FIXED_SIZE )
208 
209 // Length of Read By Type Response's fixed fields: Length (1)
210 #define ATT_READ_BY_TYPE_RSP_FIXED_SIZE 1
211 #define ATT_READ_BY_TYPE_RSP_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_READ_BY_TYPE_RSP_FIXED_SIZE )
212 
213 // Length of Read Request: Attribute Handle (2)
214 #define ATT_READ_REQ_SIZE 2
215 
216 // Length of Read By Type Response's fixed fields: Length (1)
217 #define ATT_READ_BY_GRP_TYPE_RSP_FIXED_SIZE 1
218 #define ATT_READ_BY_GRP_TYPE_RSP_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_READ_BY_GRP_TYPE_RSP_FIXED_SIZE )
219 
220 // Length of Write Request's fixed field: Attribute Handle (2)
221 #define ATT_WRITE_REQ_FIXED_SIZE 2
222 
223 // Length of Read Blob Request: Attribute Handle (2) + Value Offset (2)
224 #define ATT_READ_BLOB_REQ_SIZE 4
225 
226 // Length of Write Request's fixed field: Attribute Handle (2)
227 #define ATT_WRITE_REQ_FIXED_SIZE 2
228 #define ATT_WRITE_REQ_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_WRITE_REQ_FIXED_SIZE )
229 
230 // Length of Prepare Write Request's fixed fields: Attribute Handle (2) + Value Offset (2)
231 #define ATT_PREPARE_WRITE_REQ_FIXED_SIZE 4
232 #define ATT_PREPARE_WRITE_REQ_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_PREPARE_WRITE_REQ_FIXED_SIZE )
233 
234 // Length of Prepare Write Response's fixed size: Attribute Handle (2) + Value Offset (2)
235 #define ATT_PREPARE_WRITE_RSP_FIXED_SIZE 4
236 
237 // Length of Execute Write Request: Flags (1)
238 #define ATT_EXECUTE_WRITE_REQ_SIZE 1
239 
240 // Length of Handle Value Indication's fixed size: Attribute Handle (2)
241 #define ATT_HANDLE_VALUE_IND_FIXED_SIZE 2
242 #define ATT_HANDLE_VALUE_IND_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_HANDLE_VALUE_IND_FIXED_SIZE )
243 
244 // Length of Authentication Signature field
245 #define ATT_AUTHEN_SIG_LEN 12
246 
247 /*********************************************************************
248  * VARIABLES
249  */
250 
251 extern CONST uint8 btBaseUUID[ATT_UUID_SIZE];
252 
253 /*********************************************************************
254  * MACROS
255  */
256 
257 #define ATT_WRITE_COMMAND( method, cmd ) ( ( (method) == ATT_WRITE_REQ ) && ( (cmd) == TRUE ) )
258 
259 /*********************************************************************
260  * ATT Find Info Response macros
261  */
262 // Handle and 16-bit Bluetooth UUID pair indexes
263 #define ATT_BT_PAIR_HANDLE_IDX( i ) ( (i) * (2 + ATT_BT_UUID_SIZE) )
264 #define ATT_BT_PAIR_UUID_IDX( i ) ( ATT_BT_PAIR_HANDLE_IDX( (i) ) + 2 )
265 
266 #define ATT_BT_PAIR_HANDLE( info, i ) ( BUILD_UINT16( (info)[ATT_BT_PAIR_HANDLE_IDX((i))], \
267  (info)[ATT_BT_PAIR_HANDLE_IDX((i))+1] ) )
268 #define ATT_BT_PAIR_UUID( info, i ) ( BUILD_UINT16( (info)[ATT_BT_PAIR_UUID_IDX((i))], \
269  (info)[ATT_BT_PAIR_UUID_IDX((i))+1] ) )
270 
271 // Handle and 128-bit UUID pair indexes
272 #define ATT_PAIR_HANDLE_IDX( i ) ( (i) * (2 + ATT_UUID_SIZE) )
273 #define ATT_PAIR_UUID_IDX( i ) ( ATT_PAIR_HANDLE_IDX( (i) ) + 2 )
274 
275 #define ATT_PAIR_HANDLE( info, i ) ( BUILD_UINT16( (info)[ATT_PAIR_HANDLE_IDX((i))], \
276  (info)[ATT_PAIR_HANDLE_IDX((i))+1] ) )
277 
278 /*********************************************************************
279  * ATT Find By Type Value Response macros
280  */
281 // Attribute Handle and Group End Handle pair indexes
282 #define ATT_ATTR_HANDLE_IDX( i ) ( (i) * (2 + 2) )
283 #define ATT_GRP_END_HANDLE_IDX( i ) ( ATT_ATTR_HANDLE_IDX( (i) ) + 2 )
284 
285 #define ATT_ATTR_HANDLE( info, i ) ( BUILD_UINT16( (info)[ATT_ATTR_HANDLE_IDX((i))], \
286  (info)[ATT_ATTR_HANDLE_IDX((i))+1] ) )
287 #define ATT_GRP_END_HANDLE( info, i ) ( BUILD_UINT16( (info)[ATT_GRP_END_HANDLE_IDX((i))], \
288  (info)[ATT_GRP_END_HANDLE_IDX((i))+1] ) )
289 
290 /*********************************************************************
291  * ATT Read Multiple Request macros
292  */
293 // Attribute Handle index
294 #define ATT_HANDLE_IDX( i ) ( (i) * 2 )
295 
296 #define ATT_HANDLE( handles, i ) ( BUILD_UINT16( (handles)[ATT_HANDLE_IDX((i))], \
297  (handles)[ATT_HANDLE_IDX((i))+1] ) )
298 
299 /*********************************************************************
300  * TYPEDEFS
301  */
302 
306 typedef struct
307 {
308  uint8 sig;
309  uint8 cmd;
310  uint8 method;
311  uint16 len;
312  uint8 *pParams;
313 } attPacket_t;
314 
318 typedef struct
319 {
320  uint8 len;
321  uint8 uuid[ATT_UUID_SIZE];
322 } attAttrType_t;
323 
327 typedef struct
328 {
329  uint8 len;
330  uint8 uuid[ATT_BT_UUID_SIZE];
332 
336 typedef struct
337 {
338  uint8 reqOpcode;
339  uint16 handle;
340  uint8 errCode;
341 } attErrorRsp_t;
342 
346 typedef struct
347 {
348  uint16 clientRxMTU;
350 
354 typedef struct
355 {
356  uint16 serverRxMTU;
358 
362 typedef struct
363 {
364  uint16 startHandle;
365  uint16 endHandle;
367 
371 typedef struct
372 {
373  uint16 handle;
374  uint8 uuid[ATT_BT_UUID_SIZE];
376 
380 typedef struct
381 {
382  uint16 handle;
383  uint8 uuid[ATT_UUID_SIZE];
385 
389 typedef struct
390 {
391  uint16 numInfo;
392  uint8 format;
393  uint8 *pInfo;
395 
399 typedef struct
400 {
401  uint16 startHandle;
402  uint16 endHandle;
404  uint16 len;
405  uint8 *pValue;
407 
411 typedef struct
412 {
413  uint16 handle;
414  uint16 grpEndHandle;
416 
420 typedef struct
421 {
422  uint16 numInfo;
423  uint8 *pHandlesInfo;
425 
429 typedef struct
430 {
431  uint16 startHandle;
432  uint16 endHandle;
435 
439 typedef struct
440 {
441  uint16 numPairs;
442  uint16 len;
443  uint8 *pDataList;
444  uint16 dataLen;
446 
450 typedef struct
451 {
452  uint16 handle;
453 } attReadReq_t;
454 
458 typedef struct
459 {
460  uint16 len;
461  uint8 *pValue;
462 } attReadRsp_t;
463 
467 typedef struct
468 {
469  uint16 handle;
470  uint16 offset;
472 
476 typedef struct
477 {
478  uint16 len;
479  uint8 *pValue;
481 
485 typedef struct
486 {
487  uint8 *pHandles;
488  uint16 numHandles;
490 
494 typedef struct
495 {
496  uint16 len;
497  uint8 *pValues;
499 
503 typedef struct
504 {
505  uint16 startHandle;
506  uint16 endHandle;
509 
513 typedef struct
514 {
515  uint16 numGrps;
516  uint16 len;
517  uint8 *pDataList;
519 
523 typedef struct
524 {
525  uint16 handle;
526  uint16 len;
527  uint8 *pValue;
528  uint8 sig;
529  uint8 cmd;
530 } attWriteReq_t;
531 
535 typedef struct
536 {
537  uint16 handle;
538  uint16 offset;
539  uint16 len;
540  uint8 *pValue;
542 
546 typedef struct
547 {
548  uint16 handle;
549  uint16 offset;
550  uint16 len;
551  uint8 *pValue;
553 
557 typedef struct
558 {
559  uint8 flags;
562 
566 typedef struct
567 {
568  uint16 handle;
569  uint16 len;
570  uint8 *pValue;
572 
576 typedef struct
577 {
578  uint16 handle;
579  uint16 len;
580  uint8 *pValue;
582 
598 typedef struct
599 {
600  uint8 opcode;
603 
612 typedef struct
613 {
614  uint16 MTU;
616 
622 typedef union
623 {
624  // Request messages
636 
637  // Response messages
648 
649  // Indication and Notification messages
652 
653  // Locally-generated event messages
656 } attMsg_t;
657 
658 // Function prototype to notify GATT Server or Client about an outgoing ATT message.
659 typedef void (*attNotifyTxCB_t)( uint16 connHandle, uint8 opcode );
660 
661 /*********************************************************************
662  * VARIABLES
663  */
664 
665 /*********************************************************************
666  * API FUNCTIONS
667  */
668 
669 /*-------------------------------------------------------------------
670  * General Utility APIs
671  */
672 
673 /*
674  * Parse an attribute protocol message.
675  */
676 extern uint8 ATT_ParsePacket( l2capDataEvent_t *pL2capMsg, attPacket_t *pPkt );
677 
678 /*
679  * Compare two UUIDs. The UUIDs are converted if necessary.
680  */
681 extern uint8 ATT_CompareUUID( const uint8 *pUUID1, uint16 len1,
682  const uint8 *pUUID2, uint16 len2 );
683 /*
684  * Convert a 16-bit UUID to 128-bit UUID.
685  */
686 extern uint8 ATT_ConvertUUIDto128( const uint8 *pUUID16, uint8 *pUUID128 );
687 
688 /*
689  * Convert a 128-bit UUID to 16-bit UUID.
690  */
691 extern uint8 ATT_ConvertUUIDto16( const uint8 *pUUID128, uint8 *pUUID16 );
692 
693 
694 /*-------------------------------------------------------------------
695  * Attribute Client Utility APIs
696  */
697 
698 /*
699  * Build Error Response.
700  */
701 extern uint16 ATT_BuildErrorRsp( uint8 *pBuf, uint8 *pMsg );
702 
703 /*
704  * Parse Error Response.
705  */
706 extern bStatus_t ATT_ParseErrorRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
707 
708 /*
709  * Build Exchange MTU Request.
710  */
711 extern uint16 ATT_BuildExchangeMTUReq( uint8 *pBuf, uint8 *pMsg );
712 
713 /*
714  * Build Exchange MTU Response.
715  */
716 extern uint16 ATT_BuildExchangeMTURsp( uint8 *pBuf, uint8 *pMsg );
717 
718 /*
719  * Parse Exchange MTU Response.
720  */
721 extern bStatus_t ATT_ParseExchangeMTURsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
722 
723 /*
724  * Build Find Information Request.
725  */
726 extern uint16 ATT_BuildFindInfoReq( uint8 *pBuf, uint8 *pMsg );
727 
728 /*
729  * Parse Find Information Response.
730  */
731 extern bStatus_t ATT_ParseFindInfoRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
732 
733 /*
734  * Build Find Information Response.
735  */
736 extern uint16 ATT_BuildFindInfoRsp( uint8 *pBuf, uint8 *pMsg );
737 
738 /*
739  * Build Find By Type Value Request.
740  */
741 extern uint16 ATT_BuildFindByTypeValueReq( uint8 *pBuf, uint8 *pMsg );
742 
743 /*
744  * Build Find By Type Value Response.
745  */
746 extern uint16 ATT_BuildFindByTypeValueRsp( uint8 *pBuf, uint8 *pMsg );
747 
748 /*
749  * Parse Find By Type Value Response.
750  */
751 extern bStatus_t ATT_ParseFindByTypeValueRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
752 
753 /*
754  * Build Read By Type Request.
755  */
756 extern uint16 ATT_BuildReadByTypeReq( uint8 *pBuf, uint8 *pMsg );
757 
758 /*
759  * Build Read By Type Response.
760  */
761 extern uint16 ATT_BuildReadByTypeRsp( uint8 *pBuf, uint8 *pMsg );
762 
763 /*
764  * Parse Read By Type Response.
765  */
766 extern bStatus_t ATT_ParseReadByTypeRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
767 
768 /*
769  * Build Read Request.
770  */
771 extern uint16 ATT_BuildReadReq( uint8 *pBuf, uint8 *pMsg );
772 
773 /*
774  * Build Read Response.
775  */
776 extern uint16 ATT_BuildReadRsp( uint8 *pBuf, uint8 *pMsg );
777 
778 /*
779  * Parse Read Response.
780  */
781 extern bStatus_t ATT_ParseReadRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
782 
783 /*
784  * Build Read Blob Request.
785  */
786 extern uint16 ATT_BuildReadBlobReq( uint8 *pBuf, uint8 *pMsg );
787 
788 /*
789  * Build Read Blob Response.
790  */
791 extern uint16 ATT_BuildReadBlobRsp( uint8 *pBuf, uint8 *pMsg );
792 
793 /*
794  * Parse Read Blob Response.
795  */
796 extern bStatus_t ATT_ParseReadBlobRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
797 
798 /*
799  * Build Read Multiple Request.
800  */
801 extern uint16 ATT_BuildReadMultiReq( uint8 *pBuf, uint8 *pMsg );
802 
803 /*
804  * Build Read Multiple Response.
805  */
806 extern uint16 ATT_BuildReadMultiRsp( uint8 *pBuf, uint8 *pMsg );
807 
808 /*
809  * Parse Read Multiple Response.
810  */
811 extern bStatus_t ATT_ParseReadMultiRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
812 
813 /*
814  * Build Read By Group Type Response.
815  */
816 extern uint16 ATT_BuildReadByGrpTypeRsp( uint8 *pBuf, uint8 *pMsg );
817 
818 /*
819  * Parse Read By Group Type Response.
820  */
821 extern bStatus_t ATT_ParseReadByGrpTypeRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
822 
823 /*
824  * Build Write Request.
825  */
826 extern uint16 ATT_BuildWriteReq( uint8 *pBuf, uint8 *pMsg );
827 
828 /*
829  * Parse Write Response.
830  */
831 extern bStatus_t ATT_ParseWriteRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
832 
833 /*
834  * Build Prepare Write Request.
835  */
836 extern uint16 ATT_BuildPrepareWriteReq( uint8 *pBuf, uint8 *pMsg );
837 
838 /*
839  * Build Prepare Write Response.
840  */
841 extern uint16 ATT_BuildPrepareWriteRsp( uint8 *pBuf, uint8 *pMsg );
842 
843 /*
844  * Parse Prepare Write Response.
845  */
846 extern bStatus_t ATT_ParsePrepareWriteRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
847 
848 /*
849  * Build Execute Write Request.
850  */
851 extern uint16 ATT_BuildExecuteWriteReq( uint8 *pBuf, uint8 *pMsg );
852 
853 /*
854  * Parse Execute Write Response.
855  */
856 extern bStatus_t ATT_ParseExecuteWriteRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
857 
858 /*
859  * Build Handle Value Indication.
860  */
861 extern uint16 ATT_BuildHandleValueInd( uint8 *pBuf, uint8 *pMsg );
862 
863 /*
864  * Parse Handle Value Indication.
865  */
866 extern bStatus_t ATT_ParseHandleValueInd( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
867 
868 
869 /*-------------------------------------------------------------------
870  * Attribute Server Utility APIs
871  */
872 
873 /*
874  * Parse Exchange MTU Request.
875  */
876 extern bStatus_t ATT_ParseExchangeMTUReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
877 
878 /*
879  * Parse Find Information Request.
880  */
881 extern bStatus_t ATT_ParseFindInfoReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
882 
883 /*
884  * Parse Find By Type Value Request.
885  */
886 extern bStatus_t ATT_ParseFindByTypeValueReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
887 
888 /*
889  * Parse Read By Type Request.
890  */
891 extern bStatus_t ATT_ParseReadByTypeReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
892 
893 /*
894  * Parse Read Request.
895  */
896 extern bStatus_t ATT_ParseReadReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
897 
898 /*
899  * Parse Write Blob Request.
900  */
901 extern bStatus_t ATT_ParseReadBlobReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
902 
903 /*
904  * Parse Read Multiple Request.
905  */
906 extern bStatus_t ATT_ParseReadMultiReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
907 
908 /*
909  * Parse Write Request.
910  */
911 extern bStatus_t ATT_ParseWriteReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
912 
913 /*
914  * Parse Execute Write Request.
915  */
916 extern bStatus_t ATT_ParseExecuteWriteReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
917 
918 /*
919  * Parse Prepare Write Request.
920  */
921 extern bStatus_t ATT_ParsePrepareWriteReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
922 
923 /*
924  * Parse Handle Value Confirmation.
925  */
926 extern bStatus_t ATT_ParseHandleValueCfm( uint8 *pParams, uint16 len, attMsg_t *pMsg );
927 
928 
929 /*-------------------------------------------------------------------
930  * Attribute Client Public APIs
931  */
932 
951 extern bStatus_t ATT_ExchangeMTUReq( uint16 connHandle, attExchangeMTUReq_t *pReq );
952 
965 extern bStatus_t ATT_FindInfoReq( uint16 connHandle, attFindInfoReq_t *pReq );
966 
979 extern bStatus_t ATT_FindByTypeValueReq( uint16 connHandle, attFindByTypeValueReq_t *pReq );
980 
993 extern bStatus_t ATT_ReadByTypeReq( uint16 connHandle, attReadByTypeReq_t *pReq );
994 
1007 extern bStatus_t ATT_ReadReq( uint16 connHandle, attReadReq_t *pReq );
1008 
1021 extern bStatus_t ATT_ReadBlobReq( uint16 connHandle, attReadBlobReq_t *pReq );
1022 
1035 extern bStatus_t ATT_ReadMultiReq( uint16 connHandle, attReadMultiReq_t *pReq );
1036 
1049 extern bStatus_t ATT_ReadByGrpTypeReq( uint16 connHandle, attReadByGrpTypeReq_t *pReq );
1050 
1064 extern bStatus_t ATT_WriteReq( uint16 connHandle, attWriteReq_t *pReq );
1065 
1078 extern bStatus_t ATT_PrepareWriteReq( uint16 connHandle, attPrepareWriteReq_t *pReq );
1079 
1092 extern bStatus_t ATT_ExecuteWriteReq( uint16 connHandle, attExecuteWriteReq_t *pReq );
1093 
1105 extern bStatus_t ATT_HandleValueCfm( uint16 connHandle );
1106 
1111 /*-------------------------------------------------------------------
1112  * Attribute Server Public APIs
1113  */
1114 
1133 extern bStatus_t ATT_ErrorRsp( uint16 connHandle, attErrorRsp_t *pRsp );
1134 
1147 extern bStatus_t ATT_ExchangeMTURsp( uint16 connHandle, attExchangeMTURsp_t *pRsp );
1148 
1161 extern bStatus_t ATT_FindInfoRsp( uint16 connHandle, attFindInfoRsp_t *pRsp );
1162 
1175 extern bStatus_t ATT_FindByTypeValueRsp( uint16 connHandle, attFindByTypeValueRsp_t *pRsp );
1176 
1189 extern bStatus_t ATT_ReadByTypeRsp( uint16 connHandle, attReadByTypeRsp_t *pRsp );
1190 
1203 extern bStatus_t ATT_ReadRsp( uint16 connHandle, attReadRsp_t *pRsp );
1204 
1217 extern bStatus_t ATT_ReadBlobRsp( uint16 connHandle, attReadBlobRsp_t *pRsp );
1218 
1231 extern bStatus_t ATT_ReadMultiRsp( uint16 connHandle, attReadMultiRsp_t *pRsp ) ;
1232 
1245 extern bStatus_t ATT_ReadByGrpTypeRsp( uint16 connHandle, attReadByGrpTypeRsp_t *pRsp );
1246 
1258 extern bStatus_t ATT_WriteRsp( uint16 connHandle );
1259 
1272 extern bStatus_t ATT_PrepareWriteRsp( uint16 connHandle, attPrepareWriteRsp_t *pRsp );
1273 
1285 extern bStatus_t ATT_ExecuteWriteRsp( uint16 connHandle );
1286 
1299 extern bStatus_t ATT_HandleValueNoti( uint16 connHandle, attHandleValueNoti_t *pNoti );
1300 
1313 extern bStatus_t ATT_HandleValueInd( uint16 connHandle, attHandleValueInd_t *pInd );
1314 
1319 /*-------------------------------------------------------------------
1320  * Attribute Common Public APIs
1321  */
1322 
1338 extern uint8 ATT_UpdateMTU( uint16 connHandle, uint16 MTU );
1339 
1347 extern uint16 ATT_GetMTU( uint16 connHandle );
1348 
1361 extern void ATT_SetParamValue( uint16 value );
1362 
1370 extern uint16 ATT_GetParamValue( void );
1371 
1379 extern void ATT_RegisterServer( attNotifyTxCB_t pfnNotifyTx );
1380 
1388 extern void ATT_RegisterClient( attNotifyTxCB_t pfnNotifyTx );
1389 
1390 /*********************************************************************
1391 *********************************************************************/
1392 
1393 #ifdef __cplusplus
1394 }
1395 #endif
1396 
1397 #endif /* ATT_H */
bStatus_t ATT_ExchangeMTUReq(uint16 connHandle, attExchangeMTUReq_t *pReq)
Send Exchange MTU Request.
bStatus_t ATT_ErrorRsp(uint16 connHandle, attErrorRsp_t *pRsp)
Send Error Response.
uint16 numInfo
Number of attribute handle-UUID pairs found.
Definition: att.h:391
uint8 * pValue
Part of the value of the attribute with the handle given (0 to ATT_MTU_SIZE-1)
Definition: att.h:479
Definition: att.h:420
bStatus_t ATT_ReadRsp(uint16 connHandle, attReadRsp_t *pRsp)
Send Read Response.
uint16 handle
Handle.
Definition: att.h:373
uint16 clientRxMTU
Client receive MTU size.
Definition: att.h:348
uint8 cmd
Command Flag.
Definition: att.h:529
Definition: att.h:411
attHandleValueInd_t handleValueInd
ATT Handle Value Indication.
Definition: att.h:651
attReadByGrpTypeRsp_t readByGrpTypeRsp
ATT Read By Group Type Response.
Definition: att.h:646
bStatus_t ATT_ReadMultiReq(uint16 connHandle, attReadMultiReq_t *pReq)
Send Read Multiple Request.
uint8 cmd
Command Flag.
Definition: att.h:309
uint16 handle
Found attribute handle.
Definition: att.h:413
bStatus_t ATT_ReadByTypeRsp(uint16 connHandle, attReadByTypeRsp_t *pRsp)
Send Read By Type Respond.
bStatus_t ATT_HandleValueCfm(uint16 connHandle)
Send Handle Value Confirmation.
uint16 offset
Offset of the first octet to be written.
Definition: att.h:549
uint16 startHandle
First requested handle number (must be first field)
Definition: att.h:364
attReadByTypeRsp_t readByTypeRsp
ATT Read By Type Response.
Definition: att.h:642
bStatus_t ATT_ExecuteWriteRsp(uint16 connHandle)
Send Execute Write Response.
uint16 numPairs
Number of attribute handle-UUID pairs found.
Definition: att.h:441
Definition: att.h:371
Definition: att.h:336
uint16 len
Length of value.
Definition: att.h:579
uint8 len
Length of UUID (2)
Definition: att.h:329
Definition: att.h:476
uint16 endHandle
Last requested handle number.
Definition: att.h:365
attFindByTypeValueRsp_t findByTypeValueRsp
ATT Find By Type Value Response.
Definition: att.h:641
uint8 ATT_UpdateMTU(uint16 connHandle, uint16 MTU)
This function is used to update the MTU size of a connection.
uint16 endHandle
Last requested handle number.
Definition: att.h:432
Definition: att.h:346
Definition: att.h:612
uint8 * pInfo
Information data whose format is determined by format field (4 to ATT_MTU_SIZE-2) ...
Definition: att.h:393
bStatus_t ATT_PrepareWriteRsp(uint16 connHandle, attPrepareWriteRsp_t *pRsp)
Send Prepare Write Response.
attReadBlobReq_t readBlobReq
ATT Read Blob Request.
Definition: att.h:630
bStatus_t ATT_ReadBlobReq(uint16 connHandle, attReadBlobReq_t *pReq)
Send Read Blob Request.
uint8 format
Format of information data.
Definition: att.h:392
Definition: att.h:513
uint8 sig
Authentication Signature status (not included (0), valid (1), invalid (2))
Definition: att.h:528
uint16 len
Length of each attribute handle, end group handle and value set.
Definition: att.h:516
uint8 * pValue
Current value of the attribute (0 to ATT_MTU_SIZE-3)
Definition: att.h:570
bStatus_t ATT_ReadReq(uint16 connHandle, attReadReq_t *pReq)
Send Read Request.
bStatus_t ATT_PrepareWriteReq(uint16 connHandle, attPrepareWriteReq_t *pReq)
Send Prepare Write Request.
bStatus_t ATT_FindByTypeValueRsp(uint16 connHandle, attFindByTypeValueRsp_t *pRsp)
Send Find By Type Value Response.
attReadMultiRsp_t readMultiRsp
ATT Read Multiple Response.
Definition: att.h:645
attHandleValueNoti_t handleValueNoti
ATT Handle Value Notification.
Definition: att.h:650
attMtuUpdatedEvt_t mtuEvt
ATT MTU Updated Event.
Definition: att.h:655
bStatus_t ATT_FindByTypeValueReq(uint16 connHandle, attFindByTypeValueReq_t *pReq)
Send Find By Type Value Request.
Definition: att.h:354
bStatus_t ATT_WriteReq(uint16 connHandle, attWriteReq_t *pReq)
Send Write Request.
uint16 len
Length of value.
Definition: att.h:478
Definition: att.h:485
attReadByTypeReq_t readByTypeReq
ATT Read By Type Request.
Definition: att.h:628
uint8 * pParams
Attribute Parameters.
Definition: att.h:312
attFindByTypeValueReq_t findByTypeValueReq
ATT Find By Type Value Request.
Definition: att.h:627
uint16 len
Length of value.
Definition: att.h:539
attAttrBtType_t type
2-octet UUID to find
Definition: att.h:403
attErrorRsp_t errorRsp
ATT Error Response.
Definition: att.h:638
uint16 handle
Handle.
Definition: att.h:382
uint16 handle
Handle of the attribute to be written (must be first field)
Definition: att.h:525
Definition: att.h:494
uint16 len
Length of Attribute Parameters.
Definition: att.h:311
attReadRsp_t readRsp
ATT Read Response.
Definition: att.h:643
bStatus_t ATT_ReadByGrpTypeRsp(uint16 connHandle, attReadByGrpTypeRsp_t *pRsp)
Send Read By Group Type Respond.
bStatus_t ATT_WriteRsp(uint16 connHandle)
Send Write Response.
bStatus_t ATT_ExecuteWriteReq(uint16 connHandle, attExecuteWriteReq_t *pReq)
Send Execute Write Request.
uint16 handle
Handle of the attribute that has been changed (must be first field)
Definition: att.h:578
uint16 len
Length of value.
Definition: att.h:460
Definition: att.h:622
uint16 numHandles
Number of attribute handles.
Definition: att.h:488
bStatus_t ATT_ReadByTypeReq(uint16 connHandle, attReadByTypeReq_t *pReq)
Send Read By Type Request.
attPrepareWriteReq_t prepareWriteReq
ATT Prepare Write Request.
Definition: att.h:634
uint16 startHandle
First requested handle number (must be first field)
Definition: att.h:431
attExecuteWriteReq_t executeWriteReq
ATT Execute Write Request.
Definition: att.h:635
Definition: att.h:380
uint16 handle
Handle of the attribute that has been read.
Definition: att.h:548
uint8 * pValue
Current value of the attribute (0 to ATT_MTU_SIZE-3)
Definition: att.h:580
uint8 * pHandlesInfo
List of 1 or more handles information (4 to ATT_MTU_SIZE-1)
Definition: att.h:423
uint16 len
Length of value.
Definition: att.h:404
uint16 len
Length of values.
Definition: att.h:496
uint8 * pValue
Value of the attribute with the handle given (0 to ATT_MTU_SIZE-1)
Definition: att.h:461
attReadReq_t readReq
ATT Read Request.
Definition: att.h:629
uint16 len
Length of value.
Definition: att.h:569
attReadByGrpTypeReq_t readByGrpTypeReq
ATT Read By Group Type Request.
Definition: att.h:632
Status_t bStatus_t
BLE Generic Status return: BLE Default BLE Status Values.
Definition: bcomdef.h:244
attReadBlobRsp_t readBlobRsp
ATT Read Blob Response.
Definition: att.h:644
uint8 * pValue
Part of the value of the attribute to be written (0 to ATT_MTU_SIZE-5) - must be allocated.
Definition: att.h:540
attAttrType_t type
Requested group type (2 or 16 octet UUID)
Definition: att.h:507
uint16 startHandle
First requested handle number (must be first field)
Definition: att.h:505
Definition: att.h:450
uint16 len
Length of value.
Definition: att.h:526
uint16 offset
Offset of the first octet to be read.
Definition: att.h:470
Definition: att.h:546
uint8 * pDataList
List of 1 or more attribute handle, end group handle and value (4 to ATT_MTU_SIZE-2) ...
Definition: att.h:517
uint8 len
Length of UUID (2 or 16)
Definition: att.h:320
uint8 * pValue
Part of the value of the attribute to be written (0 to ATT_MTU_SIZE-5)
Definition: att.h:551
uint16 handle
Handle of the attribute to be read (must be first field)
Definition: att.h:469
Definition: att.h:598
uint16 numGrps
Number of attribute handle, end group handle and value sets found.
Definition: att.h:515
bStatus_t ATT_ReadMultiRsp(uint16 connHandle, attReadMultiRsp_t *pRsp)
Send Read Multiple Response.
uint16 handle
Handle of the attribute that has been changed (must be first field)
Definition: att.h:568
bStatus_t ATT_FindInfoReq(uint16 connHandle, attFindInfoReq_t *pReq)
Send Find Information Request.
Definition: att.h:389
Definition: att.h:399
uint8 sig
Authentication Signature status (not included (0), valid (1), invalid (2))
Definition: att.h:308
uint8 pendingOpcode
opcode of pending message
Definition: att.h:601
uint16 numInfo
Number of handles information found.
Definition: att.h:422
uint16 handle
Handle of the attribute to be read (must be first field)
Definition: att.h:452
Definition: att.h:429
Definition: att.h:362
uint8 * pValue
Value of the attribute to be written (0 to ATT_MTU_SIZE-3)
Definition: att.h:527
uint16 dataLen
Length of data written into pDataList. Not part of actual ATT Response.
Definition: att.h:444
bStatus_t ATT_FindInfoRsp(uint16 connHandle, attFindInfoRsp_t *pRsp)
Send Find Information Response.
Definition: att.h:523
attWriteReq_t writeReq
ATT Write Request.
Definition: att.h:633
attFlowCtrlViolatedEvt_t flowCtrlEvt
ATT Flow Control Violated Event.
Definition: att.h:654
Definition: att.h:576
attPrepareWriteRsp_t prepareWriteRsp
ATT Prepare Write Response.
Definition: att.h:647
uint8 flags
Definition: att.h:559
uint8 method
Method.
Definition: att.h:310
Definition: att.h:439
Definition: att.h:306
Definition: att.h:557
uint16 serverRxMTU
Server receive MTU size.
Definition: att.h:356
uint16 ATT_GetMTU(uint16 connHandle)
This function is used to get the MTU size of a connection.
uint16 offset
Offset of the first octet to be written.
Definition: att.h:538
attFindInfoRsp_t findInfoRsp
ATT Find Information Response.
Definition: att.h:640
attAttrType_t type
Requested type (2 or 16 octet UUID)
Definition: att.h:433
attReadMultiReq_t readMultiReq
ATT Read Multiple Request.
Definition: att.h:631
Definition: att.h:318
uint16 endHandle
Last requested handle number.
Definition: att.h:402
uint8 opcode
opcode of message that caused flow control violation
Definition: att.h:600
uint8 reqOpcode
Request that generated this error response.
Definition: att.h:338
uint16 handle
Handle of the attribute to be written (must be first field)
Definition: att.h:537
bStatus_t ATT_HandleValueInd(uint16 connHandle, attHandleValueInd_t *pInd)
Send Handle Value Indication.
bStatus_t ATT_ReadBlobRsp(uint16 connHandle, attReadBlobRsp_t *pRsp)
Send Read Blob Response.
uint16 len
Length of value.
Definition: att.h:550
uint8 errCode
Reason why the request has generated error response.
Definition: att.h:340
uint16 startHandle
First requested handle number (must be first field)
Definition: att.h:401
uint8 * pDataList
List of 1 or more attribute handle-value pairs (2 to ATT_MTU_SIZE-2)
Definition: att.h:443
uint16 endHandle
Last requested handle number.
Definition: att.h:506
uint8 * pValues
Set of two or more values (0 to ATT_MTU_SIZE-1)
Definition: att.h:497
uint16 grpEndHandle
Group end handle.
Definition: att.h:414
Definition: l2cap.h:618
uint16 MTU
new MTU size
Definition: att.h:614
bStatus_t ATT_HandleValueNoti(uint16 connHandle, attHandleValueNoti_t *pNoti)
Send Handle Value Notification.
Definition: att.h:566
Definition: att.h:458
attExchangeMTURsp_t exchangeMTURsp
ATT Exchange MTU Response.
Definition: att.h:639
uint16 handle
Attribute handle that generated error response.
Definition: att.h:339
uint8 * pHandles
Set of two or more attribute handles (4 to ATT_MTU_SIZE-1) - must be first field. ...
Definition: att.h:487
bStatus_t ATT_ExchangeMTURsp(uint16 connHandle, attExchangeMTURsp_t *pRsp)
Send Exchange MTU Response.
uint8 * pValue
Attribute value to find (0 to ATT_MTU_SIZE-7)
Definition: att.h:405
bStatus_t ATT_ReadByGrpTypeReq(uint16 connHandle, attReadByGrpTypeReq_t *pReq)
Send Read By Group Type Request.
Definition: att.h:467
Definition: att.h:327
attFindInfoReq_t findInfoReq
ATT Find Information Request.
Definition: att.h:626
attExchangeMTUReq_t exchangeMTUReq
ATT Exchange MTU Request.
Definition: att.h:625
Definition: att.h:503
uint16 len
Size of each attribute handle-value pair.
Definition: att.h:442
Definition: att.h:535