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.

RTOS/CC2650EM-7ID-RD: SimpleBLECentral read/write characteristic

Part Number: CC2650EM-7ID-RD

Tool/software: TI-RTOS

Hello,

I've setup two SmartRF06, one in central mode, the other in peripheral mode. I have created 4 custom services and was able to connect the central to the peripheral. If connected, button UP will alternate sample read/write requests.

The responses are:

  • read: 0
  • write: error 3

In peripheral the characteristics are set read only. My problem is, I have no clue which chara is tried to read.

So if this is a read/write request, how do I perform the actual read/write of a characteristics? And at which point have I to set the UUID?

note:

This is the request function I used:

bStatus_t GATT_ReadCharValue(uint16 connHandle, attReadReq_t *pReq,
                             uint8 taskId)
{
  return gattRequest(connHandle, (attMsg_t *)pReq, taskId, ATT_READ_REQ);
}

bStatus_t GATT_WriteCharValue(uint16 connHandle, attWriteReq_t *pReq,
                              uint8 taskId)
{
  return gattRequest(connHandle, (attMsg_t *)pReq, taskId, ATT_WRITE_REQ);
}

  • Hi Luis,

    Yes, you can use those API to read/write to the characteristics. For example, you can look at the simple_central project to see how it is done:

    Write a character:

    req.handle = charHdl;
    req.len = 1;
    req.pValue[0] = charVal;
    req.sig = 0;
    req.cmd = 0;

    status = GATT_WriteCharValue(connHandle, &req, selfEntity);

    Read a character:
    // Do a read
    attReadReq_t req;

    req.handle = charHdl;
    status = GATT_ReadCharValue(connHandle, &req, selfEntity);

    You have to know the handle of the characteristic, which is found in the discovery process. Also you should not try to write to a characteristic if it does not have write properties otherwise it will return an error.

    Best wishes
  • Hi Zahid,

    thank you for your response. Now I understand that I have to work with the handle and not with the UUID.  There is another thread, similar to mine: e2e.ti.com/.../508093

    There was still the question how to reference the UUID to the handle and at this point I have still no idea. For my example, I do have some custom services. How do I know which one is the one I want to read/write?

    Btw, I figured out what my problem was. I wasn't able to read/write because the discovery routine couldn't findthe right service and so it couldn't continue with the characteristic discovery. At this point:

    // Service found, store handles
        if (pMsg->method == ATT_FIND_BY_TYPE_VALUE_RSP &&
            pMsg->msg.findByTypeValueRsp.numInfo > 0)

    pMsg.method is 0x01.

    My service got 0xFF01 as UUID. I'm sure there is something incompatible with the SimpleBLECentral_processGATTDiscEvent function. Have you any suggestions?

    best regards

  • Hi,

    0x01 corresponds to ATT_ERROR_RSP.
    Did you call the GATT_DiscPrimaryServiceByUUID()?

    Best wishes
  • Hi,

    yes I called

    status = GATT_DiscPrimaryServiceByUUID(connHandle, uuid, ATT_BT_UUID_SIZE, selfEntity);

    Where uuid = 0xF0FF given by

    uint8_t uuid[ATT_BT_UUID_SIZE] = { LO_UINT16(SIMPLEPROFILE_SERV_UUID),
                                             HI_UINT16(SIMPLEPROFILE_SERV_UUID) };

    The response of GATT_DiscPrimaryServiceByUUID() is 0x00 (status = 0x00).

    If I got ATT_ERROR_RSP, does this mean, that my peripheral is not answering or my central sends the wrong request?

  • I found out, that the response of GATT_DiscPrimaryServiceByUUID() is always SUCCESS, I don't know why. I've given now another UUID as parameter, the one from a primary service on my peripheral (0x180A). Response is also SUCCESS, but discState never changes to BLE_DISC_STATE_SVC (0x02). There are also no more gattDiscEvents...

    What I'm doing now is just using TI's predefined functions & services. Am I missing something?

    best regards

    UPDATE: After service discovery I get

    pMsg->msg.errorRsp.errCode (= 0x0A) //ATT_ERR_ATTR_NOT_FOUND
    pMsg->msg.errorRsp.reqOpcode (= 0x06) //ATT_FIND_BY_TYPE_VALUE_REQ

    as response. It seems like it is a failed request. This error is only set, when a red or write request of an attribute fails.