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

Setting the BLE Public Address on nRF5340

I am trying to set the public ble mac address from the application core of a nRF5340, I understand that I need to use bt_ctlr_set_public_addr() but I can't seem to get my project to compile when I include bluetooth/controller.h, due to the source file that defines bt_ctlr_set_public_addr() not being added to the project. I am using the SoftDevice currently that is CONFIG_BT_LL_SOFTDEVICE. So my question is what configurations do I need to set to make this work? I have also been thinking that it might be that it is only possible to use the function from the network core, if this is the case then where do I find the source so that I can make the changes that I need or should I instead of change the source use rpc?

If I forgot to mention something important then I apologise in advance.

  • Hi,

    The Bluetooth HCI RPMsg sample on the network core exposes the Bluetooth Controller for the application core, so I believe you should be able to use bt_ctlr_set_public_addr() in the application to set the public address. The function can also be found in the HCI driver, <ncs_root>nrf/subsys/bluetooth/controller/hci_driver.c, where they simply use the function sdc_hci_cmd_vs_zephyr_write_bd_addr() to write the address to memory. Please try using this instead and see if that solves your issue.

    Best regards,

    Marte

  • Thank you for replaying, I have tried using sdc_hci_cmd_vs_zephyr_write_bd_addr() but I am not able to compile the project when I use the function I get the following "error undefined reference to `sdc_hci_cmd_vs_zephyr_write_bd_addr'" even thought I included the same header files as are included in hci_driver.c. Are there any config flags I have to set to get the project generated in such a way that I can use the function, I have tried with CONFIG_BT_LL_SOFTDEVICE_VS_INCLUDE=y.

  • Hi,

    I have asked our developers for a clarification about this. Since the function bt_ctlr_set_public_addr() is part of the controller API, it should be called in the application running on the network core, HCI RPMsg, and not the application core. So unfortunately you cannot use this from the application core. They are going to check if there are other ways to change the public address on nRF5340. I will let you know when I hear back from them.

    Best regards,

    Marte

  • Hello again, I was wondering if you had heard back from the developers? Maybe they would like some additional details about my problem?

  • Hi,

    They have not come back to me regarding other ways to change this yet, but I have asked them for an update.

    I do not believe we have a function to change the address directly from the application core. However, the network core has access to the memory of the application core, and the two cores communicate, using OpenAMP. It might be possible to create something where you send a message from the application core to the network core to make it change the address, but you would then have to change the HCI RPMsg sample as well. The HCI RPMsg sample use RPMsg, which is a part of OpenAMP. If you want to look at a sample specifically for how to use the RPMsg Service, you can look at Zephyr's RPMsg Service sample Application. You can also find the repository for OpenAMP on github here: OpenAMP.

    I am sorry for the delayed answer, and for not having more to help you with right now. If you want to, you can provide additional details about your problem and I can forward it to our developers.

    Best regards,

    Marte

Related