Mistake on this page? Email us
Data Structures

Data Structures

struct  attsAttr_t
 Attribute structure. More...
 
struct  attsCsfRec_t
 Client supported features record structure. More...
 
struct  attsGroup_t
 Attribute group. More...
 
struct  attsCccSet_t
 Client characteristc configuration settings. More...
 
struct  attsCccEvt_t
 ATTS client characteristic configuration callback structure. More...
 

ATT Server Attribute Settings

Settings that may be set on each attribute.

#define ATTS_SET_UUID_128   0x01
 Set if the UUID is 128 bits in length.
 
#define ATTS_SET_WRITE_CBACK   0x02
 Set if the group callback is executed when this attribute is written by a client device.
 
#define ATTS_SET_READ_CBACK   0x04
 Set if the group callback is executed when this attribute is read by a client device.
 
#define ATTS_SET_VARIABLE_LEN   0x08
 Set if the attribute has a variable length.
 
#define ATTS_SET_ALLOW_OFFSET   0x10
 Set if writes are allowed with an offset.
 
#define ATTS_SET_CCC   0x20
 Set if the attribute is a client characteristic configuration descriptor.
 
#define ATTS_SET_ALLOW_SIGNED   0x40
 Set if signed writes are allowed.
 
#define ATTS_SET_REQ_SIGNED   0x80
 Set if signed writes are required if link is not encrypted.
 

ATT Server Attribute Permissions

Permissions used to describe a attribute's security setting. These values can be set in any combination.

#define ATTS_PERMIT_READ   0x01
 Set if attribute can be read.
 
#define ATTS_PERMIT_READ_AUTH   0x02
 Set if attribute read requires authentication.
 
#define ATTS_PERMIT_READ_AUTHORIZ   0x04
 Set if attribute read requires authorization.
 
#define ATTS_PERMIT_READ_ENC   0x08
 Set if attribute read requires encryption.
 
#define ATTS_PERMIT_WRITE   0x10
 Set if attribute can be written.
 
#define ATTS_PERMIT_WRITE_AUTH   0x20
 Set if attribute write requires authentication.
 
#define ATTS_PERMIT_WRITE_AUTHORIZ   0x40
 Set if attribute write requires authorization.
 
#define ATTS_PERMIT_WRITE_ENC   0x80
 Set if attribute write requires encryption.
 

ATT Server Callbacks

typedef uint8_t(* attsReadCback_t) (dmConnId_t connId, uint16_t handle, uint8_t operation, uint16_t offset, attsAttr_t *pAttr)
 Attribute group read callback. More...
 
typedef uint8_t(* attsWriteCback_t) (dmConnId_t connId, uint16_t handle, uint8_t operation, uint16_t offset, uint16_t len, uint8_t *pValue, attsAttr_t *pAttr)
 Attribute group write callback. More...
 
typedef uint8_t(* attsAuthorCback_t) (dmConnId_t connId, uint8_t permit, uint16_t handle)
 ATTS authorization callback type. More...
 
typedef void(* attsCsfWriteCback_t) (dmConnId_t connId, uint8_t changeAwareState, uint8_t *pCsf)
 ATTS client supported features write callback type. More...
 
typedef void(* attsCccCback_t) (attsCccEvt_t *pEvt)
 ATTS client characteristic configuration callback. More...
 

ATT Server Functions

void AttsInit (void)
 Initialize ATT server. More...
 
void AttsIndInit (void)
 Initialize ATT server for indications/notifications. More...
 
void AttsSignInit (void)
 Initialize ATT server for data signing. More...
 
void AttsAuthorRegister (attsAuthorCback_t cback)
 Register an authorization callback with the attribute server. More...
 
void AttsAddGroup (attsGroup_t *pGroup)
 Add an attribute group to the attribute server. More...
 
void AttsRemoveGroup (uint16_t startHandle)
 Remove an attribute group from the attribute server. More...
 
void AttsCalculateDbHash (void)
 Calculate database hash from the GATT database. More...
 
bool_t AttsHashDatabaseString (uint8_t *pKey, uint8_t *pMsg, uint16_t msgLen)
 Create hash from the database string. More...
 
