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

Consider implementing WiFiManager for runtime configuration #2

Open
cosmocracy opened this issue Dec 20, 2016 · 39 comments
Open

Consider implementing WiFiManager for runtime configuration #2

cosmocracy opened this issue Dec 20, 2016 · 39 comments

Comments

@cosmocracy
Copy link

cosmocracy commented Dec 20, 2016

The WiFiManager project provides the ability to dynamically configure an ESP8266, including wifi SSID/credentials. WiFiManager also supports additional arbitrary config parameters which seems ideal for capturing the Alexa names associated with each of the relays. This would make the image more useful to end-users as it would not require changes to the .INO (and the entire Arduino IDE) just to configure a LinkNodeR4 once it has the initial image.

@cosmocracy
Copy link
Author

I would be happy to investigate this if you would like.

@joeman2116
Copy link

An excellent Idea!

I have several esp8266 and nodelink r4 using the Alexa echo Dot. - works well

The multiple wemos emulation code works great but hard coding the ssid, pw and device names makes it difficult to install at other locations etc.

@cosmocracy
Copy link
Author

I've been doing some work on this in a forked repo. Worked nicely in some of my testing. Once I get it fully ironed out I'll send you a PR for your consideration, @CharlesJGantt. Thanks for this great project!
See https://github.com/cosmocracy/LinkNode-R4-Controlled-By-Amazon-Alexa

@joeman2116
Copy link

Had a quick look at the code.
The new configuration controls look very interesting. Can hardly wait to test on a spare linknode R4

Thanks for your work and sharing it to those of who are not so talented.

Joe

Canada

@cosmocracy
Copy link
Author

Glad you liked it, @joeman2116. I'll probably do a little refactoring of the code to reduce duplication--less code to test and less to go wrong ;-) before the PR to @CharlesJGantt.

@joeman2116
Copy link

cosmocracy

Compiled your new test code and it uploaded fine.
Looking at serial monitor:
Jumper set for boot - will attempt autoconnect, else config portal
mounting FS...
mounted file system
reading config file
opened config file
{"alexa_name1":"","alexa_name2":"","alexa_name3":"","alexa_name4":""}
parsed json
*WM: Adding parameter
*WM: alexa_name1
*WM: Adding parameter
*WM: alexa_name2
*WM: Adding parameter
*WM: alexa_name3
*WM: Adding parameter
*WM: alexa_name4
*WM:
*WM: AutoConnect
*WM: Connecting as wifi client...
*WM: Already connected. Bailing out.
*WM: IP Address:
*WM: 192.168.1.127
connected...yeey :)
SSID: ASUS66ujoe
Local IP: 192.168.1.127
Begin multicast ..
Udp multicast server started at 239.255.255.250:1900
WebServer started on port:
96
WebServer started on port:
97
WebServer started on port:
98
WebServer started on port:
99
Adding switches upnp broadcast responder
Adding switch : index : 0
Adding switch : index : 1
Adding switch : index : 2
Adding switch : index : 3

All looks perfect up to here -----------------------------Then udp errors------

UDP packet encountered, size: 391Found 'M-SEARCH' in request
::UDP packet encountered, size: 391Found 'M-SEARCH' in request
::UDP packet encountered, size: 391Found 'M-SEARCH' in request
:::UDP packet encountered, size: 444Found 'M-SEARCH' in request
::UDP packet encountered, size: 446Found 'M-SEARCH' in request

Basic udp error repeats over and over

Joe

@joeman2116
Copy link

I changed the ports as the original were in use.....

@cosmocracy
Copy link
Author

@joeman2116, are those errors or just the logging I added when the device sees UDP multicasts? I was having trouble with autodiscovery at one point so I added the logging. I should probably either remove it or add some logging level setting. All worked ok though, right?

@joeman2116
Copy link

I think they are just info but they wipe out the serial monitor because of repetition.

When i tell alexa to discover devices

Got UDP Belkin Request..

Sending response to 192.168.1.128
Port : 50000
Response sent !

Sending response to 192.168.1.128
Port : 50000
Response sent !

Sending response to 192.168.1.128
Port : 50000
Response sent !

Sending response to 192.168.1.128
Port : 50000
Response sent !
---------------------------------------------------------looks good
then i get:

ending :urn:Belkin:device:controllee:1Belkin International Inc.Emulated Socket3.1415uuid:Socket-1_0-38323636-4558-4dda-9188-cda0e6d0fca5-72221517K01017690urn:Belkin:service:basicevent:1urn:Belkin:serviceId:basicevent1/upnp/control/basicevent1/upnp/event/basicevent1/eventservice.xml

########## Responding to setup.xml ... ########

I get 4 of the above

Are there default alexa device names? I looked at alexa after discover devices but did not see any new names Alexa name 1 etc

How to i get to the config to change the device names , ssid etc

I tried connecting to 192.168.1.4 - but no responses when connected to module
also tried 192.168.1.127 on my pc (the ip shown on serial monitor - no response.

Must be me......

Joe

@cosmocracy
Copy link
Author

@joeman2116, pull the boot/flash jumper and put it in the flash position (even though you're not flashing). Then restart the LinkNode and it should start in "configuration" mode (with a new wifi AP called EchoBase-something. If you associate with and access the wifi config there will be four parameter slots at the bottom of the page where you can specify names. After you save those, put the jumper back to the boot position and restart the LinkNode. (Also, those XML snippets you're seeing are just from the autodiscovery probes that Alexa (or other UPnP clients) are sending).

@cosmocracy
Copy link
Author

I think we can tighten down the logging so there will be an "info" level vs. "debug" so your console won't be overwhelmed with output when you're not in need of so much detail.

@joeman2116
Copy link

joeman2116 commented Dec 26, 2016 via email

@cosmocracy
Copy link
Author

I'll have to scrutinize the WiFiManager code to see how long the AP stays up. I've had to retry scanning/connecting multiple times--this may be a wifi/channel issue. Try a restart?

@cosmocracy
Copy link
Author

I'll troubleshoot more this week and make sure my code isn't the problem :)

@joeman2116
Copy link

cosmocracy,

Did a clean bin file on flash, then reflash with your code
EchoBase1 appeared as AP
I then selected my ssid and assigned 4 device names
Did a discover and all are seen and work fine off and on.

The issue now is I want to change info
So i put jumper in flash mode
reset power
Did wifi search for the EchoBase ap but no go.
tried other devices but they and router do not see the Echobase AP

As a test again - i cleaned the module, did a reflash and echobase appeared.

It appears once config settings are done... I cannot get the Config EchoBase AP back.

Looking very close......

Thanks.....

Joe

@cosmocracy
Copy link
Author

Excellent testing--thank you for documenting this scenario I think it will help me debug.

@joeman2116
Copy link

joeman2116 commented Dec 29, 2016 via email

@cosmocracy
Copy link
Author

@joeman2116 Interesting. Did you happen to have the WifiManager-enabled Linknode hooked up to a serial monitor to see if there was anything being logged? I really wish there were a couple spare pins exposed on the Linknode so we could hook up either a small LCD display or at least a "heartbeat LED". Hmmm.

@joeman2116
Copy link

joeman2116 commented Dec 30, 2016 via email

@cosmocracy
Copy link
Author

@joeman2116 Getting back to this now. Any word how your serial-monitored experiment is going? Thanks!

@joeman2116
Copy link

joeman2116 commented Dec 31, 2016 via email

@cosmocracy
Copy link
Author

cosmocracy commented Dec 31, 2016

Ok, I'm about to commit a version with more logging statements. That might help pinpoint things. Thanks for your continued help from Up North, @joeman2116 :-)

@cosmocracy
Copy link
Author

cosmocracy commented Dec 31, 2016

@joeman2116 Wondering if the problem is the underling WiFi library for the ESP8266. Looks like there is an issue being investigated with the most recent version: esp8266/Arduino#2186

In particular see this comment: esp8266/Arduino#2186 (comment)

@joeman2116
Copy link

joeman2116 commented Dec 31, 2016 via email

cosmocracy added a commit to cosmocracy/LinkNode-R4-Controlled-By-Amazon-Alexa that referenced this issue Dec 31, 2016
Added additional logging during startup and [re]connection. Working
toward implementation of issue CharlesJGantt#2
@cosmocracy
Copy link
Author

@joeman2116 New commit 3bdaf05 in my repo that adds more logging and some additional reconnection tweaks. Give it a go when you have a moment? (I have a LinkNode running it now and will see what the serial logging shows)

@cosmocracy
Copy link
Author

@CharlesJGantt Would you consider adding me to the project? I'd be interested in spinning up an "add-wifi-manager" branch and moving my commits to this/your repo. Thanks!

@CharlesJGantt
Copy link
Owner

CharlesJGantt commented Dec 31, 2016 via email

@cosmocracy
Copy link
Author

@joeman2116 Another commit, 7b5f223, that adds further logging to help see what's going on. :-)

@joeman2116
Copy link

joeman2116 commented Jan 1, 2017 via email

@joeman2116
Copy link

joeman2116 commented Jan 1, 2017 via email

@joeman2116
Copy link

joeman2116 commented Jan 2, 2017 via email

@cosmocracy
Copy link
Author

@joeman2116 good work! I think we are closing in on this. I'll investigate adding more robustness to the reconnect handling.

@joeman2116
Copy link

joeman2116 commented Jan 2, 2017 via email

@cosmocracy
Copy link
Author

Hmmmm, good research. One short-term option would be to trigger a quick reboot/restart after X attempts connecting. But the better fix is to get the reconnect working.

On a related note, I have other ESP8266 projects--not using the LinkNode--that do periodically and spontaneously disconnect from wifi for 10-30sec at a time... but the code there reconnects fine. I'll see about porting some of that code to this project.

@joeman2116
Copy link

joeman2116 commented Jan 2, 2017 via email

@cosmocracy
Copy link
Author

@joeman2116 Good news. Commit e875783 implements some improvements to connection robustness. Specifically, when a disconnect occurs the reconnect attempt is done in a slightly different manner. In my testing--I rebooted my router--it reconnected after only a couple of attempts:

Disconnected while in loop(); Attempting reconnect to SEVERUS...
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
Failure to establish connection after 10sec. Will reattempt connection in 2 sec
Disconnected while in loop(); Attempting reconnect to SEVERUS...
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
Failure to establish connection after 10sec. Will reattempt connection in 2 sec
Disconnected while in loop(); Attempting reconnect to SEVERUS...
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Disconnected
WiFi status = Connected

@joeman2116
Copy link

joeman2116 commented Jan 3, 2017 via email

@joeman2116
Copy link

joeman2116 commented Jan 3, 2017 via email

@littledrumer
Copy link

After I upload the code to my Linknode R4 and switch it to normal run mode it continuously flashes the power LED on the Linknode and on the ESP8266 . I am getting this in the serial window.

ets Jan 8 2013,rst cause:1, boot mode:(3:7)

I have searched for an explanation and have only found that the function wdt_disable() is no longer working but I can't seem to find that function in the code anywhere. Any ideas as to what is wrong?

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

No branches or pull requests

4 participants