This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

pstorage opration

Hi,everyone, In my project ,I want to save some data when disconnect evt happens; here is my code: the problem is ths program always stuck in power_manage() function; what shell i do to fix it?thanks.

 pstorage_handle_t               handle;
 pstorage_handle_t	        block_0_handle;
 pstorage_module_param_t   param;
 uint32_t                              retval;

static void on_disconnect(ble_pwm_t * p_pwm, ble_evt_t * p_ble_evt)
 {
        UNUSED_PARAMETER(p_ble_evt);
        p_pwm->conn_handle = BLE_CONN_HANDLE_INVALID;
        retval = pstorage_init();
    if(retval != NRF_SUCCESS)
    {
       nrf_gpio_pin_set(LED_0);
    }	
	param.block_size  = 16;                   
	param.block_count = 1;                   
	param.cb          = example_cb_handler;   
	retval = pstorage_register(&param, &handle);
	if (retval != NRF_SUCCESS)
	{
			nrf_gpio_pin_set(LED_0);
	}
	pstorage_block_identifier_get(&handle, 0, &block_0_handle);
            pstorage_load(dest_data_0, &block_0_handle, 16, 0);
	pstorage_wait_handle = block_0_handle.block_id;            
	pstorage_wait_flag = 1;                                    
	pstorage_clear(&block_0_handle, 16);
            while(pstorage_wait_flag) { power_manage(); } 
        pstorage_load(dest_data_0, &block_0_handle, 16, 0);

	pstorage_wait_handle = block_0_handle.block_id;            
	pstorage_wait_flag = 1; 
	pstorage_store(&block_0_handle, source_data_0, 16, 0);
            while(pstorage_wait_flag) {power_manage();}     
	pstorage_load(dest_data_0, &block_0_handle, 16, 0);

}

Parents
  • Hi

    I assume you have copied the example code that is provided on this thread.

    If it never gets out of the while(pstorage_wait_flag) {power_manage();} loop, then the pstorage_wait_flag is never cleared. Have you included the event handler in the example that clears the pstorage_wait_flag when the pstorage callback is received? It is the example_cb_handler in the example.

Reply
  • Hi

    I assume you have copied the example code that is provided on this thread.

    If it never gets out of the while(pstorage_wait_flag) {power_manage();} loop, then the pstorage_wait_flag is never cleared. Have you included the event handler in the example that clears the pstorage_wait_flag when the pstorage callback is received? It is the example_cb_handler in the example.

Children
Related