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

How to disable Bluetooth ?

Hello,

I'm looking to disable the Bluetooth in the ledButtonDemo,. In the led_write_handler, I've replaced the code by :

if(led_state == 0) { sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); sd_ble_gap_adv_stop(); NRF_RADIO->TASKS_DISABLE=1; nrf_gpio_pin_clear(24); }

else { nrf_gpio_pin_set(24); }

But with the dongle, I'm still seeing the device "ledButtonDemo", and I'm able to connect it, and to change the settings.

Is there a mistake in my code ?

I used this topic to create my code : devzone.nordicsemi.com/.../

Thanks in advance !

Parents
  • I'm not sure exactly what is happening here, but you shouldn't do NRF_RADIO->TASKS_DISABLE=1; as seen from the comment of Ole Bauck in the linked question.

    There is also no point in stopping advertising if you aren't advertising.

    I'm guessing that either an error is returned somewhere and because of that you get a reset. It seems you are not using APP_ERROR_CHECK() so that may not be the reason.

    Are you getting the BLE_GAP_EVT_DISCONNECTED event? Maybe you have an advertising_start(); in on_ble_evt()?

    If you are a peripheral, the radio is "disabled" or not used, as long as you are not in a connection and you are not advertising.

Reply
  • I'm not sure exactly what is happening here, but you shouldn't do NRF_RADIO->TASKS_DISABLE=1; as seen from the comment of Ole Bauck in the linked question.

    There is also no point in stopping advertising if you aren't advertising.

    I'm guessing that either an error is returned somewhere and because of that you get a reset. It seems you are not using APP_ERROR_CHECK() so that may not be the reason.

    Are you getting the BLE_GAP_EVT_DISCONNECTED event? Maybe you have an advertising_start(); in on_ble_evt()?

    If you are a peripheral, the radio is "disabled" or not used, as long as you are not in a connection and you are not advertising.

Children
Related