Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sonoff RF Bridge cant change "Boot Mode" of switch #1597

Closed
kiralikbeyin opened this issue Mar 1, 2019 · 15 comments
Closed

Sonoff RF Bridge cant change "Boot Mode" of switch #1597

kiralikbeyin opened this issue Mar 1, 2019 · 15 comments

Comments

@kiralikbeyin
Copy link

Espurna 1.13.5
rc2.5.0 and rc2.4.2

When i want to change "Always OFF" to "Same as before" it doesnt save and restarts...
So my switches turns off everytime SRFB restarts.

@reaper7
Copy link
Contributor

reaper7 commented Mar 1, 2019

looks like common problem with "save".
My S20 and RF Bridge do not save settings.
Only Sonoff T1 save settings but I do not know how I forced him to do it...
It seems to me that I had to enable the following options:
TELNET_SUPPORT & DEBUG_TELNET_SUPPORT & DEBUG_WEB_SUPPORT
from this moment pressing the SAVE key on the web interaface began to save the settings.

Espurna current git / LWIP 1.4

@mcspr
Copy link
Collaborator

mcspr commented Mar 1, 2019

Can't reproduce with rfbridge built with 2.4.2, with or without DEBUG_SUPPORT flags active.
Does using lwip2 make any difference?
Does setting LOOP_DELAY_TIME to 10 change anything? (or without rebuilding - loopDelay setting via terminal / settings upload)

@kiralikbeyin
Copy link
Author

@reaper7 yes, save problem. TELNET_SUPPORT & DEBUG_TELNET_SUPPORT & DEBUG_WEB_SUPPORT didnt work Espurna current git / LWIP 1.4 AND Espurna current git / V2 Low mem didnt work.

@mcspr loopDelay 10, 20, 55, 200 didnt work

I have a IR RECEIVE problem maybe these problems are related. #1596

I will fallback to 1.13.3 v

@kiralikbeyin
Copy link
Author

kiralikbeyin commented Mar 2, 2019

I uploaded espurna-1.13.5-itead-sonoff-rfbridge.bin with esptool.py and it saves no reboot.

I think main problem is we are downloading external libraries like https://github.com/markszabo/IRremoteESP8266 and other 10-15 libraries and they are crushing something. (i downloaded all latest external libs and i cant save which is the most basic thing)

Please add external libaries with exact relase in source.zip of nice Espurna.
Also please give info which "rc version" and "lwIP Variant" is used for these bin files.
@xoseperez Thanks alot!

Is there any way to enable IR receive-send from terminal?
1.13.3 - 1.13.4 - 1.13.5 compiled from source didnt save config also cant receive IR codes #1596

@reaper7
Copy link
Contributor

reaper7 commented Mar 2, 2019

my observations:


custom config:

  #define WIFI_FALLBACK_APMODE        0                                         // Fallback to AP mode if no STA connection
  #define USE_PASSWORD                0

  #define TELNET_SUPPORT              0                                         // Enable telnet support by default (3.34Kb)
  #define TELNET_STA                  0                                         // By default, disallow connections via STA interface
  #define TELNET_AUTHENTICATION       0                                         // Request password to start telnet session by default
  
  #define TERMINAL_SUPPORT            0                                         // Enable terminal commands (0.97Kb)

  #define WEB_SUPPORT                 1                                         // Enable web support (http, api, 121.65Kb)
  #define WEB_EMBEDDED                1                                         // Build the firmware with the web interface embedded in
  #define WEB_FORCE_PASS_CHANGE       0

  #define DEBUG_SERIAL_SUPPORT        0                                         // Enable serial debug log
  #define DEBUG_UDP_SUPPORT           0                                         // Enable UDP debug log
  #define DEBUG_TELNET_SUPPORT        0                                         // Enable telnet debug log (will only work if TELNET_SUPPORT is also 1)
  #define DEBUG_WEB_SUPPORT           0                                         // Enable web debug log (will only work if WEB_SUPPORT is also 1)

  #define SCHEDULER_SUPPORT           0                                         // Enable scheduler (1.77Kb)

  #define NTP_SUPPORT                 1                                         // Build with NTP support by default (6.78Kb)
  #define NTP_SERVER                  "myhouse.lan"

  #define MQTT_SUPPORT                0                                         // MQTT support (22.38Kb async, 12.48Kb sync)
  #define MQTT_ENABLED                1                                         // Do not enable MQTT connection by default
  #define MQTT_AUTOCONNECT            1                                         // If enabled and MDNS_SERVER_SUPPORT=1 will perform an autodiscover and
  #define MQTT_SERVER                 "rpi"                                     // Default MQTT broker address
  #define MQTT_USER                   "user"                                    // Default MQTT broker usename
  #define MQTT_PASS                   "pass"                                    // Default MQTT broker password
  #define MQTT_RETAIN                 true                                      // MQTT retain flag
  #define MQTT_QOS                    0                                         // MQTT QoS value for all messages
  #define MQTT_USE_JSON               0                                         // Group messages in a JSON body

  #define HOMEASSISTANT_SUPPORT       0                                         // Build with home assistant support (if MQTT, 1.64Kb)
  #define HOMEASSISTANT_ENABLED       1                                         // Integration not enabled by default
  #define HOMEASSISTANT_PREFIX        MY_HOME                                   // Default MQTT prefix

  #define DOMOTICZ_SUPPORT            0                                         // Build with domoticz (if MQTT) support (1.72Kb)
  #define THINGSPEAK_SUPPORT          0                                         // Enable Thingspeak support by default (2.56Kb)
  #define ALEXA_SUPPORT               0                                         // Enable Alexa support by default (10.84Kb)

with the same settings, I enable and disable mqtt support only (MQTT_SUPPORT):


with MQTT_SUPPORT disabled all works, I can SAVE, when SAVE button pressed wireshark show:

without_mqtt

main window:
without_mqtt_without_hass

and I see popup window like "No changes detected" or "Changes saved"


with MQTT_SUPPORT enabled I can't SAVE, when SAVE button pressed wireshark show:

with_mqtt

main window:
with_mqtt_without_hass

No popup window!


arduino libs used:

Użycie biblioteki ArduinoJson-5.11.2 w wersji 5.11.2 z folderu: C:\PROGRAMY\arduino_projekty\libraries\ArduinoJson-5.11.2 
Użycie biblioteki eeprom_rotate w wersji 0.9.2 z folderu: C:\PROGRAMY\arduino_projekty\libraries\eeprom_rotate 
Użycie biblioteki EEPROM w wersji 1.0 z folderu: C:\PROGRAMY\Arduino\hardware\esp8266com\esp8266\libraries\EEPROM 
Użycie biblioteki ESPAsyncTCP w wersji 1.2.0 z folderu: C:\PROGRAMY\arduino_projekty\libraries\ESPAsyncTCP 
Użycie biblioteki embedis w wersji 1.2.0 z folderu: C:\PROGRAMY\arduino_projekty\libraries\embedis 
Użycie biblioteki ESPAsyncWebServer w wersji 1.2.0 z folderu: C:\PROGRAMY\arduino_projekty\libraries\ESPAsyncWebServer 
Użycie biblioteki ESP8266WiFi w wersji 1.0 z folderu: C:\PROGRAMY\Arduino\hardware\esp8266com\esp8266\libraries\ESP8266WiFi 
Użycie biblioteki justwifi w wersji 2.0.2 z folderu: C:\PROGRAMY\arduino_projekty\libraries\justwifi 
Użycie biblioteki debounceevent w wersji 2.0.5 z folderu: C:\PROGRAMY\arduino_projekty\libraries\debounceevent 
Użycie biblioteki ESP8266mDNS w wersji 1.2 z folderu: C:\PROGRAMY\Arduino\hardware\esp8266com\esp8266\libraries\ESP8266mDNS 
Użycie biblioteki Time w wersji 1.5 z folderu: C:\PROGRAMY\arduino_projekty\libraries\Time 
Użycie biblioteki NtpClient w wersji 2.5.0 z folderu: C:\PROGRAMY\arduino_projekty\libraries\NtpClient 
Użycie biblioteki Ticker w wersji 1.0 z folderu: C:\PROGRAMY\Arduino\hardware\esp8266com\esp8266\libraries\Ticker 
Użycie biblioteki ArduinoOTA w wersji 1.0 z folderu: C:\PROGRAMY\Arduino\hardware\esp8266com\esp8266\libraries\ArduinoOTA 
Użycie biblioteki Hash w wersji 1.0 z folderu: C:\PROGRAMY\Arduino\hardware\esp8266com\esp8266\libraries\Hash 
Użycie biblioteki DNSServer w wersji 1.1.1 z folderu: C:\PROGRAMY\Arduino\hardware\esp8266com\esp8266\libraries\DNSServer 

arduino settings:
ardu_settings

@kiralikbeyin
Copy link
Author

@reaper7 thanks for showing all info. Did you try https://github.com/xoseperez/espurna/releases/download/1.13.5/espurna-1.13.5-itead-sonoff-rfbridge.bin

I enabled MQTT everything is fine, i can save.

@reaper7
Copy link
Contributor

reaper7 commented Mar 2, 2019

@kiralikbeyin - it's better for me to find the cause, because I use custom config with predefined settings for each of my devices (ip addresses, relays boot modes, way the diodes works, topics for mqtt etc...)

@kiralikbeyin
Copy link
Author

@reaper7 @mcspr
Found solution - cut USB to GPIO 4-5 connection

Also i can receive IR codes :)

more info :arendst/Tasmota#5379

@mcspr
Copy link
Collaborator

mcspr commented Mar 2, 2019

@kiralikbeyin binaries are built by platformio. libraries are pinned, like this:

https://github.com/markszabo/IRremoteESP8266#v2.2.0

and it is using 2.3.0 core, single option of lwip1.4. glad that you solved your problem with ir lib. so does it mean that the latest version works ok and that was some kind of power problem?

But, @reaper7 mentioned the same problem with different devices.
since device is seemingly crashing, here's the custom build based on 1.13.5 with /crash http endpoint to get the stacktrace for https://github.com/me-no-dev/EspExceptionDecoder (just make sure to keep .bin / .elf from the build directory before restarting IDE)

patch: dev...mcspr:check-1.13.5
platformio 2.4.2 .bin with custom config above, minus personalized server settings

edit: formatting...

@kiralikbeyin
Copy link
Author

@mcspr Thanks for information i never tried rc2.3 or IR REMOTE LIB v2.2.0 (20170922) but i will check this file everytime in the future.

Strange thing about this lib 1technophile/OpenMQTTGateway#367 works fine with USB power (without cutting) and also FTDI connection.

When i cut USB -GPIO4-GPIO5 connection Espurna and Tasmato libs also work (IR receive)

My strange idea for this strange problem is esp chip needs more power if it loops more code like MQTT SUPPORT :) (Note that OpenMQTTGateway is smaller than Espurna / Tasmota )

@reaper7 cut the USB-GPIO4-5 connection and you will save your config

@mcspr
Copy link
Collaborator

mcspr commented Mar 2, 2019

Yeah, that is strange. One thing that comes to mind are recent weblog changes that could be more power-hungry. But there are not much weblog messages after config upload, so 🤷‍♂️

For comparison:
OpenMQTTGateway uses the same IR library, but version 2.5.5:
https://github.com/1technophile/OpenMQTTGateway/tree/development/lib/IRremoteESP8266
And there's the same flavour of MQTT PubSubClient in ESPurna, by adding #define MQTT_USE_ASYNC 0 and setting MQTT_MAX_PACKET_SIZE to 1024 in PubSubClient sources.

@reaper7
Copy link
Contributor

reaper7 commented Mar 2, 2019

@mcspr - looks like you've solved my problem!
#define MQTT_USE_ASYNC 0
this is a solution for me 👍

now all my sonoff devices saves changes :)

schowek01

@mcspr
Copy link
Collaborator

mcspr commented Mar 2, 2019

Ok, assuming MQTT client is at fault then. Probably related to the #1115
Possible requirements to reproduce:

  • set mqtt server in the headers and enable it by default (mqtt should be connected)
  • do not have any settings related to mqtt in the eeprom
  • push save in the web or run this via web debugging tools console:
> websock.send('{"config": {"mqttEnabled": 1, "mqttServer": "...server address..."}}')

I don't see any crashes though.

@reaper7 what mqtt server are you using?

@reaper7
Copy link
Contributor

reaper7 commented Mar 3, 2019

@mcspr - mosquitto 1.4.10-3 (with user/pass!!!) on rpi

@mcspr
Copy link
Collaborator

mcspr commented Mar 4, 2019

Well, turns out it is not about the server. #1115 (comment) already described the solution for the mqtt client codebase. pr for async-mqtt-client is still hanging there.

The culprit is lwip's tcp_output, which does not check if connection is closed. While inside websocket callback, mqttReset() does immediately disconnect leaving connection object NULL and causing the crash. Ofcourse, doing the exact same thing inside loop() + yield() right after is a possible workaround (while making things somewhat slower...)

Also note, that this only affects git version. Release version of async-mqtt-client is still ok, and is being used by the platformio builds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants