代码如下:,GATT_WriteNoRsp()这个函数返回值是0x00,理论上发送没问题,但是与之一对一连接的从机始终收不到数据,从机我用蓝牙调试助手发数据,从机能收到
uint8_t bleTxMsg()
{
static uint8 CharVal = 0x5A;
attPrepareWriteReq_t reqs;
attWriteReq_t req;
bStatus_t state = 0;
req.handle = centralCCCDHdl;
req.len = 1;
req.cmd = 0;
req.sig = 0;
req.pValue = GATT_bm_alloc(centralConnHandle,ATT_WRITE_REQ,req.len,NULL,0);
if(req.pValue != NULL){
*req.pValue = CharVal;
//state = GATT_WriteCharValue(centralConnHandle,&req,centralTaskId);
state =GATT_WriteNoRsp(centralConnHandle,&req);
PRINT("current state (%x)\n",state);
}
else
GATT_bm_free((gattMsg_t *)&req, ATT_WRITE_REQ);
return 0;
}
void TMR0_IRQHandler( void ) // TMR0 定时中断
{
if( TMR0_GetITFlag( TMR0_3_IT_CYC_END ) )
{
TMR0_ClearITFlag( TMR0_3_IT_CYC_END ); // 清除中断标志
bleTxMsg();
}
} |