Closed loulou4cv closed 4 years ago
This must be related to different core libraries used by PlatformIO. Unfortunately there is nothing we can do here on SDK side. What's your PIO Espressif32 Version and which core version do you use?
I have version 1.12.0, which has same arduino Espressif32 framework version.
These issues happens inside arduino core [E][WiFiGeneric.cpp:654]
, [E][WiFiClient.cpp:482]
and ESP-IDF /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/core/dns.c
.
The only (real) external library which are used is WebSockets and ArduinoJson. ArduinoJson can be excluded here.
Which WebSocket library do you use and do you use the provided platformio.ini
file from examples?
Hello, my websockets library is 2.2.0
I used the below platformio.ini because it didn't compile with yours, saying some files were missing. With below platformio.ini, it compiled without errors : [env:esp32dev] platform = espressif32 board = esp32dev framework = arduino upload_speed = 921600 monitor_speed=115200
Today I have tried again to compile with your platformio.ini. Again it didn't compile. I clicked on compile again because I have seen sometimes strange compilation behavior (not same console messages if you compile several times without changing a code line) and then it compiled ! without changing anything between the 2.
Then I have tried my program and no more communication error.
solution : using your platformio.ini
However I don't understand why platformio doesn't compile, then compile without changing things. By the way, that occurs not only with this program using Sinricpro, but also on some other programs sometimes. Must be a platformio problem but I don't know how to go forward on it.
Thank you
Our platformio.ini downloads automatlicly the correct needed external libraries and put them into your project folder. When you try to compile it the first time there might some issues about missing files, but compiling it 2nd time everything should work.
Thank you, have a good day.
Hello,
ESP32 Arduinojson 6.15.1 Sinricpro 2.4.0 identical code in ArduinoIDE and platformIO, with serial console to monitor.
my code is at the end of this post.
Issue 1 :
Issue 2 :
immediately after flashing and connected to WIFI, connects to SinricPro : OK
console says : WiFi: IP-Address is 192.168.1.22 [E][WiFiGeneric.cpp:654] hostByName(): DNS Failed for ws.sinric.pro
then it disconnects after a while from Sinricpro, but it doesn't reconnect to Sinricpro as easily as with Arduino IDE.
then after some minutes : [E][WiFiClient.cpp:482] flush(): fail on fd 57, errno: 11, "No more processes"
then after some minutes, several DNS failed error again
and randomly it reboots after some time, writing in the console : assertion "dns server out of array" failed: file "/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/core/dns.c", line 790, function: dns_send abort() was called at PC 0x40106293 on core 1
Backtrace: 0x4008c454:0x3ffb1da0 0x4008c685:0x3ffb1dc0 0x40106293:0x3ffb1de0 0x40124cfe:0x3ffb1e10 0x40125036:0x3ffb1e50 0x40125645:0x3ffb1e70 0x40125ccd:0x3ffb1ea0 0x40125d19:0x3ffb1ec0 0x400d559d:0x3ffb1ee0 0x4013e7db:0x3ffb1f20 0x400d7639:0x3ffb1f50 0x400d5223:0x3ffb1f70 0x400d5242:0x3ffb1f90 0x400dc5ed:0x3ffb1fb0 0x40088b9d:0x3ffb1fd0
Rebooting... ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:2 load:0x3fff0018,len:4 load:0x3fff001c,len:1044 load:0x40078000,len:8896 load:0x40080400,len:5828 entry 0x400806ac
my code :
include
include
include
include
include
define WIFI_SSID "XXXX"
define WIFI_PASS "XXXX"
define APP_KEY "XXXX" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx"
define APP_SECRET "XXXX" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx"
define BLINDS_ID "XXXX" // Should look like "5dc1564130xxxxxxxxxxxxxx"
define SWITCH_ID "XXXX" // Should look like "5dc1564130xxxxxxxxxxxxxx"
define BAUD_RATE 115200 // Change baudrate to your need
define LED_PIN 2 // led de la carte ESP32 dev kit, associée ici à l'état de la commande de la ventouse.
// variables pour la bibliothèque
define OPEN 1
define CLOSE 0
int LibraryPosition = 255; // pourcentage d'ouverture de la bibliothèque (255 si inconnu) bool MotorPower = false; // ON=allumer l'alimentation du moteur; OFF=éteint. bool MotorDir = OPEN; // sens de déplacement du moteur; int MotorSpeed = 0; // PWM de Vitesse du moteur (à limiter à 98% pour le bon fonctionnement de la carte puissance, jamais 100%). bool ventousePowerState = false; // alimentation de la ventouse (false=éteint --> ouverture manuelle possible). bool bibliothequePowerState = false; int blindsPosition; int LibraryLightPower; // de 0 à 100% pour le dimming. int LibraryLightRed; // couleur rouge : optionnel, dépend du ruban led utilisé. int LibraryLightGreen; // couleur verte : optionnel, dépend du ruban led utilisé. int LibraryLightBlue; // couleur bleue : optionnel, dépend du ruban led utilisé. int LibraryLightWhite; // couleur blanche : optionnel, dépend du ruban led utilisé. int LibraryLightAmber; // couleur Ambre : optionnel, dépend du ruban led utilisé.
// timer(s). unsigned long previousmillis1 = 0;
define timer500 500 // 500 millisecondes.
define timer1000 1000 // 1 seconde.
define timer2000 5000 // 2 secondes.
define timer5000 5000 // 5 secondes.
define timer10000 10000 // 10 secondes.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // gestion des commandes ON/OFF --> appelée par le Handle de Sinric pro. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool onPowerState(const String &deviceId, bool &state) { Serial.printf("Device %s power turned %s \r\n", deviceId.c_str(), state?"on":"off");
if(deviceId==SWITCH_ID) { // si la commande concerne la ventouse ventousePowerState = state; Serial.print("commande reçue : "); Serial.print("ventouse="); Serial.println(ventousePowerState); } else if (deviceId==BLINDS_ID) { bibliothequePowerState = state; Serial.print("commande reçue : "); Serial.print("commande bibliothèque="); Serial.println(bibliothequePowerState); } return true; // request handled properly }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // gestion des commandes de position absolue --> appelée par le Handle de Sinric pro. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool onSetPosition(const String &deviceId, int &position) { Serial.printf("Device %s set position to %d\r\n", deviceId.c_str(), position); // no code associated to this function. return true; // request handled properly }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // gestion des commandes de position relative --> appelée par le Handle de Sinric pro. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool onAdjustPosition(const String &deviceId, int &positionDelta) { blindsPosition += positionDelta; Serial.printf("Device %s position changed about %i to %d\r\n", deviceId.c_str(), positionDelta, blindsPosition); // for debug purpose only positionDelta = blindsPosition; // calculate and return absolute position return true; // request handled properly }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Setup du Wifi /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void setupWiFi() { Serial.printf("\r\nWifi: Connecting"); WiFi.begin(WIFI_SSID, WIFI_PASS);
while (WiFi.status() != WL_CONNECTED) { Serial.printf("."); delay(250); } IPAddress localIP = WiFi.localIP(); Serial.printf("connected!\r\nWiFi: IP-Address is %d.%d.%d.%d\r\n", localIP[0], localIP[1], localIP[2], localIP[3]); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Setup Sinricpro /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void setupSinricPro() { // get a new Blinds device from SinricPro SinricProBlinds &myBlinds = SinricPro[BLINDS_ID]; myBlinds.onPowerState(onPowerState); myBlinds.onSetPosition(onSetPosition); myBlinds.onAdjustPosition(onAdjustPosition);
// add device to SinricPro SinricProSwitch& mySwitch = SinricPro[SWITCH_ID];
// set callback function to device mySwitch.onPowerState(onPowerState);
// setup SinricPro SinricPro.onConnected([](){ Serial.printf("Connected to SinricPro\r\n"); }); SinricPro.onDisconnected([](){ Serial.printf("Disconnected from SinricPro\r\n"); }); SinricPro.begin(APP_KEY, APP_SECRET); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Main Program Setup (automatic call at startup) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void setup() { pinMode(LED_PIN, OUTPUT); // define LED GPIO as output digitalWrite(LED_PIN, LOW); // turn on LED on bootup
Serial.begin(BAUD_RATE); Serial.printf("\r\n\r\n"); setupWiFi(); setupSinricPro(); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Main Program loop /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void loop() { SinricPro.handle();
//for debug purpose only
if (millis()-previousmillis1>timer5000) { previousmillis1 = millis();
} }