How to disconnect/Disable BLE peripheral Zephyr

I have a use case where a Peripheral requires to disconnect itself from the Central. Is this possible?

I have tried using the peripheral_hr example and modified as follows

https://github.com/vChavezB/peripheral_disconnect/blob/main/main.c

I am using the bt_disable and bt_conn_disconnect API but neither of these seam to work.

I get the following log

*** Booting Zephyr OS build v3.0.99-ncs1  ***
[0Bluetooth initialized
Advertising successfully started
0:00:00.004,150] <inf> sdc_hci_driver: SoftDevice Controller build revision:
                                         33 78 2a 18 20 f5 61 61  a6 8b 77 60 62 83 39 2a |3x*. .aa ..w`b.9*
                                         7c f1 14 e4                                      ||...
[00:00:00.007,568] <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
[00:00:00.007,598] <inf> bt_hci_core: HW Variant: nRF52x (0x0002)
[00:00:00.007,629] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 51.10872 Build 1643454488
[00:00:00.008,941] <inf> bt_hci_core: Identity: FE:4C:08:6B:72:E8 (random)
[00:00:00.008,941] <inf> bt_hci_core: HCI: version 5.3 (0x0c) revision 0x1136, manufacturer 0x0059
[00:00:00.008,972] <inf> bt_hci_core: LMP: version 5.3 (0x0c) subver 0x1136
disconnect err -128
disable err -134

Parents
  • Ok I think I solved it.
    Disconnection error reason needs to be BT_HCI_ERR_REMOTE_USER_TERM_CONN as mentioned in another post and in the zephyr API docs.
    The disable error seems to be that the NRF52833 DK does not support the api bt_disable

  • Thanks for updating your ticket. Yes, you need to select one of the listed disconnect reasons (link), and  BT_HCI_ERR_REMOTE_USER_TERM_CONN is usually the one you want if you just want to terminate a connection.

    The disable error seems to be that the NRF52833 DK does not support the api bt_disable

    Yes, you are right. The disable API is supported by the BT host, but not our controller. That is why it returns with -ENOTSUP / -134. But are you sure you need to disable the stack in your case? In most cases it is sufficient to stop or pause ongoing BLE tasks such as advertising.

Reply
  • Thanks for updating your ticket. Yes, you need to select one of the listed disconnect reasons (link), and  BT_HCI_ERR_REMOTE_USER_TERM_CONN is usually the one you want if you just want to terminate a connection.

    The disable error seems to be that the NRF52833 DK does not support the api bt_disable

    Yes, you are right. The disable API is supported by the BT host, but not our controller. That is why it returns with -ENOTSUP / -134. But are you sure you need to disable the stack in your case? In most cases it is sufficient to stop or pause ongoing BLE tasks such as advertising.

Children
No Data
Related