ZMAC: Makes an Arduino Library from the Atmel 802.15.4 MAC distribution
Atmel produces an IEEE 802.15.4 MAC layer for its radios, which works great on Zigduino. Unfortunately, it will not work in the Arduino IDE. We cannot modify it and redistribute it, due to the license.
Here's how we solve this. You download the MAC distribution yourself, sign up with Atmel, agree to the license, etc. Then you get ZMAC, and run the fileprep script. This will copy and modify the files as needed to organize them so the Arduino library can pick them up. It will even translate some of the examples into a form that will load and compile and run using the Arduino IDE.
Make sure you have these all in place, or this libary won't do you much good.
- Zigduino hardware.
- Arduino environment. Obviously, you'll need Arduino. This has been tested with 1.0.1.
- Zigduino modifications to Arduino environment. Make sure this is all set up properly, and you can upload the 'Blink' sketch successfully.
- Atmel's IEEE 802.15.4 MAC distribution. This has been tested with 2.8.0.
- Unpack this distribution where you put your Arduino libaries, e.g. C:\users\me\Documents\Arduino\libraries\ZMAC
- Download and install gawk
- Edit fileprep.cmd on Windows or fileprep.sh on Mac or Linux...
- ...Update the MAC_INSTALL variable to where you installed the MAC, typically "C:\Atmel\MAC_v_2_8_0"
- ...Update the GAWK variable to the location of the gawk binary, typically "C:\Program Files\GnuWin32\bin\gawk.exe"
- Open a command window, cd to the ZMAC directory
- Type "fileprep.cmd" on Windows or "./fileprep.sh" on Mac or Linux
- Exit Arduino
- Start Arduino
- Select Tools > Board > Zigduino
- Select File > Examples > ZMAC > Star_NoBeacon
How you know it's working
To test the Star_NoBeacon example...
- Upload it to two Zigduinos.
- Only power up one of them. This will become the coordinator. Leave the other one off.
- The first unit will search for a network (fast blinking red light), then give up and create its own (solid red light).
- Then power on the second unit. This will become the end device.
- The second unit will search for the first one (fast blinking red light), and then find it.
- They will then transmit data every few seconds, indicated by a slow blinking red light, in sync between the two units.
Now the fun is just beginning
This MAC library is not particularly easy to use for beginners. It expects a crisp understanding of the principles of the IEEE 802.15.4 MAC design. There are two things to study to help understanding this:
- 802.15.4 guides and documentation. Try This Whitepaper, and anything else you can find searching the web.
- The user guide in the Atmel MAC. Read through the Doc/User_Guide/AVR2025_User_Guide.pdf. This is a dense guide chock full of stuff you need to know. Start with Chapter 9, which explains the sample applications in great detail.
- Dig through the Star_Nobeacon example code. I recommend putting in "printf" debugging statements everywhere so you can keep track of what's going on.
A better solution
The next logical step to this is to create a library that's easier to use for mainstream Arduino users (e.g. beginners) that presents a higher-level layer to the user. Currently the app is expected to handle much of the details of scanning and association. This could all be pulled into the higher-level library.
This hypothetical library should enable all the functionality covered in Robert Faludi's excellent Wireless Sensor Networks book.