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
234 stars 124 forks source link

WiFiClient setOption() Bad file number #254

Closed eos1d3 closed 2 years ago

eos1d3 commented 2 years ago

Hi, just found an error using Light_FastLED_WS2812 example.

Using VS Code with ESP32. No modification to source except the credentials and WiFi settings. After start, I see the console messages:

--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
......connected!
[WiFi]: IP-Address is 192.168.5.113
[E][WiFiClient.cpp:309] setOption(): fail on fd -1, errno: 9, "Bad file number"
Connected to SinricPro

These are compilation information:

PLATFORM: Espressif 32 (3.5.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-arduinoespressif32 3.10006.210326 (1.0.6) 
 - tool-esptoolpy 1.30100.210531 (3.1.0) 
 - toolchain-xtensa32 2.50200.97 (5.2.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 32 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <SinricPro> 2.9.17
|   |-- <ArduinoJson> 6.19.1
|   |-- <WebSockets> 2.3.6
|   |   |-- <WiFi> 1.0
|   |   |-- <SPI> 1.0
|   |   |-- <WiFiClientSecure> 1.0
|   |   |   |-- <WiFi> 1.0
|   |-- <WiFi> 1.0
|-- <FastLED> 3.5.0
|   |-- <SPI> 1.0
|-- <WiFi> 1.0

Each time I see the error when power up ESP32. But it works without problem. Dimming, color changes, power on/off work fine. Any idea to fix this?

sivar2311 commented 2 years ago

This is a warning message from the underlying WiFiClient and can be ignored. To avoid this serial output simply add Serial.setDebugOutput(false); right after Serial.begin()

eos1d3 commented 2 years ago

Thank you!

eos1d3 commented 2 years ago

Sorry to reopen the issue regarding to the same example, I find onAdjustBrightness is never called by using GVA, Alexa and also SinricPro app. So is it deprecated?

sivar2311 commented 2 years ago

Normally this should be a new issue as it is not related to the original question.

Anyways, onAdjustBrightness gets called when you say something like "Alexa, lower the light by 10%" The parameter brightnessDelta is a relative value (-100 to +100) which the light should change about. The callback function must calculate the new absolute value and return this in the valueDelta parameter!

See the example code here: https://github.com/sinricpro/esp8266-esp32-sdk/blob/46bc97268a71dcc929d39811fca1a6ab94e9177e/examples/Light/Light/Light.ino#L81-L86

kakopappa commented 2 years ago

@eos1d3 did a quick test and onAdjustBrightness gets called in the light example provided.

adjust

eos1d3 commented 2 years ago

@sivar2311 @kakopappa Thank a lot for help.

I can confirm "lower the light by 10%" will call onAdjustBrightness by Alexa, while GVA will calculate the brightness itself and call onBrightness instead.

Is that normal?

sivar2311 commented 2 years ago

Sorry for my question, but what do you mean by "GVA" ?

eos1d3 commented 2 years ago

Sorry for that, I mean Google Voice Assistant.

sivar2311 commented 2 years ago

Ah ok :) @kakopappa Can you please check this when you get a chance?

kakopappa commented 2 years ago

@sivar2311 @kakopappa Thank a lot for help.

I can confirm "lower the light by 10%" will call onAdjustBrightness by Alexa, while GVA will calculate the brightness itself and call onBrightness instead.

Is that normal?

@eos1d3

Yes, Did a quick test. It seems Google Home has the ability to calculate the relative value and send as a percentage change correctly.

lightbulb at 100%

Ok Google, Dim my lightbulb sends setBrightness {"brightness":70}

Ok Google, Brighten my lightbulb by 20%. sends setBrightness {"brightness":90}

eos1d3 commented 2 years ago

Thank you for confirming the results!