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

Adding peer manager to ble_app_uart

Hi,

I'm developing with 52840 DK, trying to add peer manager to another project I've modified from ble_app_uart (basically I've added saadc, SPI, USB and I2C module based on original example. Also this project was migrated from 52832 DK to 52840 DK and has been proven working).

As for peer manager example, I referred ble_app_bms from SDK16.

Here are the attempts I've done:

- Copying peer_manager_init(); and its evt_handler() from ble_app_bms. Copying and modifying erase_bonds and advertising_start().

- Adding source files from         ...\components\ble\peer_manager   to nRF_BLE group

- Adding        fds.c     fstorage.c        fstorage_sd.c   to nRF_Libraries group

- Including     fds.h   peer_manager.h   peer_manager_handler.h to main.c

- Enable fds, fstorage, peer_manager module in sdk_config

Now here is my situation,

I could compile the project without error and burned it into 52840DK.

Seems like I could erase existing bonds from flash.

I could connect without bonding(which is not what we want) and it works as usual, but when I manually bond it, connection failed and it shows "invalid pin or passkey, bonding failed" on nrf_connect.

And it LOG shows as follows when bonding failed.

I've been stuck by this problem for weeks. But it just works differently from sample projects.

Which part of it goes wrong.

Your help is appreciated, I could upload my project if necessary.

Parents
  • Hi,

    Please provide the debug log in text (using Insert -> Code). It would be interesting to see the full log, particularly the whole line starting with "Could not perform security procedure".

    Without knowing more I cannot say much, but this could for instance be because you have not included the required crypto libraries as in this thread.

  • Hi Einar,

    Here are some updates.

    I modified ble_evt_handler based on https://devzone.nordicsemi.com/f/nordic-q-a/35433/configuring-peer-manager-for-bonding and it works.

    However bonding window does not pop up automatically, I have to press bond manually.

    Thanks

  • Hello Avadacadabara,

    Einar is currently out of office, so I will be handling this case from now on.

    Avadacadabara said:

    I am happy to hear that bonding works now!

    Avadacadabara said:
    However bonding window does not pop up automatically, I have to press bond manually.

    I am not sure that I understand what you mean when you say this - do you mean the bonding option in the nRF Connect application for smartphones? Is this option not showing up when you enter into the connection, or is the issue that you have to manually press the bond option that appears?
    In case of the latter, this is likely due to the security requirements of the service provided. If you take a look at the services_init function of the ble_app_hrs you could see where this may be configured. If the central tries to interact with a service that it does not have the required security for, the peripheral will send a security request.

    Best regards,
    Karl

  • Hi Karl,

    Thanks for reply.

    I was saying that peering option didn't show up after ble connected and I have to hit "bond" option to call it out.

    After several attempts, this issue fixed somehow...But I didn't change any part of the code.

    I think I'll just let it be. But your advice is appreciated!

    Thanks Karl and Einer.

  • Hello again,

    Avadacadabara said:
    Thanks for reply.
    Avadacadabara said:
    Thanks Karl and Einer.

    No problem at all, we are happy to help!

    Avadacadabara said:
    After several attempts, this issue fixed somehow...But I didn't change any part of the code.
    Avadacadabara said:
    I think I'll just let it be. But your advice is appreciated!

    I am glad to hear that it works as intended now, but it is strange that you the behavior changed without you making any changes to the code yourself.
    Could it be that your central tries to access a service that require bonding?

    Best regards,
    Karl

  • Hi Karl,

    I'm using nordic uart service only. I'm not quite sure if central app requires bonding to access it cuz previously it's possible to connect it directly w/o bonding...

    Now the bonding option pop up everytime when I hit "connect"(which is exactally what we were expecting), perhaps because I allowed "repairing" function in pm_evt_handler like below?

    		case PM_EVT_CONN_SEC_CONFIG_REQ:
            {
                // Reject pairing request from an already bonded peer.
                pm_conn_sec_config_t cfg;
                cfg.allow_repairing = true;
                pm_conn_sec_config_reply(p_evt->conn_handle, &cfg);
            } break;

    Or I might have some unnoticed modification somewhere else...

    Thanks

  • Hello again,

    Avadacadabara said:
    I'm not quite sure if central app requires bonding to access it cuz previously it's possible to connect it directly w/o bonding...

    You are correct that the NUS service does not require bonding to access it by default, yes. I was under the impression that you would have liked to change this, but I might have misunderstood your intentions.

    Avadacadabara said:
    perhaps because I allowed "repairing" function in pm_evt_handler like below?

    You can test this by disabling this again, to see if the behavior changes.

    Avadacadabara said:
    I might have some unnoticed modification somewhere else...

    That does indeed make it harder to pintpoint exactly what led to the change - I thought you did not make any changes to the code when the behavior changed.

    If you would like to find out the root cause, please iteratively revert changes you have made and test the application again each time, to find out exactly what changed the behavior.
     
    Best regards,
    Karl

Reply
  • Hello again,

    Avadacadabara said:
    I'm not quite sure if central app requires bonding to access it cuz previously it's possible to connect it directly w/o bonding...

    You are correct that the NUS service does not require bonding to access it by default, yes. I was under the impression that you would have liked to change this, but I might have misunderstood your intentions.

    Avadacadabara said:
    perhaps because I allowed "repairing" function in pm_evt_handler like below?

    You can test this by disabling this again, to see if the behavior changes.

    Avadacadabara said:
    I might have some unnoticed modification somewhere else...

    That does indeed make it harder to pintpoint exactly what led to the change - I thought you did not make any changes to the code when the behavior changed.

    If you would like to find out the root cause, please iteratively revert changes you have made and test the application again each time, to find out exactly what changed the behavior.
     
    Best regards,
    Karl

Children
No Data
Related