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

Assistance with FDS

Hi, I am testing github.com/.../nRF52-fds-example

I am on nrf52832 with sdk 12.2.0. I can't seem to make it work. What i have done:

  • Separated FDS stuff to separate file
  • Exposed the functions which are used by main file
  • Added files to my Makefile

And now i'm testing it in main.c with this code:

  c = SEGGER_RTT_WaitKey(); // will block until data is available
  if(c == 'r'){
    SEGGER_RTT_WriteString(0, "Resetting..\n");
    nrf_delay_ms(1000);
    sd_nvic_SystemReset();
  } 
  else if(c == '1')
  {
    SEGGER_RTT_printf(0, "1\n");
    err_code = fds_test_init();
    APP_ERROR_CHECK(err_code);
    SEGGER_RTT_printf(0, "err_code = %08x\n", err_code);
  }
  else if(c == '2')
  {
    SEGGER_RTT_printf(0, "2\n");
    err_code = fds_test_find_and_delete();
    APP_ERROR_CHECK(err_code);
    SEGGER_RTT_printf(0, "err_code = %08x\n", err_code);
  }
  else if(c == '3')
  {
    SEGGER_RTT_printf(0, "3\n");
    err_code =fds_test_write();
    APP_ERROR_CHECK(err_code);
    SEGGER_RTT_printf(0, "err_code = %08x\n", err_code);
  }
  else if(c == '4')
  {
    SEGGER_RTT_printf(0, "4\n");
    err_code = fds_read();
    APP_ERROR_CHECK(err_code);
    SEGGER_RTT_printf(0, "err_code = %08x\n", err_code);
  }

All functions return 0 as a result. But fds_read() does not find anything. Suggestions?

Parents
  • FormerMember
    0 FormerMember

    Which error code does fds_read() return?

    Update 07.02.2017: fds_read() should not return NRF_SUCCESS unless it successfully found the record, if it doesn't find the record, the error code should be returned.

    static ret_code_t fds_read(void)
    {
    	#define FILE_ID     0x1111
    	#define REC_KEY     0x2222
    	fds_flash_record_t  flash_record;
    	fds_record_desc_t   record_desc;
    	fds_find_token_t    ftok ={0};//Important, make sure you zero init the ftok token
    	uint32_t *data;
    	uint32_t err_code;
    	
    	NRF_LOG_INFO("Start searching... \r\n");
    	// Loop until all records with the given key and file ID have been found.
    	while (fds_record_find(FILE_ID, REC_KEY, &record_desc, &ftok) == FDS_SUCCESS)
    	{
    			err_code = fds_record_open(&record_desc, &flash_record);
    			if ( err_code != FDS_SUCCESS)
    			{
    				return err_code;		
    			}
    			
    			NRF_LOG_INFO("Found Record ID = %d\r\n",record_desc.record_id);
    			NRF_LOG_INFO("Data = ");
    			data = (uint32_t *) flash_record.p_data;
    			for (uint8_t i=0;i<flash_record.p_header->tl.length_words;i++)
    			{
    				NRF_LOG_INFO("0x%8x ",data[i]);
    			}
    			NRF_LOG_INFO("\r\n");
    			// Access the record through the flash_record structure.
    			// Close the record when done.
    			err_code = fds_record_close(&record_desc);
    			if (err_code != FDS_SUCCESS)
    			{
    				return err_code;	
    			}
    	}
    	return NRF_SUCCESS;		
    }
    

    When fds_record() is running, does it print the starting string, "start searching"?

    Could you test the example I have been using for the testing, so that it is easier to compare your results with my results? It is the example from github placed in ble_app_hrs (SDK 12.2),to be used with S132 v. 3.0.0: ble_app_hrs-fds-test-github.zip

    In the sdk_config.h file, you can change the logging module to use RTT instead of UART.

  • FormerMember
    0 FormerMember in reply to FormerMember

    How do you check if the KEY/ID was found or not?

Reply Children
No Data
Related