EasyManuals Logo

Texas Instruments CC2541 Software Developers Guide

Texas Instruments CC2541
162 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #85 background imageLoading...
Page #85 background image
www.ti.com
Porting From Earlier BLE-Stack Versions
85
SWRU271HOctober 2010Revised 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, &noti.len,
0, len, GATT_LOCAL_READ );
if ( status == SUCCESS )
{
noti.handle = pAttr->handle;
if ( cccValue & GATT_CLIENT_CFG_NOTIFY )
{
status = GATT_Notification( connHandle, &noti, authenticated );
}
else // GATT_CLIENT_CFG_INDICATE
{
status = GATT_Indication( connHandle, (attHandleValueInd_t *)&noti,
authenticated, taskId );
}
}
if ( status != SUCCESS )
{
GATT_bm_free( (gattMsg_t *)&noti, 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 );
}

Table of Contents

Other manuals for Texas Instruments CC2541

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments CC2541 and is the answer not in the manual?

Texas Instruments CC2541 Specifications

General IconGeneral
BrandTexas Instruments
ModelCC2541
CategoryMicrocontrollers
LanguageEnglish

Related product manuals