Infineon Logo AIROC BTSDK v4.9 - Documentation
 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups
legattdb.h File Reference

This file provides definitions and macros for generating GATT database. More...

Macros

#define LEATTDB_GET_UINT16(a)   ( * ((UINT16 *)(a)) )
 
#define LEATTDB_SET_UINT16(a, b)   ( * ((UINT16 *)(a)) = (b) )
 
#define LEATTDB_LAST_HANDLE   0xffff
 
#define LEGATTDB_PERM_NONE   (0x00)
 
#define LEGATTDB_PERM_VARIABLE_LENGTH   (0x1<<0)
 
#define LEGATTDB_PERM_READABLE   (0x1<<1)
 
#define LEGATTDB_PERM_WRITE_CMD   (0x1<<2)
 
#define LEGATTDB_PERM_WRITE_REQ   (0x1<<3)
 
#define LEGATTDB_PERM_AUTH_READABLE   (0x1<<4)
 
#define LEGATTDB_PERM_RELIABLE_WRITE   (0x1<<5)
 
#define LEGATTDB_PERM_AUTH_WRITABLE   (0x1<<6)
 
#define LEGATTDB_PERM_WRITABLE   (LEGATTDB_PERM_WRITE_CMD | LEGATTDB_PERM_WRITE_REQ| LEGATTDB_PERM_AUTH_WRITABLE)
 
#define LEGATTDB_PERM_MASK   (0x7f)
 
#define LEGATTDB_PERM_SERVCIE_UUID_128   (0x1<<7)
 
#define LEGATTDB_CHAR_PROP_BROADCAST   (0x1<<0)
 
#define LEGATTDB_CHAR_PROP_READ   (0x1<<1)
 
#define LEGATTDB_CHAR_PROP_WRITE_NO_RESPONSE   (0x1<<2)
 
#define LEGATTDB_CHAR_PROP_WRITE   (0x1<<3)
 
#define LEGATTDB_CHAR_PROP_NOTIFY   (0x1<<4)
 
#define LEGATTDB_CHAR_PROP_INDICATE   (0x1<<5)
 
#define LEGATTDB_CHAR_PROP_AUTHD_WRITES   (0x1<<6)
 
#define LEGATTDB_CHAR_PROP_EXTENDED   (0x1<<7)
 
#define LEGATTDB_PERM_FLAG_WRITE_CMD   LEGATTDB_PERM_WRITE_CMD
 
#define LEGATTDB_PERM_FLAG_AUTH   LEGATTDB_PERM_AUTH_WRITABLE
 
#define LEGATTDB_PERM_FLAG_INTERNAL   (0x1ul << 31)
 

Typedefs

struct {
   UINT16   handle
 
   UINT8   perm
 
   UINT8   len
 
LEGATTDB_ENTRY_HDR
 
struct {
   UINT16   handle
 
   UINT8   perm
 
   UINT8   len
 
   UINT8   maxLen
 
LEGATTDB_WRITABLE_ENTRY_HDR
 
struct {
   UINT16   handle
 
   UINT8   perm
 
   UINT16   len
 
LEGATTDB_ENTRY_HDR16
 
struct {
   UINT16   handle
 
   UINT8   perm
 
   UINT16   len
 
   UINT16   maxLen
 
LEGATTDB_WRITABLE_ENTRY_HDR16
 
typedef INT32(* LEGATTDB_WRITE_CB )(void *)
 

Functions

void legattdb_init (void)
 GATT DB Initi. More...
 
void legattdb_SetDb (UINT8 *ptr, UINT16 size)
 
INT32 legattdb_readBlob (UINT16 handle, INT32 offset, LEATT_INTERNAL_PDU *pdu)
 
INT32 legattdb_readMultipleReq (UINT8 *attrHandleList, INT32 numAttrHandles, LEATT_INTERNAL_PDU *pdu)
 
INT32 legattdb_findInfo (UINT16 startHandle, UINT16 endHandle, LEATT_INTERNAL_PDU *outPdu)
 
INT32 legattdb_readByAttrGroupTypeUUID16 (UINT16 startHandle, UINT16 endHandle, UINT16 uuid, LEATT_INTERNAL_PDU *outPdu)
 
void legattdb_readByGroupTypeUUID128 (UINT16 startHandle, UINT16 endHandle, UINT8 *uuid, LEATT_INTERNAL_PDU *outPdu)
 
INT32 legattdb_findByTypeValue (UINT16 startHandle, UINT16 endHandle, UINT16 uuid, UINT8 *attrValue, INT32 attrValueLen, LEATT_INTERNAL_PDU *outPdu)
 
INT32 legattdb_readByType (UINT16 startHandle, UINT16 endHandle, INT32 uuidLen, UINT8 *uuid, LEATT_INTERNAL_PDU *outPdu)
 
INT32 legattdb_readHandle (UINT16 handle, LEATT_INTERNAL_PDU *pdu, UINT32 permFlag)
 
INT32 legattdb_writeHandle (UINT16 handle, UINT16 offset, UINT8 *attrValue, INT32 attrValLen, UINT32 permFlag)
 
INT32 legattdb_prepareWriteReq (LEATT_PDU_PREPARE_WRITE_REQ_HDR *hdr, INT32 attrValLen)
 
INT32 legattdb_executeWriteReq (UINT8 flag)
 
void legattdb_dumpDb (void)
 
UINT8 legattdb_checkNotificationDb (void)
 
LEGATTDB_ENTRY_HDR * legattdb_nextEntry (LEGATTDB_ENTRY_HDR *p)
 Get Next database entry. More...
 
UINT16 legattdb_getHandle (LEGATTDB_ENTRY_HDR *p)
 Get entry handle. More...
 
UINT16 legattdb_getAttrUUID16 (LEGATTDB_ENTRY_HDR *p)
 Get entry handle. More...
 
INT32 legattdb_getAttrUUID (LEGATTDB_ENTRY_HDR *h, UINT8 *buf)
 Copy UUID of an entry to a buffer. More...
 
UINT16 legattdb_getAttrValueUUID16 (LEGATTDB_ENTRY_HDR *p)
 Get value UUID. More...
 
UINT8 * legattdb_getAttrValue (LEGATTDB_ENTRY_HDR *p)
 Get Attribute Value. More...
 
INT32 legattdb_getAttrValueLen (LEGATTDB_ENTRY_HDR *p)
 Get Attribute Value Length. More...
 
void legattdb_setAttrValueLen (LEGATTDB_ENTRY_HDR *p, INT32 len)
 Set Attribute Value Length. More...
 
INT32 legattdb_getMaxWritableAttrValueLen (LEGATTDB_ENTRY_HDR *p)
 Get Maxmimut Writable Attribute Value Length. More...
 
INT32 legattdb_writeAttrValue (LEGATTDB_ENTRY_HDR *p, UINT16 offset, UINT8 *val, INT32 len, UINT32 permFlag)
 Update Value of the Attribute. More...
 
INT32 legattdb_getPerm (LEGATTDB_ENTRY_HDR *p)
 Get Attribute Permissions. More...
 
UINT8 * legattdb_getAttrPtr (LEGATTDB_ENTRY_HDR *p)
 Get Pointer to Attribute. More...
 
INT32 legattdb_uuidIsTheSame (INT32 uuidLen_1, UINT8 *uuidPtr_1, INT32 uuidLen_2, UINT8 *uuidPtr_2)
 Compare UUIDs. More...
 
UINT32 legattdb_checkPermission (INT32 permToCheck, UINT32 perm, LEGATTDB_ENTRY_HDR *p)
 
void legattdb_connDown ()
 
void legattdb_connUp ()
 
INT32 legattdb_regWriteHandleCb (LEGATTDB_WRITE_CB cb)
 Register write callback. More...
 
void legattdb_deRegWriteHandleCb (LEGATTDB_WRITE_CB cb)
 Register write callback. More...
 
INT32 legattdb_dispatchWriteCb (LEGATTDB_ENTRY_HDR *p)
 
UINT32 legattdb_checkEncAuthRequirement ()
 
UINT16 legattdb_findCharacteristicDescriptor (UINT16 char_handle, UINT16 descriptor_uuid)
 Finds Characteristic Descriptor. More...
 

Detailed Description

This file provides definitions and macros for generating GATT database.

Function Documentation

void legattdb_deRegWriteHandleCb ( LEGATTDB_WRITE_CB  cb)

Register write callback.

This function de-register a callback set by legattdb_regWriteHandleCb

Parameters
cbPointer to the application callback.
UINT16 legattdb_findCharacteristicDescriptor ( UINT16  char_handle,
UINT16  descriptor_uuid 
)

Finds Characteristic Descriptor.

This function finds descriptor with specified UUID which belongs to the specific characteristic

Parameters
cbPointer to the application callback.
UINT8* legattdb_getAttrPtr ( LEGATTDB_ENTRY_HDR *  p)

Get Pointer to Attribute.

This function will return a pointer to the actual attribute skipping over the header.

Parameters
pPointer to the entry.
Returns
Pointer to the attribute.
INT32 legattdb_getAttrUUID ( LEGATTDB_ENTRY_HDR *  h,
UINT8 *  buf 
)

Copy UUID of an entry to a buffer.

This function will copy UUID of the entry to a buf

Parameters
pPointer to the current entry.
Returns
Length of the UUID which can be 2 or 16 bytes.
UINT16 legattdb_getAttrUUID16 ( LEGATTDB_ENTRY_HDR *  p)

Get entry handle.

This will return a attribute UUID in the entry. If the attribute uuid is not 2 bytes the function will return invalid uuid 0x00.

Parameters
pPointer to the current entry.
Returns
Attribute UUID of the entry.
UINT8* legattdb_getAttrValue ( LEGATTDB_ENTRY_HDR *  p)

Get Attribute Value.

This function will return a pointer to the attribute value.

Parameters
pPointer to the current entry.
Returns
Pointer to the attribute value.
INT32 legattdb_getAttrValueLen ( LEGATTDB_ENTRY_HDR *  p)

Get Attribute Value Length.

This function returns length of the attribute value.

Parameters
pPointer to the current entry.
Returns
Length of the attrbute value.
UINT16 legattdb_getAttrValueUUID16 ( LEGATTDB_ENTRY_HDR *  p)

Get value UUID.

This is a convenient function. It returns the attribute value in the form of UUID16. Caller need to be sure this is a UUID16. Or else it...

Parameters
pPointer to the current entry.
Returns
Value UUID of the entry.
UINT16 legattdb_getHandle ( LEGATTDB_ENTRY_HDR *  p)

Get entry handle.

This function returns the attribute handle of this entry.

Parameters
pPointer to the current entry.
Returns
Handle of the entry.
INT32 legattdb_getMaxWritableAttrValueLen ( LEGATTDB_ENTRY_HDR *  p)

Get Maxmimut Writable Attribute Value Length.

This function return the maximum writable attribute length. If the attribute is not writable, it will return 0.

Parameters
pPointer to the current entry.
Returns
Length that can be written to the current entrie's value, or 0 if not writable.
INT32 legattdb_getPerm ( LEGATTDB_ENTRY_HDR *  p)

Get Attribute Permissions.

This function will return permission byte of the attribute.

Parameters
pPointer to the entry.
Returns
Permission byte.
void legattdb_init ( void  )

GATT DB Initi.

This function should be called to initialize the variable.

LEGATTDB_ENTRY_HDR* legattdb_nextEntry ( LEGATTDB_ENTRY_HDR *  p)

Get Next database entry.

This function will return a pointer to next entry.

Parameters
pPointer to the current entry
Returns
Pointer to the next entry, or NULL if the entry is the last in the database.
INT32 legattdb_regWriteHandleCb ( LEGATTDB_WRITE_CB  cb)

Register write callback.

This function register a callback when data is written

Parameters
cbPointer to the application callback.
Returns
TRUE if callback was set successully, FALSE if not enough space.
void legattdb_setAttrValueLen ( LEGATTDB_ENTRY_HDR *  p,
INT32  len 
)

Set Attribute Value Length.

This function change the length of current attriute length.

Parameters
pPointer to the current entry.
lenNew length.
INT32 legattdb_uuidIsTheSame ( INT32  uuidLen_1,
UINT8 *  uuidPtr_1,
INT32  uuidLen_2,
UINT8 *  uuidPtr_2 
)

Compare UUIDs.

This function will compare the UUID of _1 and _2 . It return TRUE if they are the same. if the size of the two uuid are not the same, they will be converted to 128 bit uuid for comparison.

Parameters
uuidLen_1Length of the first UUID to compare.
uuidPtr_1Pointer to the first UUID to compare.
uuidLen_2Length of the second UUID to compare.
uuidPtr_2Pointer to the second UUID to compare.
Returns
TRUE if UUIDs are the same, FALSE otherwise.
INT32 legattdb_writeAttrValue ( LEGATTDB_ENTRY_HDR *  p,
UINT16  offset,
UINT8 *  val,
INT32  len,
UINT32  permFlag 
)

Update Value of the Attribute.

This function will update the writable attribute.

Parameters
pPointer to the current entry.
offsetOffset at which data need to be written.
Pointerto the data to write.
lenLength of the data to write.
pwermFlagAttribute permissions.
Returns
Length that can be written to the current entrie's value, or 0 if not writable.