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

Version / Previous SSID and password #9

Open
elar-systems opened this issue Oct 12, 2016 · 8 comments
Open

Version / Previous SSID and password #9

elar-systems opened this issue Oct 12, 2016 · 8 comments
Assignees
Milestone

Comments

@elar-systems
Copy link

elar-systems commented Oct 12, 2016

Hello,
I really like your development it helped a lot and I really am happy that I could find your codes as it helps a lot.
However, I have confusion about versions!
I could not compile version 2.0 as it needs 'css.h' and 'password.h' files which are missing!
However, the version 1.1 is compiling and working fine.
Now my question is that, why you said , in front page, that the version 0.6 is the current development one?
What version should I use to have the latest stable codes?

Also, i see you already now about this bug "Previous SSID and password still remains in memory even after factory reset".
Have you found any solution for that yet?

Thanks again...

By the way, I am using your codes on "Wemos D1 Mini Pro" and except the existing bug it works fantastic.

And, PLEASE: do not stop working on this great project. I can help if you want to improve it...

@lovelesh
Copy link
Member

lovelesh commented Oct 12, 2016

Hi,
Thanks for using my project. It really helps me as I hear from you guys that the code is working great.
You are right: V2.0 is sitll in development as I wanted to use some CSS for look and feel, but then I thought an android App is even better. So I am working on it.

All versions from v0.6 to v1.1 will work with different features. In v1.1 you will get all the features.
If you can open wireshark you will notice a broadcast packet on port 5000 every 15 seconds. this can be used to as heartbeat packet for gateways.
Also whenever you change the status of plug, a notification broadcast is sent on 5002 port. This can be listened by other devices to understand status changes happening on remote devices.

I have tested on NodeMCU and my custom built hardware to control sockets
20161012_113752
20161012_113810

Also, i see you already now about this bug "Previous SSID and password still remains in memory even after factory reset"

I still havent found any working solution, but you can use EEPROM erase code in arduino and burn the code again.

I will contact you if I need you help. And do keep sending me you feedback. Its valuable to me.

@lovelesh lovelesh self-assigned this Oct 12, 2016
@sghazagh
Copy link

sghazagh commented Oct 12, 2016

Hi Lovelesh,
Thanks for your reply,
I am using the code now and I'm really happy that I found it.

I have added another feature can be called by /config.
Then you can enter IP,Subnet and Gateway and these will be saved to eeprom from address 150.
at the time of start(reboot), I have added another function to check the IP,Subnet and Gateway.
Then connect to wifi_sta with set IP,Subnet and Gateway addresses.

If the network changes. and you go to AP mode to join the new network, the addresses will be cleared when you set new SSID to join the new network and get the IP from DHCP.
You can then again set the desired IP,Subnet and Gateway to specific ones in /config page.

That is actually very handy as you can change the IP address of the device through config page to whatever you need.
I use my devices to be controlled over the Internet from Android app which I have implemented. So having the static IP to forward the port to my device web server is a requirement.

I can share the code with you if you like to add it to the project.

I have tested and I am using that on "Wemos D1 mini Pro" and it works great.

@sghazagh
Copy link

With regard to Android app, I have created an app that can send the URL through Internet to my device and reads the respond to update the status of buttons.
With this way,you can send whatever command which you like to your web server and control your device through Android app , similar way you can control over the web.

here is a snapshot of my app.
I also have added a sensor to read room Temperature and Humidity and show on my app everywhere I am, even out of the home...

screenshot_20161013-072429

@lovelesh
Copy link
Member

That's GREAT.

How are you solving the problem of addressing a device behind NAT? I am facing similar issues and I have to use a cloud server. I am looking for an approach that skips this cloud server.

@sghazagh
Copy link

sghazagh commented Oct 13, 2016

That's actually is simple and you do not need Cloud Server at all.
You need to open a port on your router to point to your device IP and port.
That's why we normally need to set the static IP for our devices.

Suppose your device has address 192.168.1.20 and the web server is running on port 8080 (do not set port 80 as default on devise web server, 80 is common for http and you really do not need that port)

And also imagine your outside IP address is "123.123.123.123".
And if you do not have static IP address, then you have to use some services like "dyndns".

anyway, you need a link like:
http://123.123.123.123:8080/plug/on
or
http://lovelesh.dyndns.com:8080/plug/on (sample)

to use outside of your home to access the web server on your device. Same concept on Android app.
You will send the URL request to above addresses from your Android app.
(I am using Google Volley Library for transmitting network request... it's quite extensive and works great )

Then the request first comes to your router and your router forwards the request to port 8080 of your deceive with IP address 192.168.1.20 (or whatever port you want to set internally for your device) .

If your router has the loopback capability, which most of the recent router does, you also can use the external IP address/dyndns address to use within your LAN too.

Hope it helps...

@elar-systems
Copy link
Author

elar-systems commented Oct 13, 2016

I think I have found the issue for memorizing the SSID and Password after factory reset.
I read somewhere that the ESP8266, keeps the wifi connection.
To reset and erase the connection info, we have to do this:

On setup() section, place these statements as the first executed in setup();

WiFi.persistent(false); // Do not memorize new connections
ESP.flashEraseSector(0x3fe); // Erase remembered connection info. (Only do this once).

I haven't tried it yet but will do when I get home and can work on it...

@elar-systems
Copy link
Author

elar-systems commented Oct 13, 2016

Hi, Lovelesh,
I can confirm that the SSID and Password is written in segment 0x3fe000 and after /factoryreset the data still is there.
You can dump the data on that address and have a look in HEX editor yourself.
here is the command you can dump the data on that address by "esptools.py":
esptool.py -p COM3 read_flash 0x3fe000 512 d:\flashdump.bin

Obviously you have to adjust the port number.

So, you have to find the way to clear this segment and implement that in your code.
I believe the bellow code should works but you have to manage to run the 'ESP.flashEraseSector(0x3fe);" part of that once and at /factoryreset time.
Perhaps a flag can trig it:

place these statements as the first executed in setup():
---------------------------------------------------------
WiFi.persistent(false); // Do not memorize new connections
ESP.flashEraseSector(0x3fe); // Erase remembered connection info. (Only do this once).

Hope we see you fixed that in next release.

@lovelesh
Copy link
Member

@elar-systems this is a very nice idea.
Make shift solution could be to use these APIs in factory reset section of the code.
I will try it out and update the code

@lovelesh lovelesh added this to the releasev1.0 milestone Oct 14, 2016
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

3 participants