PlatformIO Community

I need to implement a big list

Hi.

My name is Jorge and I am a Firmware Engineer.

I am developing a BLE scan that gets into lists the main characteristics of the BLEs founded.

The struct I am using for that is:

typedef struct
{
char minor[5];
char rssi[3];
int rssi_number;
int epoch_date;
}
ble_list_info_t;

I need an aux array and an RTC data array to save data in deep sleep. The aux array doesn’t need to be saved, it can be called by malloc() and free().

I use this struct as an array of structs.

//Internal BLE list
ble_list_info_t aux_list[MAX_LIST_BLE_VISUALIZATION];

//Saved list
RTC_DATA_ATTR ble_list_info_t visualization_list[MAX_LIST_BLE_VISUALIZATION];

The problem is that when I try to increment the define MAX_LIST_BLE_VISUALIZATION to 1000 I have this compilation problem:
image

I need a long list in my main code. RTC_DATA_ATTR doesn´t fit.

  1. Is there any method to declare the variable RTC_DATA_ATTR ble_list_info_t visualization_list[MAX_LIST_BLE_VISUALIZATION]; in another segment that saves data during deep sleep and doesn´t overflow?

  2. If not, how I can fix my problem?

Thanks in advance.

Jorge

The rtc_slow_seg has a length of 7,680 bytes. Your structure there is 16 bytes long. 1000 of them would need 16,0000 bytes. That cannot fit, you can fit at maximum 480 elements, assuming nothing else is occupying RTC memory.

You may try to reduce the structure size, e.g. uint16_t instead of ints? Or why is the rssi a 3-byte string and not a say, int8_t (-128 to 127 [dB])?. Or save it somewhere with more space, e.g. internal flash / SPIFFS.

Dear maxgerhardt:

I will fix the int variable to int8_t, but that will make me gain a little more entries.

Is there a simple form to declare my struct into the flash?

I ask that because I have used the flash but for simple variables:

//handler variable
nvs_handle_t my_handle;

//READ STATE VALUE FROM EEPROM
esp_err_t err=nvs_flash_init();
err=nvs_open(“storage”, NVS_READWRITE, &my_handle);
if(err == ESP_OK)
{
nvs_get_i8(my_handle, “get_ARMED_value”, &device_mode);
}
nvs_close(my_handle);
nvs_flash_deinit();

//WRITE STATE TO EEPROM// READ STATE VALUE FROM EEPROM
esp_err_t err=nvs_flash_init();
err=nvs_open(“storage”, NVS_READWRITE, &my_handle);
if(err == ESP_OK)
{
nvs_set_i8(my_handle, “get_ARMED_value”, device_mode);
printf_debug(1, "Error code ", err, 0, “”, PRINTF_ENABLER);
}
nvs_close(my_handle);
nvs_flash_deinit();

For Arduino there is the EEPROM library, for ESP-IDF there’s the NVS library as you’ve mentioned. I don’t know of a very-simple way to declare a variable into flash that is also changed on demand – if you declare it const it will be in flash but unchangable, if not const it will end up in RAM.