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

pstorage_load stops Ble_advertising

Hey , My application stores the data on BLE disconnect to pstorage succesfully. But on reset if i try to read the data from pstorage it stops advertising, but the pstorage_load returns the same value that i stored previously.

can anyone please help me with this. Here is my code

       int main(void)
 {
	ret_code_t err_code ;
	
	SEGGER_RTT_WriteString(0, "Initialization...\n");
	// Initialize.
    timers_init();
    ble_stack_init();
	pstorage_test_init();
	gap_params_init();
services_init();
advertising_init();
conn_params_init();
	gpiote_init();
		
SEGGER_RTT_WriteString(0, "Advertising starts..\n");
advertising_start();
	
  appRTCInit();
  epoch_pstorage_load();
// Enter main loop.
for (;;)
{
    power_manage();
}

}

i have attached my code

main.c

image description

  • That snippet doesn't really help. What are you doing with the loaded data, changing an advertisement packet? Is your device advertising before you load or it doesn't advertise at all? What error messages are you getting?

  • the module is not advertising at all. if i comment epoch_pstorage_load(); function it is advertising . the code snippet for epoch_pstorage_load() is : void epoch_pstorage_load() { uint8_t dest_data_0[4]; uint32_t retval; uint8_t i; uint32_t count;

    	char 										recieved_data[20];					
    	SEGGER_RTT_WriteString(0,"pstorage load blocks 0 \r\n");
    	retval= pstorage_load(dest_data_0, &block_handle, 32, 0);				 //Read from flash, only one block is allowed for each pstorage_load comman		
    	if(retval != NRF_SUCCESS)
    	{	
    		SEGGER_RTT_WriteString(0,"Error in Store Pstorage");
    	}
    	
    	for( i= 0; i<4 ;i++)
    	{
    	sprintf(recieved_data," Load Data:%x\n",dest_data_0[i]);
      SEGGER_RTT_WriteString(0, recieved_data);
    	}
    
    	pstorage_wait_handle = block_handle.block_id;            
    pstorage_wait_flag = 1;                                    
    pstorage_clear(&block_handle, 32);
    while(pstorage_wait_flag) { power_manage(); }
    

    }

  • My application needs to store the data on ble disconnect and retrieve the data on readvertising. I can store the data to pstorage succesfully on ble_disconnect. and im calling the pstorage_load in main loop which is stopping advertising. My doubt is: does calling pstorage_load function from main loop stops advertising? is there any example such that it explains where should call the pstorage_load function so that i can get the data after reset.?

  • Your code snippets do not match your questions. If you want to read data saved in flash after reset then put a call just before your main loop. Why would you put it in the main loop if you only ever needed it to be retrieved once on reset? The word "loop" should be enough of a hint.

  • Hey i have attached my code. I read the data from flash just before the main loop but still it not advertising.

Related