I want to use pstorage with ble uart to store the data over bluetooth to flash . I did the coding for the pstorage operations. But the problem is that the pstorage store, clear and update functions not making the callback to exampleb_cb_handler.But the the load operation is working fine. The pstorage_access_status_get always show count greater than 0. what I am doing wrong?
static void example_cb_handler(pstorage_handle_t * handle,
uint8_t op_code,
uint32_t result,
uint8_t * p_data,
uint32_t data_len){
app_uart_put('e');
switch(op_code)
{
case PSTORAGE_LOAD_OP_CODE:
if (result == NRF_SUCCESS)
{
// Store operation successful.
app_uart_put('l');
}
else
{
app_uart_put('f');
// Store operation failed.
}
// Source memory can now be reused or freed.
break;
case PSTORAGE_UPDATE_OP_CODE:
if (result == NRF_SUCCESS)
{
app_uart_put('u');
// Update operation successful.
}
else
{
// Update operation failed.
app_uart_put('f');
}
break;
case PSTORAGE_CLEAR_OP_CODE:
if (result == NRF_SUCCESS)
{
pstorage_wait_flag = 0;
app_uart_put('c');
// Clear operation successful.
}
else
{
app_uart_put('f');
// Clear operation failed.
}
break;
case PSTORAGE_STORE_OP_CODE:
if (result == NRF_SUCCESS)
{
app_uart_put('s');
// Clear operation successful.
}
else
{
app_uart_put('f');
// Clear operation failed.
}
break;
}}
void example_pstorage_init(void)
{
uint32_t retval;
pstorage_handle_t base_handle;
pstorage_handle_t block_handle;
pstorage_module_param_t param;
uint8_t source_data[500]={79,79,0,0,0,0,0,0,125,0,69,68,82,83,84};
uint8_t dest_data[500];
retval = pstorage_init();
if(retval == NRF_SUCCESS)
{
// Module initialization successful.
}
else
{
// Initialization failed, take corrective action.
}
param.block_size = 1024;
param.block_count = 1;
param.cb = example_cb_handler;
retval = pstorage_register(¶m, & base_handle);
app_uart_put(retval);
if (retval == NRF_SUCCESS)
{
// Registration successful.
}
else
{
// Failed to register, take corrective action.
}
retval = pstorage_block_identifier_get(&base_handle, 0, &block_handle);
app_uart_put(retval);
if (retval == NRF_SUCCESS)
{
// Get Block Identifier successful.
}
else
{
// Failed to get block id, take corrective action.
}
retval = pstorage_clear(&block_handle, 1024);
app_uart_put(retval);
pstorage_wait_flag = 1;
//while(pstorage_wait_flag) { power_manage(); }
uint32_t count;
app_uart_put(retval);
pstorage_store(&block_handle, source_data, 500, 0);
pstorage_load(dest_data, &block_handle, 100, 0);
retval = pstorage_access_status_get(&count);
app_uart_put(count);
for(i=0;i<100;i++)
{
app_uart_put(dest_data[i]);
}
}