Storing data (Recieved by nRF Toolbox Android App via UART) in a CSV file.

Hello Nordic family, I hope everyone is fine. 

I want to do modifications to the nRF Toolbox android App such that the data received by the nRF Toolbox android App from the peripheral (nRF52840 DK) via UART can be saved in a CSV file. The current version of the nRF Toolbox App only shows the received data in the log but I want to store the received data in a CSV file. I am new to App development and I just run the source code of the nRF Toolbox App from GitHub in the Android Studio, I have successfully got the app on the mobile and it is working properly. Now I want to do modifications to the App's source code to store the UART data in the CSV file. But I don't know how to do this. Can someone please help me in this regard? 

Best Regards,

Sami

Parents
  • Hello,

    Data are collected using BLE in ViewModel in profile_uart module:

    https://github.com/NordicSemiconductor/Android-nRF-Toolbox/blob/main/profile_uart/src/main/java/no/nordicsemi/android/uart/viewmodel/UARTViewModel.kt#L70

    In the Flow you will receive Bluetooth statuses like: ConnectingResult, ConnectedResult, SuccessResult... and SuccessResult contains inside a field with all messages. SuccessResult can be sent multiple time, one for each message send or received.

    So inside the flow you may need to do sth like that:

    (it as? SuccessResult)?.let { result ->
       val incomeMessages = result.data.messages
       //save $incomeMessages to CSV now or later
    }

    In this list you will have messages which were sent and received from the device. Just check type field of each message.

    How to store the values in CSV is up to you. You may look for some Android libraries on Github.

    Regards,

    Sylwester Zieliński

  • **Updates:

    Yes, I found this location in Android Studio. 

    So inside the flow you may need to do sth like that:

    Fullscreen
    1
    2
    3
    4
    (it as? SuccessResult)?.let { result ->
    val incomeMessages = result.data.messages
    //save $incomeMessages to CSV now or later
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    In this list you will have messages which were sent and received from the device. Just check type field of each message.

    How to store the values in CSV is up to you. You may look for some Android libraries on Github.

    Can you please refer me to a code snippet/library etc where they have implemented the logic of generating CSV files and storing data in it using kotlin language, I am totally new to kotlin and app development and don't how to do it. Your help will be highly appreciated.

    Best Regards,

    Sami

  • There are many libraries available on Github and you should look for one appropriate for you.

    We don't have knowledge about every library.

    At first glance I can say that the flow may look like that:

    1. Take these messages and serialize them to the single "String".
    2. Write this "String" to the "File" - stored somewhere on the disk.

    Maybe there are libraries which can do both points together, maybe you will need to find two separate.

    You can find example usages in README files in repositories on Github.

    You should look for a library which usage will be convenient for you.

    I am sure that you will be able to find something on your own.

    Regards,

    Sylwester Zieliński

  • Hi Sylwester Zieliński, I hope you will be fine.

    I have tried my best to add this functionality(Storing UART data in a CSV file) but I couldn't add it as I am new to app development. Can you please add this update to the nRF Toolbox for me(of course in your free time)? I will be very thankful to you for this kind act. 

    Best Regards,

    Sami

  • Hi Sami, 

    Samiulhaq said:
    Can you please add this update to the nRF Toolbox for me(of course in your free time)?

    Please contact your regional sales manager (RSM) for the feature request. If you don't know who the RSM is you can get in touch by filling in our sales related questions form.

    -Amanda H.

  • Hi Amanda H. & Sylwester Zieliński

    Now I can store the data received via UART(of the nRF Toolbox app) in a CSV file, but the problem is that the receiving data lags a lot in the nRF Toolbox app(as I am confirming from the log in the Android studio). It means that let's say the nRF52 has sent the data/file in around 1-2 minutes but the app is receiving it very slowly (taking more than 10 minutes to finish the receiving) as I am confirming from the log in the Android studio. Even if I erase or power down the nRF DK after sending the data, the app still receives the data due to lagging. As I am storing the log data in a CSV file, therefore, storing the data in a CSV file in the app is not synced with the nRF52.

    This lagging problem occurs when the data rate of sending the data (by nRF DK) is high (~1200kbps).

    One other problem, the nRF Toolbox app got hanged on the high data rate(~1200kbps) and then I am not able to do anything with the app. what will be the reason in your opinion? 

    Any help regarding this will be highly appreciated. 

    Best Regards,

    Sami

Reply
  • Hi Amanda H. & Sylwester Zieliński

    Now I can store the data received via UART(of the nRF Toolbox app) in a CSV file, but the problem is that the receiving data lags a lot in the nRF Toolbox app(as I am confirming from the log in the Android studio). It means that let's say the nRF52 has sent the data/file in around 1-2 minutes but the app is receiving it very slowly (taking more than 10 minutes to finish the receiving) as I am confirming from the log in the Android studio. Even if I erase or power down the nRF DK after sending the data, the app still receives the data due to lagging. As I am storing the log data in a CSV file, therefore, storing the data in a CSV file in the app is not synced with the nRF52.

    This lagging problem occurs when the data rate of sending the data (by nRF DK) is high (~1200kbps).

    One other problem, the nRF Toolbox app got hanged on the high data rate(~1200kbps) and then I am not able to do anything with the app. what will be the reason in your opinion? 

    Any help regarding this will be highly appreciated. 

    Best Regards,

    Sami

Children
No Data
Related