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

  • Hi

    Sorry for late answer.

    I have previously seen some problems with missing callbacks, which most likely were due to incompatible versions of SDK modules, SoftDevice version and/or SoftDevice header files. Did you start this as an SDK 10 project, or is it upgraded from previous SDKs? And are you sure you have included the correct SoftDevice headers and versions?

    I usually do not use Packs, but it seems to me that you do in your project. There are two things I see with your project settings that I think may be problematic: First, there are no Include Paths in the "C/C++" tab under "Options for Target...". This seems strange to me. It also seems to cause the following error: "no source": Error: #5: cannot open source input file "function.c": No such file or directory. Second, all the packs seem to be of version 0 and the icon by the file in the Project pane signifies "File with incompatible modifications. A file update is required." (See Keil documentation for what the icons mean.)

    Apart from the above I will have a look at the code to see if I spot anything.

    Regards, Terje

Reply
  • Hi

    Sorry for late answer.

    I have previously seen some problems with missing callbacks, which most likely were due to incompatible versions of SDK modules, SoftDevice version and/or SoftDevice header files. Did you start this as an SDK 10 project, or is it upgraded from previous SDKs? And are you sure you have included the correct SoftDevice headers and versions?

    I usually do not use Packs, but it seems to me that you do in your project. There are two things I see with your project settings that I think may be problematic: First, there are no Include Paths in the "C/C++" tab under "Options for Target...". This seems strange to me. It also seems to cause the following error: "no source": Error: #5: cannot open source input file "function.c": No such file or directory. Second, all the packs seem to be of version 0 and the icon by the file in the Project pane signifies "File with incompatible modifications. A file update is required." (See Keil documentation for what the icons mean.)

    Apart from the above I will have a look at the code to see if I spot anything.

    Regards, Terje

Children
No Data
Related