TI BLE-Stack for Bluetooth API Documentation  3.03.01.00
gattservapp.h
Go to the documentation of this file.
1 /******************************************************************************
2 
3  Group: WCS, BTS
4  $Target Device: DEVICES $
5 
6  ******************************************************************************
7  $License: BSD3 2009 $
8  ******************************************************************************
9  $Release Name: PACKAGE NAME $
10  $Release Date: PACKAGE RELEASE DATE $
11  *****************************************************************************/
12 
21 #ifndef GATTSERVAPP_H
22 #define GATTSERVAPP_H
23 
24 #ifdef __cplusplus
25 extern "C"
26 {
27 #endif
28 
29 /*********************************************************************
30  * INCLUDES
31  */
32 #include "bcomdef.h"
33 #include "osal.h"
34 
35 /*********************************************************************
36  * CONSTANTS
37  */
38 
47 #define GATT_CLIENT_CHAR_CFG_UPDATED_EVENT 0x00
48 
49 
56 #define GATT_PROP_BCAST 0x01
57 #define GATT_PROP_READ 0x02
58 #define GATT_PROP_WRITE_NO_RSP 0x04
59 #define GATT_PROP_WRITE 0x08
60 #define GATT_PROP_NOTIFY 0x10
61 #define GATT_PROP_INDICATE 0x20
62 #define GATT_PROP_AUTHEN 0x40
63 #define GATT_PROP_EXTENDED 0x80
64 
65 
71 #define GATT_EXT_PROP_RELIABLE_WRITE 0x0001
72 #define GATT_EXT_PROP_WRITABLE_AUX 0x0002
73 
74 
80 #define GATT_CLIENT_CFG_NOTIFY 0x0001
81 #define GATT_CLIENT_CFG_INDICATE 0x0002
82 
83 
89 #define GATT_SERV_CFG_BCAST 0x0001
90 
91 
93 #define GATT_CFG_NO_OPERATION 0x0000
94 
95 
99 #define GATT_FORMAT_BOOL 0x01
100 #define GATT_FORMAT_2BIT 0x02
101 #define GATT_FORMAT_NIBBLE 0x03
102 #define GATT_FORMAT_UINT8 0x04
103 #define GATT_FORMAT_UINT12 0x05
104 #define GATT_FORMAT_UINT16 0x06
105 #define GATT_FORMAT_UINT24 0x07
106 #define GATT_FORMAT_UINT32 0x08
107 #define GATT_FORMAT_UINT48 0x09
108 #define GATT_FORMAT_UINT64 0x0a
109 #define GATT_FORMAT_UINT128 0x0b
110 #define GATT_FORMAT_SINT8 0x0c
111 #define GATT_FORMAT_SINT12 0x0d
112 #define GATT_FORMAT_SINT16 0x0e
113 #define GATT_FORMAT_SINT24 0x0f
114 #define GATT_FORMAT_SINT32 0x10
115 #define GATT_FORMAT_SINT48 0x11
116 #define GATT_FORMAT_SINT64 0x12
117 #define GATT_FORMAT_SINT128 0x13
118 #define GATT_FORMAT_FLOAT32 0x14
119 #define GATT_FORMAT_FLOAT64 0x15
120 #define GATT_FORMAT_SFLOAT 0x16
121 #define GATT_FORMAT_FLOAT 0x17
122 #define GATT_FORMAT_DUINT16 0x18
123 #define GATT_FORMAT_UTF8S 0x19
124 #define GATT_FORMAT_UTF16S 0x1a
125 #define GATT_FORMAT_STRUCT 0x1b
126 
127 
132 #define GATT_NS_NONE 0x00
133 #define GATT_NS_BT_SIG 0x01
134 #define GATT_NS_BT_DESC_UNKNOWN 0x0000
135 
137 #define GATT_ALL_SERVICES 0xFFFFFFFF
139 
141 #define GATT_SERVICE 0x00000001
142 
144 #if defined ( TESTMODES )
145  // GATT Test Modes
146  #define GATT_TESTMODE_OFF 0 // Test mode off
147  #define GATT_TESTMODE_NO_RSP 1 // Ignore incoming request
148  #define GATT_TESTMODE_PREPARE_WRITE 2 // Forward Prepare Write Request right away
149  #define GATT_TESTMODE_MAX_MTU_SIZE 3 // Use Max ATT MTU size with Exchange MTU Rsp
150  #define GATT_TESTMODE_CORRUPT_PW_DATA 4 // Corrupt incoming Prepare Write Request data
151 #endif
152 
157 #define GATT_PARAM_NUM_PREPARE_WRITES 0
158 
160 #define PTR_TYPE unsigned int *
163 
166 #define GATT_LOCAL_READ 0xFF
167 #define GATT_LOCAL_WRITE 0xFE
169 
172 /*********************************************************************
173  * VARIABLES
174  */
175 
176 /*********************************************************************
177  * MACROS
178  */
179 
181 #define GATT_NUM_ATTRS( attrs ) ( sizeof( attrs ) / sizeof( gattAttribute_t ) )
182 
184 #define GATT_SERVICE_HANDLE( attrs ) ( (attrs)[0].handle )
185 
187 #define GATT_INCLUDED_HANDLE( attrs, i ) ( *((uint16 *)((attrs)[(i)].pValue)) )
188 
190 #define GATT_CCC_TBL( pValue ) ( (gattCharCfg_t *)(*((PTR_TYPE)(pValue))) )
191 
192 /*********************************************************************
193  * TYPEDEFS
194  */
195 
231 typedef bStatus_t (*pfnGATTReadAttrCB_t)( uint16 connHandle, gattAttribute_t *pAttr,
232  uint8 *pValue, uint16 *pLen, uint16 offset,
233  uint16 maxLen, uint8 method );
234 
266 typedef bStatus_t (*pfnGATTWriteAttrCB_t)( uint16 connHandle, gattAttribute_t *pAttr,
267  uint8 *pValue, uint16 len, uint16 offset,
268  uint8 method );
280 typedef bStatus_t (*pfnGATTAuthorizeAttrCB_t)( uint16 connHandle, gattAttribute_t *pAttr,
281  uint8 opcode );
282 
289 typedef struct
291 {
292  uint8 format;
293  int8 exponent;
294  uint16 unit;
295  uint8 nameSpace;
296  uint16 desc;
298 
300 typedef struct
301 {
302  uint16 connHandle;
303  uint8 value;
304 } gattCharCfg_t;
305 
312 typedef struct
313 {
318 
320 typedef struct
321 {
323  uint16 connHandle;
324  uint8 method;
326 
333 typedef struct
334 {
336  uint16 connHandle;
337  uint8 method;
338  uint16 attrHandle;
339  uint16 value;
341 
342 
344 typedef struct
345 {
346  uint16 connHandle;
349 
351 typedef struct
352 {
353  uint16 handle;
356 
358 typedef struct _serviceCBsList
359 {
363 
364 
365 /*********************************************************************
366  * VARIABLES
367  */
368 
371 
374 
377 /*********************************************************************
378  * API FUNCTIONS
379  */
380 
387 extern void GATTServApp_RegisterForMsg( uint8 taskID );
388 
405  uint16 numAttrs, uint8 encKeySize,
406  CONST gattServiceCBs_t *pServiceCBs );
407 
422 bStatus_t GATTServApp_DeregisterService( uint16 handle, gattAttribute_t **p2pAttrs );
423 
436  uint16 numAttrs, uint8 *pValue );
448 extern bStatus_t GATTServApp_AddService( uint32 services );
449 
459 extern bStatus_t GATTServApp_DelService( uint32 services );
460 
477 extern bStatus_t GATTServApp_SetParameter( uint8 param, uint8 len, void *pValue );
478 
491 extern bStatus_t GATTServApp_GetParameter( uint8 param, void *pValue );
492 
507 extern bStatus_t GATTServApp_UpdateCharCfg( uint16 connHandle, uint16 attrHandle, uint16 value );
508 
521 extern void GATTServApp_InitCharCfg( uint16 connHandle, gattCharCfg_t *charCfgTbl );
522 
538 extern uint16 GATTServApp_ReadCharCfg( uint16 connHandle, gattCharCfg_t *charCfgTbl );
539 
556 extern uint8 GATTServApp_WriteCharCfg( uint16 connHandle, gattCharCfg_t *charCfgTbl, uint16 value );
557 
576 extern bStatus_t GATTServApp_ProcessCCCWriteReq( uint16 connHandle, gattAttribute_t *pAttr,
577  uint8 *pValue, uint16 len, uint16 offset,
578  uint16 validCfg );
579 
598 extern bStatus_t GATTServApp_ProcessCharCfg( gattCharCfg_t *charCfgTbl, uint8 *pValue,
599  uint8 authenticated, gattAttribute_t *attrTbl,
600  uint16 numAttrs, uint8 taskId,
601  pfnGATTReadAttrCB_t pfnReadAttrCB );
602 
611 extern void GATTServApp_SendCCCUpdatedEvent( uint16 connHandle, uint16 attrHandle, uint16 value );
612 
626 extern bStatus_t GATTServApp_SendServiceChangedInd( uint16 connHandle, uint8 taskId );
627 
645 extern uint8 GATTServApp_ReadAttr( uint16 connHandle, gattAttribute_t *pAttr,
646  uint16 service, uint8 *pValue, uint16 *pLen,
647  uint16 offset, uint16 maxLen, uint8 method );
648 
662 extern uint8 GATTServApp_WriteAttr( uint16 connHandle, uint16 handle,
663  uint8 *pValue, uint16 len, uint16 offset,
664  uint8 method );
665 
679 extern bStatus_t GATTServApp_ReadRsp( uint16 connHandle, uint8 *pValue,
680  uint16 pLen, uint16 offset );
681 
688 extern void GATTServApp_SetParamValue( uint16 value );
689 
695 extern uint16 GATTServApp_GetParamValue( void );
696 
697 /*-------------------------------------------------------------------
698  * TASK API - These functions must only be called by OSAL.
699  */
700 
702 
713 extern void GATTServApp_Init( uint8 taskId );
714 
726 extern uint16 GATTServApp_ProcessEvent( uint8 taskId, uint16 events );
727 
737 extern pfnGATTAuthorizeAttrCB_t gattServApp_FindAuthorizeAttrCB( uint16 handle );
738 
749 extern bStatus_t gattServApp_EnqueuePrepareWriteReq( uint16 connHandle, attPrepareWriteReq_t *pReq );
750 
762 extern bStatus_t gattServApp_ProcessWriteLong( gattMsgEvent_t *pMsg, prepareWrites_t *pQueue, uint16 *pErrHandle );
763 
775 extern bStatus_t gattServApp_ProcessReliableWrites( gattMsgEvent_t *pMsg, prepareWrites_t *pQueue, uint16 *pErrHandle );
776 
790 extern bStatus_t gattServApp_buildReadByTypeRsp( uint16 connHandle, uint8 *pAttrValue, uint16 attrLen, uint16 attrHandle );
791 
801 extern prepareWrites_t *gattServApp_FindPrepareWriteQ( uint16 connHandle );
802 
813 extern uint8 gattServApp_IsWriteLong( attExecuteWriteReq_t *pReq, prepareWrites_t *pQueue );
814 
822 extern void gattServApp_ClearPrepareWriteQ( prepareWrites_t *pQueue );
823 
825 
826 /*********************************************************************
827 *********************************************************************/
828 
829 #ifdef __cplusplus
830 }
831 #endif
832 
833 #endif /* GATTSERVAPP_H */
834 
uint16 GATTServApp_GetParamValue(void)
Get a GATT Server Application Parameter value.
GATT Structure for Characteristic Presentation Format Value.
Definition: gattservapp.h:290
This API allows the software components in the Z-Stack to be written independently of the specifics o...
uint16 connHandle
Connection message was received on.
Definition: gattservapp.h:323
gattServiceCBsInfo_t serviceInfo
service handle/callbacks
Definition: gattservapp.h:361
GATT Server App event header format.
Definition: gattservapp.h:320
void GATTServApp_SetParamValue(uint16 value)
Set a GATT Server Application Parameter value. Use this function to change the default GATT parameter...
gattAttribute_t * GATTServApp_FindAttr(gattAttribute_t *pAttrTbl, uint16 numAttrs, uint8 *pValue)
Find the attribute record within a service attribute table for a given attribute value pointer...
pfnGATTAuthorizeAttrCB_t pfnAuthorizeAttrCB
Authorization callback function pointer.
Definition: gattservapp.h:316
Service callbacks list item.
Definition: gattservapp.h:358
void GATTServApp_SendCCCUpdatedEvent(uint16 connHandle, uint16 attrHandle, uint16 value)
Build and send the GATT_CLIENT_CHAR_CFG_UPDATED_EVENT to the application.
uint16 handle
Service handle - assigned internally by GATT Server.
Definition: gattservapp.h:353
Structure to keep Prepare Write Requests for each Client.
Definition: gattservapp.h:344
bStatus_t GATTServApp_GetParameter(uint8 param, void *pValue)
Get a GATT Server parameter.
pfnGATTWriteAttrCB_t pfnWriteAttrCB
Write callback function pointer.
Definition: gattservapp.h:315
prepareWrites_t * prepareWritesTbl
Server Prepare Write table (one entry per each physical link)
GATT Structure to keep CBs information for each service being registered.
Definition: gattservapp.h:351
uint8 value
Characteristic configuration value for this client.
Definition: gattservapp.h:303
bStatus_t GATTServApp_AddService(uint32 services)
Add function for the GATT Service.
pfnGATTReadAttrCB_t pfnReadAttrCB
Read callback function pointer.
Definition: gattservapp.h:314
bStatus_t(* pfnGATTReadAttrCB_t)(uint16 connHandle, gattAttribute_t *pAttr, uint8 *pValue, uint16 *pLen, uint16 offset, uint16 maxLen, uint8 method)
Callback function prototype to read an attribute value.
Definition: gattservapp.h:231
uint8 format
Format of the value of this characteristic.
Definition: gattservapp.h:292
bStatus_t GATTServApp_ReadRsp(uint16 connHandle, uint8 *pValue, uint16 pLen, uint16 offset)
If a service returns blePending to the read attribute call back invoked from GATTServApp, the service can later respond to with the value to be read using this API.
uint8 GATTServApp_WriteAttr(uint16 connHandle, uint16 handle, uint8 *pValue, uint16 len, uint16 offset, uint8 method)
Write attribute data.
struct _serviceCBsList * next
pointer to next service callbacks record
Definition: gattservapp.h:360
Structure for Client Characteristic Configuration.
Definition: gattservapp.h:300
osal_event_hdr_t hdr
GATT_SERV_MSG_EVENT and status.
Definition: gattservapp.h:322
uint16 connHandle
Client connection handle.
Definition: gattservapp.h:302
bStatus_t GATTServApp_ProcessCharCfg(gattCharCfg_t *charCfgTbl, uint8 *pValue, uint8 authenticated, gattAttribute_t *attrTbl, uint16 numAttrs, uint8 taskId, pfnGATTReadAttrCB_t pfnReadAttrCB)
Process Client Characteristic Configuration change.
uint16 GATTServApp_ReadCharCfg(uint16 connHandle, gattCharCfg_t *charCfgTbl)
Read the client characteristic configuration for a given client.
void GATTServApp_RegisterForMsg(uint8 taskID)
Register your task ID to receive event messages from the GATT Server Application. ...
attPrepareWriteReq_t * pPrepareWriteQ
Prepare Write Request queue.
Definition: gattservapp.h:347
void GATTServApp_InitCharCfg(uint16 connHandle, gattCharCfg_t *charCfgTbl)
Initialize the client characteristic configuration table.
uint16 value
attribute new value
Definition: gattservapp.h:339
uint16 connHandle
Connection message was received on.
Definition: gattservapp.h:336
Type definitions and macros for BLE stack.
bStatus_t GATTServApp_SetParameter(uint8 param, uint8 len, void *pValue)
Set a GATT Server parameter.
bStatus_t GATTServApp_SendServiceChangedInd(uint16 connHandle, uint8 taskId)
Send out a Service Changed Indication.
bStatus_t GATTServApp_DelService(uint32 services)
Delete function for the GATT Service.
uint32_t len
Image length in bytes.
Definition: oad_image_header.h:662
uint16 connHandle
connection message was received on
Definition: gattservapp.h:346
uint16 attrHandle
attribute handle
Definition: gattservapp.h:338
serviceCBsList_t * serviceCBsList
Callbacks for services.
OSAL Event Header.
Definition: osal.h:92
GATT_CLIENT_CHAR_CFG_UPDATED_EVENT message format.
Definition: gattservapp.h:333
uint16 unit
Unit of this attribute as defined in the data dictionary.
Definition: gattservapp.h:294
uint8 nameSpace
Name space of the description.
Definition: gattservapp.h:295
struct _serviceCBsList serviceCBsList_t
Service callbacks list item.
GATT GATT_MSG_EVENT message format.
Definition: gatt.h:211
uint8 method
GATT type of command. Ref: GATT Server Message IDs.
Definition: gattservapp.h:324
bStatus_t GATTServApp_RegisterService(gattAttribute_t *pAttrs, uint16 numAttrs, uint8 encKeySize, CONST gattServiceCBs_t *pServiceCBs)
Register a service's attribute list and callback functions with the GATT Server Application.
bStatus_t GATTServApp_ProcessCCCWriteReq(uint16 connHandle, gattAttribute_t *pAttr, uint8 *pValue, uint16 len, uint16 offset, uint16 validCfg)
Process the client characteristic configuration write request for a given client. ...
osal_event_hdr_t hdr
GATT_SERV_MSG_EVENT and status.
Definition: gattservapp.h:335
GATT Attribute format.
Definition: gatt.h:240
Status_t bStatus_t
BLE Generic Status return.
Definition: bcomdef.h:233
CONST gattServiceCBs_t * pCBs
Service callback function pointers.
Definition: gattservapp.h:354
uint16 desc
Description of this attribute as defined in a higher layer profile.
Definition: gattservapp.h:296
Prepare Write Request format.
Definition: att.h:545
uint8 method
GATT_CLIENT_CHAR_CFG_UPDATED_EVENT.
Definition: gattservapp.h:337
int8 exponent
A sign integer which represents the exponent of an integer.
Definition: gattservapp.h:293
bStatus_t GATTServApp_UpdateCharCfg(uint16 connHandle, uint16 attrHandle, uint16 value)
Update the Client Characteristic Configuration for a given Client.
uint8 GATTServApp_WriteCharCfg(uint16 connHandle, gattCharCfg_t *charCfgTbl, uint16 value)
Write the client characteristic configuration for a given client.
GATT Structure for service callback functions.
Definition: gattservapp.h:312
bStatus_t(* pfnGATTAuthorizeAttrCB_t)(uint16 connHandle, gattAttribute_t *pAttr, uint8 opcode)
Callback function prototype to authorize a Read or Write operation on a given attribute.
Definition: gattservapp.h:280
Execute Write Request format.
Definition: att.h:571
bStatus_t GATTServApp_DeregisterService(uint16 handle, gattAttribute_t **p2pAttrs)
Deregister a service's attribute list and callback functions from the GATT Server Application...
bStatus_t(* pfnGATTWriteAttrCB_t)(uint16 connHandle, gattAttribute_t *pAttr, uint8 *pValue, uint16 len, uint16 offset, uint8 method)
Callback function prototype to write an attribute value.
Definition: gattservapp.h:266
uint8 GATTServApp_ReadAttr(uint16 connHandle, gattAttribute_t *pAttr, uint16 service, uint8 *pValue, uint16 *pLen, uint16 offset, uint16 maxLen, uint8 method)
Read an attribute. If the format of the attribute value is unknown to GATT Server, use the callback function provided by the Service.
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale