Skip to content

Turn Bluetooth on and off #167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jeremypoulter opened this issue Jul 26, 2018 · 17 comments
Open

Turn Bluetooth on and off #167

jeremypoulter opened this issue Jul 26, 2018 · 17 comments

Comments

@jeremypoulter
Copy link
Contributor

Related to #165 I am also working on Low power, is it possible to stop the Bluetooth once started?

@hathach
Copy link
Member

hathach commented Jul 27, 2018

indeed, there should be a Bluefruit.stop() . We will include it in the next release. Thanks for posting the issue.

@jeremypoulter
Copy link
Contributor Author

If you can post some direction more than happy to do a PR

@hathach
Copy link
Member

hathach commented Jul 27, 2018

It is essentially revert of the Bluefruit.begin()

https://github.com/adafruit/Adafruit_nRF52_Arduino/blob/master/libraries/Bluefruit52Lib/src/bluefruit.cpp#L235

free up all resources task stack memory, delete task etc ... then call sd_softdevice_disable ( counter-part of sd_softdevice_enable )

@jeremypoulter
Copy link
Contributor Author

jeremypoulter commented Jul 27, 2018 via email

@hathach
Copy link
Member

hathach commented Jul 27, 2018

Ah I guess I got what you mean now, it is some sort of Bluefruit.pause() rather, I don't have any particular ideas now. But I think you could disable the BLE stack without disable the whole SoftDevice. Too bad, I am currently too busy with nrf52840, if you don't mind checking out the S132 specifications and docs, it may have something stated there. I will try to go back to 52832 a bit after getting 52840 a bit more stable.

@pbecchi
Copy link

pbecchi commented Jul 30, 2018

From the test I did for issue #165 ,power consumption depend mainly from advertising, if you stop advertising the uA should go back to ≤10 when you are in low power mode...... eg.delay()!

@hathach
Copy link
Member

hathach commented Jul 31, 2018

@pbecchi Yeah, I will note this for upcoming tutorial as well. You want to disable auto start advertising on timeout, using low/fast interval theme, and start advertising base only when you thing needed button press or after large enough delay etc ..) depending on usage.

@jappavoo
Copy link

Any updates on this? For my use a full stop would be great.

@hathach
Copy link
Member

hathach commented May 21, 2019

I have't got time to work on this

@joshysav
Copy link

Sorry @hathach , any updates? :|

@MuckYu
Copy link

MuckYu commented May 20, 2020

Would also like to see a .pause function.

Right now I use .stop to stop the BLE for a short time before enabling it again.

@glenne
Copy link

glenne commented Jan 28, 2021

I need this as well. @MuckYu , Where did you find a .stop() method? Are you referring to just Advertising.stop() as opposed to Bluefruit.stop()?

@hathach , any update on stopping BLE altogether? I need to go into a deep sleep waiting on a button press.

@MuckYu
Copy link

MuckYu commented Jan 30, 2021 via email

@ando600
Copy link

ando600 commented Mar 27, 2022

Hi, is there a way to stop the BLE service? I have a need similar to glenee.

Is there a workaround that I can do to fix this? Even if it's not included in the library, I really need to put the device in low power mode, and Bluefruit.begin causes the device to exit low power mode immediately, which does not work for my needs.

Thanks,
Andrew

@mittlc
Copy link

mittlc commented Sep 15, 2023

Dear Adafruit team,
is there any news on this issue?

I am looking for a way to stop the Bluefruit device and start it back up (Bluefruit.begin()) later to try to work around compatibility issues with my gps module, which seem to be blocked as soon as i start using the BLE.

I am looking for this on the Client side, and i already tried to disconnect from the peripheral and stop the scanning for the peripheral - but this doesn´t fix the issue, why i would like to try to disable the entire Bluefruit alltogether and start it back up.

@glenne
Copy link

glenne commented Sep 15, 2023

I use the following before going to deep sleep. Maybe it'll help you. After deep sleep and waiting on a button press, it comes up like coming out of reset and reconfigures everything.

static void disconnectBle() {
  uint16_t connections = Bluefruit.connected();
  for (uint16_t conn = 0; conn < connections; conn++) {
    Bluefruit.disconnect(conn);
  }
}

void ble_sleep(void) {
  Bluefruit.Advertising.restartOnDisconnect(false);
  disconnectBle();
  Bluefruit.Advertising.stop();
}

After setting some lines hi-z and setting up a power-up interrupt I use

sd_power_system_off();

Maybe the ble_sleep() is sufficient for your needs followed by restarting advertising when you want to start again.

@mittlc
Copy link

mittlc commented Sep 18, 2023

Thanks @glenne,
Disconnecting on the client Side was actually sufficient. The issue was related to timing and to many activities at once. As soon as i introduced some time for each Operation GPS and Bluetooth go along just fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants