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

Program not pairing/bonding and pm_evt_handler never called

Using SDK13

I have a Central program and I included the peer manager code from ble_app_hrs_c but I am having issues after connecting to another dev kit with Peripheral code running on it. It seems that the pm_evt_handler function is never called (logs that I added aren't being printed), and so it never pairs/bonds. When running the ble_app_hrs_c and connecting to the Peripheral, it pairs/bonds automatically and pm_evt_handler is called fine. I looked through both ble_app_hrs_c and my code and I am trying to implement the differences but I ran into some issues when I added

// If there is any pending write to flash, defer scanning until it completes.
(void) fs_queued_op_count_get(&flash_busy);       ***in scan_start()***

fs_sys_event_handler(sys_evt);       ***in sys_evt_dispatch()***

and all of the whitelist code.

So my question is, why is my program never calling pm_evt_handler?

Here is my current "working" program: main.c

And here is my program after I have added in the remaining code from the ble_app_hrs_c, this is the one that regressed quite a lot: mainChanges.c

If there is any other information you need, please let me know. Thank you!

  • Hi Mushiru,

    Could you explain what are you planing to do ? From which example you based your "working" program on? There are lots of commented code in your mainChanges.c make it really hard to figure out what is used what is not .

    What exactly the issue you have with fs_queued_op_count_get() ?

    If you simply want to add hrs service in don't think much modification needed. Simply add hrs_c_init(), hrs_c_evt_handler, and ble_hrs_c_on_ble_evt() , should make it work.

    Note that bonding is not required for HRS profile.

  • I'm not sure if this is the exact thing that fixed my issue, but basically my code wasn't bonding and then after adding this:

    				// Initiate bonding.
    			err_code = pm_conn_secure(p_evt->conn_handle, false);
    			if (err_code != NRF_ERROR_INVALID_STATE)
    			{
    				APP_ERROR_CHECK(err_code);
    			}
    

    my program bonds with no problems.

Related