Issue on sending Widget on init
-
Hi everyone,
I'm currently working on a project using an ESP32-S3 to send data and commands to the GUI-O app over Bluetooth Low Energy (BLE). My code creates a series of widgets in the app, but I'm facing an issue where only a maximum of 29 widgets are successfully displayed in the GUI-O interface. Any additional widgets beyond 29 are missing.
I've set up the widgets using commands like sendMsg() that are sent to the app over BLE. It seems that not all widgets are properly received by the app, even though all the commands are being executed in the code. I suspect it might be due to BLE packet size limitations or possibly some commands being sent too quickly for the app to handle.
Here are some key points:
The commands are sent from an ESP32-S3 using BLE.
I'm sending a long list of widget creation commands, but only 29 widgets get displayed.
It looks like some of the messages are getting truncated or lost, as additional widgets beyond the 29th don't appear in the GUI-O app.
The BLE message size limit may be around 512 bytes, and I’m trying to figure out the best way to fragment these commands to ensure all widgets are properly created.
I've already tried adding delays between the commands (e.g., delay(50)), but the issue persists. I’m wondering if there's a better way to manage this, such as breaking up the message to fit within BLE packet limits, or another approach to guarantee that all widgets are properly rendered.Any advice on how to ensure all BLE messages are successfully received by the GUI-O app and all widgets are displayed would be greatly appreciated!
Thanks in advance for your help!
-
@mathieu Hi!
Can you try the following:
- Open GUI-O app and navigate to "Info" from the settings menu
- Tap the app version info 10 times - this will enable developer mode
- Scroll to the bottom, tap on "Developer mode" and enable "Log incoming messages".
Next, try sending the widget commands then exit the app and connect your device to a PC. Navigate to com.guio.app folder (Android - > Data) and observe the contents of the incoming log. You can post the log here.
Note that the log will be truncated / cleared next time you start GUI-O app.
Best regards,
Klemen -
This post is deleted! -
[2024-11-14T23:17:08.818] @cls
[2024-11-14T23:17:08.819] @guis BGC:#FFFFFF
[2024-11-14T23:17:08.819] |SORI UID:sori1 HID:sori ORI:2 SEN:0
[2024-11-14T23:17:08.821] |IM UID:im0 X:10 Y:12 W:12 H:20 IP:"https://xxxxxxxxxxxxxx"
[2024-11-14T23:17:08.836] |LB UID:lb0 X:20 Y:10 FGC:#CE9D15 SHC:#83000000 FSZ:5 FFA:"font11" TXT:"Environnemental Sensor" ALP:1 LALP:1
[2024-11-14T23:17:08.838] |BSL UID:bsl1 X:40 Y:146 ROT:90 LEN:80
[2024-11-14T23:17:08.838] |LB UID:lb1 X:30 Y:17 FSZ:4 TXT:"Sound / Lux"
[2024-11-14T23:17:08.839] |LB UID:lb2 X:75 Y:17 FSZ:4 TXT:"Air quality"
[2024-11-14T23:17:08.840] |LB UID:SENSORLUX1 X:10 Y:25 FSZ:4 TXT:"SENSORLUX1 : " ALP:1 LALP:1
[2024-11-14T23:17:08.841] |LB UID:SENSORLUX2 X:10 Y:35 FSZ:4 TXT:"SENSORLUX2" ALP:1 LALP:1
[2024-11-14T23:17:08.842] |LB UID:VEML6030_lux X:10 Y:45 FSZ:4 TXT:"VEML6030_lux" ALP:1 LALP:1
[2024-11-14T23:17:08.842] |LB UID:Mic1 X:10 Y:55 FSZ:4 TXT:"Mic 1" ALP:1 LALP:1
[2024-11-14T23:17:08.843] |LB UID:Mic2 X:10 Y:65 FSZ:4 TXT:"Mic 2" ALP:1 LALP:1
[2024-11-14T23:17:08.844] |LB UID:BME680_IAQ X:41 Y:25 FSZ:4 TXT:"IAQ" ALP:1 LALP:1
[2024-11-14T23:17:08.845] |LB UID:BME680_IAQ_accuracy X:75 Y:25 FSZ:4 TXT:"IAQ_accuracy" ALP:1 LALP:1
[2024-11-14T23:17:08.846] |LB UID:BME680_Temperature X:41 Y:35 FSZ:4 TXT:"Temperature" ALP:1 LALP:1
[2024-11-14T23:17:08.847] |LB UID:BME680_Pressure X:75 Y:35 FSZ:4 TXT:"Pressure" ALP:1 LALP:1
[2024-11-14T23:17:08.847] |LB UID:BME680_Humidity X:41 Y:45 FSZ:4 TXT:"Humidity" ALP:1 LALP:1
[2024-11-14T23:17:08.848] |LB UID:BME680_Gas_resistance X:75 Y:45 FSZ:4 TXT:"Gaz resist" ALP:1 LALP:1
[2024-11-14T23:17:08.853] |LB UID:BME680_Stabilization X:41 Y:55 FSZ:4 TXT:"Stabilization" ALP:1 LALP:1
[2024-11-14T23:17:08.853] |LB UID:BME680_Run_in_status X:75 Y:55 FSZ:4 TXT:"Run_in" ALP:1 LALP:1
[2024-11-14T23:17:08.854] |LB UID:BME680_Compensated_temperature X:41 Y:65 FSZ:4 TXT:"Comp. temp." ALP:1 LALP:1
[2024-11-14T23:17:08.865] |LB UID:BME680_Compensated_humidity X:75 Y:65 FSZ:4 TXT:"Comp. humidity" ALP:1 LALP:1
[2024-11-14T23:17:08.897] |LB UID:BME680_Static_IAQ X:41 Y:75 FSZ:4 TXT:"Static_IAQ" ALP:1 LALP:1
[2024-11-14T23:17:08.898] |LB UID:BME680_CO2_Equivalent X:75 Y:75 FSZ:4 TXT:"CO2 Equ." ALP:1 LALP:1
[2024-11-14T23:17:08.899] |LB UID:BME680_bVOC_equivalent X:41 Y:85 FSZ:4 TXT:"bVOC equ" ALP:1 LALP:1
[2024-11-14T23:17:08.904] |LB UID:BME680_Gas_percentage X:75 Y:85 FSZ:4 TXT:"Gaz %" ALP:1 LALP:1
[2024-11-14T23:17:08.905] |LB UID:BME680_Compensated_gas X:41 Y:95 FSZ:4 TXT:"Comp. gas" ALP:1 LALP:1
[2024-11-14T23:17:08.906] |BSL UID:bsl0 X:18 Y:13 LEN:100
[2024-11-14T23:17:08.906] |BSL UID:bsl2 X:0 Y:20 LEN:100
[2024-11-14T23:17:08.907] |BSL UID:bsl3 X:0 Y:30 LEN:100
[2024-11-14T23:17:08.908] |BSL UID:bsl4 X:0 Y:40 LEN:100
[2024-11-14T23:17:10.303] @lb0 TXT:"Environnemental Sensor 00:00:00:00:00:00 __"
[2024-11-14T23:17:10.305] @SENSORLUX1 TXT:"SENSORLUX1 : 0"
[2024-11-14T23:17:10.305] @SENSORLUX2 TXT:"SENSORLUX2 : 0"
[2024-11-14T23:17:10.305] @VEML6030_lux TXT:"VEML6030_lux : 27.65"
[2024-11-14T23:17:10.306] @Mic1 TXT:"Mic1 : 0"
[2024-11-14T23:17:10.306] @Mic2 TXT:"Mic2 : 0"
[2024-11-14T23:17:10.306] @BME680_IAQ TXT:"IAQ : 50.00"
[2024-11-14T23:17:10.306] @BME680_IAQ_accuracy TXT:"IAQ_accuracy : 0.00"
[2024-11-14T23:17:10.306] @BME680_Temperature TXT:"Temperature : 22.34C"
[2024-11-14T23:17:10.306] @BME680_Pressure TXT:"Pressure : 10.14hPa"
[2024-11-14T23:17:10.306] @BME680_Humidity TXT:"Humidity : 44.44%"
[2024-11-14T23:17:10.358] @BME680_Gas_resistance TXT:"Gas_resis : 73.58KOhms"
[2024-11-14T23:17:10.447] @BME680_Stabilization TXT:"Stabilization : 1.00"
[2024-11-14T23:17:10.535] @BME680_Run_in_status TXT:"Run_in : 0.00"
[2024-11-14T23:17:10.622] @BME680_Compensated_temperature TXT:"Comp. temp. : 21.88C"
[2024-11-14T23:17:10.758] @BME680_Compensated_humidity TXT:"Comp. hum : 45.72"
[2024-11-14T23:17:10.845] @BME680_Static_IAQ TXT:"Static_IAQ : 50.00"
[2024-11-14T23:17:10.933] @BME680_CO2_Equivalent TXT:"CO2_Equ. : 500.00ppm"
[2024-11-14T23:17:11.021] @BME680_bVOC_equivalent TXT:"bVOC_equ. : 0.50ppm"
[2024-11-14T23:17:11.157] @BME680_Gas_percentage TXT:"Gas perc : 0.00%"
[2024-11-14T23:17:11.247] @BME680_Compensated_gas TXT:"Comp. gas : 4.83"
[2024-11-14T23:17:11.836] @lb0 TXT:"Environnemental Sensor 00:00:00:00:00:00 __"
[2024-11-14T23:17:11.967] @SENSORLUX1 TXT:"SENSORLUX1 : 0" -
@mathieu Hi!
I can see only 29 widgets in the log, which means GUI-O did not receive commands for other widgets.
I am guessing that there is a problem with message loss (too much data in a short interval) due to limited buffer space of the BLE stack.But, as you've said - adding a "short" delay did not help. Can you try adding a larger delay just for testing? You can add it after every 3rd command for example.
You could also try updating the connection parameters (decrease connection interval) after the connection is established (using pServer->updateConnParams method):
https://github.com/espressif/arduino-esp32/blob/master/libraries/BLE/src/BLEServer.h#L78Also you can try more structured approach by sending a "chunk" of data (e.g., 100 bytes - without breaking the individual commands) and then waiting for a short time before sending the next chunk.
Best regards,
Kl3m3n -
@kl3m3n by adding 200 of delay looks good. But no very efficien I didn't find an acknoledge mecanism in the api .
And with this time out I receive message "No response from remote device"
I'm not an software expert I'm hardware designer and frankly speaking I don't know exactly the behaviour if I change the connection settings.
void sendMsg(const String &msg) { // Set value and notify the client Serial.println("Envoi du message : " + msg); pCharacteristic->setValue(msg.c_str()); pCharacteristic->notify(); delay(DELAYSENDMSG); } //with delay at 200
if I put delay each 3 instruction the issue is the same
-
@mathieu Hi!
Is it possible for you to send me the initialization commands, so I can reproduce your issue and try to solve it? You can send them to info.guio.app@gmail.com.
Did you consider using legacy Bluetooth (not BLE, but Classic), which is more suited for such large payloads?
Best regards,
Kl3m3n -
@kl3m3n said in Issue on sending Widget on init:
I will send you the code for my esp32 .
via network it's works perfectly with the software for windows.
unfortunatly via esp32 I have only BLE. -
@mathieu Hi.
I will take a look at your initalization and see how the issue can be mitigated. I will get back to you.
Some Esp32 variants support classic bluetooth also. Here is the GUI-O example:
https://www.gui-o.com/examples/gui-o-and-boards/esp32#h.91so3s2tov2eBest regards,
Kl3m3n -
@kl3m3n sure but unfortunatly I'm using an esp32-S3 on my custom hardware
https://esp32.com/viewtopic.php?t=32664
Best regards
-
@mathieu Hi!
I have sent the initialization code to your e-mail (I have included your full commands there, but not here on the forum).
Basically, the commands are sent in a non-blocking fashion one-by one:
#include <BLEDevice.h> #include <BLEServer.h> #include <BLEUtils.h> #include <BLE2902.h> #include <pgmspace.h> const char* const commands[] PROGMEM = { "|LB UID:lb0 X:20 Y:10\r\n", ... ... ... }; const size_t numCommands = sizeof(commands) / sizeof(commands[0]); namespace uuid { static const char *SERVICE_UUID = "6E400001-B5A3-F393-E0A9-E50E24DCCA9E"; static const char *RX_CHARACTERISTIC_UUID = "6E400002-B5A3-F393-E0A9-E50E24DCCA9E"; static const char *TX_CHARACTERISTIC_UUID = "6E400003-B5A3-F393-E0A9-E50E24DCCA9E"; } // namespace uuid // forward declare parser for incoming messages void parseGuioMsg(const String &msg); // setup done flag bool setupDone = false; // init active flag bool initActive = false; // send command period in msec static const unsigned long sendCommandPeriod = 50; // custom handling of server callbacks class CustomBLEServerCallbacks: public BLEServerCallbacks { void onConnect(BLEServer* pServer) { Serial.println("Connected!"); }; void onDisconnect(BLEServer* pServer) { Serial.println("Disconnected!"); // fix provided by BM // restart advertising after disconnect, otherwise GUI-O cannot re-connect if(setupDone) { // restart advertising on disconnect delay(500); pServer->startAdvertising(); } } }; // custom handling of characteristic callbacks class CustomBLECharacteristicCallbacks: public BLECharacteristicCallbacks { void onWrite(BLECharacteristic *pCharacteristic) { std::string msg = pCharacteristic->getValue(); // parse message string parseGuioMsg(String(msg.c_str())); } }; // global ptr BLECharacteristic *pTxCharacteristic; void setup() { // debug output Serial.begin(115200); // create device BLEDevice::init("BasicBLE_NUS"); // create server and register callback BLEServer *pServer = BLEDevice::createServer(); pServer->setCallbacks(new CustomBLEServerCallbacks()); // create service BLEService *pService = pServer->createService(uuid::SERVICE_UUID); // crate Tx characteristic and add descriptor pTxCharacteristic = pService->createCharacteristic(uuid::TX_CHARACTERISTIC_UUID, BLECharacteristic::PROPERTY_NOTIFY); pTxCharacteristic->addDescriptor(new BLE2902()); // crate Rx characteristic and register callback BLECharacteristic *pRxCharacteristic = pService->createCharacteristic(uuid::RX_CHARACTERISTIC_UUID, BLECharacteristic::PROPERTY_WRITE | BLECharacteristic::PROPERTY_WRITE_NR); pRxCharacteristic->setCallbacks(new CustomBLECharacteristicCallbacks()); // start the service and start advertising pService->start(); pServer->getAdvertising()->start(); // setup done flag setupDone = true; } void loop() { static size_t currentCommandIndex = 0; static unsigned long lastCommandTime = 0; if (initActive) { if (currentCommandIndex < numCommands) { if (millis() - lastCommandTime > sendCommandPeriod) { lastCommandTime = millis(); // retrieve and send the command char commandBuffer[256]; strcpy_P(commandBuffer, (char*)pgm_read_ptr(&commands[currentCommandIndex])); sendMsg(commandBuffer); Serial.print("Sending: "); Serial.println(commandBuffer); currentCommandIndex++; } } else { initActive = false; // hide loading screen sendMsg("@hls\r\n"); } } } /***************************/ /* IMPLEMENT YOUR GUI HERE */ /***************************/ void sendMsg(const String &msg) { pTxCharacteristic->setValue(std::string(msg.c_str())); pTxCharacteristic->notify(); delay(50); } void parseGuioMsg(const String &msg) { if(msg.startsWith("@init")) { Serial.println("GUI-O app is requesting INITIALIZATION!"); // clear screen and set background sendMsg("@cls\r\n"); sendMsg("@guis BGC:#FFFFFF\r\n"); sendMsg("|SORI UID:sori2 HID:sori ORI:2 SEN:0\r\n"); // wait for orientation change (alternatively catch GUI-O screen orientation change event...) delay(500); // show loading screen sendMsg("@sls\r\n"); initActive = true; } }
Can you please test it and see if it works for you?
You can try extending sendCommandPeriod if you have any issues... Also you can comment out the @sls and @hls commands to see exactly what is going on...
Best regards,
Kl3m3n