This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LAUNCHXL-CC2640R2: GATT_WriteCharValue selfEntity problem

Part Number: LAUNCHXL-CC2640R2

Hello,

I am trying to implement the following setup using an iPhone and two TI CC2640R2. My SDK is : simplelink_cc2640r2_sdk_1_40_00_45 and I am using ble5stack. Both TI devices use multi_role project.

iPhone --> CC2640R <--> CC2640R2

First I connect the first TI device with the other TI device so 

connHandleMap[0].connHandle

becomes the handler for the second TI device. And then I connect the iPhone to the first TI device and

connHandleMap[1].connHandle

becomes the handler for the iPhone connection. I do not use this second handler since I only want to pass the data coming from the iPhone to the first TI device to the second TI device.

My problem is the following, inside multi_role.c file, inside this method:

static void multi_role_processCharValueChangeEvt(uint8_t paramID)

Inside the switch statement 

case SIMPLEPROFILE_CHAR3:

I am trying to send the incoming data to characteristic 3 from the iPhone to the other TI device. To do this I did the following inside the CASE statement:


// Do a write to connected TI // Allocate GATT write request req.pValue = GATT_bm_alloc(connHandleMap[0].connHandle, ATT_WRITE_REQ, 2, NULL); // If successfully allocated if (req.pValue != NULL) { // Fill up request req.handle = discInfo[0].charHdl; req.len = 2; req.pValue[0] = (uint16_t)newValue; //SEND THE DATA THAT JUST ARRIVED req.sig = 0; req.cmd = 0; Display_print0(dispHandle, MR_ROW_STATUS2+4,0,"SENDING DATA"); // Send GATT write to controller status = GATT_WriteCharValue(connHandleMap[0].connHandle, &req, selfEntity); //connHandleMap[0] is the connection to the other TI CC2640R2 device. Display_print1(dispHandle,MR_ROW_STATUS2+5,0,"DID IT SUCCEED? %d",status); // If not sucessfully sent if ( status != SUCCESS ) { // Free write request as the controller will not GATT_bm_free((gattMsg_t *)&req, ATT_WRITE_REQ); } }

I expect this code to send the incoming data to the characteristic 3 to the connected TI device but it doesn't. The status returns false. I also get a "Write Error 13" every time I try to write to characteristic 3 from the iPhone.

I think that the error happens because of the selfEntity input to GATT_WriteCharValue. I think I need to put the entity of the connected TI device but I could not figure out how to get that entity.

However, the problem may be something else. In that case, could you explain how to pass the data coming to a characteristic to a connected device?

Any help would be appreciated,

Thanks.

Berkan

  • Hi,

    I don't see in your code where you are printing "Write Error" in your code snippet. I don't think the selfentity is the issue, there should be just one selfentity value in the task that tells the stack which task to send the event message back.

    Can you confirm the return value of GATT_WriteCharValue()?

    The error code 0x0D refers to Invalid Attribute Value Length. Can you use memcpy when writing the value to req.pValue?

    Best wishes
  • Hello,

    I am not printing "Write Error 13", it automatically prints once the GATT_WriteCharValue() line is evaluated. After you mentioned value length, I inspected the code a little bit and found that only length of 1 is accepted. After changing the length to 1, the problem was solved. I didn't need to use memcpy.

    Thanks for your response.