Setting IP, Gateway, and Netmask

Top  Previous  Next

The Wi-Fi is a separate network interface and so it has its own IP address, which is set using the wln.ip property. This address is different from the IP address of the Ethernet interface (see net.ip). We noticed that many people find it "unusual" that Tibbo hardware device would turn out to have two IP addresses. In fact, this is completely normal. On the PC, every network interface has the IP of its own as well.

Technically speaking, IP address configuration can be done at any time. This topic has been placed into this section to remind you that the IP of the wln. object has to be set, if not right after the boot, then at some later point. If your application uses a static IP, then setting it in the boot section of your code is a good idea. If the application obtains the IP address through DHCP, then the IP can only be set after communicating with the DHCP server, and this will only be possible after successful association. You may even need to set the IP address repeatedly if your product switches between different networks (access points).

There are also wln.gatewayip and wln.netmask properties that may need to be set along with the IP address. This is optional and is only required if your device will have to establish outgoing connections to the network hosts outside of your LAN.

Note that IP, gateway IP, and netmask of the Wi-Fi interface can't be set when there is at least one open socket in your system (sock.statesimple<> 0- PL_SSTS_CLOSED)  that operates on the Wi-Fi interface (sock.currentinterface= 2- PL_SOCK_INTERFACE_WLN).



A very useful DHCP library can handle IP, gateway IP, and netmask configuration both for the Ethernet (net.) and Wi-Fi (wln.) interfaces of your device. Use it and save yourself a ton of work!