Part Number: CC2340R5
Hello,
I have an issue in the example of basic_ble_profiles. I have activated the Glucose profile and modified the example to send a Glucose measurement notification every 1 minute. I have run the example and established a connection with the mobile app and activated the notification of the Glucose Measurment characteristic through the mobile app. When the application came to the GATT_Notification function, it didn't sent any notification to the central and returned a status code (5) although it wasn't mentioned in the API documentation of that function. I have searched for that error code and found that it means an INVALID_MSG_POINTER, but I debugged the code and found pointers sent to the function were valid. What can the problem be??
static bStatus_t GLS_sendNotiInd(uint8 *pValue, uint16 len, gattCharCfg_t *charCfgTbl, uint8 *pAttValue)
{
bStatus_t status = SUCCESS;
gattAttribute_t *pAttr = NULL;
attHandleValueNoti_t noti = {0};
linkDBInfo_t connInfo = {0};
uint16 offset = 0;
uint8 i = 0;
// Verify input parameters
if (( charCfgTbl == NULL ) || ( pValue == NULL ) || ( pAttValue == NULL ))
{
return ( INVALIDPARAMETER );
}
// Find the characteristic value attribute
pAttr = GATTServApp_FindAttr(gls_attrTbl, GATT_NUM_ATTRS(gls_attrTbl), pAttValue);
if ( pAttr != NULL )
{
for ( i = 0; i < MAX_NUM_BLE_CONNS; i++ )
{
gattCharCfg_t *pItem = &( charCfgTbl[i] );
if ( ( pItem->connHandle != LINKDB_CONNHANDLE_INVALID ) &&
( pItem->value != GATT_CFG_NO_OPERATION) )
{
// Find out what the maximum MTU size is for each connection
status = linkDB_GetInfo(pItem->connHandle, &connInfo);
offset = 0;
while ( status != bleTimeout && status != bleNotConnected && len > offset )
// Determine allocation size
{
uint16_t allocLen = (len - offset);
if ( allocLen > ( connInfo.MTU - GLS_NOTI_HDR_SIZE ) )
{
// If len > MTU split data to chunks of MTU size
allocLen = connInfo.MTU - GLS_NOTI_HDR_SIZE;
}
noti.len = allocLen;
noti.pValue = (uint8 *)GATT_bm_alloc( pItem->connHandle, ATT_HANDLE_VALUE_NOTI, allocLen, 0 );
if ( noti.pValue != NULL )
{
// If allocation was successful, copy out data and send it
VOID memcpy(noti.pValue, pValue + offset, noti.len);
noti.handle = pAttr->handle;
if( pItem->value == GATT_CLIENT_CFG_NOTIFY )
{
// Send the data over BLE notifications
status = GATT_Notification( pItem->connHandle, ¬i, TRUE );
}
else if ( pItem->value == GATT_CLIENT_CFG_INDICATE )
{
// Send the data over BLE indication
status = GATT_Indication( pItem->connHandle, (attHandleValueInd_t *)¬i, TRUE, INVALID_TASK_ID);
}
else
{
// If Client Characteristic Configuration is not notifications/indication
status = INVALIDPARAMETER;
}
// If unable to send the data, free allocated buffers and return
if ( status != SUCCESS )
{
GATT_bm_free( (gattMsg_t *)¬i, ATT_HANDLE_VALUE_NOTI );
// Failed to send notification/indication, print error message
MenuModule_printf(APP_MENU_PROFILE_STATUS_LINE4, 0,
"Failed to send notification/indication - Error: " MENU_MODULE_COLOR_RED "%d " MENU_MODULE_COLOR_RESET,
status);
}
else
{
// Increment data offset
offset += allocLen;
// Notification/indication sent
MenuModule_printf(APP_MENU_PROFILE_STATUS_LINE4, 0,
"Notification/indication sent");
}
}
else
{
status = bleNoResources;
}
} // End of while
}
} // End of for
} // End of if
// Return status value
return ( status );
}
Thank you in advance!