Creat and send a file over BLE

Hi,

I use NCS 2.4.2 and i want to save data sensor with a hight frequency in a nrf5340 device and send it over BLE to a nrf52840 dongle device. The nrf5340 is the peripheral.
The sensor data are at a ver hight frequency (more than 400Hz), that's why i need to save it in a file and send it by block.

I need help to find the right solution to perform this. I saw Throughput Service, Objet transfer service, NUS but i can't figure out what is the best solution.

I use coded phy also.

Regards,

Pierre-Yves

  • Is OTS can have a fastest transfer ? i can implement it with peripheral OTS and central OTC .

    I wanted to use QSPI flash because there is a lot of data to store and because i already use the flash to save other data. Also because i want to use th e OTS service and i thought that it was easier with the data in file as object to send.

    Also when i receive the data in the central device, how can i send directely the data in a file on the pc ?

    The central device is conencted in serial with a linux pc.

  • In theory, you can get a slightly better transfer rate if you set up a  CoC with OTS as discussed in this post:  L2CAP Connection-Oriented Channel (CoC) - how is it different then HVX? . However, it will not be sufficient to transmit all the sensor data with CODED phy. Remember that the bitrate is only 125 kbit/s with the s=8 encoding. 

    Piwy said:
    I wanted to use QSPI flash because there is a lot of data to store and because i already use the flash to save other data. Also because i want to use th e OTS service and i thought that it was easier with the data in file as object to send.

    I don't see any reason for storing the data to flash if the goal is to immediately relay the data to the connected client. This would make more sense if you want to store sensor data while the device is "offline".

    Piwy said:
    Also when i receive the data in the central device, how can i send directely the data in a file on the pc ?

    It should be trivial to store it to any file you want once you have figured out how to receive the data on the PC side.

  • I don't see any reason for storing the data to flash if the goal is to immediately relay the data to the connected client. This would make more sense if you want to store sensor data while the device is "offline".

    => it's because i can sometimes lose connexion beetween my devices, my peripheral is in motion
    And i could use this file as a black box also, do you know how to do this ?

    i succed to use ots object with both sample in coded and i succed to read the object from the peripheral, but the data that i read i want to save them directly with my device in my pc, do you know if it's possible and how to do it ?

  • => it's because i can sometimes lose connexion beetween my devices, my peripheral is in motion
    And i could use this file as a black box also, do you know how to do this ?

    it's possible to back up sensor measurements to the external flash and attempt to send them to the client as soon as the connection is re-established. You can use the flash API to store the raw sensor values for this as suggested earlier. However, there are some considerations that need to be made. For example, let's say for a given connection, you only have the bandwidth to send data currently being sampled. In such cases, how would you handle the backup? 

    i succed to use ots object with both sample in coded and i succed to read the object from the peripheral, but the data that i read i want to save them directly with my device in my pc, do you know if it's possible and how to do it ?

    It depends on how you're receiving the data on your PC. If it's being written to the console, you could simply redirect this data to a new file.

    https://askubuntu.com/questions/420981/how-do-i-save-terminal-output-to-a-file 

  • Hi,
    Sry i was not able to test before, that's why i don't answer before.
    I succed to use ots service and use multiple object to send data in large packets.

    I don't know haw to handle the backups, do have any idea ?

    I have a dongle ble that is used as a central device. I use the bluetooth shell sample on it. The device is plug on a rasberry. I create a software that connect to my dongle nrf52840 that extract all output from my dongle. on the other hand my peripheral send many datas. I print them on my dongle with some commands and it ake the output and put it in a file. I have rally too many data, that's why i asked if it was possible to have a thread that take only the data from the acc and put it directely on a file in my pc ?
    Because i don't want to print them if possible

Related