www.ti.com
Porting From Earlier BLE-Stack Versions
85
SWRU271H–October 2010–Revised April 2019
Submit Documentation Feedback
Copyright © 2010–2019, Texas Instruments Incorporated
General Information
If using GATT_Notification() or GATT_Indication() directly, this memory management will need to be
added:
1. Attempt to allocate memory for the notification / indication using GATT_bm_alloc().
2. If allocation succeeds, send notification / indication using GATT_Notification() / GATT_Indication().
3. If the return value of the notification / indication is SUCCESS (0x00), this means the memory was freed
by the stack. If the return value is something other than SUCCESS (blePending), free the memory
using GATT_bm_free(). There is an example of this in the gattServApp_SendNotiInd() function in
gattservapp_util.c:
noti.pValue = (uint8 *)GATT_bm_alloc( connHandle, ATT_HANDLE_VALUE_NOTI,
GATT_MAX_MTU, &len );
if ( noti.pValue != NULL )
{
status = (*pfnReadAttrCB)( connHandle, pAttr, noti.pValue, ¬i.len,
0, len, GATT_LOCAL_READ );
if ( status == SUCCESS )
{
noti.handle = pAttr->handle;
if ( cccValue & GATT_CLIENT_CFG_NOTIFY )
{
status = GATT_Notification( connHandle, ¬i, authenticated );
}
else // GATT_CLIENT_CFG_INDICATE
{
status = GATT_Indication( connHandle, (attHandleValueInd_t *)¬i,
authenticated, taskId );
}
}
if ( status != SUCCESS )
{
GATT_bm_free( (gattMsg_t *)¬i, ATT_HANDLE_VALUE_NOTI );
}
}
else
{
status = bleNoResources;
}
This will need to be done for other GATT messages also.
9.3.2.7 Allocation of Client Characteristic Configuration Table
The client characteristic configuration descriptors (CCCD's) are now initialized as pointers which must be
allocated. For example, the CCCD for simpleProfileCharacteristic 4 is declared as a pointer in
simpleGATTprofile.c:
static gattCharCfg_t *simpleProfileChar4Config
This must then be allocated when the profile is added to the application (in SimpleProfile_AddService()):
bStatus_t SimpleProfile_AddService( uint32 services )
{
uint8 status;
// Allocate Client Characteristic Configuration table
simpleProfileChar4Config = (gattCharCfg_t *)osal_mem_alloc( sizeof(gattCharCfg_t) *
linkDBNumConns );
if ( simpleProfileChar4Config == NULL )
{
return ( bleMemAllocError );
}