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
  • Yes,I have includes the example_cb_handler in the code,I have fixed the problem, the point is that I should put the code in the main.c to init and register pstorage, and before the unlimited loop, in the disconnect event handler, we should only call pstorage_clear and pstorage_store function to realize our function,there is no delay function; the stack will handle our clearing and writing operation, internally.

  • hello, i have a similar problem, could you show me your sample code?

Reply Children
No Data
Related