如上图:
代码:
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] );
centralProcedureInProgress = FALSE;
// 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 4 handle : %x \n",centralCharHdl);
// Do a write
<font color="#ff0000"> attWriteReq_t req;
req.cmd = FALSE;
req.sig = FALSE;
req.handle = centralCharHdl+1;
req.len = 2;
//centralConnHandle=0;
PRINT( "222!\n");
req.pValue = GATT_bm_alloc(centralConnHandle,ATT_WRITE_REQ,req.len,NULL,0);
if ( req.pValue != NULL )
{
req.pValue[0] = 0x01;
req.pValue[1] = 0x00;
PRINT( "333!\n");
if( GATT_WriteCharValue(centralConnHandle,&req,centralTaskId) == SUCCESS )
{
centralProcedureInProgress = TRUE;
PRINT( "Open Notify ok!\n");
//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);
PRINT( "Open Notify Fail!\n");
}</font>
}
}
centralDiscState = BLE_DISC_STATE_IDLE;
}
我用CC2541主机打开CC2541从机的char4通知使能是可以的。
用沁恒就失败。
请问高手,哪里有错?谢谢
|