Hello,
I use pstorage to store in nvm some default values after first boot, and change those values via uart commands. My cb handler looks the same as one in this example: devzone.nordicsemi.com/.../
Function responsible for clear, store, and load those values is run after first boot.
static void ps_load_default_parameters(void)
{
printf("pstorage clear 16 bytes from block 0 \r\n");
pstorage_clear(&block_0_handle, 16);
printf("pstorage clear 16 bytes from block 1 \r\n");
pstorage_clear(&block_1_handle, 16);
printf("pstorage clear 16 bytes from block 2 \r\n");
pstorage_clear(&block_2_handle, 16);
printf("pstorage clear 16 bytes from block 3 \r\n");
pstorage_clear(&block_3_handle, 16);
printf("pstorage clear 16 bytes from block 4 \r\n");
pstorage_clear(&block_4_handle, 16);
printf("pstorage clear 16 bytes from block 5 \r\n");
pstorage_wait_handle = block_5_handle.block_id; //Specify which pstorage handle to wait for
pstorage_wait_flag = 1; //Set the wait flag. Cleared in the example_cb_handler
pstorage_clear(&block_5_handle, 16);
while(pstorage_wait_flag) {power_manage();}
printf("pstorage store into block 0 \r\n");
pstorage_store(&block_0_handle, key_dv, 16, 0); //Write to flash, only one block is allowed for each pstorage_store command
printf("pstorage store into block 1 \r\n");
pstorage_store(&block_1_handle, uuid_dv, 16, 0);
printf("pstorage store into block 2 \r\n");
pstorage_store(&block_2_handle, minor_dv, 2, 14);
printf("pstorage store into block 3 \r\n");
pstorage_store(&block_3_handle, majnor_dv, 2, 14);
printf("pstorage store into block 4 \r\n");
pstorage_store(&block_4_handle, tx_power_dv, 1, 15);
printf("pstorage store into block 5 \r\n");
pstorage_wait_handle = block_5_handle.block_id; //Specify which pstorage handle to wait for
pstorage_wait_flag = 1; //Set the wait flag. Cleared in the example_cb_handler
pstorage_store(&block_5_handle, advertising_interval_dv, 2, 14);
while(pstorage_wait_flag) {power_manage();}
printf("pstorage load into block 0 \r\n");
pstorage_load(key_av, &block_0_handle, 16, 0); //Read from flash, only one block is allowed for each pstorage_load command
printf("pstorage load into block 1 \r\n");
pstorage_load(uuid_av, &block_1_handle, 16, 0);
printf("pstorage load into block 2 \r\n");
pstorage_load(minor_av, &block_2_handle, 2, 14);
printf("pstorage load into block 3 \r\n");
pstorage_load(majnor_av, &block_3_handle, 2, 14);
printf("pstorage load into block 4 \r\n");
pstorage_load(tx_power_av, &block_4_handle, 1, 15);
printf("pstorage load into block 5 \r\n");
pstorage_wait_handle = block_5_handle.block_id; //Specify which pstorage handle to wait for
pstorage_wait_flag = 1; //Set the wait flag. Cleared in the example_cb_handler
pstorage_load(advertising_interval_av, &block_5_handle, 2, 14);
while(pstorage_wait_flag) {power_manage();}
}
After function being executed, this is on terminal:
pstorage clear 16 bytes from block 0
pstorage clear 16 bytes from block 1
pstorage clear 16 bytes from block 2
pstorage clear 16 bytes from block 3
pstopstorage CLEAR callback received
rage clear 16 bytes from block 4
pstorage clear 16 bytes from block 5
pstorage CLEAR callback received
pstorage CLEAR callback received
pstorage CLEAR callback received
pstorage CLEAR callback received
Flag = 0
pstorage CLEAR callback received
pstorage store into block 0
pstorage store into block 1
pstopstorage STORE callback received
rage store into block 2pstorage STORE callback received
pstorage store into block 3
pstorage store into block 4
pstorage store into block 5
It stop after second store callback. Why this is happening?