Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

FDS mix fds_record_find_by_key() and fds_record_find()

Hi, I was wondering if it's safe to do something like:

uint16_t recordKey = 15;
fds_record_desc_t desc;
fds_flash_record_t flashRecord;
fds_find_token_t outerToken;
fds_find_token_t innerToken;
memset(&outerToken, 0x00, sizeof(fds_find_token_t));


while (fds_record_find_by_key(recordKey, &desc, &outerToken) == FDS_SUCCESS) {
    fds_record_open(&desc, &flashRecord);
    uint16_t fileId = flashRecord.p_header->file_id;
    fds_record_close(&recordDesc);
    
    memcpy(&innerToken, &outerToken, sizeof(fds_find_token_t));
    while (fds_record_find(fileId, recordKey, &desc, &innerToken) == FDS_SUCCESS) {
        fds_record_open(&desc, &flashRecord);
        // Read the record.
        fds_record_close(&recordDesc);
    }
}

Related