uint8_t AttsSetAttr (uint16_t handle, uint16_t valueLen, uint8_t *pValue)
 Set an attribute value in the attribute server. More...
 
uint8_t AttsGetAttr (uint16_t handle, uint16_t *pLen, uint8_t **pValue)
 Get an attribute value in the attribute server. More...
 
void AttsHandleValueInd (dmConnId_t connId, uint16_t handle, uint16_t valueLen, uint8_t *pValue)
 Send an attribute protocol Handle Value Indication. More...
 
void AttsHandleValueNtf (dmConnId_t connId, uint16_t handle, uint16_t valueLen, uint8_t *pValue)
 Send an attribute protocol Handle Value Notification. More...
 
void AttsHandleValueIndZeroCpy (dmConnId_t connId, uint16_t handle, uint16_t valueLen, uint8_t *pValue)
 Send an attribute protocol Handle Value Indication without copying the attribute value data. More...
 
void AttsHandleValueNtfZeroCpy (dmConnId_t connId, uint16_t handle, uint16_t valueLen, uint8_t *pValue)
 Send an attribute protocol Handle Value Notification without copying the attribute value data. More...
 
void AttsCccRegister (uint8_t setLen, attsCccSet_t *pSet, attsCccCback_t cback)
 Register the utility service for managing client characteristic configuration descriptors. This function is typically called once on system initialization. More...
 
void AttsCccInitTable (dmConnId_t connId, uint16_t *pCccTbl)
 Initialize the client characteristic configuration descriptor value table for a connection. The table is initialized with the values from pCccTbl. If pCccTbl is NULL the table will be initialized to zero. More...
 
void AttsCccClearTable (dmConnId_t connId)
 Clear and deallocate the client characteristic configuration descriptor value table for a connection. This function must be called when a connection is closed. More...
 
uint16_t AttsCccGet (dmConnId_t connId, uint8_t idx)
 Get the value of a client characteristic configuration descriptor by its index. If not found, return zero. More...
 
void AttsCccSet (dmConnId_t connId, uint8_t idx, uint16_t value)
 Set the value of a client characteristic configuration descriptor by its index. More...
 
uint16_t AttsCccEnabled (dmConnId_t connId, uint8_t idx)
 Check if a client characteristic configuration descriptor is enabled and if the characteristic's security level has been met. More...
 
uint8_t AttsGetCccTableLen (void)
 Get number of CCC entries in table. More...
 
void AttsContinueWriteReq (dmConnId_t connId, uint16_t handle, uint8_t status)
 Send a response to a pending write request. For use with ATT_RSP_PENDING. More...
 
void AttsSetCsrk (dmConnId_t connId, uint8_t *pCsrk)
 Set the peer's data signing key on this connection. This function is typically called from the ATT connection callback when the connection is established. The caller is responsible for maintaining the memory that contains the key. More...
 
void AttsSetSignCounter (dmConnId_t connId, uint32_t signCounter)
 Set the peer's sign counter on this connection. This function is typically called from the ATT connection callback when the connection is established. ATT maintains the value of the sign counter internally and sets the value when a signed packet is successfully received. More...
 
uint32_t AttsGetSignCounter (dmConnId_t connId)
 Get the current value peer's sign counter on this connection. This function is typically called from the ATT connection callback when the connection is closed so the application can store the sign counter for use on future connections. More...
 
void AttsCsfInit (void)
 Initialize ATTS client supported features module. More...
 
void AttsCsfConnOpen (dmConnId_t connId, uint8_t changeAwareState, uint8_t *pCsf)
 Initialize the client supported features for a connection. More...
 
uint8_t AttsCsfWriteFeatures (dmConnId_t connId, uint16_t offset, uint16_t valueLen, uint8_t *pValue)
 GATT write of client supported feature characteristic value. More...
 
void AttsCsfGetFeatures (dmConnId_t connId, uint8_t *pCsfOut, uint8_t pCsfOutLen)
 Get client supported feature record. More...
 
