CC2541 一个包可以发送超过20个字节的数据吗
答案:1 悬赏:60 手机版
解决时间 2021-02-27 17:50
- 提问者网友:酱爆肉
- 2021-02-26 17:01
CC2541 一个包可以发送超过20个字节的数据吗
最佳答案
- 五星知识达人网友:末日狂欢
- 2021-02-26 17:59
我发送的程序为一个子函数,如下:
void write_center_data_to_client()//向center数据通道写入数据,大小为20个字节
{
if ( simpleBLEState == BLE_STATE_CONNECTED &&
CENTER_data_valueHdl != 0 &&
simpleBLEProcedureInProgress == FALSE )
{//必须为可读写状态才能读写
attWriteReq_t req;
req.handle = CENTER_data_valueHdl;
req.len = 20;
osal_memcpy(req.value,center_data_buff,req.len);
req.sig = 0;
req.cmd = 0;
if ( GATT_WriteCharValue( simpleBLEConnHandle, &req, simpleBLETaskId ) == SUCCESS )
{
simpleBLEProcedureInProgress = TRUE;
}
else
{
simpleBLEProcedureInProgress = FALSE;
}
}
}
其中uint8 center_data_buff[20];//固定向client写入的20字节数据缓冲
在发送的时候,首先调用这个子函数发送第一包,然后在MSG函数中得到回应后,才发送第二包,如此循环,我将后续函数放到这里:
else if ( ( pMsg->method == ATT_WRITE_RSP ) ||
( ( pMsg->method == ATT_ERROR_RSP ) &&
( pMsg->msg.errorRsp.reqOpcode == ATT_WRITE_REQ ) ) )//写特征值回调确认状态
{
if ( pMsg->method == ATT_ERROR_RSP == ATT_ERROR_RSP )
{
uint8 status = pMsg->msg.errorRsp.errCode;
LCD_WRITE_STRING_VALUE( "Write Error", status, 10, HAL_LCD_LINE_1 );
}
else
void write_center_data_to_client()//向center数据通道写入数据,大小为20个字节
{
if ( simpleBLEState == BLE_STATE_CONNECTED &&
CENTER_data_valueHdl != 0 &&
simpleBLEProcedureInProgress == FALSE )
{//必须为可读写状态才能读写
attWriteReq_t req;
req.handle = CENTER_data_valueHdl;
req.len = 20;
osal_memcpy(req.value,center_data_buff,req.len);
req.sig = 0;
req.cmd = 0;
if ( GATT_WriteCharValue( simpleBLEConnHandle, &req, simpleBLETaskId ) == SUCCESS )
{
simpleBLEProcedureInProgress = TRUE;
}
else
{
simpleBLEProcedureInProgress = FALSE;
}
}
}
其中uint8 center_data_buff[20];//固定向client写入的20字节数据缓冲
在发送的时候,首先调用这个子函数发送第一包,然后在MSG函数中得到回应后,才发送第二包,如此循环,我将后续函数放到这里:
else if ( ( pMsg->method == ATT_WRITE_RSP ) ||
( ( pMsg->method == ATT_ERROR_RSP ) &&
( pMsg->msg.errorRsp.reqOpcode == ATT_WRITE_REQ ) ) )//写特征值回调确认状态
{
if ( pMsg->method == ATT_ERROR_RSP == ATT_ERROR_RSP )
{
uint8 status = pMsg->msg.errorRsp.errCode;
LCD_WRITE_STRING_VALUE( "Write Error", status, 10, HAL_LCD_LINE_1 );
}
else
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