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

Reboot if KASA App is startet #1428

Open
werde45 opened this issue Dec 15, 2018 · 11 comments
Open

Reboot if KASA App is startet #1428

werde45 opened this issue Dec 15, 2018 · 11 comments

Comments

@werde45
Copy link

werde45 commented Dec 15, 2018

When i start the KASA App (https://www.tp-link.com/us/kasa-smart/kasa.html) in the same WLAN to setup my Powerswitch, all my espurna devices are offline. Powercycle is needed.

@mcspr
Copy link
Collaborator

mcspr commented Dec 15, 2018

Hey,
See esp8266/Arduino#4720

Sadly, just MDNS_SERVER_SUPPORT=0 does not cut it. mDNS is implicitly enabled when using Core's ArduinoOTA library, and no obvious way to disable it without manually editing it out / not using ArduinoOTA includes and startup code.

Future Core version 2.5.0 provides replacement mDNS library that fixes this.
(Wonder if it is compatible with the old ones. Have not tested it)

@davebuk
Copy link
Contributor

davebuk commented Oct 5, 2019

I think I have just run into this issue. I'm using the KASA app with one of their WiFi cameras. All of my various esp hardware devices (except one), all running espurna reboot when I'm switching the camera OFF/ON from the app. They crash due to Hardware Watchdog.

It's there something I can do or try to stop it happening? Is it the app or the camera causing the issue?

@mcspr
Copy link
Collaborator

mcspr commented Oct 5, 2019

@davebuk We can disable mDNS usage. -DMDNS_SERVER_SUPPORT=0 will disable our own entries, -DOTA_ARDUINOOTA_SUPPORT=0 will disable ArduinoOTA discovery.
edit: ArduinoOTA module is used by platformio -ota enviroments, so that functionality would be lost. mDNS library is part of the Core distribution, so using Core 2.5.2 (see platform = ... in the platformio.ini) also fixes this, but increases firmware size significantly if you need 1MB boards support

@davebuk
Copy link
Contributor

davebuk commented Oct 6, 2019

What size do the .bin files come to with 2.5.2 core? All my devices are 1MB boards. Is this the best fix? I guess I'd have to start using 2 step OTA updates if using the newer core?

I presume it's using the KASA app that causes the issue. Is there something they need to fix or is it the espurna mDNS implementation that is the main issue?

@mcspr
Copy link
Collaborator

mcspr commented Oct 6, 2019

There is a testing nodemcu-lolin-252 platform.io environment to track that. Default configuration bumps the size +61KB (62432 B)

espurna-1.13.6-dev.nightly20191001+gitbd385f9f-nodemcu-lolin-252.bin
528 KB (540912 B)
espurna-1.13.6-dev.nightly20191001+gitbd385f9f-nodemcu-lolin.bin
467 KB (478480 B)

mDNS implementation is the issue, see the referenced discussion at the esp8266/Arduino. Whenever esp8266 receives multicast packets from KASA app it stops working, so another practical solution is to isolate either one on a network level e.g. put them into a different subnets.

@davebuk
Copy link
Contributor

davebuk commented Oct 7, 2019

I think I'll look to go down the larger core route as I guess that's the way espurna is going.

I have managed to get a 2.5.2 core version on a test Sonof Basic. I'll see if that works before updating my other devices.

Can I build a very small version of espurna with the web interface for upgrading OTA, or does having .bin files over 500kB stop this. Could 1MB core with web access work?

@mcspr
Copy link
Collaborator

mcspr commented Oct 7, 2019

It could. Why I mentioned mDNS is because it adds up 40KB (yes), so disabling both ArduinoOTA and mDNS announces saves a lot. You can also strip terminal / telnet debug messages on top of that (~12...30KB)

@davebuk
Copy link
Contributor

davebuk commented Oct 8, 2019

Using the 1MB core and the following build defined, my .bin comes out at 382KB. I was then able to flash a 508KB, 2.5.2 core based normal image. I tend to use a custom build for my devices leaving out parts I do not use like Alexa, thingspeak and home assistant support.

I guess with a basic 382KB build I could then flash up to around 600KB as a second step, or does the file storage on the ESP limit the space to less than 600KB with 382KB already used?

#elif defined(ESPURNA_CORE)

    // This is a special device targeted to generate a light-weight binary image
    // meant to be able to do two-step-updates:
    // https://github.com/xoseperez/espurna/wiki/TwoStepUpdates

    // Info
    #define MANUFACTURER            "ESPRESSIF"
    #define DEVICE                  "ESPURNA_CORE"

    // Disable non-core modules
    #define ALEXA_SUPPORT           0
    #define API_SUPPORT             0
    #define BROKER_SUPPORT          0
    #define DOMOTICZ_SUPPORT        0
    #define DEBUG_SERIAL_SUPPORT    0
    #define DEBUG_TELNET_SUPPORT    0
    #define DEBUG_WEB_SUPPORT       0
    #define HOMEASSISTANT_SUPPORT   0
    #define I2C_SUPPORT             0
    #define MQTT_SUPPORT            0
    #define NTP_SUPPORT             0
    #define SCHEDULER_SUPPORT       0
    #define SENSOR_SUPPORT          0
    #define THINGSPEAK_SUPPORT      0
    #define WEB_SUPPORT             1

    // Extra light-weight image
    #define BUTTON_SUPPORT          0
    #define LED_SUPPORT             0
    #define MDNS_SERVER_SUPPORT     0
    #define TELNET_SUPPORT          0
    #define TERMINAL_SUPPORT        0

@davebuk
Copy link
Contributor

davebuk commented Oct 8, 2019

Can I define platform = ${common.arduino_core_2_5_2} in the custom.h file rather than putting it in the platformio.ini file?

@mcspr
Copy link
Collaborator

mcspr commented Oct 8, 2019

Yes, just subtract the available space with the base sketch size + 20KB - 16KB reserved by the SDK and 4KB by settings. Also see the output of info, I think it uses the method from Core classes to give the real available space (which knows about reserved space + is rounding the result to a nearest 4KB)

No, platform is a separate thing altogether. platform = ... setting controls which toolchain, Core version and uploader tool it will use to build the app.
But, you can use src_build_flags to add -Dkey=value / -Ddefinetoken instead of modifying the header.

I think we are getting really off-topic here... but it is probably a useful reference for someone searching for the KASA issue.

@davebuk
Copy link
Contributor

davebuk commented Oct 8, 2019

Yeah sorry, it was relevant to building with core 2.5.2 for the KASA issue but the OTA is a bit off topic. ;-) I have managed to flash a 528KB .bin after a 2.3.0 core version from the web GUI.

Just to update, all my sonoff basics, SWA1 WiFi switches and Teckin power monitoring switches are stable with the 2.5.2 core and the KASA app. Just need to get my TUYA dimmer updated.

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