Setting MAC Address (Optional)

Top  Previous  Next

Every network interface needs its own MAC, and the Wi-Fi port is no exception. The wln.mac property exists for this purpose. Your Wi-Fi module already carries a MAC address onboard — it is preset during manufacturing, so you don't actually have to take care of the MAC. Leave the wln.mac at its default pre-boot value of "0.0.0.0.0.0", boot up the Wi-Fi interface (wln.boot), and the wln.mac will be updated with the pre-assigned address that is stored inside the Wi-Fi module.

You can use another MAC if you want, too. Set the desired MAC address before booting up the Wi-Fi, and this MAC will be used instead of the pre-assigned one. That is, if wln.mac is set to anything but "0.0.0.0.0.0" and then wln.boot is called, then "your" MAC will be used instead.

 

 

'set the mac address

wln.mac="0.1.2.3.100.200" 'override pre-assigned MAC with another address

...

romfile.open("ga1000fw.bin")

wln.boot(romfile.offset) 'the hardware will start using your MAC

 

 

The pre-assigned MAC inside the Wi-Fi module will not be altered. It is always there and can be called up by leaving the wln.mac at "all zeroes", then booting the Wi-Fi hardware.

 

A bit of info on MACs

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 purchase a block of globally 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 (wln.enabled= 1- YES).