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

Pstorage and NUS not working together

Hi,

I have a project that uses PStorage and the Nordic UART Service. PStorage is used to store a variable that is updated by the device, irrespective of the Bluetooth, and needs to be sent over the NUS when requested. Without using PStorage, the application works perfectly. However, the variables are lost on reset which is not ideal.

The steps taken to reproduce the issue are as follows:

  1. Initialise PStorage
  2. Initialise BLE (Device Manager is initialised here as well. PStorage is NOT initialised again)
  3. Initialise Peripherals + Register PStorage
  4. Connect to Device via BLE

After connecting to the device, the device will respond to one or 2 commands that do not utilise the PStorage before freezing. On freezing, the only way to start the code again is to restart the device.

In the debugger, app_error_handler is never called and the wdt never times out. However, the device is unresponsive.

Any help would be much appreciated. I am using SDK10, SD8.0.0 on the nRF51822.

Thanks,

EDIT 1:

Attached are my header and C file for the pstorage functions.

pstorage_custom.c

pstorage_custom.h

EDIT 2:

Please find attached an example project that proves the incorrect functionality. The while loop at the end of the pstorage_custom_init() function never ends.

Pstorage-Issues.zip

Parents
  • Hi Petter, in the process of getting code that reproduces the error now. I have narrowed the error down to the callback not always being called. I assume this means that the pstorage operation has not finished and the code is waiting for the callback to be called to set the wait flag to 0. I am unsure why it is not completing though. I thought it might be my advertising interval being too low, so I upped that. Do you know of any other common practices that cause this error?

Reply
  • Hi Petter, in the process of getting code that reproduces the error now. I have narrowed the error down to the callback not always being called. I assume this means that the pstorage operation has not finished and the code is waiting for the callback to be called to set the wait flag to 0. I am unsure why it is not completing though. I thought it might be my advertising interval being too low, so I upped that. Do you know of any other common practices that cause this error?

Children
No Data
Related