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

Hung up on advertising

I'm migrating an old (but working) app from the S110 5.2.1 (SDK 4.X) to the latest SDK9/S110 8.0. I've read the migration doc, and I'm following the examples carefully (specifically app_hids_keyboard, app_uart, and app_hrs). All my init functions are happy: timer, scheduler (with the new APPSH stuff), softdevice (using SOFTDEVICE_HANDLER_APPSH_INIT), everything comes up nicely. Scheduler works.

Then, I call ble_advertising_start(), I get a single BLE_ADV_EVT_FAST, then never another event of any kind. My phone can't see it advertising like it used to, and I never get any errors or anything--just quiet.

The major difference I noticed with my old code is that is has the sec_params_init() and responds to BLE_GAP_EVT_SEC_INFO_REQUEST, while most of the demos respond to that with a BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP. I never get that event in any case. I noticed that the device manager seems to make those similar security settings, but when I add it into the mix, I don't even get the first advertising event I was getting.

I'm really at a loss what to look for to debug this: If I get errors, I can see them; if I get events, I can see them. But I'm getting nothing.

  • I assume sd_ble_gap_adv_start() returns NRF_SUCCESS (0x00000000)? Could you include your main()? and ble_stack_init()?

  • Yes, everything returns success. Here's my ble_stack_init:

    void bluetooth_init(void) {
        softdevice_init(); // does SOFTDEVICE_HANDLER_APPSH_INIT
        sd_ble_gap_tx_power_set(4);
        pstorage_init();
        device_manager_init(true);
    
        gap_params_init();
        services_init();
        advertising_init(); // does ble_advertising_init()
        conn_params_init();
        radio_notification_init();
    }
    

    and main():

    int main(void) {
        hardware_init();
        scheduler_init();
        timers_init();
    
        bluetooth_init();
        timers_start();
        advertise(); // does sd_ble_gap_adv_start()
    
        TRACE("main_loop_start");
        while (1) {
            app_sched_execute();
            power_manage(); // does sd_app_evt_wait()
        }
    }
    
  • Are you initializing pstorage twice? There is a pstorage_init() in device_manager_init() as well. Shouldn't matter though. I can't see anything wrong with your code. Could you include your softdevice_init() as well? Or maybe just include your complete project so I can test it here? If it is secret you could also open a private case on your MyPage.

  • I removed the extra pstorage_init(). I appreciate the generous offer, but I'd be more interested in learning how to debug this myself. I can add traces to the C code for most of the library, but the softdevice is a black box. It's not sending me any events, but is there any other way to probe its state, or otherwise peek under the hood?

    static void softdevice_init(void) {
        SOFTDEVICE_HANDLER_APPSH_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, true);
    
        ble_enable_params_t ble_enable_params = {
            .gatts_enable_params = {
                .service_changed = IS_SRVC_CHANGED_CHARACT_PRESENT,
                .attr_tab_size = BLE_GATTS_ATTR_TAB_SIZE_DEFAULT
            },
        };
        uint32_t err_code = sd_ble_enable(&ble_enable_params);
        APP_ERROR_CHECK(err_code);
    
        err_code = softdevice_ble_evt_handler_set(ble_event_dispatch);
        APP_ERROR_CHECK(err_code);
    
        err_code = softdevice_sys_evt_handler_set(sys_event_dispatch);
        APP_ERROR_CHECK(err_code);
    }
    
  • I understand. Not really. But if the API doesn't return an error it should work, i.e. start advertising. I'm not sure how to help you. You application seem similar to the ble_app_hids_keyboard, so if I were you I would start with that, and try to compare what is different. Are you using a nRF51 DK?

Related