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

Unexpected return value when calling sd_ble_gatts_hvx() when notifications are not enabled

This issue concerns code using Softdevice S132 v6.1.1. v5.0.0. I did not test with any other version.

From the documentation of sd_ble_gatts_hvx in ble_gatts.h, I expect that the return value when calling this function while notifications are disabled for the characteristic in question is NRF_ERROR_INVALID_STATE.

Instead, the function returns BLE_ERROR_NOT_ENABLED, which suggests that the softdevice is not enabled, but this is of course not the case because the device in question is connected when the issue arises.

Parents Reply Children
  • Have you enabled the SoftDevice?

    As I mentioned in my initial question, the softdevice is enabled. Even a BLE connection has been established at the point that issue arises, so the behaviour of this call is indeed not as documented.

    I just assume that there was a simple mishap when implementing the function, "BLE_ERROR_NOT_ENABLED" by itself does sound like the right error to return when notifications are "not enabled"... ;-)

  • Hi.

    Could you help me reproduce the issue? Perhaps share your project? I can make the ticket private if you like :-)

    Best regards,

    Andreas

  • Hi,

    Unfortunately I haven't gotten around looking into it more closely, but I noticed that I mixed up two projects. This issue specifically concerns S132 v5.0.0 and not v6.1.1 as originally mentioned!

    Also, the product has actually been in production for some time and is not still in development.

    Regards,

    -mike

  • Hi.

    It's the same check performed for v6.1.1 as for v5.0.0, so it should not be different as far as I know.

    Best regards,

    Andreas

  • Hi Andreas,

    Could you help me reproduce the issue? Perhaps share your project? I can make the ticket private if you like :-)

    I finally managed to reproduce the issue for you. I don't even have to provide code, the Nordic SDK provides the example directly.

    Steps to reproduce:

    1. Download SDK 15.2.0
    2. Flash the associated softdevice onto an nRF52 DK (S132 v6.1.0)
    3. Build and flash the exmple "ble_peripheral\ble_app_blinky"
    4. Start the debugger and set a breakpoint in main.c, function button_event_handler(), in the if-block on line 497:
      if (err_code != NRF_SUCCESS &&
                      err_code != BLE_ERROR_INVALID_CONN_HANDLE &&
                      err_code != NRF_ERROR_INVALID_STATE &&
                      err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING)
    5. Connect to the peripheral with e.g. nRF Connect.
    6. Press Button 1 on the nRF52 DK.
    7. When you inspect the contents of the err_code variable in the debugger, you will notice that the value reads 0x3401, which corresponds to BLE_ERROR_NOT_ENABLED and is documented in ble_err.h as indicating that "sd_ble_enable has not been called."

    Best regards,

    -mike

Related