TI BLE Stack API Documentation  2.03.09
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 #define ATT_UNSUPPORTED_METHOD 0x20
77 
78 #define ATT_WRITE_CMD 0x52
79 #define ATT_SIGNED_WRITE_CMD 0xD2
80 
81 
86 #define ATT_FLOW_CTRL_VIOLATED_EVENT 0x7E
87 #define ATT_MTU_UPDATED_EVENT 0x7F
88 
89 
91 /*** Opcode fields: bitmasks ***/
92 // Method (bits 5-0)
93 #define ATT_METHOD_BITS 0x3f
94 
95 // Command Flag (bit 6)
96 #define ATT_CMD_FLAG_BIT 0x40
97 
98 // Authentication Signature Flag (bit 7)
99 #define ATT_AUTHEN_SIG_FLAG_BIT 0x80
100 
101 // Size of 16-bit Bluetooth UUID
102 #define ATT_BT_UUID_SIZE 2
103 
104 // Size of 128-bit UUID
105 #define ATT_UUID_SIZE 16
106 
107 // ATT Response or Confirmation timeout
108 #define ATT_MSG_TIMEOUT 30
109 
110 // Authentication Signature status for received PDU; it's TRUE or FALSE for PDU to be sent
111 #define ATT_SIG_NOT_INCLUDED 0x00 // Signature not included
112 #define ATT_SIG_VALID 0x01 // Included signature valid
113 #define ATT_SIG_INVALID 0x02 // Included signature not valid
114 
115 /*********************************************************************
116  * Error Response: Error Code
117  */
118 
123 #define ATT_ERR_INVALID_HANDLE 0x01
124 #define ATT_ERR_READ_NOT_PERMITTED 0x02
125 #define ATT_ERR_WRITE_NOT_PERMITTED 0x03
126 #define ATT_ERR_INVALID_PDU 0x04
127 #define ATT_ERR_INSUFFICIENT_AUTHEN 0x05
128 #define ATT_ERR_UNSUPPORTED_REQ 0x06
129 #define ATT_ERR_INVALID_OFFSET 0x07
130 #define ATT_ERR_INSUFFICIENT_AUTHOR 0x08
131 #define ATT_ERR_PREPARE_QUEUE_FULL 0x09
132 #define ATT_ERR_ATTR_NOT_FOUND 0x0a
133 #define ATT_ERR_ATTR_NOT_LONG 0x0b
134 #define ATT_ERR_INSUFFICIENT_KEY_SIZE 0x0c
135 #define ATT_ERR_INVALID_VALUE_SIZE 0x0d
136 #define ATT_ERR_UNLIKELY 0x0e
137 #define ATT_ERR_INSUFFICIENT_ENCRYPT 0x0f
138 #define ATT_ERR_UNSUPPORTED_GRP_TYPE 0x10
139 #define ATT_ERR_INSUFFICIENT_RESOURCES 0x11
140 
141 /*** Reserved for future use: 0x12 - 0x7F ***/
142 
143 /*** Application error code defined by a higher layer specification: 0x80-0x9F ***/
144 
145 #define ATT_ERR_INVALID_VALUE 0x80
146 
147 
149 /*********************************************************************
150  * Find Information Response: UUID Format
151  */
152  // Handle and 16-bit Bluetooth UUID
153 #define ATT_HANDLE_BT_UUID_TYPE 0x01
154 
155  // Handle and 128-bit UUID
156 #define ATT_HANDLE_UUID_TYPE 0x02
157 
158 /*********************************************************************
159  * Read Multiple Request: Handles
160  */
161  // Minimum number of handles in a single Read Multiple Request
162 #define ATT_MIN_NUM_HANDLES 2
163 
164 /*********************************************************************
165  * Execute Write Request: Flags
166  */
167  // Cancel all prepared writes
168 #define ATT_CANCEL_PREPARED_WRITES 0x00
169 
170  // Immediately write all pending prepared values
171 #define ATT_WRITE_PREPARED_VALUES 0x01
172 
173 #if defined ( TESTMODES )
174  // ATT Test Modes
175  #define ATT_TESTMODE_OFF 0 // Test mode off
176  #define ATT_TESTMODE_UNAUTHEN_SIG 1 // Do not authenticate incoming signature
177  #define ATT_TESTMODE_SEND_UNS_REQ 2 // Send ATT request with unsupported opcode
178  #define ATT_TESTMODE_SEND_UNS_CMD 3 // Send ATT command with unsupported opcode
179 #endif
180 
181 /*********************************************************************
182  * Size of mandatory fields of ATT requests
183  */
184 
185 // Length of opcode field: Opcode (1)
186 #define ATT_OPCODE_SIZE 1
187 
188 // Length of Exchange MTU Request: client receive MTU size (2)
189 #define ATT_EXCHANGE_MTU_REQ_SIZE 2
190 
191 // Length of Exchange MTU Response: server receive MTU size (2)
192 #define ATT_EXCHANGE_MTU_RSP_SIZE 2
193 
194 // Length of Error Response: Command opcode in error (1) + Attribute handle in error (2) + Status code (1)
195 #define ATT_ERROR_RSP_SIZE 4
196 
197 // Length of Find Information Request's fixed fields: First handle number (2) + Last handle number (2)
198 #define ATT_FIND_INFO_REQ_FIXED_SIZE 4
199 
200 // Length of Find Information Response's fixed field: Format (1)
201 #define ATT_FIND_INFO_RSP_FIXED_SIZE 1
202 #define ATT_FIND_INFO_RSP_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_FIND_INFO_RSP_FIXED_SIZE )
203 
204 // Length of Find By Type Value Request's fixed fields: Start handle (2) + End handle (2) + Type (2)
205 #define ATT_FIND_BY_TYPE_VALUE_REQ_FIXED_SIZE 6
206 #define ATT_FIND_BY_TYPE_VALUE_REQ_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_FIND_BY_TYPE_VALUE_REQ_FIXED_SIZE )
207 
208 // Length of Read By Type Request's fixed fields: First handle number (2) + Last handle number (2)
209 #define ATT_READ_BY_TYPE_REQ_FIXED_SIZE 4
210 #define ATT_READ_BY_TYPE_REQ_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_READ_BY_TYPE_REQ_FIXED_SIZE )
211 
212 // Length of Read By Type Response's fixed fields: Length (1)
213 #define ATT_READ_BY_TYPE_RSP_FIXED_SIZE 1
214 #define ATT_READ_BY_TYPE_RSP_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_READ_BY_TYPE_RSP_FIXED_SIZE )
215 
216 // Length of Read Request: Attribute Handle (2)
217 #define ATT_READ_REQ_SIZE 2
218 
219 // Length of Read By Type Response's fixed fields: Length (1)
220 #define ATT_READ_BY_GRP_TYPE_RSP_FIXED_SIZE 1
221 #define ATT_READ_BY_GRP_TYPE_RSP_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_READ_BY_GRP_TYPE_RSP_FIXED_SIZE )
222 
223 // Length of Write Request's fixed field: Attribute Handle (2)
224 #define ATT_WRITE_REQ_FIXED_SIZE 2
225 
226 // Length of Read Blob Request: Attribute Handle (2) + Value Offset (2)
227 #define ATT_READ_BLOB_REQ_SIZE 4
228 
229 // Length of Write Request's fixed field: Attribute Handle (2)
230 #define ATT_WRITE_REQ_FIXED_SIZE 2
231 #define ATT_WRITE_REQ_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_WRITE_REQ_FIXED_SIZE )
232 
233 // Length of Prepare Write Request's fixed fields: Attribute Handle (2) + Value Offset (2)
234 #define ATT_PREPARE_WRITE_REQ_FIXED_SIZE 4
235 #define ATT_PREPARE_WRITE_REQ_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_PREPARE_WRITE_REQ_FIXED_SIZE )
236 
237 // Length of Prepare Write Response's fixed size: Attribute Handle (2) + Value Offset (2)
238 #define ATT_PREPARE_WRITE_RSP_FIXED_SIZE 4
239 
240 // Length of Execute Write Request: Flags (1)
241 #define ATT_EXECUTE_WRITE_REQ_SIZE 1
242 
243 // Length of Handle Value Indication's fixed size: Attribute Handle (2)
244 #define ATT_HANDLE_VALUE_IND_FIXED_SIZE 2
245 #define ATT_HANDLE_VALUE_IND_HDR_SIZE ( ATT_OPCODE_SIZE + ATT_HANDLE_VALUE_IND_FIXED_SIZE )
246 
247 // Length of Authentication Signature field
248 #define ATT_AUTHEN_SIG_LEN 12
249 
250 /*********************************************************************
251  * VARIABLES
252  */
253 
254 extern CONST uint8 btBaseUUID[ATT_UUID_SIZE];
255 
256 /*********************************************************************
257  * MACROS
258  */
259 
260 #define ATT_WRITE_COMMAND( method, cmd ) ( ( (method) == ATT_WRITE_REQ ) && ( (cmd) == TRUE ) )
261 
262 /*********************************************************************
263  * ATT Find Info Response macros
264  */
265 // Handle and 16-bit Bluetooth UUID pair indexes
266 #define ATT_BT_PAIR_HANDLE_IDX( i ) ( (i) * (2 + ATT_BT_UUID_SIZE) )
267 #define ATT_BT_PAIR_UUID_IDX( i ) ( ATT_BT_PAIR_HANDLE_IDX( (i) ) + 2 )
268 
269 #define ATT_BT_PAIR_HANDLE( info, i ) ( BUILD_UINT16( (info)[ATT_BT_PAIR_HANDLE_IDX((i))], \
270  (info)[ATT_BT_PAIR_HANDLE_IDX((i))+1] ) )
271 #define ATT_BT_PAIR_UUID( info, i ) ( BUILD_UINT16( (info)[ATT_BT_PAIR_UUID_IDX((i))], \
272  (info)[ATT_BT_PAIR_UUID_IDX((i))+1] ) )
273 
274 // Handle and 128-bit UUID pair indexes
275 #define ATT_PAIR_HANDLE_IDX( i ) ( (i) * (2 + ATT_UUID_SIZE) )
276 #define ATT_PAIR_UUID_IDX( i ) ( ATT_PAIR_HANDLE_IDX( (i) ) + 2 )
277 
278 #define ATT_PAIR_HANDLE( info, i ) ( BUILD_UINT16( (info)[ATT_PAIR_HANDLE_IDX((i))], \
279  (info)[ATT_PAIR_HANDLE_IDX((i))+1] ) )
280 
281 /*********************************************************************
282  * ATT Find By Type Value Response macros
283  */
284 // Attribute Handle and Group End Handle pair indexes
285 #define ATT_ATTR_HANDLE_IDX( i ) ( (i) * (2 + 2) )
286 #define ATT_GRP_END_HANDLE_IDX( i ) ( ATT_ATTR_HANDLE_IDX( (i) ) + 2 )
287 
288 #define ATT_ATTR_HANDLE( info, i ) ( BUILD_UINT16( (info)[ATT_ATTR_HANDLE_IDX((i))], \
289  (info)[ATT_ATTR_HANDLE_IDX((i))+1] ) )
290 #define ATT_GRP_END_HANDLE( info, i ) ( BUILD_UINT16( (info)[ATT_GRP_END_HANDLE_IDX((i))], \
291  (info)[ATT_GRP_END_HANDLE_IDX((i))+1] ) )
292 
293 /*********************************************************************
294  * ATT Read Multiple Request macros
295  */
296 // Attribute Handle index
297 #define ATT_HANDLE_IDX( i ) ( (i) * 2 )
298 
299 #define ATT_HANDLE( handles, i ) ( BUILD_UINT16( (handles)[ATT_HANDLE_IDX((i))], \
300  (handles)[ATT_HANDLE_IDX((i))+1] ) )
301 
302 /*********************************************************************
303  * TYPEDEFS
304  */
305 
309 typedef struct
310 {
311  uint8 sig;
312  uint8 cmd;
313  uint8 method;
314  uint16 len;
315  uint8 *pParams;
316 } attPacket_t;
317 
321 typedef struct
322 {
323  uint8 len;
324  uint8 uuid[ATT_UUID_SIZE];
325 } attAttrType_t;
326 
330 typedef struct
331 {
332  uint8 len;
333  uint8 uuid[ATT_BT_UUID_SIZE];
335 
339 typedef struct
340 {
341  uint8 reqOpcode;
342  uint16 handle;
343  uint8 errCode;
344 } attErrorRsp_t;
345 
349 typedef struct
350 {
351  uint16 clientRxMTU;
353 
357 typedef struct
358 {
359  uint16 serverRxMTU;
361 
365 typedef struct
366 {
367  uint16 startHandle;
368  uint16 endHandle;
370 
374 typedef struct
375 {
376  uint16 handle;
377  uint8 uuid[ATT_BT_UUID_SIZE];
379 
383 typedef struct
384 {
385  uint16 handle;
386  uint8 uuid[ATT_UUID_SIZE];
388 
392 typedef struct
393 {
394  uint16 numInfo;
395  uint8 format;
396  uint8 *pInfo;
398 
402 typedef struct
403 {
404  uint16 startHandle;
405  uint16 endHandle;
407  uint16 len;
408  uint8 *pValue;
410 
414 typedef struct
415 {
416  uint16 handle;
417  uint16 grpEndHandle;
419 
423 typedef struct
424 {
425  uint16 numInfo;
426  uint8 *pHandlesInfo;
428 
432 typedef struct
433 {
434  uint16 startHandle;
435  uint16 endHandle;
438 
442 typedef struct
443 {
444  uint16 numPairs;
445  uint16 len;
446  uint8 *pDataList;
447  uint16 dataLen;
449 
453 typedef struct
454 {
455  uint16 handle;
456 } attReadReq_t;
457 
461 typedef struct
462 {
463  uint16 len;
464  uint8 *pValue;
465 } attReadRsp_t;
466 
470 typedef struct
471 {
472  uint16 handle;
473  uint16 offset;
475 
479 typedef struct
480 {
481  uint16 len;
482  uint8 *pValue;
484 
488 typedef struct
489 {
490  uint8 *pHandles;
491  uint16 numHandles;
493 
497 typedef struct
498 {
499  uint16 len;
500  uint8 *pValues;
502 
506 typedef struct
507 {
508  uint16 startHandle;
509  uint16 endHandle;
512 
516 typedef struct
517 {
518  uint16 numGrps;
519  uint16 len;
520  uint8 *pDataList;
522 
526 typedef struct
527 {
528  uint16 handle;
529  uint16 len;
530  uint8 *pValue;
531  uint8 sig;
532  uint8 cmd;
533 } attWriteReq_t;
534 
538 typedef struct
539 {
540  uint16 handle;
541  uint16 offset;
542  uint16 len;
543  uint8 *pValue;
545 
549 typedef struct
550 {
551  uint16 handle;
552  uint16 offset;
553  uint16 len;
554  uint8 *pValue;
556 
560 typedef struct
561 {
562  uint8 flags;
565 
569 typedef struct
570 {
571  uint16 handle;
572  uint16 len;
573  uint8 *pValue;
575 
579 typedef struct
580 {
581  uint16 handle;
582  uint16 len;
583  uint8 *pValue;
585 
601 typedef struct
602 {
603  uint8 opcode;
606 
615 typedef struct
616 {
617  uint16 MTU;
619 
625 typedef union
626 {
627  // Request messages
639 
640  // Response messages
651 
652  // Indication and Notification messages
655 
656  // Locally-generated event messages
659 } attMsg_t;
660 
661 // Function prototype to notify GATT Server or Client about an outgoing ATT message.
662 typedef void (*attNotifyTxCB_t)( uint16 connHandle, uint8 opcode );
663 
664 /*********************************************************************
665  * VARIABLES
666  */
667 
668 /*********************************************************************
669  * API FUNCTIONS
670  */
671 
672 /*-------------------------------------------------------------------
673  * General Utility APIs
674  */
675 
676 /*
677  * Parse an attribute protocol message.
678  */
679 extern uint8 ATT_ParsePacket( l2capDataEvent_t *pL2capMsg, attPacket_t *pPkt );
680 
681 /*
682  * Compare two UUIDs. The UUIDs are converted if necessary.
683  */
684 extern uint8 ATT_CompareUUID( const uint8 *pUUID1, uint16 len1,
685  const uint8 *pUUID2, uint16 len2 );
686 /*
687  * Convert a 16-bit UUID to 128-bit UUID.
688  */
689 extern uint8 ATT_ConvertUUIDto128( const uint8 *pUUID16, uint8 *pUUID128 );
690 
691 /*
692  * Convert a 128-bit UUID to 16-bit UUID.
693  */
694 extern uint8 ATT_ConvertUUIDto16( const uint8 *pUUID128, uint8 *pUUID16 );
695 
696 
697 /*-------------------------------------------------------------------
698  * Attribute Client Utility APIs
699  */
700 
701 /*
702  * Build Error Response.
703  */
704 extern uint16 ATT_BuildErrorRsp( uint8 *pBuf, uint8 *pMsg );
705 
706 /*
707  * Parse Error Response.
708  */
709 extern bStatus_t ATT_ParseErrorRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
710 
711 /*
712  * Build Exchange MTU Request.
713  */
714 extern uint16 ATT_BuildExchangeMTUReq( uint8 *pBuf, uint8 *pMsg );
715 
716 /*
717  * Build Exchange MTU Response.
718  */
719 extern uint16 ATT_BuildExchangeMTURsp( uint8 *pBuf, uint8 *pMsg );
720 
721 /*
722  * Parse Exchange MTU Response.
723  */
724 extern bStatus_t ATT_ParseExchangeMTURsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
725 
726 /*
727  * Build Find Information Request.
728  */
729 extern uint16 ATT_BuildFindInfoReq( uint8 *pBuf, uint8 *pMsg );
730 
731 /*
732  * Parse Find Information Response.
733  */
734 extern bStatus_t ATT_ParseFindInfoRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
735 
736 /*
737  * Build Find Information Response.
738  */
739 extern uint16 ATT_BuildFindInfoRsp( uint8 *pBuf, uint8 *pMsg );
740 
741 /*
742  * Build Find By Type Value Request.
743  */
744 extern uint16 ATT_BuildFindByTypeValueReq( uint8 *pBuf, uint8 *pMsg );
745 
746 /*
747  * Build Find By Type Value Response.
748  */
749 extern uint16 ATT_BuildFindByTypeValueRsp( uint8 *pBuf, uint8 *pMsg );
750 
751 /*
752  * Parse Find By Type Value Response.
753  */
754 extern bStatus_t ATT_ParseFindByTypeValueRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
755 
756 /*
757  * Build Read By Type Request.
758  */
759 extern uint16 ATT_BuildReadByTypeReq( uint8 *pBuf, uint8 *pMsg );
760 
761 /*
762  * Build Read By Type Response.
763  */
764 extern uint16 ATT_BuildReadByTypeRsp( uint8 *pBuf, uint8 *pMsg );
765 
766 /*
767  * Parse Read By Type Response.
768  */
769 extern bStatus_t ATT_ParseReadByTypeRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
770 
771 /*
772  * Build Read Request.
773  */
774 extern uint16 ATT_BuildReadReq( uint8 *pBuf, uint8 *pMsg );
775 
776 /*
777  * Build Read Response.
778  */
779 extern uint16 ATT_BuildReadRsp( uint8 *pBuf, uint8 *pMsg );
780 
781 /*
782  * Parse Read Response.
783  */
784 extern bStatus_t ATT_ParseReadRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
785 
786 /*
787  * Build Read Blob Request.
788  */
789 extern uint16 ATT_BuildReadBlobReq( uint8 *pBuf, uint8 *pMsg );
790 
791 /*
792  * Build Read Blob Response.
793  */
794 extern uint16 ATT_BuildReadBlobRsp( uint8 *pBuf, uint8 *pMsg );
795 
796 /*
797  * Parse Read Blob Response.
798  */
799 extern bStatus_t ATT_ParseReadBlobRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
800 
801 /*
802  * Build Read Multiple Request.
803  */
804 extern uint16 ATT_BuildReadMultiReq( uint8 *pBuf, uint8 *pMsg );
805 
806 /*
807  * Build Read Multiple Response.
808  */
809 extern uint16 ATT_BuildReadMultiRsp( uint8 *pBuf, uint8 *pMsg );
810 
811 /*
812  * Parse Read Multiple Response.
813  */
814 extern bStatus_t ATT_ParseReadMultiRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
815 
816 /*
817  * Build Read By Group Type Response.
818  */
819 extern uint16 ATT_BuildReadByGrpTypeRsp( uint8 *pBuf, uint8 *pMsg );
820 
821 /*
822  * Parse Read By Group Type Response.
823  */
824 extern bStatus_t ATT_ParseReadByGrpTypeRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
825 
826 /*
827  * Build Write Request.
828  */
829 extern uint16 ATT_BuildWriteReq( uint8 *pBuf, uint8 *pMsg );
830 
831 /*
832  * Parse Write Response.
833  */
834 extern bStatus_t ATT_ParseWriteRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
835 
836 /*
837  * Build Prepare Write Request.
838  */
839 extern uint16 ATT_BuildPrepareWriteReq( uint8 *pBuf, uint8 *pMsg );
840 
841 /*
842  * Build Prepare Write Response.
843  */
844 extern uint16 ATT_BuildPrepareWriteRsp( uint8 *pBuf, uint8 *pMsg );
845 
846 /*
847  * Parse Prepare Write Response.
848  */
849 extern bStatus_t ATT_ParsePrepareWriteRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
850 
851 /*
852  * Build Execute Write Request.
853  */
854 extern uint16 ATT_BuildExecuteWriteReq( uint8 *pBuf, uint8 *pMsg );
855 
856 /*
857  * Parse Execute Write Response.
858  */
859 extern bStatus_t ATT_ParseExecuteWriteRsp( uint8 *pParams, uint16 len, attMsg_t *pMsg );
860 
861 /*
862  * Build Handle Value Indication.
863  */
864 extern uint16 ATT_BuildHandleValueInd( uint8 *pBuf, uint8 *pMsg );
865 
866 /*
867  * Parse Handle Value Indication.
868  */
869 extern bStatus_t ATT_ParseHandleValueInd( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
870 
871 
872 /*-------------------------------------------------------------------
873  * Attribute Server Utility APIs
874  */
875 
876 /*
877  * Parse Exchange MTU Request.
878  */
879 extern bStatus_t ATT_ParseExchangeMTUReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
880 
881 /*
882  * Parse Find Information Request.
883  */
884 extern bStatus_t ATT_ParseFindInfoReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
885 
886 /*
887  * Parse Find By Type Value Request.
888  */
889 extern bStatus_t ATT_ParseFindByTypeValueReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
890 
891 /*
892  * Parse Read By Type Request.
893  */
894 extern bStatus_t ATT_ParseReadByTypeReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
895 
896 /*
897  * Parse Read Request.
898  */
899 extern bStatus_t ATT_ParseReadReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
900 
901 /*
902  * Parse Write Blob Request.
903  */
904 extern bStatus_t ATT_ParseReadBlobReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
905 
906 /*
907  * Parse Read Multiple Request.
908  */
909 extern bStatus_t ATT_ParseReadMultiReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
910 
911 /*
912  * Parse Write Request.
913  */
914 extern bStatus_t ATT_ParseWriteReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
915 
916 /*
917  * Parse Execute Write Request.
918  */
919 extern bStatus_t ATT_ParseExecuteWriteReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
920 
921 /*
922  * Parse Prepare Write Request.
923  */
924 extern bStatus_t ATT_ParsePrepareWriteReq( uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg );
925 
926 /*
927  * Parse Handle Value Confirmation.
928  */
929 extern bStatus_t ATT_ParseHandleValueCfm( uint8 *pParams, uint16 len, attMsg_t *pMsg );
930 
931 
932 /*-------------------------------------------------------------------
933  * Attribute Client Public APIs
934  */
935 
954 extern bStatus_t ATT_ExchangeMTUReq( uint16 connHandle, attExchangeMTUReq_t *pReq );
955 
968 extern bStatus_t ATT_FindInfoReq( uint16 connHandle, attFindInfoReq_t *pReq );
969 
982 extern bStatus_t ATT_FindByTypeValueReq( uint16 connHandle, attFindByTypeValueReq_t *pReq );
983 
996 extern bStatus_t ATT_ReadByTypeReq( uint16 connHandle, attReadByTypeReq_t *pReq );
997 
1010 extern bStatus_t ATT_ReadReq( uint16 connHandle, attReadReq_t *pReq );
1011 
1024 extern bStatus_t ATT_ReadBlobReq( uint16 connHandle, attReadBlobReq_t *pReq );
1025 
1038 extern bStatus_t ATT_ReadMultiReq( uint16 connHandle, attReadMultiReq_t *pReq );
1039 
1052 extern bStatus_t ATT_ReadByGrpTypeReq( uint16 connHandle, attReadByGrpTypeReq_t *pReq );
1053 
1067 extern bStatus_t ATT_WriteReq( uint16 connHandle, attWriteReq_t *pReq );
1068 
1081 extern bStatus_t ATT_PrepareWriteReq( uint16 connHandle, attPrepareWriteReq_t *pReq );
1082 
1095 extern bStatus_t ATT_ExecuteWriteReq( uint16 connHandle, attExecuteWriteReq_t *pReq );
1096 
1108 extern bStatus_t ATT_HandleValueCfm( uint16 connHandle );
1109 
1114 /*-------------------------------------------------------------------
1115  * Attribute Server Public APIs
1116  */
1117 
1136 extern bStatus_t ATT_ErrorRsp( uint16 connHandle, attErrorRsp_t *pRsp );
1137 
1150 extern bStatus_t ATT_ExchangeMTURsp( uint16 connHandle, attExchangeMTURsp_t *pRsp );
1151 
1164 extern bStatus_t ATT_FindInfoRsp( uint16 connHandle, attFindInfoRsp_t *pRsp );
1165 
1178 extern bStatus_t ATT_FindByTypeValueRsp( uint16 connHandle, attFindByTypeValueRsp_t *pRsp );
1179 
1192 extern bStatus_t ATT_ReadByTypeRsp( uint16 connHandle, attReadByTypeRsp_t *pRsp );
1193 
1206 extern bStatus_t ATT_ReadRsp( uint16 connHandle, attReadRsp_t *pRsp );
1207 
1220 extern bStatus_t ATT_ReadBlobRsp( uint16 connHandle, attReadBlobRsp_t *pRsp );
1221 
1234 extern bStatus_t ATT_ReadMultiRsp( uint16 connHandle, attReadMultiRsp_t *pRsp ) ;
1235 
1248 extern bStatus_t ATT_ReadByGrpTypeRsp( uint16 connHandle, attReadByGrpTypeRsp_t *pRsp );
1249 
1261 extern bStatus_t ATT_WriteRsp( uint16 connHandle );
1262 
1275 extern bStatus_t ATT_PrepareWriteRsp( uint16 connHandle, attPrepareWriteRsp_t *pRsp );
1276 
1288 extern bStatus_t ATT_ExecuteWriteRsp( uint16 connHandle );
1289 
1302 extern bStatus_t ATT_HandleValueNoti( uint16 connHandle, attHandleValueNoti_t *pNoti );
1303 
1316 extern bStatus_t ATT_HandleValueInd( uint16 connHandle, attHandleValueInd_t *pInd );
1317 
1322 /*-------------------------------------------------------------------
1323  * Attribute Common Public APIs
1324  */
1325 
1341 extern uint8 ATT_UpdateMTU( uint16 connHandle, uint16 MTU );
1342 
1350 extern uint16 ATT_GetMTU( uint16 connHandle );
1351 
1364 extern void ATT_SetParamValue( uint16 value );
1365 
1373 extern uint16 ATT_GetParamValue( void );
1374 
1382 extern void ATT_RegisterServer( attNotifyTxCB_t pfnNotifyTx );
1383 
1391 extern void ATT_RegisterClient( attNotifyTxCB_t pfnNotifyTx );
1392 
1393 /*********************************************************************
1394 *********************************************************************/
1395 
1396 #ifdef __cplusplus
1397 }
1398 #endif
1399 
1400 #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:394
uint8 * pValue
Part of the value of the attribute with the handle given (0 to ATT_MTU_SIZE-1)
Definition: att.h:482
Definition: att.h:423
bStatus_t ATT_ReadRsp(uint16 connHandle, attReadRsp_t *pRsp)
Send Read Response.
uint16 handle
Handle.
Definition: att.h:376
uint16 clientRxMTU
Client receive MTU size.
Definition: att.h:351
uint8 cmd
Command Flag.
Definition: att.h:532
Definition: att.h:414
attHandleValueInd_t handleValueInd
ATT Handle Value Indication.
Definition: att.h:654
attReadByGrpTypeRsp_t readByGrpTypeRsp
ATT Read By Group Type Response.
Definition: att.h:649
bStatus_t ATT_ReadMultiReq(uint16 connHandle, attReadMultiReq_t *pReq)
Send Read Multiple Request.
uint8 cmd
Command Flag.
Definition: att.h:312
uint16 handle
Found attribute handle.
Definition: att.h:416
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:552
uint16 startHandle
First requested handle number (must be first field)
Definition: att.h:367
attReadByTypeRsp_t readByTypeRsp
ATT Read By Type Response.
Definition: att.h:645
bStatus_t ATT_ExecuteWriteRsp(uint16 connHandle)
Send Execute Write Response.
uint16 numPairs
Number of attribute handle-UUID pairs found.
Definition: att.h:444
Definition: att.h:374
Definition: att.h:339
uint16 len
Length of value.
Definition: att.h:582
uint8 len
Length of UUID (2)
Definition: att.h:332
Definition: att.h:479
uint16 endHandle
Last requested handle number.
Definition: att.h:368
attFindByTypeValueRsp_t findByTypeValueRsp
ATT Find By Type Value Response.
Definition: att.h:644
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:435
Definition: att.h:349
Definition: att.h:615
uint8 * pInfo
Information data whose format is determined by format field (4 to ATT_MTU_SIZE-2) ...
Definition: att.h:396
bStatus_t ATT_PrepareWriteRsp(uint16 connHandle, attPrepareWriteRsp_t *pRsp)
Send Prepare Write Response.
attReadBlobReq_t readBlobReq
ATT Read Blob Request.
Definition: att.h:633
bStatus_t ATT_ReadBlobReq(uint16 connHandle, attReadBlobReq_t *pReq)
Send Read Blob Request.
uint8 format
Format of information data.
Definition: att.h:395
Definition: att.h:516
uint8 sig
Authentication Signature status (not included (0), valid (1), invalid (2))
Definition: att.h:531
uint16 len
Length of each attribute handle, end group handle and value set.
Definition: att.h:519
uint8 * pValue
Current value of the attribute (0 to ATT_MTU_SIZE-3)
Definition: att.h:573
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:648
attHandleValueNoti_t handleValueNoti
ATT Handle Value Notification.
Definition: att.h:653
attMtuUpdatedEvt_t mtuEvt
ATT MTU Updated Event.
Definition: att.h:658
bStatus_t ATT_FindByTypeValueReq(uint16 connHandle, attFindByTypeValueReq_t *pReq)
Send Find By Type Value Request.
Definition: att.h:357
bStatus_t ATT_WriteReq(uint16 connHandle, attWriteReq_t *pReq)
Send Write Request.
uint16 len
Length of value.
Definition: att.h:481
Definition: att.h:488
attReadByTypeReq_t readByTypeReq
ATT Read By Type Request.
Definition: att.h:631
uint8 * pParams
Attribute Parameters.
Definition: att.h:315
attFindByTypeValueReq_t findByTypeValueReq
ATT Find By Type Value Request.
Definition: att.h:630
uint16 len
Length of value.
Definition: att.h:542
attAttrBtType_t type
2-octet UUID to find
Definition: att.h:406
attErrorRsp_t errorRsp
ATT Error Response.
Definition: att.h:641
uint16 handle
Handle.
Definition: att.h:385
uint16 handle
Handle of the attribute to be written (must be first field)
Definition: att.h:528
Definition: att.h:497
uint16 len
Length of Attribute Parameters.
Definition: att.h:314
attReadRsp_t readRsp
ATT Read Response.
Definition: att.h:646
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:581
uint16 len
Length of value.
Definition: att.h:463
Definition: att.h:625
uint16 numHandles
Number of attribute handles.
Definition: att.h:491
bStatus_t ATT_ReadByTypeReq(uint16 connHandle, attReadByTypeReq_t *pReq)
Send Read By Type Request.
attPrepareWriteReq_t prepareWriteReq
ATT Prepare Write Request.
Definition: att.h:637
uint16 startHandle
First requested handle number (must be first field)
Definition: att.h:434
attExecuteWriteReq_t executeWriteReq
ATT Execute Write Request.
Definition: att.h:638
Definition: att.h:383
uint16 handle
Handle of the attribute that has been read.
Definition: att.h:551
uint8 * pValue
Current value of the attribute (0 to ATT_MTU_SIZE-3)
Definition: att.h:583
uint8 * pHandlesInfo
List of 1 or more handles information (4 to ATT_MTU_SIZE-1)
Definition: att.h:426
uint16 len
Length of value.
Definition: att.h:407
uint16 len
Length of values.
Definition: att.h:499
uint8 * pValue
Value of the attribute with the handle given (0 to ATT_MTU_SIZE-1)
Definition: att.h:464
attReadReq_t readReq
ATT Read Request.
Definition: att.h:632
uint16 len
Length of value.
Definition: att.h:572
attReadByGrpTypeReq_t readByGrpTypeReq
ATT Read By Group Type Request.
Definition: att.h:635
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:647
uint8 * pValue
Part of the value of the attribute to be written (0 to ATT_MTU_SIZE-5) - must be allocated.
Definition: att.h:543
attAttrType_t type
Requested group type (2 or 16 octet UUID)
Definition: att.h:510
uint16 startHandle
First requested handle number (must be first field)
Definition: att.h:508
Definition: att.h:453
uint16 len
Length of value.
Definition: att.h:529
uint16 offset
Offset of the first octet to be read.
Definition: att.h:473
Definition: att.h:549
uint8 * pDataList
List of 1 or more attribute handle, end group handle and value (4 to ATT_MTU_SIZE-2) ...
Definition: att.h:520
uint8 len
Length of UUID (2 or 16)
Definition: att.h:323
uint8 * pValue
Part of the value of the attribute to be written (0 to ATT_MTU_SIZE-5)
Definition: att.h:554
uint16 handle
Handle of the attribute to be read (must be first field)
Definition: att.h:472
Definition: att.h:601
uint16 numGrps
Number of attribute handle, end group handle and value sets found.
Definition: att.h:518
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:571
bStatus_t ATT_FindInfoReq(uint16 connHandle, attFindInfoReq_t *pReq)
Send Find Information Request.
Definition: att.h:392
Definition: att.h:402
uint8 sig
Authentication Signature status (not included (0), valid (1), invalid (2))
Definition: att.h:311
uint8 pendingOpcode
opcode of pending message
Definition: att.h:604
uint16 numInfo
Number of handles information found.
Definition: att.h:425
uint16 handle
Handle of the attribute to be read (must be first field)
Definition: att.h:455
Definition: att.h:432
Definition: att.h:365
uint8 * pValue
Value of the attribute to be written (0 to ATT_MTU_SIZE-3)
Definition: att.h:530
uint16 dataLen
Length of data written into pDataList. Not part of actual ATT Response.
Definition: att.h:447
bStatus_t ATT_FindInfoRsp(uint16 connHandle, attFindInfoRsp_t *pRsp)
Send Find Information Response.
Definition: att.h:526
attWriteReq_t writeReq
ATT Write Request.
Definition: att.h:636
attFlowCtrlViolatedEvt_t flowCtrlEvt
ATT Flow Control Violated Event.
Definition: att.h:657
Definition: att.h:579
attPrepareWriteRsp_t prepareWriteRsp
ATT Prepare Write Response.
Definition: att.h:650
uint8 flags
Definition: att.h:562
uint8 method
Method.
Definition: att.h:313
Definition: att.h:442
Definition: att.h:309
Definition: att.h:560
uint16 serverRxMTU
Server receive MTU size.
Definition: att.h:359
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:541
attFindInfoRsp_t findInfoRsp
ATT Find Information Response.
Definition: att.h:643
attAttrType_t type
Requested type (2 or 16 octet UUID)
Definition: att.h:436
attReadMultiReq_t readMultiReq
ATT Read Multiple Request.
Definition: att.h:634
Definition: att.h:321
uint16 endHandle
Last requested handle number.
Definition: att.h:405
uint8 opcode
opcode of message that caused flow control violation
Definition: att.h:603
uint8 reqOpcode
Request that generated this error response.
Definition: att.h:341
uint16 handle
Handle of the attribute to be written (must be first field)
Definition: att.h:540
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:553
uint8 errCode
Reason why the request has generated error response.
Definition: att.h:343
uint16 startHandle
First requested handle number (must be first field)
Definition: att.h:404
uint8 * pDataList
List of 1 or more attribute handle-value pairs (2 to ATT_MTU_SIZE-2)
Definition: att.h:446
uint16 endHandle
Last requested handle number.
Definition: att.h:509
uint8 * pValues
Set of two or more values (0 to ATT_MTU_SIZE-1)
Definition: att.h:500
uint16 grpEndHandle
Group end handle.
Definition: att.h:417
Definition: l2cap.h:623
uint16 MTU
new MTU size
Definition: att.h:617
bStatus_t ATT_HandleValueNoti(uint16 connHandle, attHandleValueNoti_t *pNoti)
Send Handle Value Notification.
Definition: att.h:569
Definition: att.h:461
attExchangeMTURsp_t exchangeMTURsp
ATT Exchange MTU Response.
Definition: att.h:642
uint16 handle
Attribute handle that generated error response.
Definition: att.h:342
uint8 * pHandles
Set of two or more attribute handles (4 to ATT_MTU_SIZE-1) - must be first field. ...
Definition: att.h:490
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:408
bStatus_t ATT_ReadByGrpTypeReq(uint16 connHandle, attReadByGrpTypeReq_t *pReq)
Send Read By Group Type Request.
Definition: att.h:470
Definition: att.h:330
attFindInfoReq_t findInfoReq
ATT Find Information Request.
Definition: att.h:629
attExchangeMTUReq_t exchangeMTUReq
ATT Exchange MTU Request.
Definition: att.h:628
Definition: att.h:506
uint16 len
Size of each attribute handle-value pair.
Definition: att.h:445
Definition: att.h:538