Hello everyone,
I am working on a project using FDS. I am using the nRF52832 with the s132 SoftDevice.
As far as I can tell, the code I've written to store data records and retrieve them should work, yet I am having problems. I've confirmed with FDS stats that there are records being written, but when going to retrieve the records, I only get garbage data. I know that when writing records, the correct data is passed to the function.
My code to write records:
static void write_record(data_record_t* p_data, uint16_t key) {
fds_record_t record_to_write;
fds_record_desc_t record_desc;
ret_code_t err_code;
record_to_write.file_id = FILE_ID;
record_to_write.key = key;
record_to_write.data.p_data = (const data_record_t*) p_data;
record_to_write.data.length_words = 2;
err_code = fds_record_write(&record_desc, &record_to_write);
APP_ERROR_CHECK(err_code);
}
My code to read records:
static void read_record(uint16_t key, data_record_t* p_record) {
ret_code_t err_code;
fds_record_desc_t record_desc;
fds_find_token_t ftok;
fds_flash_record_t flash_record;
data_record_t data;
memset(&ftok, 0, sizeof(fds_find_token_t));
err_code = fds_record_find(FILE_ID, key, &record_desc, &ftok);
APP_ERROR_CHECK(err_code);
err_code = fds_record_open(&record_desc, &flash_record);
APP_ERROR_CHECK(err_code);
memcpy(&data, flash_record.p_data, sizeof(data_record_t));
p_record->next_record_key = data.next_record_key;
p_record->reading = data.reading;
err_code = fds_record_close(&record_desc);
APP_ERROR_CHECK(err_code);
}
Any ideas what might be going on here?
Thanks.