TinyOS/nesC tip: ActiveMessage

Just a quick note for those who are looking on the web for the reason that their nesC code is not working:

calling AMSend.setSource( *amsg,  addr) may change the source address locally, but when you are sending the packet it will be reset to ActiveMessageAddressC$addr.

After almost two days of wondering why I couldn’t forge messages on a base station, a friend more familiar with TinyOS gave me this warning. I couldn’t find it on the web, so .. here it is!

One other note: if you are using a bash script to do the TOS_NODE_ID assignment for you, you should call tos-set-symbol with ActiveMessageAddressC__addr. Using $ would -obviously- cause bash to consider it a variable and replace it with empty string.