uint8_t AttsCsfGetChangeAwareState (dmConnId_t connId)
 Get client state of awareness to a change in the database. More...
 
void AttsCsfSetClientsChangeAwarenessState (dmConnId_t connId, uint8_t state)
 Update a client's state of awareness to a change in the database. More...
 
void AttsCsfRegister (attsCsfWriteCback_t writeCback)
 Register callback. More...
 

ATT Server Dynamic Service Subsystem Functions

void AttsDynInit (void)
 Initialize the Dynamic ATT Service subsystem. More...
 
void * AttsDynCreateGroup (uint16_t startHandle, uint16_t endHandle)
 Dynamically create an ATT Service at runtime. More...
 
void AttsDynDeleteGroup (void *pSvcHandle)
 Dynamically delete an ATT Service at runtime. More...
 
void AttsDynRegister (void *pSvcHandle, attsReadCback_t readCback, attsWriteCback_t writeCback)
 Register callback functions for a dynamic ATT Service at runtime. More...
 
void AttsDynAddAttr (void *pSvcHandle, const uint8_t *pUuid, const uint8_t *pValue, uint16_t len, const uint16_t maxLen, uint8_t settings, uint8_t permissions)
 Dynamically add an attribute to a dynamic ATT Services at runtime. More...
 
void AttsDynAddAttrConst (void *pSvcHandle, const uint8_t *pUuid, const uint8_t *pValue, const uint16_t len, uint8_t settings, uint8_t permissions)
 Dynamically add an attribute with a constant value to a dynamic ATT Services at runtime. More...
 

ATT Server Testing

void AttsErrorTest (uint8_t status)
 For testing purposes only. More...
 

Detailed Description

Typedef Documentation

typedef uint8_t(* attsReadCback_t) (dmConnId_t connId, uint16_t handle, uint8_t operation, uint16_t offset, attsAttr_t *pAttr)

Attribute group read callback.

This is the attribute server read callback. It is executed on an attribute read operation if bitmask ATTS_SET_READ_CBACK is set in the settings field of the attribute structure. For a read operation, if the operation is successful the function must set pAttr->pValue to the data to be read. In addition, if the attribute is variable length then pAttr->pLen must be set as well.

Parameters
connIdDM connection ID.
handleAttribute handle.
operationOperation type.
offsetRead data offset.
pAttrPointer to attribute structure.
Returns
status of the operation. ATT_SUCCESS if successful.

Definition at line 231 of file att_api.h.

typedef uint8_t(* attsWriteCback_t) (dmConnId_t connId, uint16_t handle, uint8_t operation, uint16_t offset, uint16_t len, uint8_t *pValue, attsAttr_t *pAttr)

Attribute group write callback.

This is the attribute server write callback. It is executed on an attribute write operation if bitmask ATTS_SET_WRITE_CBACK is set in the settings field of the attribute structure.

Parameters
connIdDM connection ID.
handleAttribute handle.
operationOperation type.
offsetWrite data offset.
lenLength of data to write.
pValuePointer to data to write.
pAttrPointer to attribute structure.
Returns
status of operation. ATT_SUCCESS if successful.

Definition at line 250 of file att_api.h.

typedef uint8_t(* attsAuthorCback_t) (dmConnId_t connId, uint8_t permit, uint16_t handle)

ATTS authorization callback type.

This callback function is executed when a read or write operation occurs and the security field of an attribute structure is set to ATTS_PERMIT_READ_AUTHORIZ or ATTS_PERMIT_WRITE_AUTHORIZ respectively.

Parameters
connIdDM Connection ID.
permitSet to ATTS_PERMIT_WRITE for a writre operation or ATTS_PERMIT_READ for a read operation.
handleAttribute handle.
Returns
status of the operation. ATT_SUCCESS if successful, else if failure the ATT_ERR_AUTH is typically returned.

Definition at line 268 of file att_api.h.

typedef void(* attsCsfWriteCback_t) (dmConnId_t connId, uint8_t changeAwareState, uint8_t *pCsf)

ATTS client supported features write callback type.

This callback function is executed when the client supported features record for this client has been updated.

