Setting MAC Address

Top  Previous  Next

Your application is responsible for setting the MAC address for the Wi-Fi port. The wln.mac property exists for this purpose. This is different from the net object, which controls the Ethernet port of the device. The Ethernet MAC address is pre-assigned during the production of Tibbo, so the net.mac property is read-only. The MAC is stored in the EEPROM memory. Each Tibbo device must have a preexisting Ethernet MAC address because this is required for finding this device on the Ethernet network and communicating with it from the TIDE software. Without the Ethernet MAC you wouldn't be able to start working with Tibbo devices!

For the Wi-Fi interface, you have a complete freedom in setting you own MAC. Correct MAC address consists of 6 bytes of data. The wln.mac property is of string type, and the MAC address data is presented in the dot-delimited format, like this:

 

 

'set the mac address

wln.mac="0.1.2.3.100.200" 'notice that the values are in decimal representation

 

 

The MAC address can be either "globally unique" or "locally administered". There is also a provision for "unicast" and "multicast" addressing. You can find more information on this here: http://en.wikipedia.org/wiki/Mac_address.

Your organization can either purchase a block of globaly unique addresses, or choose to assign random locally administered addresses. In the latter case, set the most significant byte of the address to 2, and choose random values for the remaining 5 bytes (random function will help). Note that each device you are using should have a unique MAC address. It is a good idea to generate the MAC once, and store it in the EEPROM memory (see the stor object). The MAC can then be retrieved on each boot and written into the wln.mac property.

Note that the MAC address of the Wi-Fi interface can't be set when the hardware is already booted, and when there is at least one open socket in your system (sock.statesimple<> 0- PL_SSTS_CLOSED for any socket).