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

Parents
  • 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

Reply
  • 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

Children
No Data
Related