renatobo / bonogps

A GPS setup to log your track lap times, based on ESP32, with the ability to interface with several mobile phone apps that log your speed and position via Bluetooth Low Energy, Bluetooth or WiFi

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug: Reconnect with Racechrono and BT SPP

R1Snake opened this issue · comments

I am using Racechrono with the presets for it (BL SPP)

The first connection is great and I see the data in Racechrono. After I finish my recording in Racechrono and click again on Start, Racechrono has a problem to establish the connection.

A restart of the module fixes the problem.

Thanks for the bug report
This is an annoying behavior, I have not encountered it as I have not used RaceChrono on the field with repeated sessions.

Would you have any log? Is it consistently happening?
One possibility is an issue with BT SPP event management due to incomplete closure of connection, this the callback which responds to open and close

void bt_callback(esp_spp_cb_event_t event, esp_spp_cb_param_t *param)
{
  if (event == ESP_SPP_SRV_OPEN_EVT)
  {
    log_d("BT-SPP Client Connected");
#ifdef BLEENABLED
    ble_deviceConnected = false;
#endif
    bt_deviceConnected = true;
  }
  if (event == ESP_SPP_CLOSE_EVT)
  {
    log_d("BT-SPP Client closed connection");
    bt_deviceConnected = false;
  }
}

I have not looked into different types of events or timeout mechanisms: if bt_deviceConnected is true, no new connection is established.

The bug is consistently happening.

My log is:
[I][GPSProvider.cpp:246] pollGSAGSVInfo(): Gs true
[I][BluetoothSerial.cpp:238] esp_spp_cb(): ESP_SPP_SRV_OPEN_EVT
Client Connected
[I][GPSProvider.cpp:259] pollGSAGSVInfo(): Gs false
[I][BluetoothSerial.cpp:250] esp_spp_cb(): ESP_SPP_CLOSE_EVT
Client disconnected
[I][GPSProvider.cpp:246] pollGSAGSVInfo(): Gs true
[I][GPSProvider.cpp:259] pollGSAGSVInfo(): Gs false
[I][GPSProvider.cpp:246] pollGSAGSVInfo(): Gs true

As you can see, when i start logging the bt connection is established and after the ending the connection is closed. After that the Event isn´t called again.

I tried to create a routine to restart the BT Service but this was without success.

My code for the restart is:

if (btSppStop())
{
btSppStart();
}

Thanks for confirming!
Let me reproduce locally.

Restarting BT might bring more troubles than anything, I find the BLE+BT stacks on esp32 quite unreliable when you start/stop outside of specific conditions. I would focus on understanding why the new connect event is not picked up by callback.

I assume btSppStart and btSppStop are routines you created correct? There are 2 functions bt_spp_stop and bt_spp_start in this code.

I know.

I tested it also with your code the be sure that this bug is not only on me side.

el mismo problema :(