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
Setting Static IP #863
Comments
Just an ESP8266, or an Espruino board connected to one? |
Just the ESP8266. I am using the NodeMCU dev board that is based on the ESP8266. |
I didn't think this was possible yet?
|
I'm not sure as I don't generally do too much ESP8266 work, but it seems like it isn't available - @tve? You might have some luck asking on Gitter? https://gitter.im/espruino/Espruino?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge |
@tscrip If this is in a home network you can archive the same thing by using the MAC address of the device and adding that to a dhcp reservation in your router, so it gets allocated the static address you want - still using dhcp - but getting a fixed address. |
Yup & yup. Someone "just" needs to implement the static IP piece and test it... |
@tve something like this ? add a function to jswrap_esp8266_network.c /*JSON{
*/ ....... coding ...... } use in Espruino:
|
IMO it'd be great to put 'index' in the setting object too (and if it's omitted and you're only in AP or Station mode, juse set the right IP automatically) - then it's the same as the other Espruino stuff |
sure - thanks for that hint |
That index stuff doesn't fit into the other Wifi methods at all. Unless you want to change everything around, it should be SetIP and SetAPIP... |
Sounds good to me! I'm not sure how the index stuff ever got included - perhaps it's related to NodeMCU or EspressIf's API? Either way it's not very user-friendly :) |
ok it is SetIP and SetAPIP - thanks for your comments. the index stuff is Espressif API ;-) |
@gfwilliams can you please assist, added a empty function to jswrap_esp8266_network.c and tried to compile .... got some errors I do not know how to fix. ` /*JSON{
Return
*/ JsVar *jswrap_ESP8266_wifi_setIP(JsVar *jsSettings, JsVar *jsCallback) { ` make
|
Put |
now - thanks - miss the wood for the trees ;-) |
ok - got three functions, first one is doing the work the other two are calling the worker. not sure about the unlocks, call back and parameters .... please assist.
|
running some tests and networkParseIPAddress() returns for incomplete ip4 strings a valid result "255.255.255" to "0.255.255.255" "192.168.194" to "0.192.168.194" Is this how networkParseIPAddress() should work ? checking the source code my answer is yes - hmm Is there a more strict version of networkParseIPAddress() ? |
@gfwilliams and @tve should Wifi.setIP look like WLAN.setIP - please assist. |
I don't think so - you could try and make it return a bool or something if the address wasn't correct?
I'm trying to move to using callbacks for this stuff, so what you have looks fine (especially if you don't error if there is no callback). In the case of just setting IP I guess on ESP8266 you might be able to get away without it, but on other devices you won't... and you will definitely have trouble if you go for having |
ok - changed coding and started testing |
@tve it is working, Wifi.getIP() shows the new value, but the ESP is not reachable on the ne IP. |
@MaBecker |
@tve with your hint for ping() the _setIP() and _setAPIP() is working - thanks. @wilberforce yes - now you can find it there |
Looks good.
Does this need to be static or can it be allocated on the stack? |
not sure, used the same style as ping |
Ok. The difference is that a static object is allocated space at link time, and always takes up that space. |
Will these new settings get preserved in a |
hm , I guess yes, but let me test |
@wilberforce: NO - the ip setting is not saved.
At the moment I have no use case where _setIP() or _setAPIP() is needed. |
Hi @tve can you please double check, this would be very helpful, because I am not sure about the JSON stuff and if this two function should return a boolean or not. Next step is to create a PR for this enhancement.
MaBecker@072dcac#diff-f388853956d7ecb9f108259d968da34a
|
Hi @gfwilliams added code to my fork and like to check the description How to create the http://www.espruino.com/Reference# page ? |
Just run |
Hi @gfwilliams how can I merge this commit into the Espruino/master ? |
Just done - if you made a branch that tracked the main Espruino repo, did |
Closing this with eabffa4 |
Can we |
This bug is the one for ESP8266 itself. Espruino WiFi doesn't do it yet, but I just filed a new one here with a workaround for it: espruino/EspruinoDocs#363 |
I have been looking through the code, but I currently do not see a way to set a static IP. All of the comments for static IP say this feature if for future development. Is that true?
I am currently using a ESP8266 if that makes any difference.
The text was updated successfully, but these errors were encountered: