InterpretSM
(On Main XBee PIC)
Init communication and I/O Pins
Pseudo Init State: Goto Searching Controller
SearchingController :
Frame Received: If handshake, store address, start 1 sec Timeout timer, Call ControllerFound(), goto InterpretingMsg state, post to TransmitXbeeSM
PostDirByte: send dir byte to Motor Pic
PostFlagByte: send flag byte to Motor Pic
BalloonPopped: Set zombie flag high
InterpretingMsg
Frame Received: If command from LUC that we connected to, send Speedbyte to Motor pic, post PostDirByte to current SM, Post to TransmitXbeeSM,
Attack or not depending on attack byte.
if command from Necromancer, form flag byte
start Timer for TransmitXbeeSM
PostDirByte: send dir byte to MotorPic, Post PostFlagByte
PostFlagByte: send Flag byte to MotorPic
BalloonPopped: set zombie flag, set speedbyte, dirbyte to 0, send speed byte to MotorPic, post SendDirByte to currentSM, set state to SearchingController
Call LookingForController()
Timeout: same as above except no change in zombie flag
End
Function: Controller Found()
Light the beacon
End
Function: Searching for Controller()
Switch off the beacon
End