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_handle_t is lost in BLE NUS data event

why m_storageHandle_DeviceName became to 0xFFFFFFFF, its value was init by pstorage_register when app startup, but here it lost value. Can anybody help me ?

// event on receiving data from ble uart service
static void on_nus_data_evt(ble_nus_t * p_nus, uint8_t * p_data, uint16_t length)
{
    uint32_t err_code = 0;
    if (p_data != NULL && length > 0)
    {
        err = pstorage_clear( & m_storageHandle_DeviceName, 
                                       DEVICE_NAME_LENGTH*4);
	APP_ERROR_CHECK(err);
    }
}
  • You mean before calling pstorage_clear() m_storageHandle_DeviceName != 0xFFFFFFFF and after calling pstorage_clear() m_storageHandle_DeviceName == 0xFFFFFFFF?

    Where do you declare m_storageHandle_DeviceName variable? In the same file with on_nus_data_evt()? If not then are you exporting it properly?

  • Yes, m_storageHandle_DeviceName is declared in the same file with on_nus_data_evt(). When startup, I called follow 3 functions successfully. 1, pstorage_init(); 2, pstorage_register(); 3, pstorage_load(); Here, m_storageHandle_DeviceName has a valid value.

    When on_nus_data_evt() is triggered, I found the value of m_storageHandle_DeviceName become 0xFFFFFFFF. WHY?

  • Are you calling pstorage_init() yourself or are you talking about pstorage_init() inside device_manager_init()? Did you test the value of m_storageHandle_DeviceName right before calling pstorage_clear() inside on_nus_data_evt()?

  • 1, pstorage_init() is in bond_manager_init, not called by myself. 2, Yes, I test the value of m_storageHandle_DeviceName right before calling pstorage_clear() inside on_nus_data_evt(), it is 0xFFFFFFFF

  • It's 0xFFFFFFFF right before calling pstorage_clear()? Not after?

    Do you have on_nus_data_evt() and pstorage_register() in the same file? Or pstorage_register in main and on_nus_data_evt() in ble_nus.c or somewhere else?

    Show your code so I can check it.

Related