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

I have a question about pairing control.

Hi, I have a question about Bluetooth pairing control.

I use nrf52dk board and sdk v17.  I am working on many things using the example of sdk.

Now I'm trying to control pairing using the button.  I found two ways to stop pairing.

    //No pairing1
     //uint32_t err_code = sd_ble_gap_sec_params_reply(m_conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL);
     //APP_ERROR_CHECK(err_code);



    //No pairing2
     //uint32_t err_code = pm_sec_params_set(NULL);
     //APP_ERROR_CHECK(err_code);

But I don't know how to restart pairing.  How can I restart pairing?
And to start pairing with buttons, should I modify it at the button input of the function 'bsp_evt_handler'?
Thank you very much.
  • Hi,

    You can try calling pm_sec_params_set() and passing the initial parameter that is used when first initializing the module. 

     

    And to start pairing with buttons, should I modify it at the button input of the function 'bsp_evt_handler'?

    Yes, I think this should work.

    regards

    Jared 

  • Thank you for your answer.  I'm sorry, but I'm not sure yet.
    I think it's a simple problem, but I'm sorry to keep asking you.
    I wrote it like this so I wouldn't pair up at the beginning.
    (For your information, I combined 'ble_app_uart' and 'peer_manager'.)
    int main(void)
    {
        uint32_t err_code;
        err_code = pm_sec_params_set(NULL);
        APP_ERROR_CHECK(err_code);
    .
    .
    }
    
    So it doesn't pairing at first.
    And this code enables pairing with button input.
    void bsp_event_handler(bsp_event_t event)
    {
        uint32_t err_code;
        switch (event)
        {
    .
    .
             case BSP_EVENT_KEY_2: //button3
                //peer_manager_init(); //Not doing nothing
                //err_code = pm_sec_params_set(&sec_param); //error
                //APP_ERROR_CHECK(err_code);
                break;
        }
    }
     
    I tried this, but I think I did something wrong.
    What do I need to enter in the parameters for pm_sec_params_set()?
  • What are you doing in peer_manager_init()? Most examples in the SDK that use the peer manager already have a pm_sec_param_set() call in peer_manager_init() Which would make line 10 redundant. I would try calling the peer_manager_init() in start of main and remove both the pm_sec_params_set(NULL) call and the call in the init function if you have one. You could then only call pm_sec_params_set(&sec_param) in the BSP_EVENT_KEY_2. Notice that it's not recommended to do too much in the interrupt handlers as it can interfere with other priority tasks.  

    schosdas said:
    I tried this, but I think I did something wrong.

     Elaborate more on this. Does the function call return any errors?

Related