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

Is it possible in a HID mode disable bonding to HID?

Hi!

SDK15, s132, SD6.0.0, nRF52832

I have nRF52832 in central mode and some bonded HID devices and another nRF52832 peripherial devices.

Now in the my central nRF52832 I start advertise with HID services. If any smartphon wants to bond with my device, it can bond with passkey. 

How to make on my nRF52832 HID device that all boneded devices will works and connect, but there will be no bond request from any not bonded smartphon?

Parents
  • Hi, 

    Please correct me if I'm wrong. You have a central device that connect to some HID devices. Now on your central device you also want it to be a HID peripheral so the phone can connect to it ? And you only wants some phones which are bonded to connect to it. Any other phones shouldn't be able to connect and bond with it ? 

    If it's the case, you can use whitelist to block any non-bonded phone to connect to your device. You can have a special mode (pairing mode) that whitelist is disabled to allow unknown device to connect to your device.  

  • May be you mean instead of whitelist

    static void peer_manager_init(void)?

  • Ok, but I need possibility connect my advertise device to not bonded devices. Is there another method to forbid bonding with HID? May be worth considering peer_manager_init() with bond settings?

  • You mean, to allow connection but not allowing bonding ? 
    If that's the case you would need to call pm_sec_params_set() with p_sec_param = NULL to reject pairing. 

  • Yes, I mean just allow connect, but without bonding. If I set pm_sec_params_set() with p_sec_param = NULL, I can't connect to already bonded devices with central. As you remember, I use central with whitelist and advertise with HID service and with nus services. When pm_sec_params_set() with p_sec_param = NULL I also need possibility connect to previous bonded devices with central.

  • If you need to customize for such specific use case, I think you need to modify the peer manager code on your need. The bonding process start with SEC_PARAMS_REQUEST event and you can call sd_ble_gap_sec_params_reply() with PAIRING_NOT_SUP. Please have a look here

    Note that an already bonded device when reconnecting and re-encryp the link, there will be no SEC_PARAMS_REQUEST event, but a SEC_INFO_REQUEST event. Please have a look here.

  • I try to use ble_app_bms project.

    In func static void advertising_init(void) I configure whitelist for works. 

    init.config.ble_adv_whitelist_enabled = false;

    also I configure flags with BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE

    But if I try to comment slow advertise- project fall.

    What should correct for works with whitelist and one advertise settings? Slow, for example.

    static void advertising_init(void)
    {
        ret_code_t     err_code;
        ble_advertising_init_t init;
    
        memset(&init, 0, sizeof(init));
    
        init.advdata.name_type                = BLE_ADVDATA_FULL_NAME;
        init.advdata.include_appearance       = true;
        init.advdata.flags                    = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
        
        init.advdata.uuids_complete.uuid_cnt  = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
        init.advdata.uuids_complete.p_uuids   = m_adv_uuids;
    
        init.config.ble_adv_whitelist_enabled = true; // false
        init.config.ble_adv_fast_enabled      = true;
        init.config.ble_adv_fast_interval     = APP_ADV_FAST_INTERVAL;
    ////    init.config.ble_adv_fast_timeout      = APP_ADV_DURATION;
    ////    init.config.ble_adv_slow_enabled      = false;
    
        init.evt_handler   = on_adv_evt;
        init.error_handler = ble_advertising_error_handler;
    
        err_code = ble_advertising_init(&m_advertising, &init);
        APP_ERROR_CHECK(err_code);
    
        ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
    }

Reply
  • I try to use ble_app_bms project.

    In func static void advertising_init(void) I configure whitelist for works. 

    init.config.ble_adv_whitelist_enabled = false;

    also I configure flags with BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE

    But if I try to comment slow advertise- project fall.

    What should correct for works with whitelist and one advertise settings? Slow, for example.

    static void advertising_init(void)
    {
        ret_code_t     err_code;
        ble_advertising_init_t init;
    
        memset(&init, 0, sizeof(init));
    
        init.advdata.name_type                = BLE_ADVDATA_FULL_NAME;
        init.advdata.include_appearance       = true;
        init.advdata.flags                    = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
        
        init.advdata.uuids_complete.uuid_cnt  = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
        init.advdata.uuids_complete.p_uuids   = m_adv_uuids;
    
        init.config.ble_adv_whitelist_enabled = true; // false
        init.config.ble_adv_fast_enabled      = true;
        init.config.ble_adv_fast_interval     = APP_ADV_FAST_INTERVAL;
    ////    init.config.ble_adv_fast_timeout      = APP_ADV_DURATION;
    ////    init.config.ble_adv_slow_enabled      = false;
    
        init.evt_handler   = on_adv_evt;
        init.error_handler = ble_advertising_error_handler;
    
        err_code = ble_advertising_init(&m_advertising, &init);
        APP_ERROR_CHECK(err_code);
    
        ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
    }

Children
Related