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

How do I save RSSI value information to a .csv file from the ble_app_interactive example?

I am trying to save rssi data that I print to the command line to a .csv file.

In the ble_app_interactive example in the cli_m.c file, here is my code:

static void device_list_print(nrf_cli_t const * p_cli, scanned_device_t * p_device)
{
    FILE * fp = fopen("rssi.csv","w");
    for (uint8_t i = 0; i < DEVICE_TO_FIND_MAX; i++)
    {
        if (p_device[i].is_not_empty)
        {
            nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "Device/RSSI(in dBm): ");

            char buffer[ADDR_STRING_LEN];
            int_addr_to_hex_str(buffer, BLE_GAP_ADDR_LEN, p_device[i].addr);

            nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "%6s %4s %4d\n", buffer,  p_device[i].dev_name, p_device[i].rssi);
            fprintf(fp, "%4d\n", p_device[i].rssi);
        }
    }
    fclose(fp);

}

Without the following lines, the command line runs:

  • FILE * fp = fopen("rssi.csv","w");    //creates my .csv file
  • fprintf(fp, "%4d\n", p_device[i].rssi);  //prints the p_device[i].rssi value
  • fclose(fp); //closes file

With those commands, the rssi.csv file is not created.

What I have tried and did not work:

  • editing the main.c file to have the .csv values
  • printing numbers other than p_device[i].rssi in the Nordic Example

What works:

  • running a simple program with the same commands from above works (see attached code, terminal, and file created)

What I want to know:

  • how do I save the rssi value information to a .csv file?

Extra info:

Here is a picture of the cli that works without the .csv commands

Related