sinricpro / esp8266-esp32-sdk

Library for https://sinric.pro - simple way to connect your device to Alexa, Google Home, SmartThings and cloud
https://sinric.pro
Other
231 stars 124 forks source link

ESP32 using sdk 2.9.1 will not connect using SSL #156

Closed sgrizzi closed 3 years ago

sgrizzi commented 3 years ago

(Linked to issue #155 )

Hi Boris, if I exclude the use of SSL then the code connects and works fine. I used this in Platformio.ini: build_flags = -D DEBUG_ESP_PORT=Serial -D NODEBUG_WEBSOCKETS -D NDEBUG -D NODEBUG_SINRIC -D SINRICPRO_NOSSL -Wl,-Map,output.map

and this is the serial output: ets Jun 8 2016 00:22:57

rst:0x1 (POWERON_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

WiFi: IP-Address is 192.168.1.77 Timer set to 10 seconds (timerDelay variable), it will take 10 seconds before publishing the first airco reading. Scanning BLE... hopefully scanning in the background... Connected to SinricPro Temperaturesensor turned on (via SinricPro) Temperature: 0.0 Celsius Humidity: 0.0% Device xxxxxxxxx turned on (via SinricPro) Thermostat xxxxxxxxxxx turned off etc. etc.

The dependency graph does show the use of WebSockets 2.3.5 Dependency Graph |-- 6.11.5 |-- 2.3.5 | |-- 1.0 | |-- 1.0 | |-- 1.0 | | |-- 1.0 |-- 1.0.1 |-- 0.1.0 |-- 0.4.2 |-- 2.9.1 | |-- 6.11.5 | |-- 1.0 | |-- 2.3.5 | | |-- 1.0 | | |-- 1.0 | | |-- 1.0 | | | |-- 1.0 |-- 1.0 |-- 1.2 | |-- 1.0 | |-- 1.0 | | |-- 1.0

This is lib_deps in Platformio.ini lib_deps = ArduinoJson@~6.11 WebSockets nkolban/ESP32 BLE Arduino@^1.0.1 arduino-libraries/Arduino_JSON@^0.1.0 cygig/TimerEvent@^0.4.2 sinricpro/SinricPro@^2.9.1

Any sugegstions? Rgds, Gabriele

sivar2311 commented 3 years ago

Ok, so without SSL everything is working fine.

Did you update the WebSockets library to latest version from github? (you need to download from github)

sgrizzi commented 3 years ago

Hi Boris, as per your suggestion, I uninstalled the old WebSockets and installed a fresh one from the link you mentioned in a previous message "https://github.com/Links2004/arduinoWebSockets" Now I get this error when compiling: lib/arduinoWebSockets-master/src/WebSocketsClient.cpp: In member function 'void WebSocketsClient::loop()': lib/arduinoWebSockets-master/src/WebSocketsClient.cpp:234:30: error: 'class WiFiClientSecure' has no member named 'setInsecure' _client.ssl->setInsecure(); ^ ** [.pio/build/ESP32/lib94b/arduinoWebSockets-master/WebSocketsClient.cpp.o] Error 1 .pio/libdeps/ESP32/SinricPro/src/extralib/Crypto/AESLib.cpp: In member function 'String AESLib::encrypt(String, byte, byte)': .pio/libdeps/ESP32/SinricPro/src/extralib/Crypto/AESLib.cpp:63:32: warning: 'sizeof' on array function parameter 'key' will return size of 'byte {aka unsigned char*}' [-Wsizeof-array-argument] aes.set_key( key , sizeof(key)); ^ .pio/libdeps/ESP32/SinricPro/src/extralib/Crypto/AESLib.cpp:59:45: note: declared here String AESLib::encrypt(String msg, byte key[], byte my_iv[]) { and obviously the compilation fails.

Any ideas?

Rgds, Gabriele

sivar2311 commented 3 years ago

I did a test and everything works perfect for me.

For the test, i ported the sketch from #134 to ESP32 and it is working as expected.

The message you have now: WebSocket version is not correct (does not contain latest SSL fix!) Download WebSockets from github.

Edit: Please check arduino core version too!

sgrizzi commented 3 years ago

Boris, I downloaded WebSockets from here: "https://github.com/Links2004/arduinoWebSockets" is it not correct? or, simpler, can you give the link to the correct library release, please? Rgds, Gabriele

sivar2311 commented 3 years ago

The link is correct. The best would be to wait until tomorrow - Markus released 2.3.5 few minutes ago It takes up to 24hrs that the library become available via library manager!

Next thing (more important thing): The message 'class WiFiClientSecure' has no member named 'setInsecure' tells me that your ArduinoCore version doesn't match! (Did you downgrade the ESP32 platform in pio?) Please check the version!

You need:

sgrizzi commented 3 years ago

(Did you downgrade the ESP32 platform in pio?) ...no.... but I had not upgraded it either !!! with Espressif 32 Version 3.1.0 the code compiles and works fine. I still get a strange error from WiFiClient (see below)... but the ESP32 connects with no problem.

rst:0x1 (POWERON_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:10124 load:0x40080400,len:5828 entry 0x400806a8

WiFi: IP-Address is 192.168.1.77 Timer set to 10 seconds (timerDelay variable), it will take 10 seconds before publishing the first airco reading. Scanning BLE... hopefully scanning in the background... [E][WiFiClient.cpp:309] setOption(): fail on fd -1, errno: 9, "Bad file number" Connected to SinricPro Temperaturesensor turned on (via SinricPro) Temperature: 0.0 Celsius Humidity: 0.0% Device xxxxxxxxxx turned on (via SinricPro) Thermostat xxxxxxxxxx turned off Thermostat xxxxxxxxxx set temperature to 27.000000 Thermostat xxxxxxxxxx set to mode AUTO Thermostat xxxxxxxxxx turned off Thermostat xxxxxxxxxx set temperature to 27.000000 Thermostat xxxxxxxxxx turned off Thermostat xxxxxxxxxx turned off Thermostat xxxxxxxxxx set temperature to 28.000000 Fan xxxxxxxxxx turned off Fan xxxxxxxxxx speed changed to A Fan xxxxxxxxxx turned off Fan xxxxxxxxxx speed changed to A Fan xxxxxxxxxx turned off Fan xxxxxxxxxx speed changed to A Fan xxxxxxxxxx turned off Fan xxxxxxxxxx speed changed to A Monitra Advertised Device found: Name: , Address: 00:0b:57:f1:03:03, manufacturer data: 3e03010400a14918001b01b0 light 1b 01 temp b0 04

Thanks for your prompt support !!! Regards, Gabriele

sivar2311 commented 3 years ago

Strange Error? Do you mean [E][WiFiClient.cpp:309] setOption(): fail on fd -1, errno: 9, "Bad file number" ? I'm having this message too (on ESP32) This can be ignored... It seems this happens since years but have no effects.

sgrizzi commented 3 years ago

Clear! Thanks a lot! Have a nice evening. Rgds, Gabriele