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.

CC2540: Trying to make OAD characteristic readable

Part Number: CC2540

We are using the OAD firmware with the "oad_target" service.

However I have been running into problems on android to perform an Over the Air Download when to phone sends the firmware and is subscribed to the same characterisitc at the same time. So the best solution so far is to simply not subscribe and just send the firmware blindly.

Since this would be a completely blind operation I wanted to enable the oadReadAttrCB to send a read request from the phone every 100 blocks or something and get feedback from the update status like this instead.

I added the ability to read to the characteristic properties "GATT_PROP_READ | GATT_PROP_WRITE_NO_RSP | GATT_PROP_WRITE | GATT_PROP_NOTIFY;"

This works because the phone reports the characteristic is readable afterI made this change. However, when I send the read request the phone throws an error that reading is not permitted. Obviously this problem could be on the phone but I have successfully used read requests like this before, so I am thinking I am missing something on the firmware side to make this readable.

My question is basically: Do I need to do something elso to make the oad_target characteristic adImgBlock readable? 

  • Hi,

    I am not very familiar with the older CC254x devices, but looking at your description I would check if you have the Filter Accept list (formerly known as whitelist) enabled and allowing the phone included. Also, the behaviour is very similar to what happens if the characteristic is encrypted but the phone is not paired - given your list of characteristic properties does not include any encryption (GATT_PERMIT_ENCRYPT_READ), I suspect this is not the case but it might be worth checking.

    One question: why does your list of properties has both GATT_PROP_WRITE_NO_RSP and GATT_PROP_WRITE?

    Hope this helps,

    Rafael

  • EDIT: I just found another permission that was not set and I can now trigger a breakpoint in the ReadAttrCB by sending a read request. I'm going to test this now to see if the data I'm reading is actually what I'm expecting and mark this as resolved if it is the case.

    Hi and thanks for the infos.

    I can connect the phone to the BLE device and perform the write requests and also receice data via notifies so I think the whitelist should not be the problem. I have never used the whitelist before so I'm not 100% certain.

    The OAD firmware is the one TI provided, I only want to add behaviour on a read request. The ReadAttr callback function is already implemented by TI und there is even a //TBD comment that says: "TBD: is there any use for supporting readsread behavior" and thats basically what I'm trying to do.

    I also don't think encryption is a problem here. Just to clarify. i can perform a complete and successful firmware update with this firmware. So everything works as expected I just want to add the read function to improve the statbility on android devices.

    GATT_PROP_WRITE_NO_RSP and GATT_PROP_WRITE is already set per standard by TI. but it makes sense to alwas set both since it is up to the device that is sending data to decide wether it wants to send it blindly or with a success prompt.

    So it seems like adding the GATT_PROP_READ should normaly be enough to enable read? I have tried setting up a breakpoint in the AttrReadCB which is never reached.

    SOLUTION:

    This is what worked. First add GATT_PROP_READ to characteristics properties.

    GATT_PROP_READ | GATT_PROP_WRITE_NO_RSP | GATT_PROP_WRITE | GATT_PROP_NOTIFY;

    Then add GATT_PERMIT_READ to the attribute table. With both of these chances the read request works.

    // OAD Image Block Request/Response Characteristic Value
          {
            { ATT_UUID_SIZE, oadCharUUID[1] },
            GATT_PERMIT_WRITE | GATT_PERMIT_READ,
            0,
            oadCharVals+1
          },