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.

How send lot of data (8ko) from external MCU -> cc2541 --> Android app

Other Parts Discussed in Thread: CC2541

Hello,

My application Android need to receive 8ko information from an external µC that communicates with a cc2541 via UART.

I have Network Processor Custom Firmware, with services etc...

What is the best way to transfert lot of data ?

I need a specific characteristic ?

A specific HCI command would be very welcome, but i don't know if it exist.

I need to send a packet ? How to do it in my setup ?

 


Best regards,

Steeve

  • Hi Steeve,

    I would take a look at the Serial Bridge example on the wiki.

    In general, Notifications are the most efficient method to transfer from Server to Client, although you would likely need to implement additional characteristics in your service to handle flow control and acknowledgements. Also, be sure to enable Overlapped Processing so you can send multiple packets per connection event (assuming your phone can accept multiple packets).

    Best wishes
  • Hi JXS,

    For starting, thank's you again for your help.
    I don't understand how i can add characteristics to handle flow control and acknowledgements... can you help to understand ?

    So for you, i need to add Serial Bridge (UART) in my Firmware (Host Test Custom cmd). Like this, i can send my 8ko data over UART, and the data received will be send over the air (BLE) by many notifications ?

    This config (Serial bridge) will not interfere with the setup of HostTest ? (with HCI command over UART).

    Thank you and best regards
  • Hello. If you are using HostTest, it may be easier to just sent GATT_Notfication HCI commands over UART to send the data. Due to the processing time needed to receive and parser UART, you may not be able to queue up multiple packets per connection this way. It really depends on your system so you should definitely try. If this is not fast enough, you can implement a custom HCI command which acts similarly to the bridge (send a large amount of data to the CC2541 and split these into packets to send over the air) as Jeff is describing. See steps to add a command here:

    processors.wiki.ti.com/.../BLE_HostTest_Add_Cmds
  • Hello Tim.

    For starting thank you. Tell me if i have understand :

    - Parsing 8ko data and divide them in notification (size of notification?).

    - My ext MCU send the HCI Command Gatt_Notification (then over UART), on my characteristic who have notify permissions. So i need to send 8ko / size max of notification = number of notification need to send ?

    - My android app, receive the notification, and save in a file while all data (8ko) are not send ?

    That is the way ?

    Or the best way is send 8ko data over uart and split these into packets to send over the air (for this, this is many notification on a characteristic again right?)

    Thank's you and best regards

    Steeve

  • Hello Steeve,

    Is 8ko 8kB?

    Regardless of the size, your methodology is correct. You send 20-byte Notifications from the Server to the Client. To enhance throughput put, used Overlapped Processing (see the wiki) to send multiple Notifications per CI. However, since you are sending HCI cmds over UART, as Tim mentions, it may be difficult to queue up multiple packets without a custom command that buffers multiple Notification packets on the CC254x.

    Best wishes
  • Hello Jeff,
    It's 8ko (like 8000 bytes).

    So i can send 20 bytes for one notification.
    I will need to send 400 notifications.

    I have to use Overlapped Processing to send multiple Notifications per connection interval. By the way, what is exactly the connection interval ?
    I just have to import Overlapped Processing patch in my project ?

    Your advice is create a custom command for queue up multiple packet and send notification ?
    But what do I put in it ?

    Thank you and best regards.
  • Hi Steeve,

    For a description of the Connection Interval (CI), refer to the SW Developer's Guide or some introductory BLE material on the BLE Wiki or the BT SIG website (bluetooth.org). There is also a formal description in the BT Core Specification.

    Yes, adding the Overlapped Processing (O/P) patch to the project should be ok. The steps listed on the O/P wiki will also work.

    For a custom command, you could do a bulk transfer over UART of X bytes (e.g., 256), then define/send a custom HCI command to send the data over multiple Notifications vs. sending an HCI cmd for each Notification. For adding the cmd, use the wiki link that Tim provided above.

    Question: Have you looked at the BLE Serial Bridge example? processors.wiki.ti.com/.../SerialBLEbridge

    Best wishes
  • Hi Jeff,

    I read the SW Developer's Guide for understand the Connection Interval. For my application, you think i need a short or long CI ?

    I have look BLE Serial Bridge example.
    But my external MCU need to read/write characteristic, and send notifications for the 8ko data.

    I use HostTestApp with Custom Command and profile for use HCI Command from my external MCU (like GATT_ReadLongCharValue, or Write).
    Can i have an alternative with BLE Serial Bridge ?

    By the way, without going into too much details, my µC need to know the setup of user (who choose parameter from android application). Once µC read all of setup characteristic, he start his program. At the end, µC need to send 8ko data and android app processes these data.
    So, i can do that with BLE Serial Bridge ? Because i don't know how i can implemente read characteristic from uart to many specific characteristic.

    Thank you,
    Best regards
  • Hello. You will want to use a short connection interval if you want to optimize throughput.

    Both methods (BLE bridge and HostTest) can achieve this:

    The BLE Bridge uses a custom interface optimized for data throughput. It basically just reads data from the transport layer and sends it over the air. You will need to modify the packet parser and add support for other commands such as advertising, connecting, etc.

    HostTest uses the standard HCI interface. This already supports all BLE HCI commands. You will need to add your own command if the 20-byte GATT_Notification mechanism does not satisfy your throughout requirements. This custom command would just receive a large amount of data which you would then parse and send over-the-air in HostTestApp.
  • Hello Tim,


    Thank you.

    I prefer use HostTest beacause i don't wan't program lot of with IAR. If i have to add service in the future, i create him, add on my project, add "myService_AddServices", and it's finish).

    But i have 3 problems :

    Problem 1  : i have 3 custom services (5 soon) to add. In a simpleBLEPeripheral or BLEBridge project... etc no problem ! But, in my Host Test App, i add my service in custom commande :

      case HCI_EXT_PROFILE_ADD_ARB_SVC:
          stat = ArbitraryService_AddService();           
          stat = Seuil_AddService(GATT_ALL_SERVICES);
          stat = Mesure_AddService(GATT_ALL_SERVICES);

    And i have this error :

    Error[e104]: Failed to fit all segments into specified ranges. Problem discovered in segment XDATA_N. Unable to place 2 block(s) (0xc02 byte(s) total) in 0xb33 byte(s) of memory. The problem occurred while processing the segment placement command "-P(XDATA)XDATA_N=_XDATA_START-_XDATA_END", where at the moment of placement the available memory ranges were "XDATA:13cd-1eff"

    How can i resolve that ?

    Problem 2 : With serial interface, i wan't create a read attribute fonction. So if i send (77 : 04 : B1) according to the format IDSERIAL + OPCODE (read) + IDCharacteristic

    How i can use GetParameter ? Because the parameter xxxx_GetParameter( uint8 param, void *value ). So the first (param) is my profile parameter (0,1,2...x), but the second value, what is ?

    Maybe is the badway to get the value of an characteristic, and if is bad, what is the good solution ?

    Problem 3 :

    "This custom command would just receive a large amount of data which you would then parse and send over-the-air in HostTestApp."

    So in my custom command, i prepare an IT in read UART ? And each packets of 20 octets i send a notification?

    Thank and best regards

    Steeve

  • Note that HostTestApp is the network processor project. Therefore, you should add services by sending HCI commands from another MCU. It is up to the host MCU to act as the application / profile layer. If you want to add services on the embedded project then you may as well use simpleBLEPeripheral.

    The IAR compiler error you are seeing is that you are running out of RAM. You can try decreasing the heap size via the INT_HEAP_LEN preprocessor definition. However, if you decrease this too much, there will be heap allocation errors. You can profile this with the OSALMEM_PROFILER preprocessor define (see related forum posts).

    I don't really understand the second problem. What GetParameter command are you referring to?

    For your third question, the idea is that you send a large amount of data (like 500 bytes) over UART in a custom HCI command. When this data is received in HostTestApp, you will split it into 20-byte notifications to send over the air.
  • Hello Tim,

    Thank's for HostTestApp. So when i add my customService.c/.h and call my command customService_AddService() in a custom command (like FF81), it's a bad way ?

    Concerning my second problem, i will try to explain more. I hesitate between HostTestApp or a project like bleBridge (a simpleBlePeripheral project with serial interface).

    I like HostTestApp because, i can use Btool for read my custom characteristics, get the hexadecimal command to send, and implement this hci command in my host mcu. But HostTest it's not optimised i think, because my futur device will be always in peripheral.

    That why secondly, i use BleBridge project (for uart between external mcu and cc2541). But, i don't know how i can implemant a read fonction. Example :

    I have 5 characteristics to read. I wan't send a command from my MCU who said "Give me the value of characteristic x". I have to implement a parsing in my cc2541 and i will have something like that :

    switch (characteristic){

    case CHAR_1 : //need to call a function for read.    break;

    case CHAR_2 : //same..

    }


    I mean i have to use GetParameter (function in all profile), but i don't know how.

    Thank's.

  • Hello.

    I advanced. Now, the data that I send via UART notify my characteristic . But I lost a lot of data and for my final product , it is not conceivable.

    Therefore, it is easier not to send a .txt file that contains all my data via Bluetooth? If yes, how i can do that ?

    My question for "which function use and how to read a specific characteristic" still persists...

    Thank you !