@title  Wireless Trilateration
@author Gregory Parsons
CSC714 Real Time Computer Systems
Fall, 2005, North Carolina State University

Description of the Network Construction Prosses:
  Each Mote has a unique ID stored in 'MoteID' which was derived during the network construction phase. 

  Each Mote waits to hear the previous ID accross the WiFi channel until broadcasting its own packet on the 
    channel. This technique is very similar to a token ring network. 
  Mote 0 is Base Station #1 and is hooked to the USB port of a PC.
  The first step is to send a code to the USB port of the soon to be Mote 0, in order to set the Motes ID to 0. 
  Secondly, each additional network mote is power or reset in sequence, waiting a second for it to be added to 
    the network and turn on its blue LED before activating the next Mote. 
  Thirdly, a command is sent from the PC to end the construction phase. 

Packet Byte Descriptions:
  [0]  Sender MoteID
  [1]  Highest MoteID Received
  [2]  Cycle
  [3]  UART
  [4]  0x0a; network access code
  [5]  
  [6]  
  [7]  
  [8]  Close Network command
  [9]  Error if not zero
  [10] reading from Node 0
  [11] reading from Node 1
  [12] reading from Node 2
  [13] reading from Node 3
  [14] reading from Node 4
  [15] reading from Node 5
  [16] reading from Node 6
  [17] reading from Node 7
  [18] reading from Node 8
  [19] reading from Node 9
  [20] reading from Node 10



MoteID state magic values:
   0 - Master Node
  99 - Halted Node
  -1 - Waiting

Error Codes:
01 - Identical Mote ID received


Java Execution:
  javac testRCV.java
  MOTECOM=serial@/dev/ttyS5:telos java testRCV

  At this point, the application is running, although it may not yet be communication with the 
  attached mote. If nothing happens upon execution, and the mote is already attached, 
  then go ahead and issue the command to start the network construction phase by pressing
  's' and then 'Enter' on the keyboard. 

Telos Mote Execution:
  After extracting the code, go to the "rcv" directory and enter the following command
  to compile the TinyOS code:
    make telos
  Next, enter the following command to load the code onto all the motes that will be used
  in the network:
    msp430-bsl --telosb -c /dev/ttyUSB0 -r -e -I -p build/telosb/main.ihex


Issuing Commands:
  To issue a command, simply enter the key associated with the command sought and then press 'Enter'
  If a command has caused the computer to send a message to the attached mote, a message will appear 
  saying what command was issued. Otherwise, no notification will be given. 
 
Commands:
  's' - start network, inits USB attached Mote to MoteID 0
  'h' - halts network, sets all motes into halted state

  // The following commands change the display mode
  '1' - print the raw packet data
  '2' - print the averaged packet data matrix
  '3' - print the averaged/negated data matrix
  '4' - print the calculated channel distance matrix
  '5' - print the derived relative mote positions (? denotes an impossible answer)
  '6' - print the derived relative mote positions only if the answer is possible
 
 