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:
- #include <Arduino.h>
- #include <BluetoothSerial.h>
- BluetoothSerial MyBT;
- bool connesso = 0;
- /* I use some other variables here
- ...
- ...
- */
- void callback(esp_spp_cb_event_t event, esp_spp_cb_param_t *param)
- {
- if (event == ESP_SPP_SRV_OPEN_EVT)
- {
- Serial.println("Client Connected");
- connesso = true;
- }
- if (event == ESP_SPP_CLOSE_EVT)
- {
- Serial.println("Client disconnected");
- connesso = false;
- }
- }
- /* I implement some other functions here
- .....
- .....
- */
- void setup()
- {
- Serial.begin(9600);
- MyBT.register_callback(callback);
- MyBT.begin("ESP32-BT");
- while (!MyBT.hasClient())
- {
- delay(1000);
- Serial.println("ESP32 is ready to pair.");
- }
- Serial.println("ESP32 PAIRED!!");
- delay(1000);
- }
- void loop()
- {
- /* I initialize here all the variables that I'll send using BluetoothSerial.write()
- .....
- .....
- */
- if (connesso)
- {
- /*I perform some other tasks on the aforementioned variables here
- .......
- .......
- .......
- */
- MyBT.write(AddParityAndPosition(&MyUint8_t_here, true));
- MyBT.write(AddParityAndPosition(&AnotherUint8_t_here, false));
- /*If I insert some delay in the order of hundreds of milliseconds, as in the subsequent line of code, the issue disappear*/
- //delay(100);
- }
- else{
- Serial.println("Waiting for a client connection");
- delay(500);
- }
- }
Any help/explanation on the issue is very welcome!
Thanks!