TI中文支持网
TI专业的中文技术问题搜集分享网站

cc2540作为主机向从机发送大于20字节的数据,该怎么样处理

这是我自己的分包的程序,但是在我测试的时候,从机只能收到18字节的数据,大于18字节的数据丢失了,希望能有帮忙指导下,谢谢了

uint8 sbpGattWriteString(uint8 *pBuffer, uint16 length)
{
uint8 status;
uint8 len;
if(length > 20)
osal_set_event( simpleBLETaskId, SBP_SEND_DATA_EVT) ;
else
len = length;
attWriteReq_t req;
req.handle = simpleBLECharHdl;
req.len = len;
req.sig = 0;//必须要填
req.cmd = 0;//必须要填
osal_memcpy(req.value,pBuffer,len);
status = GATT_WriteCharValue( simpleBLEConnHandle, &req, simpleBLETaskId );
return status;
}

static void senddata(void)
{
uint8 status;
static uint16 counter = 0;
uint8 dat[20]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
dat[0] = (counter & 0xff00)>>8;
dat[1] = (counter & 0xff00);
attWriteReq_t ndat;
ndat.handle = simpleBLECharHdl;
ndat.len = 20;
ndat.sig = 0;//必须要填
ndat.cmd = 0;//必须要填
osal_memcpy(ndat.value,&dat,20);
status = GATT_WriteCharValue( simpleBLEConnHandle, &ndat, simpleBLETaskId );
if(status==SUCCESS)
{
counter++;
simpleBLEProcedureInProgress = TRUE;
}
if(counter>100)
{
osal_stop_timerEx(simpleBLETaskId,SBP_SEND_DATA_EVT);
counter = 0;
simpleBLEProcedureInProgress = FALSE;
}
}

if(events & SBP_SEND_DATA_EVT)
{
senddata();
senddata();
senddata();
senddata();
return(events ^ SBP_SEND_DATA_EVT);
}

还望能有人帮忙指导下   特别急  再次谢谢

cedar_xuesong:

1.每次只发一个senddata();测试

2.参考TI的高速串口例子(high-though uart bridge)

cedar_xuesong:

回复 cedar_xuesong:

高速串口例子(high-though uart bridge)里面有分包代码

http://processors.wiki.ti.com/index.php/CC2540_Data_Throughput

赞(0)
未经允许不得转载:TI中文支持网 » cc2540作为主机向从机发送大于20字节的数据,该怎么样处理
分享到: 更多 (0)