Parameters
connIdDM Connection ID.
changeAwareStateThe state of awareness to a change, see attClientAwareStates.
pCsfPointer to the client supported features value.
Returns
None.

Definition at line 281 of file att_api.h.

typedef void(* attsCccCback_t) (attsCccEvt_t *pEvt)

ATTS client characteristic configuration callback.

Client characteristic configuration callback. This function is executed when a CCCD value changes. This happens when a peer device writes a new value to the CCCD or when a CCCD table is initialized by calling AttsCccInitTable.

Parameters
pEvtPointer to callback structure.
Returns
None.

Definition at line 373 of file att_api.h.

Function Documentation

void AttsInit ( void  )

Initialize ATT server.

Returns
None.
void AttsIndInit ( void  )

Initialize ATT server for indications/notifications.

Returns
None.
void AttsSignInit ( void  )

Initialize ATT server for data signing.

Returns
None.
void AttsAuthorRegister ( attsAuthorCback_t  cback)

Register an authorization callback with the attribute server.

Parameters
cbackClient callback function.
Returns
None.
void AttsAddGroup ( attsGroup_t pGroup)

Add an attribute group to the attribute server.

Parameters
pGroupPointer to an attribute group structure.
Returns
None.
void AttsRemoveGroup ( uint16_t  startHandle)

Remove an attribute group from the attribute server.

Parameters
startHandleStart handle of attribute group to be removed.
Returns
None.
void AttsCalculateDbHash ( void  )

Calculate database hash from the GATT database.

Returns
None.
bool_t AttsHashDatabaseString ( uint8_t *  pKey,
uint8_t *  pMsg,
uint16_t  msgLen 
)

Create hash from the database string.

Parameters
pKeyKey for hashing.
pMsgPlaintext to hash.
msgLenLength of Plaintext data.
Returns
TRUE if successful, FALSE if not.
uint8_t AttsSetAttr ( uint16_t  handle,
uint16_t  valueLen,
uint8_t *  pValue 
)

Set an attribute value in the attribute server.

Parameters
handleAttribute handle.
valueLenAttribute length.
pValueAttribute value.
Returns
ATT_SUCCESS if successful otherwise error.
uint8_t AttsGetAttr ( uint16_t  handle,
uint16_t *  pLen,
uint8_t **  pValue 
)

Get an attribute value in the attribute server.

Parameters
handleAttribute handle.
pLenReturned attribute length pointer.
pValueReturned attribute value pointer.
Returns
ATT_SUCCESS if successful otherwise error.
This function returns the attribute length in pLen and a pointer to the attribute value in pValue.
void AttsHandleValueInd ( dmConnId_t  connId,
uint16_t  handle,
uint16_t  valueLen,
uint8_t *  pValue 
)

Send an attribute protocol Handle Value Indication.

Parameters
connIdDM connection ID.
handleAttribute handle.
valueLenLength of value data.
pValuePointer to value data.
Returns
None.
void AttsHandleValueNtf ( dmConnId_t  connId,
uint16_t  handle,
uint16_t  valueLen,
uint8_t *  pValue 
)

Send an attribute protocol Handle Value Notification.

Parameters
connIdDM connection ID.
handleAttribute handle.
valueLenLength of value data.
pValuePointer to value data.
Returns
None.
void AttsHandleValueIndZeroCpy ( dmConnId_t  connId,
uint16_t  handle,
uint16_t  valueLen,
uint8_t *  pValue 
)

Send an attribute protocol Handle Value Indication without copying the attribute value data.

Note: attribute value buffer 'pValue' must be allocated with AttMsgAlloc().

Parameters
connIdDM connection ID.
handleAttribute handle.
valueLenLength of value data.
pValuePointer to value data.
Returns
None.
void AttsHandleValueNtfZeroCpy ( dmConnId_t  connId,
uint16_t  handle,
uint16_t  valueLen,
uint8_t *  pValue 
)

Send an attribute protocol Handle Value Notification without copying the attribute value data.

Note: attribute value buffer 'pValue' must be allocated with AttMsgAlloc().

