因为需求,所以要发送4000个字节的数据,我给拆成了200多个包,每个包16字节,连续多次连接执行这个操作后主机程序就死了下面是我的程序
// Minimum connection interval (units of 1.25ms) if automatic parameter update
// request is enabled
#define DEFAULT_UPDATE_MIN_CONN_INTERVAL 16//400
// Maximum connection interval (units of 1.25ms) if automatic parameter update
// request is enabled
#define DEFAULT_UPDATE_MAX_CONN_INTERVAL 16//800
// Slave latency to use if automatic parameter update request is enabled
#define DEFAULT_UPDATE_SLAVE_LATENCY 0
// Supervision timeout value (units of 10ms) if automatic parameter update
// request is enabled
#define DEFAULT_UPDATE_CONN_TIMEOUT 300//600
#define SBP_BURST_EVT_PERIOD 15
这个是连接参数,以及连接上之后每隔15ms 发送一个包,这样连续发送200多个包。
attWriteReq_t *writeReq;
writeReq = &t_Message.writeReq;
writeReq->handle = charBLECharHdl[2];
writeReq->len = dataLength;
writeReq->sig = 0;
writeReq->cmd = 1;
writeReq->pValue = (uint8 *)GATT_bm_alloc(connHandle, ATT_WRITE_REQ, dataLength, NULL);
if(icounter < 296)
{
for(temp_i = 0;temp_i < 1;temp_i ++)
{
memcpy(writeReq->pValue,&data[icounter*dataLength],dataLength);
icounter ++;
status = GATT_WriteNoRsp(connHandle, writeReq);
if (status != SUCCESS)
{
GATT_bm_free(&t_Message, ATT_WRITE_REQ);
}
else
{
uint8 txbuf[3];
txbuf[0] = 0xa0;
txbuf[1] = (uint8)(icounter >> 8);
txbuf[2] = (uint8)icounter;
sbpSerialAppWrite(txbuf,3);
}
}
}
else
{
icounter = 0;
uartCmdClass = 0;
Util_stopClock(&startSendClock);
}