123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659 |
- #ifndef GATTSERVAPP_H
- #define GATTSERVAPP_H
- #ifdef __cplusplus
- extern "C"
- {
- #endif
- #include "bcomdef.h"
- #include "OSAL.h"
- #define GATT_CLIENT_CHAR_CFG_UPDATED_EVENT 0x00
- #define GATT_PROP_BCAST 0x01
- #define GATT_PROP_READ 0x02
- #define GATT_PROP_WRITE_NO_RSP 0x04
- #define GATT_PROP_WRITE 0x08
- #define GATT_PROP_NOTIFY 0x10
- #define GATT_PROP_INDICATE 0x20
- #define GATT_PROP_AUTHEN 0x40
- #define GATT_PROP_EXTENDED 0x80
- #define GATT_EXT_PROP_RELIABLE_WRITE 0x0001
- #define GATT_EXT_PROP_WRITABLE_AUX 0x0002
- #define GATT_CLIENT_CFG_NOTIFY 0x0001
- #define GATT_CLIENT_CFG_INDICATE 0x0002
- #define GATT_SERV_CFG_BCAST 0x0001
- #define GATT_CFG_NO_OPERATION 0x0000
- #define GATT_FORMAT_BOOL 0x01
- #define GATT_FORMAT_2BIT 0x02
- #define GATT_FORMAT_NIBBLE 0x03
- #define GATT_FORMAT_UINT8 0x04
- #define GATT_FORMAT_UINT12 0x05
- #define GATT_FORMAT_UINT16 0x06
- #define GATT_FORMAT_UINT24 0x07
- #define GATT_FORMAT_UINT32 0x08
- #define GATT_FORMAT_UINT48 0x09
- #define GATT_FORMAT_UINT64 0x0a
- #define GATT_FORMAT_UINT128 0x0b
- #define GATT_FORMAT_SINT8 0x0c
- #define GATT_FORMAT_SINT12 0x0d
- #define GATT_FORMAT_SINT16 0x0e
- #define GATT_FORMAT_SINT24 0x0f
- #define GATT_FORMAT_SINT32 0x10
- #define GATT_FORMAT_SINT48 0x11
- #define GATT_FORMAT_SINT64 0x12
- #define GATT_FORMAT_SINT128 0x13
- #define GATT_FORMAT_FLOAT32 0x14
- #define GATT_FORMAT_FLOAT64 0x15
- #define GATT_FORMAT_SFLOAT 0x16
- #define GATT_FORMAT_FLOAT 0x17
- #define GATT_FORMAT_DUINT16 0x18
- #define GATT_FORMAT_UTF8S 0x19
- #define GATT_FORMAT_UTF16S 0x1a
- #define GATT_FORMAT_STRUCT 0x1b
- #define GATT_NS_NONE 0x00
- #define GATT_NS_BT_SIG 0x01
- #define GATT_NS_BT_DESC_UNKNOWN 0x0000
- #define GATT_ALL_SERVICES 0xFFFFFFFF
- #define GATT_SERVICE 0x00000001
- #if defined ( TESTMODES )
-
- #define GATT_TESTMODE_OFF 0
- #define GATT_TESTMODE_NO_RSP 1
- #define GATT_TESTMODE_PREPARE_WRITE 2
- #define GATT_TESTMODE_MAX_MTU_SIZE 3
- #define GATT_TESTMODE_CORRUPT_PW_DATA 4
- #endif
- #define GATT_PARAM_NUM_PREPARE_WRITES 0
- #define GATT_NUM_ATTRS( attrs ) ( sizeof( attrs ) / sizeof( gattAttribute_t ) )
- #define GATT_SERVICE_HANDLE( attrs ) ( (attrs)[0].handle )
- #define GATT_INCLUDED_HANDLE( attrs, i ) ( *((uint16 *)((attrs)[(i)].pValue)) )
- typedef bStatus_t (*pfnGATTReadAttrCB_t)( uint16 connHandle, gattAttribute_t *pAttr,
- uint8 *pValue, uint16 *pLen, uint16 offset,
- uint8 maxLen );
- typedef bStatus_t (*pfnGATTWriteAttrCB_t)( uint16 connHandle, gattAttribute_t *pAttr,
- uint8 *pValue, uint16 len, uint16 offset );
- typedef bStatus_t (*pfnGATTAuthorizeAttrCB_t)( uint16 connHandle, gattAttribute_t *pAttr,
- uint8 opcode );
- typedef struct
- {
- uint8 format;
- int8 exponent;
- uint16 unit;
- uint8 nameSpace;
- uint16 desc;
- } gattCharFormat_t;
- typedef struct
- {
- uint16 connHandle;
- uint8 value;
- } gattCharCfg_t;
- typedef struct
- {
- pfnGATTReadAttrCB_t pfnReadAttrCB;
- pfnGATTWriteAttrCB_t pfnWriteAttrCB;
- pfnGATTAuthorizeAttrCB_t pfnAuthorizeAttrCB;
- } gattServiceCBs_t;
- typedef struct
- {
- osal_event_hdr_t hdr;
- uint16 connHandle;
- uint8 method;
- } gattEventHdr_t;
- typedef struct
- {
- osal_event_hdr_t hdr;
- uint16 connHandle;
- uint8 method;
- uint16 attrHandle;
- uint16 value;
- } gattClientCharCfgUpdatedEvent_t;
- typedef void (*gattServMsgCB_t)( gattMsgEvent_t*pMsg);
- extern void GATTServApp_RegisterForMsg( uint8 taskID );
- extern bStatus_t GATTServApp_RegisterService( gattAttribute_t *pAttrs, uint16 numAttrs,
- CONST gattServiceCBs_t *pServiceCBs );
- bStatus_t GATTServApp_DeregisterService( uint16 handle, gattAttribute_t **p2pAttrs );
- extern gattAttribute_t *GATTServApp_FindAttr( gattAttribute_t *pAttrTbl,
- uint16 numAttrs, uint8 *pValue );
- extern bStatus_t GATTServApp_AddService( uint32 services );
- extern bStatus_t GATTServApp_DelService( uint32 services );
- extern bStatus_t GATTServApp_SetParameter( uint8 param, uint8 len, void *pValue );
- extern bStatus_t GATTServApp_GetParameter( uint8 param, void *pValue );
- extern bStatus_t GATTServApp_UpdateCharCfg( uint16 connHandle, uint16 attrHandle, uint16 value );
- extern void GATTServApp_InitCharCfg( uint16 connHandle, gattCharCfg_t *charCfgTbl );
- extern uint16 GATTServApp_ReadCharCfg( uint16 connHandle, gattCharCfg_t *charCfgTbl );
- extern uint8 GATTServApp_WriteCharCfg( uint16 connHandle, gattCharCfg_t *charCfgTbl, uint16 value );
- extern bStatus_t GATTServApp_ProcessCCCWriteReq( uint16 connHandle, gattAttribute_t *pAttr,
- uint8 *pValue, uint8 len, uint16 offset,
- uint16 validCfg );
- extern bStatus_t GATTServApp_ProcessCharCfg( gattCharCfg_t *charCfgTbl, uint8 *pValue,
- uint8 authenticated, gattAttribute_t *attrTbl,
- uint16 numAttrs, uint8 taskId );
- extern void GATTServApp_SendCCCUpdatedEvent( uint16 connHandle, uint16 attrHandle, uint16 value );
- extern bStatus_t GATTServApp_SendServiceChangedInd( uint16 connHandle, uint8 taskId );
- extern uint8 GATTServApp_ReadAttr( uint16 connHandle, gattAttribute_t *pAttr,
- uint16 service, uint8 *pValue, uint16 *pLen,
- uint16 offset, uint8 maxLen );
- extern uint8 GATTServApp_WriteAttr( uint16 connHandle, uint16 handle,
- uint8 *pValue, uint16 len, uint16 offset );
- extern void GATTServApp_SetParamValue( uint16 value );
- extern uint16 GATTServApp_GetParamValue( void );
- extern void GATTServApp_Init( uint8 taskId );
- extern uint16 GATTServApp_ProcessEvent( uint8 taskId, uint16 events );
- bStatus_t gattServApp_RegisterCB(gattServMsgCB_t cb);
- #ifdef __cplusplus
- }
- #endif
- #endif
|