SWRU271I October 2010 – January 2020 CC2540 , CC2540T , CC2541 , CC2541-Q1 , CC2640R2F
In order to prepare for a possible future fragmentation implementation, GATT / ATT payload structures are no longer fixed sized arrays and are now pointers. Therefore, the payload is allocated based on its length. This means that the names of all payload elements in the structures in att.h and gatt.h have changed. A “p” has been added in front of the old array name and the next letter has been capitalized.
typedef struct
{
uint16 handle; //!< Handle of the attribute to be written (must be first field)
uint16 offset; //!< Offset of the first octet to be written
uint8 len; //!< Length of value
uint8 value[ATT_MTU_SIZE-5]; //!< Part of the value of the attribute to be written
} attPrepareWriteReq_t
has been changed to:
typedef struct
{
uint16 handle; //!< Handle of the attribute to be written (must be first field)
uint16 offset; //!< Offset of the first octet to be written
uint8 len; //!< Length of value
uint8 *pValue; //!< Part of the value of the attribute to be written (0 to ATT_MTU_SIZE-5) - must be allocated
} attPrepareWriteReq_t;
Macro’s have been added which can be used to access offsets from these pointer locations. For example:
typedef struct
// Service found, store handles
if ( pMsg->method == ATT_FIND_BY_TYPE_VALUE_RSP &&
pMsg->msg.findByTypeValueRsp.numInfo > 0 )
{
simpleBLESvcStartHdl = pMsg->msg.findByTypeValueRsp.handlesInfo[0].handle;
simpleBLESvcEndHdl = pMsg->msg.findByTypeValueRsp.handlesInfo[0].grpEndHandle;
}
has been changed to:
// Service found, store handles
if (pMsg->method == ATT_FIND_BY_TYPE_VALUE_RSP &&
pMsg->msg.findByTypeValueRsp.numInfo > 0 )
{
simpleBLESvcStartHdl = ATT_ATTR_HANDLE(pMsg->msg.findByTypeValueRsp.pHandlesInfo, 0);
simpleBLESvcEndHdl = ATT_GRP_END_HANDLE(pMsg->msg.findByTypeValueRsp.pHandlesInfo, 0);
}
where the macro's used are defined as:
#define ATT_ATTR_HANDLE( info, i ) ( BUILD_UINT16( (info)[ATT_ATTR_HANDLE_IDX((i))], \
(info)[ATT_ATTR_HANDLE_IDX((i))+1] ) )
#define ATT_GRP_END_HANDLE( info, i ) ( BUILD_UINT16( (info)[ATT_GRP_END_HANDLE_IDX((i))], \
(info)[ATT_GRP_END_HANDLE_IDX((i))+1] ) )