-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Bluetooth connect timeout after Android phone app disconnect and reconnect (IDFGH-4889) #4915
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
Comments
Posted to esp-idf in error. Should have been posted to Can this be moved? |
Hi @cattledogGH, It's ok to leave it here. For the issue you mentioned, can you please provide more information including IDF version you use and any necessary log you have? Thanks. |
Arduino Core 1.0.5 is built with ESP-IDF release/v3.3 branch commit 7a85334d8 |
This failure to reconnect after disconnect does not occur when using Arduino Core version 1.0.4. which uses IDF v 3.2 |
See #4912 |
I can not confirm that the file revisions of #4912 correct the issue of failure to reconnect when using the BluetoothSerial library example SerialToSerialBT with an Android phone. |
I do not have an Android phone, but some fixes have been added to current master (and will come in 1.0.6), so I would ask you if you can give it a go and confirm? |
I have tested the changes in these files, and they do not solve the problem. Is there something else you would like me to test? |
@cattledogGH I would suggest that you try directly with master |
I have only loaded the Arduino core using the Boards Manager of the Arduino IDE. What is the process for getting the master into the packages of the Arduino 15 folder? I am using Windows 10. Arduino IDE 1.8.13 |
https://github.com/espressif/arduino-esp32/blob/master/docs/arduino-ide/windows.md but uninstall from board manager first |
Yes, I believe the current master fixes the issue. I followed the instructions referenced in the previous comment, and I think that I have successfully installed the current master, but I'm not quite sure where to pull a version number from the compiling report to absolutely confirm what was used. With the sketch from the SerialBluetooth library "SerialToSerialBluetooth" and the current master, I can connect and disconnect repeatedly without restarting the ESP 32. I look forward to Arduino Core 1.0.6. available through the Board Manager. |
It was found out that an update of this libbt.a binary from e8311b0 is sufficient to make a temporary fix for this issue. |
great. this will really solve the problem. thank |
Can confirm the issue and this solution is working. |
Is there a rough estimate on when this fix will be generally available e.g. in platformio? |
probably by the end of this week |
Closed with release of Arduino Core 1.0.6 available through Boards Manager |
Is this available on platformio too? |
Works just fine for me via platformio core 5.1.0 in the Arduino env. Thanks everyone! |
I have the latest 1.0.6 installed via pio and can confirm this is still an issue. I'm testing using a BT GPS receiver and the following happens when I switch the device off and on:
Have the following check to manually reconnect but it never gets past the connect() message on the next attempt it just seems to hang.
|
Hi! I'm trying to use the function
I'm using this code: #define BLUETOOTH_NAME "Parking Sensor"
#define BLUETOOTH_PINCODE "0000"
#include <ESP8266React.h>
#include "BluetoothSerial.h"
#include <ArduinoJson.h>
#include <esp_coexist.h>
BluetoothSerial SerialBT;
AsyncWebServer server(80);
ESP8266React esp8266React(&server);
unsigned start_millis;
void bluetoothHandle(String msg);
void setup()
{
esp_coex_preference_set(ESP_COEX_PREFER_BT); // Priority for bluetooth
Serial.begin(115200);
esp8266React.begin();
server.begin();
SerialBT.setPin(BLUETOOTH_PINCODE);
SerialBT.begin(BLUETOOTH_NAME);
}
void loop()
{
String msg;
esp8266React.loop();
if (SerialBT.available())
{
esp8266React.loop();
start_millis = millis();
msg = SerialBT.readString();
bluetoothHandle(msg);
}
}
void bluetoothHandle(String msg)
{
char charBuf[100];
msg.toCharArray(charBuf, 100);
DynamicJsonDocument Json(100);
Serial.print("t1 = ");
Serial.print(millis() - start_millis);
Serial.print(", ");
String mode[2] = {"reverse", "break"};
String sensor[8] = {"a", "b", "c", "d", "e", "f", "g", "h"};
Json["mode"] = mode[random(0, 2)];
Json["sensor"] = sensor[random(0, 8)];
Json["distance"] = random(0, 200);
serializeJson(Json, SerialBT);
Serial.print("cmd = ");
Serial.println(charBuf);
Serial.print("res = ");
serializeJson(Json, Serial);
Serial.print(", t2 = ");
Serial.println(millis() - start_millis);
} The ESP8266React lib (framework) is here. Webserver and bluetooth can work fine separately without I have an ESP32-Wroover IE 8MB and I'm using PIO 5.2.5 with espressif32 3.5.0. Can someone give some help? Best regards. |
I can connect and disconnect multiple times with no issues using 2.0.3RC1 with Arduino IDE 1.8.15. I do not see the problem of having to restart the esp32 to reconnect. I am using Kai Morich's Serial Bluetooth Terminal on an Android phone with Android 11. No issues as well with 2.0.2. |
@cattledogGH Thanks for testing, I'm, then closing this issue. If still needed, you can reopen it. |
Hello, i'm experiencing the same issue, using ESPIDF v4.4.4 + Arduino as component (v.2.0.8 - master branch from a few hours ago). No error messages, First connection works fine, second needs to reset the board. I have enabled the debug level for the bluetooth stuff in menuconfig, and attached the full terminal log (with some comments) https://pastebin.com/vA2uSbJG and here is the sdkconfig https://pastebin.com/iM2egQDf I've created an task that check if an client has disconnectd (state machine checking every second), it it had, i stop the SerialBT, set the callback and start the SerialBT object. this helped me to be able to connect again. |
Having the same issue with Arduino-ESP32 v3.0.3: I can connect fine the first time, but after disconnecting, it is impossible to re-establish a connection without resetting the ESP32. @italocjs Your suggestion did the trick: when we know that the BT connection has been lost, disable and re-enable the BluetoothSerial module and it is able to reconnect again. Pseudo-code here...the "flagBtWasConnected" is a one-shot so it doesn't infinitely reset the BT module if no connection is present.
|
Classis bluetooth have a lot of issues. i gave up on it and have switched to nimble + nordic uart service. on Classic BT i had issues with specific phones manufacturers not connecting or causing the device to crash, lib had a huge footprint, require weird undocumented workarounds. Anyway, if you can, take a look at Nimble+NUS. |
The problem: I'm developing a "compatible replacement" for an obsolete BT board that runs over BT Classic (does not support BLE). The requirement is to seamlessly integrate into the existing ecosystem with zero changes. So there's no way around the use of BT Classic for this project. |
ESP32 Dev Module, Arduino Core 1.0.5,
BluetoothSerial.h included with core library properties shows
name=BluetoothSerial version=1.0 author=Evandro Copercini maintainer=Evandro Copercini sentence=Simple UART to Classical Bluetooth bridge for ESP32 paragraph= category=Communication url= architectures=esp32
When using BluetoothSerial.h and library example SerialToSerialBT with an Android phone (Kai Morich SerialBluetoothTerminal) the phone app can not reconnect after disconnect without restarting the ESP32.
Initial connection and example code work as expected. Disconnect phone app. Phone will not reconnect without ESP32 reset.
I believe that this issue is related to this issue which was repaired in the esp-idf
https://github.com/espressif/esp-idf/issues/1537
Request that the reconnection error be corrected in BluetoothSerial.h for ESP32.
The text was updated successfully, but these errors were encountered: