Re: Static IP
Posted:
Wed Jan 14, 2015 2:00 pm
by Middelbh
Hi!
Had the same question, solved it in my wireless router TP-Link... There you can relate MAC address to IP address..
Hans
Re: Static IP
Posted:
Wed Jan 14, 2015 2:18 pm
by sej7278
Middelbh wrote:Hi!
Had the same question, solved it in my wireless router TP-Link... There you can relate MAC address to IP address..
Hans
that's not static ip, that's static dynamic, there is a way to do static, looks like something along the lines of:
Code: Select allwifi.sta.setip("ip", "netmask", "gateway")
e.g.
wifi.sta.setip("10.0.0.2", "255.255.255.0", "10.0.0.1")
for nodemcu anyway, see:
https://github.com/nodemcu/nodemcu-firm ... ifi.c#L229
Re: Static IP
Posted:
Sat Jan 17, 2015 2:14 pm
by mharizanov
I use something like this, you need to change the code accordingly
Code: Select allstruct station_config stationConf;
struct ip_info info;
wifi_station_set_auto_connect(FALSE);
os_memset(&stationConf, 0, sizeof(struct station_config));
os_sprintf((char *)stationConf.ssid, "%s", sysCfg.sta_ssid);
os_sprintf((char *)stationConf.password, "%s", sysCfg.sta_pass);
ip = sysCfg.sta_ip;
mask = sysCfg.sta_mask;
gw = sysCfg.sta_gw;
if (ip)
info.ip.addr = ipaddr_addr(ip);
if (mask)
info.netmask.addr = ipaddr_addr(mask);
if (gw)
info.gw.addr = ipaddr_addr(gw);
wifi_set_ip_info(STATION_IF, &info);
wifi_station_set_config(&stationConf);