Hi,
我在使用两个CH582M进行通信时,一主一从,
从机在蓝牙接收到0xFF时会执行相应的动作,我使用手机作为主机进行HEX发送时,从机可以执行正常的动作(手机蓝牙助手看到的UUID是0xFFF2),比如打印以下这一段
case BLE_USB_EVT_BLE_DATA_RECIEVED:
PRINT("BLE RX DATA len:%d\r\n", p_evt->data.length);
但是我使用CH582M主机向从机发送0xFF时,从机一直在执行的是
PRINT("profile ChangeCB CHAR1.. \n");
是因为存储的characteristic 1 handle错误了导致数据一直发送不正常吗?
主机的发送设置如下:
写函数
if (centralDoWrite)
{
// Do a write
attWriteReq_t req;
req.cmd = FALSE;
req.sig = FALSE;
req.handle = centralCharHdl;
req.len = 1;
req.pValue = GATT_bm_alloc(centralConnHandle, ATT_WRITE_REQ, req.len, NULL, 0);
if (req.pValue != NULL)
{
*req.pValue = centralCharVal;
if (GATT_WriteCharValue(centralConnHandle, &req, centralTaskId) == SUCCESS)
{
centralProcedureInProgress = TRUE;
centralDoWrite = !centralDoWrite;
tmos_start_task(centralTaskId, START_READ_OR_WRITE_EVT, DEFAULT_READ_OR_WRITE_DELAY);
}
else
{
GATT_bm_free((gattMsg_t*)&req, ATT_WRITE_REQ);
}
}
}
handle的存储:
else if(centralDiscState == BLE_DISC_STATE_CHAR)
{
// Characteristic found, store handle
if(pMsg->method == ATT_READ_BY_TYPE_RSP &&
pMsg->msg.readByTypeRsp.numPairs > 0)
{
centralCharHdl = BUILD_UINT16(pMsg->msg.readByTypeRsp.pDataList[0],
pMsg->msg.readByTypeRsp.pDataList[1]);
// Start do read or write
tmos_start_task(centralTaskId, START_READ_OR_WRITE_EVT, DEFAULT_READ_OR_WRITE_DELAY);
// Display Characteristic 1 handle
PRINT("Found Characteristic 1 handle : %x \n", centralCharHdl);
}
}