Hello,
I am using multi_role on cc2640r2f. Currently I am testing its behavior as central.
It scans for the peripheral and performs connection with peripheral. After the service and characteristic discovery is done. I tried to perform a write to slave characteristic as following:
bool mr_doGattWrite(uint8_t index) { bStatus_t status = FAILURE; uint8_t charVal2 = 0x88; // If characteristic has been discovered if (discInfo[index].charHdl != 0) { // Do a read / write as long as no other read or write is in progress if (!doWrite) { // Do a write attWriteReq_t req; // Allocate GATT write request req.pValue = GATT_bm_alloc(connHandleMap[index].connHandle, ATT_WRITE_REQ, 1, NULL); // If successfully allocated if (req.pValue != NULL) { // Fill up request req.handle = discInfo[index].charHdl; req.len = 1; req.pValue[0] = charVal2; req.sig = 0; req.cmd = 0; // Send GATT write to controller status = GATT_WriteNoRsp (connHandleMap[index].connHandle, &req); // gives an error INVALIDPARAMETER // status = GATT_WriteCharValue(connHandleMap[index].connHandle, &req, selfEntity); // gives an error blePending // If not sucessfully sent if ( status != SUCCESS ) { // Free write request as the controller will not GATT_bm_free((gattMsg_t *)&req, ATT_WRITE_REQ); } } } }
When i tried with
GATT_WriteNoRsp returns 0x02 (INVALIDPARAMETER)
and while using
GATT_WriteCharValue returns 0x16 (blePending)
I checked the discInfo[index].charHdl they are correct. I am generating a event once the characteristic discovery is done and in that event i am calling :
bool mr_doGattWrite(uint8_t index)
Following is the code where i start clock:
static void multi_role_processGATTDiscEvent(gattMsgEvent_t *pMsg) { //first performed service discovery // If we're discovering characteristics else if (discInfo[connIndex].discState == BLE_DISC_STATE_CHAR) { // Characteristic found if ((pMsg->method == ATT_READ_BY_TYPE_RSP) && (pMsg->msg.readByTypeRsp.numPairs > 0)) { // Store handle discInfo[connIndex].charHdl = BUILD_UINT16(pMsg->msg.readByTypeRsp.pDataList[0], pMsg->msg.readByTypeRsp.pDataList[1]); // "Simple Svc Found" } Util_startClock(&periodicWriteClock); } }
Why the write is not getting successful ?
Waiting for your kind reply.