The use of the ESP8266 in the world of IoT

User avatar
By Middelbh
#7305 Hi!
Had the same question, solved it in my wireless router TP-Link... There you can relate MAC address to IP address..

Hans
User avatar
By sej7278
#7306
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
User avatar
By mharizanov
#7535 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);