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

nRF52 Central NRF_ERROR_SOFTDEVICE_NOT_ENABLED error from sd_ble_gattc_write function call without disconnect event on single-connection central side which is seen on peripheral side

I've got an nRF52 application which is based on the nRF OpenMesh github.com/.../ but has been vastly customised. The application either acts as a mesh device and allows a single connection (peripheral device) or acts as a central device without initialising the mesh and writes updates to/reads updates from the other nodes over BLE.

The mesh nodes are all working fine together, and for a while the central node also works fine, it connects and sends data every 20 seconds or so. After about 5-15 minutes of this, the central node seemingly disconnects from the peripheral (the peripheral gets a disconnect event, the central is unaware of this and was expecting a response to a previous write which was never received). The only time the central device is aware of this is after attempting to write to the GATT server using sd_ble_gattc_write and getting an NRF_ERROR_SOFTDEVICE_NOT_ENABLED error returned - this strikes me as odd because the function description for sd_ble_gattc_write doesn't list this error as being a returnable error code. The softdevice functionality still seems operable as a timer that was setup still continues to run.

Here's a log of the last few events before this problem occures, debug information is printed on the central node using the Segger print functions (the timer events are set for 20 seconds whereby the ADC is setup, read, close and the value sent using GATT with messages being about 40 bytes in length with an MTU of 70 for both the peripheral and central devices):

Timer run event, write GATT characteristic (36 bytes)
SD_BLE_EVT: 56
WRITE_RSP
SD_BLE_EVT: 57
 > HVX hndl = 16: 11 0 80 

Timer run event, write GATT characteristic (36 bytes)
SD_BLE_EVT: 56
WRITE_RSP
SD_BLE_EVT: 57
 > HVX hndl = 16: 11 0 80 

Timer run event, write GATT characteristic (36 bytes)
SD_BLE_EVT: 56
WRITE_RSP
SD_BLE_EVT: 57
 > HVX hndl = 16: 11 0 80 

Timer run event, write GATT characteristic (36 bytes)

Timer run event, write GATT characteristic (36 bytes)
Error whilst sending: 2 (NRF_ERROR_SOFTDEVICE_NOT_ENABLED)

Timer run event, write GATT characteristic (36 bytes)
Error whilst sending: 2 (NRF_ERROR_SOFTDEVICE_NOT_ENABLED)

This is using a nRF52 on the nRF52-DK platform with the v12.0.0 SDK S132 v3.0.0 softdevice, all modules are running code compiled using GCC 6.x in debug mode. The connection interval is about 800ms, slave latency 1. MALLOC is used a few times in the application at startup which isn't cleaned up but the data is retained and designed to be used throughout the life of the application.

Modules enabled:

  • Application timer
  • QDecoder
  • GPIOTE
  • BLE DB Discovery
  • ECC
  • RNG
  • I2C
  • ADC
  • 20ppm crystals used for LF clock sources

Because the central node soft device doesn't seem to generate any events related to the disconnection (the peripheral node does get a disconnect event) I'm not really sure what next to check. The soft device is only disabled in certain circumstances like a low battery event (the nodes are running from USB and the low battery event isn't being ran in this) so why the central device is getting a not enabled error is a mystery to me.

Any comments or help would be greatly appreciated and I can provide code/debug if requested.

Related