meshtastic / firmware

Meshtastic device firmware
https://meshtastic.org
GNU General Public License v3.0
3k stars 719 forks source link

increase bluetooth pairing timeout #129

Closed eriktheV-king closed 4 years ago

eriktheV-king commented 4 years ago

Meshtastic’s BLE pairing timer seems a little short for slower clients. I noticed a pairing time of about 30 seconds before I got kicked out. When pairing slower Android devices (my 5.1 Android tablet f.i.), the pairing code on the ESP32 screen disappears before the pairing process is completed.

Also, after pairing stops, esp32's Oled shows I get 'Users 1/1 and ‘Started…’ ! which is not the case. I will double check what happens in serial output when I try again.

Meshtastic-device/docs/software/power.md#events-that-increase-cpu-activity reads: "While in DARK/ON: If we receive EVENT_BLUETOOTH_PAIR we transition to ON and start our screen_on_secs timeout" So a solution might be to increase this timer, but I understand there is a tradeoff between battery life and ease of connectivity. But then, as it's not systematic, it should only cost a couple of microampH more for certain devices only.

I already had a look in Meshtastic-device/src/mesh/NodeDB.cpp and saw on line 58: if (radioConfig.preferences.sds_secs == 0) { ... radioConfig.preferences.wait_bluetooth_secs = 120; but this does not seem the case. Also, a bit further down: radioConfig.preferences.wait_bluetooth_secs = 30; but is is in a commented out block // temp hack for quicker testing So I wasn't able to find out what to do.

I filed an automatic anonymous bug report because my Android 5.1 tablet is very slow and every time I tried to pair with a Tbeam, I got thrown out before the pairing process completed Result: The Tbeam stays in ‘Available devices’ list with ‘pairing’ for some more seconds, then immediately bluetooth chokes on the tablet causing bluetooth to turn off and on again, rescan starts. So I keep on seeing my Tbeam’s name in Meshtastc’s device list and it proposes me to turn BT on and that I should pair with a device!

geeksville commented 4 years ago

This issue has been mentioned on Meshtastic. There might be relevant details there:

https://meshtastic.discourse.group/t/problem-downloading-from-playstore-on-android-5/88/9

geeksville commented 4 years ago

alas - according to my reading this timeout is hardcoded in android at 30 secs. I don't see anything I can do in code from either side to change it.