ESP32 wroom32: BluetoothSerial.write doesn't work anymore at client reconnection

Alteregoxxx
Posts: 2
Joined: Tue Apr 09, 2019 9:54 pm

ESP32 wroom32: BluetoothSerial.write doesn't work anymore at client reconnection

Postby Alteregoxxx » Tue Apr 09, 2019 10:29 pm

Hello everyone,
this is my first topic, looking for your help :-)

As for the subject, using the ESP32 Wroom32 BluetoothSerial, if it's sending fast lots of a data using BluetoothSerial.write() method and the client to which it was connected disconnects, at the client reconnection, ESP32 Wroom32 accept the connection (I'm sure because I can see it from the serial prints I perform in the callback called at client connection/disconnection) , but the BluetoothSerial.write() method doesn't send data anymore.

A snippet worths a thousand words:
  1.  
  2. #include <Arduino.h>
  3. #include <BluetoothSerial.h>
  4. BluetoothSerial MyBT;
  5. bool connesso = 0;
  6. /* I use some other variables here
  7. ...
  8. ...
  9. */
  10.  
  11. void callback(esp_spp_cb_event_t event, esp_spp_cb_param_t *param)
  12. {
  13.   if (event == ESP_SPP_SRV_OPEN_EVT)
  14.   {
  15.     Serial.println("Client Connected");
  16.     connesso = true;
  17.   }
  18.  
  19.   if (event == ESP_SPP_CLOSE_EVT)
  20.   {
  21.     Serial.println("Client disconnected");
  22.     connesso = false;
  23.   }
  24. }
  25.  
  26. /* I implement some other functions here
  27. .....
  28. .....
  29. */
  30.  
  31. void setup()
  32. {
  33.  
  34.   Serial.begin(9600);
  35.   MyBT.register_callback(callback);
  36.  
  37.   MyBT.begin("ESP32-BT");
  38.   while (!MyBT.hasClient())
  39.   {
  40.     delay(1000);
  41.     Serial.println("ESP32 is ready to pair.");
  42.   }
  43.   Serial.println("ESP32 PAIRED!!");
  44.   delay(1000);
  45. }
  46.  
  47. void loop()
  48. {
  49.  
  50. /* I initialize here all the variables that I'll send using BluetoothSerial.write()
  51. .....
  52. .....
  53. */
  54.  
  55.   if (connesso)
  56.   {
  57.  
  58. /*I perform some other tasks on the aforementioned variables here
  59. .......
  60. .......
  61. .......
  62. */
  63.  
  64.     MyBT.write(AddParityAndPosition(&MyUint8_t_here, true));
  65.     MyBT.write(AddParityAndPosition(&AnotherUint8_t_here, false));
  66.     /*If I insert some delay in the order of hundreds of milliseconds, as in the subsequent line of code, the issue disappear*/
  67.     //delay(100);  
  68.  
  69.   }
  70.  
  71.   else{
  72.     Serial.println("Waiting for a client connection");
  73.     delay(500);
  74.   }
  75.  
  76. }
Is this a normal behaviour? Can someone be so kind in trying to reproduce the issue?

Any help/explanation on the issue is very welcome! :-)

Thanks!

Alteregoxxx
Posts: 2
Joined: Tue Apr 09, 2019 9:54 pm

Re: ESP32 wroom32: BluetoothSerial.write doesn't work anymore at client reconnection

Postby Alteregoxxx » Fri Apr 12, 2019 7:43 am

Has anyone managed to replicate the issue?

Darshan Panchal
Posts: 2
Joined: Sun Apr 28, 2019 3:53 pm

Re: ESP32 wroom32: BluetoothSerial.write doesn't work anymore at client reconnection

Postby Darshan Panchal » Mon Apr 29, 2019 6:23 am

Hi,

Facing the same issue on my esp32 on bleutooth serial example.

If any one find any solution, please post.

Regards.

Who is online

Users browsing this forum: No registered users and 53 guests