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.

BLE simple data transfer between two devices

Other Parts Discussed in Thread: CC2540

Hi All,

 

I am absolutely new in low-level programming, and my current project involves the following: a simple device saves data to the flash memory, and in a specific state sends all of the data to another one (which is connected to the PC via USB).

Therefore there will be two main parts:

1. Device: I found out that this should be a GAP peripheral and GATT server. 

2. PC-side: GAP central, GATT client.

The most difficult for me is the transfer of data. I think that I should start from the project SimpleBLEPeripheral for the device and SimpleBLECentral for the PC-side. I also guess that I should modify the simpleGATTProfile in a way to be one of the characteristic values (e.g. 5th) the same size as the basic unit of data (one measurement).

The scenario is something like this:

0. (saved data is given);

1. device advertises;

2. PC connects;

3. device starts to upload saved data measurement-by-measurement.

Are my previous thougths true? How can I read the current measurement data in the SimpleBLECentral project? How can PC detect that there's a new measurement in the characteristic value to be read? And how can device detect that the first measurement is succesfully uploaded, and a new one can be set? Do I have to use bond manager, or it is possible to automatically connect to any device in the neighborhood without using it?

 

Any hints are welcome!

Regards,

Gergo Zsiak

  • Hi Gergo,

    Thanks for the detailed system overview. What is the size of each measurement and more important, how much do you need to store?

    The usual case is to send a notification (max 20 Bytes) as soon as a characteristic value is updated. This would mean that a connection already has been established, not necessarily with a bond manager though.

    BR

  • Hi Nick,

     

    Thanks for your reply.

    The size of one measurement will be probably 19 Bytes. The flash memory which will be placed on the board is the size of 32 or 64 MBytes. We have to be prepared for data series of this size.

    First I should establish the connection between the devices, then update the characteristic value periodically, and a notification will be sent. Do I understand well? Can it be a problem if the other side doesn't finish handling the notification and a new one is sent meanwhile?

    Which is the best sample project for the PC-side software to start from? I haven't found any documentation about the notifications, could you recommend one? (if there's any)

     

    Thanks,

    Gergo

  • Gergo Zsiak said:
    First I should establish the connection between the devices, then update the characteristic value periodically, and a notification will be sent

    Yes, I believe this is one efficient method. Each connection event (minimum interval of 7.5ms) can send up to 4 notification, so you'll need to control the update frequency for the characteristic value. Note that the Central Device does not acknowledge the notification so you wont know if an update has been missed.

    Gergo Zsiak said:
    Which is the best sample project for the PC-side software to start from?

    I would recommend using the simpleBLEperipheral and simpleBLEcentral. You will find relevant documentation and examples in the BLEv1.1 release (ti.com/blestack), start with TI_BLE_Software_Developer's_Guide.pdf

    Good Luck

    BR

  • Now it's much clearer, I'm going to try this method.

     

    Many thanks,

    Gergo

  • Hi Nick,

    I guess, that notifcations are simple OSAL messages from the client point of view, and the event member of the message is "GATT_MSG_EVENT". Then the message should be casted into gattMsgEvent_t*. The medthod is ATT_HANDLE_VALUE_NOTIFICATION, and the actual data can be found in its msg member, more precisely in the handleValueNoti member of the msg. There the handle means which characteristic value has been changed recently, and the value is what I need. 

    Am I right? 

    Thanks,

    Gergo

     

     

  • Hi Gergo,

    You seem to understand the message flow in the central/client.  I believe that is one way to describe the process. 

    BR

  • Hi Nick,

    Another question: is this way also a rational solution for transferring larger amount of data? For example a large sized characteristic value , where I write next part ot the whole data (a few MBytes), and when a notification is sent, the client reads back the whole data (not only the 20 byte prefix). Which is the best method to transfer such amount of data?

    Thanks,

    Gergő

     

  • Hi,

    As you might seen, BLE isn’t really designed for large data transfers. For every connection event, you can send 4*20Bytes so with very small connection interval you can have transfer rate of approximately 8-10KB/s, but this also depends a lot on the quality of the link. This implies that you are able to transfer 1MB in ~100s, so we are talking of minutes for the transfer of "a few MBytes", which I assume is not even near the small amount time you would like.

    BR

  • I am also interested in realistic throughput.  The wikipedia entry for Bluetooth Low Energy calls out an application throughput of ~ .260 Mb/s.

    You mention 8-10 kB/s based on a minimum connection interval of 7.5 ms and a payload of 4*20 Bytes.

    I see the BLE SDK calls out 7.5 ms as the minimum connection interval.  Can you explain the 4*20 Byte limitation?

    Thank you,

    Ryan

  • Hi Ryan,

    there is a maximum buffer for notifications.

    Please read:

    http://e2e.ti.com/support/low_power_rf/f/538/p/108807/384844.aspx

    And this:

    http://e2e.ti.com/support/low_power_rf/f/538/t/123119.aspx

    They are short threads ;) Good luck!

  • Thanks, that helps.  

    It sounds like 80 Bytes per connection event is a limitation of the BLE Stack implementation (not necessarily of the BLE protocol):

    http://e2e.ti.com/support/low_power_rf/f/538/p/71381/267180.aspx

    Are there any plans to increase this limit in the BLE stack (or alternative firmware)?   What is the maximum MTU in the BT LE spec?

    Thanks,

    Ryan

  • That link suggests a maximum payload size of 27 bytes, but then goes on to mention "MTU larger than the above mentioned values can be supported by the L2CAP specification." The forum link I posted suggests a maximum MTU of 500+ Bytes.

    To achieve the (admittedly questionable) wikipedia BT LE application throughput of .260 Mb/s requires sending 256 Bytes every 7.5 ms.

    I'd like to reconcile these values & understand the hardware vs. firmware limitations of the cc2540.  Step 1 is probably to read the BT LE spec.

    Thanks for your help.

  • Hi Kazola

    Have you implemented this with the CC2540 (& stack)?

    Thx for an answer and BR