![]() |
Cordio Stack and Cordio Profiles
r2p3-02rel0
|
Data Structures | |
struct | attsAttr_t |
Attribute 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 | |
#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(* | 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... | |
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 | 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... | |
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... | |
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.
connId | DM connection ID. |
handle | Attribute handle. |
operation | Operation type. |
offset | Read data offset. |
pAttr | Pointer to attribute structure. |
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.
connId | DM connection ID. |
handle | Attribute handle. |
operation | Operation type. |
offset | Write data offset. |
len | Length of data to write. |
pValue | Pointer to data to write. |
pAttr | Pointer to attribute structure. |
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.
connId | DM Connection ID. |
permit | Set to ATTS_PERMIT_WRITE for a writre operation or ATTS_PERMIT_READ for a read operation. |
handle | Attribute handle. |
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.
pEvt | Pointer to callback structure. |
void AttsInit | ( | void | ) |
Initialize ATT server.
void AttsIndInit | ( | void | ) |
Initialize ATT server for indications/notifications.
void AttsSignInit | ( | void | ) |
Initialize ATT server for data signing.
void AttsAuthorRegister | ( | attsAuthorCback_t | cback | ) |
Register an authorization callback with the attribute server.
cback | Client callback function. |
void AttsAddGroup | ( | attsGroup_t * | pGroup | ) |
Add an attribute group to the attribute server.
pGroup | Pointer to an attribute group structure. |
void AttsRemoveGroup | ( | uint16_t | startHandle | ) |
Remove an attribute group from the attribute server.
startHandle | Start handle of attribute group to be removed. |
Set an attribute value in the attribute server.
handle | Attribute handle. |
valueLen | Attribute length. |
pValue | Attribute value. |
Get an attribute value in the attribute server.
handle | Attribute handle. |
pLen | Returned attribute length pointer. |
pValue | Returned attribute value pointer. |
void AttsHandleValueInd | ( | dmConnId_t | connId, |
uint16_t | handle, | ||
uint16_t | valueLen, | ||
uint8_t * | pValue | ||
) |
Send an attribute protocol Handle Value Indication.
connId | DM connection ID. |
handle | Attribute handle. |
valueLen | Length of value data. |
pValue | Pointer to value data. |
void AttsHandleValueNtf | ( | dmConnId_t | connId, |
uint16_t | handle, | ||
uint16_t | valueLen, | ||
uint8_t * | pValue | ||
) |
Send an attribute protocol Handle Value Notification.
connId | DM connection ID. |
handle | Attribute handle. |
valueLen | Length of value data. |
pValue | Pointer to value data. |
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().
connId | DM connection ID. |
handle | Attribute handle. |
valueLen | Length of value data. |
pValue | Pointer to value data. |
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().
connId | DM connection ID. |
handle | Attribute handle. |
valueLen | Length of value data. |
pValue | Pointer to value data. |
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.
setLen | Length of settings array. |
pSet | Array of CCC descriptor settings. |
cback | Client callback function. |
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.
connId | DM connection ID. |
pCccTbl | Pointer to the descriptor value array. The length of the array must equal the value of setLen passed to AttsCccRegister(). |
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.
connId | DM connection ID. |
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.
connId | DM connection ID. |
idx | Index of descriptor in CCC descriptor handle table. |
void AttsCccSet | ( | dmConnId_t | connId, |
uint8_t | idx, | ||
uint16_t | value | ||
) |
Set the value of a client characteristic configuration descriptor by its index.
connId | DM connection ID. |
idx | Index of descriptor in CCC descriptor handle table. |
value | Value of the descriptor. |
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.
connId | DM connection ID. |
idx | Index of descriptor in CCC descriptor handle table. |
uint8_t AttsGetCccTableLen | ( | void | ) |
Get number of CCC entries in table.
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.
connId | DM connection ID. |
pCsrk | Pointer to data signing key (CSRK). |
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.
connId | DM connection ID. |
signCounter | Sign counter. |
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.
connId | DM connection ID. |
void AttsDynInit | ( | void | ) |
Initialize the Dynamic ATT Service subsystem.
Dynamically create an ATT Service at runtime.
startHandle | Starting attribute handle in the service |
endHandle | Last attribute handle in the service |
void AttsDynDeleteGroup | ( | void * | pSvcHandle | ) |
Dynamically delete an ATT Service at runtime.
pSvcHandle | Service handle returned by AttsDynCreateGroup |
void AttsDynRegister | ( | void * | pSvcHandle, |
attsReadCback_t | readCback, | ||
attsWriteCback_t | writeCback | ||
) |
Register callback functions for a dynamic ATT Service at runtime.
pSvcHandle | Service handle returned by AttsDynCreateGroup |
readCback | Read callback function |
writeCback | Write callback function |
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.
pSvcHandle | Service handle returned by AttsDynCreateGroup |
pUuid | Constant UUID |
pValue | Initial value of attribute (copied into attribute memory) |
len | Length of pValue in bytes |
maxLen | Maximum length of the attribute in bytes |
settings | Attribute settings |
permissions | Attribute permissions |
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.
pSvcHandle | Service handle returned by AttsDynCreateGroup |
pUuid | Constant UUID |
pValue | Pointer to constant attribute memory |
len | Length of pValue in bytes |
settings | Attribute settings |
permissions | Attribute permissions |
void AttsErrorTest | ( | uint8_t | status | ) |
For testing purposes only.
status | ATT status |