hamishcunningham / fishy-wifi

Scripts, notes and the odd subaquatic gizmo for the ESP8266 and what-have-you.
GNU Affero General Public License v3.0
25 stars 13 forks source link

join me... give new IP #2

Closed sticilface closed 9 years ago

sticilface commented 9 years ago

Your script is great and it works which is far more than i managed to achieve with me own poor skills.

Got one request. Could it give you the IP that it receives,.. so that then you can address it?

I've tried lots of things... but nothing seems to work.. the following just gives null! and then fails to call the conn:on("sent", finish).

ip = wifi.sta.getip() tmr.delay(5000000)
print(ip)

How would you feel about calling some form of wifi watchdog that would start AP if there was no connection to wifi. Otherwise turn of AP mode for security reasons?

hamishcunningham commented 9 years ago

hi

sorry, I missed this one!

I think your getip() call is probably returning null because of timing issues -- i.e. the connection is still being established. this is a bit of a tricky thing to get right it seems -- we had similar problems getting mqtt to work, and Naomi ended up refactoring the code to use a callback style throughout...

so I'm not sure what to suggest in your case :-(

re. a watchdog, I think AP mode is not insecure if there's no listening server instantiated -- and not even then if the server doesn't implement anything potentially destructive. the problem with doing anything more sophisticated is lack of memory -- even the current simple stuff is sailing very close to the device limit. possibly nodemcu will evolve to use less RAM, or can be configured to leave out some libraries which might help, but currently it seems quite hard to do anything sophisticated :-(

hth, best

h