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

pstorage_store problem

Hi, I'm using nrf51822 board with SDK 10 and S110 softdevice. My application is based on uart over ble. It take 20 bytes data from a android device using nus, store that data and send a reply to the android that data is stored. First time when I store some data using pstorage_store(), It is stored successfully. Now second time I want to clear that data and store some new in place of that, so I first call pstorage_clear() and then again pstorage_store(). Now the problem arrived here, second time first 4 bytes becomes 0x0 and then remaining is my data. for example if my data is 12345678, it becomes like 00005678. I dont know what is going here. I'm using pstorage function like this and my function is defined in a pstorage_lock.c which is attached here. Please help me in this.

if(!pstorage_erase(0, 32))
{
	if(!pstorage_write(my_data, 0, 32))
	{
	 // some operation to do here
	}
}

my_data is an 20 bytes array in which data comes from android using nus.

Thanks. Amit

pstorage_lock.c

Parents
  • Here is some part of my application. I'm using nrF Uart App in android side. First I connect to the board then send some data from the android to the board. I received that data in nus_data_handler(), then to store this data, I just passed the data in StoreData() function from nus_data_handler(). I received NRF_SUCCESS from pstorage_erase() as well as from pstorage_write(), but on seeking memory I found starting 4 bytes becomes zero. I edited a line of pstorage.c which is m_next_page_addr, so that I know where the data is stored in memory.

    uint32_t pstorage_init(void){
    cmd_queue_init();
    
    m_next_app_instance = 0;
    **m_next_page_addr    = 0x0003e0c0;//PSTORAGE_DATA_START_ADDR;**
    m_current_page_id   = 0;
    
    for (uint32_t index = 0; index < PSTORAGE_NUM_OF_PAGES; index++)
    {
        m_app_table[index].cb           = NULL;
        m_app_table[index].block_size   = 0;
        m_app_table[index].block_count  = 0;
    }
    

    I did not receive any callback from pstorage_cb_handler that's why I just commented out pstorage_wait_flag in pstorage_lock.c and put a nrf_delay_ms(100) as asked by Terje Schjelderup.

    please go through this project and tell me what is missing in the code.

    Thanks.

    ble_app_uart.rar

Reply
  • Here is some part of my application. I'm using nrF Uart App in android side. First I connect to the board then send some data from the android to the board. I received that data in nus_data_handler(), then to store this data, I just passed the data in StoreData() function from nus_data_handler(). I received NRF_SUCCESS from pstorage_erase() as well as from pstorage_write(), but on seeking memory I found starting 4 bytes becomes zero. I edited a line of pstorage.c which is m_next_page_addr, so that I know where the data is stored in memory.

    uint32_t pstorage_init(void){
    cmd_queue_init();
    
    m_next_app_instance = 0;
    **m_next_page_addr    = 0x0003e0c0;//PSTORAGE_DATA_START_ADDR;**
    m_current_page_id   = 0;
    
    for (uint32_t index = 0; index < PSTORAGE_NUM_OF_PAGES; index++)
    {
        m_app_table[index].cb           = NULL;
        m_app_table[index].block_size   = 0;
        m_app_table[index].block_count  = 0;
    }
    

    I did not receive any callback from pstorage_cb_handler that's why I just commented out pstorage_wait_flag in pstorage_lock.c and put a nrf_delay_ms(100) as asked by Terje Schjelderup.

    please go through this project and tell me what is missing in the code.

    Thanks.

    ble_app_uart.rar

Children
Related