This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Scanning and data storage

Hello,

On the nRF 52840DK sdk 17and softdevice 140,

in example, peripheral „ble_app_template“ I need to transfer UUID, RSSI,... with time stamp to flash via FDS.

I advertise in NON-CONNECTABLE mode, with scan response.

The p_ble_evt->evt.gap_evt.params.scan_req_report.rssi variable gets populated with the RSSI.

The p_ble_evt-> evt.gap_evt.params.scan_req_report.peer_addr.addr variable gets populated

with the UUID.

I have FDS initialized .

Please,

How to get a timestamp, and how can this retrieved data be stored in flash.

Can you give me detailed information and any codes, if available.

Best regards

Regio

  • Hi Regio,

    How to get a timestamp

    If this timestamp is just a running number, then you can use the RTC and handle wrap-arounds. Your application probably use the app_timer module anyway (most do), and i it uses app_timer2.c, then that has an internal 64 bit counter that in practice never wraps around. If you want to use that you can modify app_timer2.c slightly making get_now() not static, and call that from your application. If you want to keep the time of day etc that is a bit more complicated (and often not needed), but in that case, you can refer to the unofficial nrf5-calendar-example.

    how can this retrieved data be stored in flash.

    You allready mention FDS, so I assume that is what you want to use. For that, you can refer to the usage section in the FDS documentation and also the FDS example (though it is a bit over-complicated).

    Einar

  • Hi Einar,

    Thank you for the information I have read your recommended documentation. But I would need direction which steps are wanted to do in the particular cases in order to downloading data to the indicated variables will be transfered for processing to FDS.

    Regio

  • Hi Regio,

    It is difficult for me to be more specific as you know better exactly what you need. In general it would work something like this:

    1. Obtain some data (UUID, RSSI, timestamp) to be stored in flash. Do you have this part working?
    2. Generate a timestamp (several ways to do this, as suggested in my previous post). Exactly how to do it is up to you.
    3. Put everything in a struct or other data format that makes sense in your case.
    4. Populate a FDS record with your struct and write it to FDS, following the usage section in the FDS documentation. Select record key and file ID for your use. Perhaps keeping file ID constant for this type of data, and using a counter for the record key. But this is fully flexible and you can organize it the way you want.

    Later you want to retrieve the data, and then  you also follow the usage section in the FDS documentation, specifically using fds_record_find() and fds_record_open().

    Einar

Related