主机端发送数据时申请的空间,发送失败该怎么处理?
有这样一段测试代码,发现多次发送失败后,再也申请不出空间了,是gatt_bm_free没有正确执行吗?
在GATT_MSG_EVENT事件里,release。GATT_WriteCharValue函数的注释有说明。
参考bloodpresure.c, copy 主要处理如下
static void bloodPressure_ProcessOSALMsg( osal_event_hdr_t *pMsg )
{
switch ( pMsg->event )
{
case KEY_CHANGE:
bloodPressure_HandleKeys( ((keyChange_t *)pMsg)->state, ((keyChange_t *)pMsg)->keys );
break;
case GATT_MSG_EVENT:
bloodPressureProcessGattMsg( (gattMsgEvent_t *) pMsg );
break;
default:
break;
}
}
static void bloodPressureProcessGattMsg( gattMsgEvent_t *pMsg )
{
// Measurement Indication Confirmation
if( pMsg->method == ATT_HANDLE_VALUE_CFM)
{
bpSendStoredMeas();
}
if ( pMsg->method == ATT_HANDLE_VALUE_NOTI ||
pMsg->method == ATT_HANDLE_VALUE_IND )
{
timeAppIndGattMsg( pMsg );
}
else if ( pMsg->method == ATT_READ_RSP ||
pMsg->method == ATT_WRITE_RSP )
{
timeAppConfigState = timeAppConfigGattMsg ( timeAppConfigState, pMsg );
if ( timeAppConfigState == TIMEAPP_CONFIG_CMPL )
{
timeAppDiscoveryCmpl = TRUE;
}
}
else
{
timeAppDiscState = timeAppDiscGattMsg( timeAppDiscState, pMsg );
if ( timeAppDiscState == DISC_IDLE )
{
// Start characteristic configuration
timeAppConfigState = timeAppConfigNext( TIMEAPP_CONFIG_START );
}
}
GATT_bm_free( &pMsg->msg, pMsg->method );
}