NRF_SDH_BLE_OBSERVER Why Not Run

It appears that "NRF_SDH_BLE_OBSERVER" will not be run. Why?

This project ↓

"\examples\ble_central_and_peripheral\experimental\ble_app_hrs_rscs_relay\pca10056\s140\arm5_no_packs\ble_app_hrs_rscs_relay_pca10056_s140.uvprojx/main.c"

SDK: 17
IDE: Keil
SoftDevice: 7.2
Computer platform: Windows 11
Device: nRF52840 Dongle

  • Hi

    NRF_SDH_BLE_OBSERVER is a macro and not a function that is run, what exactly is your issue here as the ble_stack_init() functionshould be running fine by default in the ble_app_hrs_rscs_relay app.

    Best regards,

    Simon

  • Hi, Simon

    I wanted to port my old pc-ble driver program to SDK17, but now there are problems, I was able to initialize successfully. The code is look like

    uint32_t ble_stack_init()
    {
      uint32_t err_code;
    
      uint32_t ram_start = 0;
      err_code = nrf_sdh_enable_request();
      BLE_USB_PRINT_MSG_NUM("NRF SDH Enabel Request Error Code = 0x", err_code, 1);
      // err_code = nrf_sdh_ble_default_cfg_set(1, &ram_start);
      err_code = nrf_sdh_ble_app_ram_start_get(&ram_start);
      BLE_USB_PRINT_MSG_NUM("NRF SDH APP Ram Start Get Error Code = 0x", err_code, 1);
      err_code = ble_cfg_set(m_config_id, ram_start);
      BLE_USB_PRINT_MSG_NUM("BLE CFG Set Error Code = 0x", err_code, 1);
      err_code = nrf_sdh_ble_enable(&ram_start);
      BLE_USB_PRINT_MSG_NUM("BLE Enable Error Code = 0x", err_code, 1);
    
      switch (err_code)
      {
      case NRF_SUCCESS:
        break;
      case NRF_ERROR_INVALID_STATE:
        usb_printf_len("BLE stack already enabled\n", 16);
        break;
      default:
        BLE_USB_PRINT_MSG_NUM("Failed to enable BLE stack. Error code: 0x", err_code, 1);
        break;
      }
      NRF_SDH_BLE_OBSERVER(m_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_dispatch, NULL);
      return err_code;
    }

    When I want to connect a device or do something else that generates a BLE event, my entire application will be rebooted. I checked that it did not enter my event handler (ble_evt_dispatch).

    So I'm confused. Don't have any ideas to solve this problem.

    Best regards,

    Genfeng

  • Hi

    From what SDK version are you trying to port your program from? It seems like you maybe call ble_cfg_set and nrf_sdh_ble_app_ram_start_get in the wrong order. Are you able to see what exactly is the last to run before failing/rebooting? Some debugging is most likely required here is my guess, so if you have an nRF52840 DK that would be the best.

    Best regards,

    Simon

  • Hi

    Thanks for your response.

    1. My ble_cfg_set() function don't have nrf_sdh_ble_app_ram_start_get(), and i look for the nrf_sdh_ble_default_cfg_set() function it have app_start_get(), so i add this function before ble_cfg_set().

    2. My previous project utilized the pc-ble-driver for development, which appeared to be based on SDK 15. This project employed connectivity firmware; however, I did not build the firmware myself. Instead, it was programmed onto the dongle through 'nRF Connect for Desktop Bluetooth Low Energy'. Currently, I am attempting to migrate my previous code to the SDK, but I am encountering difficulties in capturing BLE events.

    3. Sorry, I don't have the nRF52840 DK.

    Best regards,

    Genfeng

  • Hi

    Okay, thank you for the explanation. The serialization library used in the pc-ble-driver I'm afraid was deprecated after SDK v15, so it won't be possible to port that to SDK v17 at all I'm afraid. Is there a specific reason you need to port it to the latest SDK version?

    Next, can you explain what you mean by the application rebooting when running ble_stack_init() and the SoftDevice Handler functions thereafter? It sounds like the SoftDevice just doesn't respond, but I don't see why that should result in a full restart of the system, don't you get any kind of error code or reset reason? You could always check the RESETREAS register for what exactly triggered the system to reset.

    Best regards,

    Simon

Related