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

FDS update completion status

Hi,

I use FDS to store some data.

After creating the file, update the data using fds_record_update().

When the update is completed, FDS_EVT_UPDATE occurs in FDS_Event_handler.

However, even when the FDS is updated by the peer manager, FDS_EVT_UPDATE occurs.

void FDS_Event_handler( fds_evt_t const * p_evt )
{
    switch (p_evt->id)
    {
        case FDS_EVT_INIT:
        ......
		    break;
		case FDS_EVT_GC:
		......
		    break;
		case FDS_EVT_WRITE:
		......
		    break;
		case FDS_EVT_DEL_RECORD:
		......
		    break;
		case FDS_EVT_UPDATE:
		......
            break;
    }
}


void FDS_Init( void )
{
	fds_register(FDS_Event_handler);
	fds_init();
}

void FdsUpdate( const void *Data_c, uint16_t fid )
{
	fds_record_desc_t desc = {0};
	fds_find_token_t  tok  = {0};
	fds_record_t RecData;	
	ret_code_t fds_error;
	
	RecData.file_id = fid;
	RecData.key = DEFAULT_RKEY;
	RecData.data.p_data = Data_c;
	RecData.data.length_words = DEFAULT_SIZE;

	if( fds_record_find( RecData.file_id, RecData.key, &desc, &tok ) == NRF_SUCCESS )
	{		
		fds_error = fds_record_update( &desc, &RecData );
		if( fds_error == FDS_ERR_NO_SPACE_IN_FLASH )
		{
			fds_gc();					// run garbage collection
			fds_record_update ( &desc, &RecData );
			}
		}			
	}
}

How can I check if the file updated by FdsUpdate(), not the peer manager, is completed?

  • Hi,

    The fds_evt_t parameter contains information about the file ID and Record Key of the updated record. You can compare this to the ones used by your application and Peer Manager to determine the source of the write/update.

    #define PDS_FIRST_RESERVED_FILE_ID    (0xC000)  /**< The beginning of the range of file IDs reserved for Peer Manager. */
    #define PDS_LAST_RESERVED_FILE_ID     (0xFFFE)  /**< The end of the range of file IDs reserved for Peer Manager. */
    #define PDS_FIRST_RESERVED_RECORD_KEY (0xC000)  /**< The beginning of the range of record keys reserved for Peer Manager. */
    #define PDS_LAST_RESERVED_RECORD_KEY  (0xFFFE)  /**< The end of the range of record keys reserved for Peer Manager. */

    Best regards,
    Jørgen

Related