ble_app_hids_keyboard will not run if SEC_PARAM_BOND = 0

Hi Nordic Team,

We have no problem with using ble_app_hids_keyboard app,

However, in some use cases, we would like the application to run as "Just Works" to access other characteristics, say battery voltage characteristics for example. And well in some cases depending on the connected client HID can work without bonding too.

 Testing this just with nrf52 DVK,   When SEC_PARAM_BOND  = 0, the firmware faults.

In debug, runs to the last call in Main.c peer_manager_init();

Appears to be in the peer manager  pm_init(void)?

Any thoughs on how we can get this to run?

Regards,

Eric

  • Hi

    What SDK version are you using specifically? Have you made any other changes to the ble_app_hids_keyboard example, and are you able to see any error code if you use logging to see what happens in the application?

    If you set SEC_PARAM_BOND to 0 the device won't be able to do bonding at all, and I assume you still try to do bonding somewhere in your application, which will then not be supported. Please check out the Peer Manager usage chapter to see how the peer manager is used in various scenarios.

    Best regards,

    Simon

  • Hi Simonr,

    Just to be sure - I set up a "fresh copy of nRF5_SDK_17.1.0_ddde560", opened an unmodified ble_app_hids_keyboard.

    WIth no changes at all, load on to an nrf52-DK.  Pairs with Windows 10 and output HID chars to notepad. OK no problem

    Then With SEC_PARAM_BOND to 0,  erase target, and download. Fails to run.

    Turn on NRF_LOG_BACKEND_RTT_ENABLED 1, 

    J-Link RTT is

    00> <info> app_timer: RTC: initialized.
    00>
    00> <error> app: Fatal error  (repeats ad infinitum)

    - Note - Our main applcation service & char are all Just Works, but for a few situations HID (paired) can only be used. 

    Idea is to add our service&chars to our working HID vresion, and have dual start conditions.

    It now seems that we cannot  start with SEC_PARAM_BOND to 0 - means the standard use case (where HID not needed)  now will fail to work.

    as mentioned with BOND = 0, somewhere in the peer managment it breaks.

    Interesting that these setting below on on Windows machine only, works with sec_param.bond = true; but once connection dropped cannot reconnect.

    Disallow IRKs:

    sec_param.bond = true;
    /* Arbitrary parameters removed. */
    sec_param.kdist_own.enc = 1;
    sec_param.kdist_own.id = 0;
    sec_param.kdist_peer.enc = 1;
    sec_param.kdist_peer.id = 0;
    Regards,
    Eric
  • Hi

    Okay, we ran a test on our end as well, and found out why this is. When you disable bonding, the application still tries to do the following actions, which are only done on bonding, not pairing. If you set all these to 0 it seems to work.

        sec_param.kdist_own.enc  = 0;
        sec_param.kdist_own.id   = 0;
        sec_param.kdist_peer.enc = 0;
        sec_param.kdist_peer.id  = 0;

    Best regards,

    Simon

  • OK, this does not crash. Thanks! 
    As a test whether I can connect using just works, I try to read the battery service. I'm (using Android BLE Scanner, or on Windows 10  nrfCOnnect DeskTop). Can connect, but when  I auth battery service notification -  pairing is requested. of course with current setting this will fail. Happily does not crash the application to that looks solved.
    bas_init() & hids_init()  all look to be set to  SEC_JUST_WORKS

    <info> app: Connected
    <info> peer_manager_handler: Connection security failed: role: Peripheral, conn_handle: 0x0, procedure: Bonding, error:  1
    addtional
     once just works connected, I eneable break point in  pm_evt_handler at switch (p_evt->evt_id, then auth battery service notification. Event is PM_EVT_CONN_SEC_START
    - I just noted that I can read write to generic access 0x1800, promising
    Though would like to stop pairing requests.in general

  • Hi

    Just to make sure, you know the difference between pairing and bonding, right? Because I think you might want to do pairing, but not bonding. My colleague Einar explains this very well here

    You can also see how the battery service is implemented in the ble_app_hrs example project where it is added without using bonding. 

    Best regards,

    Simon

Related