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.

variable characteristic length , BLE stack 1.3.0, cc2540

Other Parts Discussed in Thread: BLE-STACK, CC2640

Hi All, 

I am trying to create a service with a characteristic that has variable length, but most likely I am doing something wrong and I can not implement it correctly.

I declare the characteristics size to be 20 bytes, however I want to send data between the range of 3 to 20 bytes per connection interval.

From what I've seen that is feasible, but I can not find out how to declare the characteristic correctly in order to be able to send variable length data.

The master device, iOS app in this case,can already send variable length data and I can check the "len" variable at my xxxx_WriteAttCB function and proceed accordingly.

When I try to set some data with the xxxx_SetParameter function, I get an error regarding the size of the characteristic.

By using the Bluetooth Developer Studio and the TI plug in, I can see that apart from declaring the characteristics length I can also declare minimum value etc.

Is it possible to also do that with stack 1.3.0?

(No problem if I have to port to stack 1.4.0 or any other version)

Are there any sample projects that I can look for the correct implementation?

Thanks in advance for your help.

George

  • Hello George,

    The TI Bluetooth Developer Studio is for CC2640 / BLE-Stack v2.1, so compatibility is not assured with other Stack releases, such as for CC254x.

    I think you are on the right track and should just step through the code with the CC Debugger in your SetParameter function to see why it's throwing the error. Some SetParam functions do an arbitrary len check, so you can remove that if it's not required (or you have other logic to check the length).

    I would also recommend going to BLE 1.4.1 if the opportunity presents itself. There are many updates since BLE 1.3.x including pairing updates for Android smart devices.

    Best wishes
  • Here is some iOS code that demonstrates how to send/receive variable length buffers. I used the ideas from it to implement variable length buffers in firmware, hope this helps.
  • Hi JXS, Joseph,

    Thank you both for your replies and the information you provided.

    I found a way to send variable data by using the GATT_Notification( ) function .

    My problem was that the GATTServApp_ProcessCharCfg() function was checking the length of the characteristic that was registered to the server and it didn't allow me to send notifications that were different in size.

    Best regards,
    George