if (state == BLE_STATE_CONNECTED && charHdl[connHandleIdx] != 0 && procedureInProgress == FALSE)
{ uint8_t status;
// Do a read or write as long as no other read or write is in progress
if (doWrite)
{ // Do a write
attPrepareWriteReq_t req;
req.pValue = GATT_bm_alloc(connHandle[connHandleIdx], ATT_WRITE_REQ, 15, NULL);
if ( req.pValue != NULL )
{ req.handle = charHdl[connHandleIdx];
req.offset = 0;
req.len = 15;
//req.pValue[0] = charVal;
memcpy(req.pValue,"123456789123456",15);
//req.sig = 0; //req.cmd = 0;
status = GATT_WriteLongCharValue(connHandle[connHandleIdx], &req, selfEntity);
uprintf("error cord :%d\t",status);
if ( status != SUCCESS )
{ GATT_bm_free((gattMsg_t *)&req, ATT_WRITE_REQ);
}
}
} else
{ // Do a read
attReadReq_t req;
req.handle = charHdl[connHandleIdx];
status = GATT_ReadCharValue(connHandle[connHandleIdx], &req, selfEntity);
uprintf("error cord :%d\t",status); }
if (status == SUCCESS)
{ procedureInProgress = TRUE; doWrite = !doWrite; }
}
This is the master code in the "SimpleBLECentral example" ,and it can read success tow times,but the third times,read rsp have to wait a long time,and read the rsp is big than before times."GATT_WriteLongCharValue" also can success tow times,and the third time ,it return error cord 0x17.I do not know if master or slave device have issue.I use BTool 1.41.05 to read slave ,it have no problem.