Page 1 of 1

Connect to sleeping android phone

Posted: Wed Dec 26, 2018 5:30 pm
by rmac2190
How to connect to a sleeping android phone and receive it's Bluetooth “name” . The phone would be paired with the esp32. I need to be able to find up-to three different phone names and preform a different task depending on how many phones are found (0-3). So is there a way to connect to a sleeping android phone with Bluetooth as a car does?

Re: Connect to sleeping android phone

Posted: Fri Dec 28, 2018 4:05 am
by czuvich
Have you tried using one of the example clients in the ESP32 BLE folder and connecting to the device? As long as you don’t require any custom services on the Android side then I’d try that.

You could even try an app on your phone or tablet to connect to the android device.

The only unknown for me is I think you’ll need to know either the BLE server’s broadcasting UUID or name to know that you need to connect to it (assuming your ESP32 is not running a LCD or other interface).

Re: Connect to sleeping android phone

Posted: Fri Dec 28, 2018 3:07 pm
by rmac2190
Thanks for the reply czuvich:

I tried the "esp-idf/examples/bluetooth/bt_discovery/" example and it does what I need but only when the android phone is in "visible mode" even after pairing the phone and the esp32. I think I need to connect with some service to be auto connected (like a car establishes a connection with a phone) buit that is where I am lost?

Re: Connect to sleeping android phone

Posted: Fri Dec 28, 2018 3:26 pm
by rmac2190
Administrator:
I think this post might get more replies in the ESP32 IDF forum. Could you move it there?

Thanks

Re: Connect to sleeping android phone

Posted: Fri Dec 28, 2018 3:38 pm
by ESP_Sprite
Sure. Moved Arduino -> ESP-IDF

Re: Connect to sleeping android phone

Posted: Sat Dec 29, 2018 7:18 pm
by czuvich
It’s possible while an Android device is in doze mode the BLE server is only available to “certified” clients.

I think this question is better suited on StackOverflow for connecting to Android in Doze. It may depend on the version of Android, hardware certification, etc. If you’ve got some Android dev chops, you could try running a custom app that exposes a foreground service and then try connecting to that. Do you have an example of an app that does what you’re wanting?