Parameters
connIdDM connection ID.
handleAttribute handle.
valueLenLength of value data.
pValuePointer to value data.
Returns
None.
void AttsCccRegister ( uint8_t  setLen,
attsCccSet_t pSet,
attsCccCback_t  cback 
)

Register the utility service for managing client characteristic configuration descriptors. This function is typically called once on system initialization.

Parameters
setLenLength of settings array.
pSetArray of CCC descriptor settings.
cbackClient callback function.
Returns
None.
void AttsCccInitTable ( dmConnId_t  connId,
uint16_t *  pCccTbl 
)

Initialize the client characteristic configuration descriptor value table for a connection. The table is initialized with the values from pCccTbl. If pCccTbl is NULL the table will be initialized to zero.

This function must be called when a connection is established or when a device is bonded.

Parameters
connIdDM connection ID.
pCccTblPointer to the descriptor value array. The length of the array must equal the value of setLen passed to AttsCccRegister().
Returns
None.
void AttsCccClearTable ( dmConnId_t  connId)

Clear and deallocate the client characteristic configuration descriptor value table for a connection. This function must be called when a connection is closed.

Parameters
connIdDM connection ID.
Returns
None.
uint16_t AttsCccGet ( dmConnId_t  connId,
uint8_t  idx 
)

Get the value of a client characteristic configuration descriptor by its index. If not found, return zero.

Parameters
connIdDM connection ID.
idxIndex of descriptor in CCC descriptor handle table.
Returns
Value of the descriptor.
void AttsCccSet ( dmConnId_t  connId,
uint8_t  idx,
uint16_t  value 
)

Set the value of a client characteristic configuration descriptor by its index.

Parameters
connIdDM connection ID.
idxIndex of descriptor in CCC descriptor handle table.
valueValue of the descriptor.
Returns
None.
uint16_t AttsCccEnabled ( dmConnId_t  connId,
uint8_t  idx 
)

Check if a client characteristic configuration descriptor is enabled and if the characteristic's security level has been met.

Parameters
connIdDM connection ID.
idxIndex of descriptor in CCC descriptor handle table.
Returns
Value of the descriptor if security level is met, otherwise zero.
uint8_t AttsGetCccTableLen ( void  )

Get number of CCC entries in table.

Returns
Number of CCC entries in table.
void AttsContinueWriteReq ( dmConnId_t  connId,
uint16_t  handle,
uint8_t  status 
)

Send a response to a pending write request. For use with ATT_RSP_PENDING.

Parameters
connIdConnection ID.
handleAttribute handle.
statusStatus of the write request.
Returns
None.
Note
When a higher layer returns ATT_RSP_PENDING to an ATT write callback indicating the response status is pending, the higher layer must subsequently call this function with the status of the write request.
void AttsSetCsrk ( dmConnId_t  connId,
uint8_t *  pCsrk 
)

Set the peer's data signing key on this connection. This function is typically called from the ATT connection callback when the connection is established. The caller is responsible for maintaining the memory that contains the key.

Parameters
connIdDM connection ID.
pCsrkPointer to data signing key (CSRK).
Returns
None.
void AttsSetSignCounter ( dmConnId_t  connId,
uint32_t  signCounter 
)

Set the peer's sign counter on this connection. This function is typically called from the ATT connection callback when the connection is established. ATT maintains the value of the sign counter internally and sets the value when a signed packet is successfully received.

Parameters
connIdDM connection ID.
signCounterSign counter.
Returns
None.
uint32_t AttsGetSignCounter ( dmConnId_t  connId)

Get the current value peer's sign counter on this connection. This function is typically called from the ATT connection callback when the connection is closed so the application can store the sign counter for use on future connections.

Parameters
connIdDM connection ID.
Returns
Sign counter.
void AttsCsfInit ( void  )

Initialize ATTS client supported features module.

Returns
None.
void AttsCsfConnOpen ( dmConnId_t  connId,
uint8_t  changeAwareState,
uint8_t *  pCsf 
)

Initialize the client supported features for a connection.

Parameters
connIdDM connection ID.
changeAwareStateThe state of awareness to a change in the database.
pCsfPointer to the client supported features value to cache. NULL or buffer of length ATT_CSF_LEN.
Returns
None.
uint8_t AttsCsfWriteFeatures ( dmConnId_t  connId,
uint16_t  offset,
uint16_t  valueLen,
uint8_t *  pValue 
)

GATT write of client supported feature characteristic value.

Parameters
connIdDM connection ID.
offsetoffset into csf characteristic.
valueLenlength of write in bytes.
pValuePointer to client's supported features characteristic value.
Returns
ATT_SUCCESS is successful, ATT_ERR_VALUE_NOT_ALLOWED if any supported features are flipped from 1 to 0.
void AttsCsfGetFeatures ( dmConnId_t  connId,
uint8_t *  pCsfOut,
uint8_t  pCsfOutLen 
)

Get client supported feature record.

Parameters
connIdDM connection ID.
pCsfOutOutput parameter for client supported features buffer.
pCsfOutLenLength of output parameter buffer.
Returns
None.
uint8_t AttsCsfGetChangeAwareState ( dmConnId_t  connId)

Get client state of awareness to a change in the database.

Parameters
connIdDM connection ID.
Returns
Client's change-aware state.
void AttsCsfSetClientsChangeAwarenessState ( dmConnId_t  connId,
uint8_t  state 
)

Update a client's state of awareness to a change in the database.

Parameters
connIdDM connection ID. if DM_CONN_ID_NONE, sets the state for all connected clients.
stateThe state of awareness to a change, see attClientAwareStates.
Returns
None.
Note
A callback to application is not needed as it is expected the caller (i.e. the application) will have updated all persistent records prior to calling this function.
void AttsCsfRegister ( attsCsfWriteCback_t  writeCback)

Register callback.

Parameters
writeCbackApplication callback for when client supported features record is updated.
Returns
None.
void AttsDynInit ( void  )

Initialize the Dynamic ATT Service subsystem.

Returns
None.
void* AttsDynCreateGroup ( uint16_t  startHandle,
uint16_t  endHandle 
)

Dynamically create an ATT Service at runtime.

Parameters
startHandleStarting attribute handle in the service
endHandleLast attribute handle in the service
Returns
Service Handle.
void AttsDynDeleteGroup ( void *  pSvcHandle)

Dynamically delete an ATT Service at runtime.

Parameters
pSvcHandleService handle returned by AttsDynCreateGroup
Returns
None.
void AttsDynRegister ( void *  pSvcHandle,
attsReadCback_t  readCback,
attsWriteCback_t  writeCback 
)

Register callback functions for a dynamic ATT Service at runtime.

Parameters
pSvcHandleService handle returned by AttsDynCreateGroup
readCbackRead callback function
writeCbackWrite callback function
Returns
None.
void AttsDynAddAttr ( void *  pSvcHandle,
const uint8_t *  pUuid,
const uint8_t *  pValue,
uint16_t  len,
const uint16_t  maxLen,
uint8_t  settings,
uint8_t  permissions 
)

Dynamically add an attribute to a dynamic ATT Services at runtime.

Parameters
pSvcHandleService handle returned by AttsDynCreateGroup
pUuidConstant UUID
pValueInitial value of attribute (copied into attribute memory)
lenLength of pValue in bytes
maxLenMaximum length of the attribute in bytes
settingsAttribute settings
permissionsAttribute permissions
Returns
None.
void AttsDynAddAttrConst ( void *  pSvcHandle,
const uint8_t *  pUuid,
const uint8_t *  pValue,
const uint16_t  len,
uint8_t  settings,
uint8_t  permissions 
)

Dynamically add an attribute with a constant value to a dynamic ATT Services at runtime.

Parameters
pSvcHandleService handle returned by AttsDynCreateGroup
pUuidConstant UUID
pValuePointer to constant attribute memory
lenLength of pValue in bytes
settingsAttribute settings
permissionsAttribute permissions
Returns
None.
void AttsErrorTest ( uint8_t  status)

For testing purposes only.

Parameters
statusATT status
Returns
None.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.