Research Article

A-LNT: A Wireless Sensor Network Platform for Low-Power Real-Time Voice Communications

Algorithm 2

(1)     Set address = 0xFF
(2)    Set RF channel = CHANNEL0
(2)      while (1)
(3)      Set counter = 0;
(4)      Listen to radio channel for 100 ms
(5)      if RF packet received
(6)         Calculate system time
(7)      Set system parameter;
(8)      while (counter < CMAX)
(9)        Send APPLY(CNODE)
(10)      while ( < TTIMEOUT)
(11)        Listen to radio channel
(12)        if ACK_APL received
(13)           break;
(14)        else if DENY received
(15)           break;
(16)      if ( TTIMEOUT)
(17)       counter++;
(18)      else if DENY received
(19)      RF channel = unavailable;
(20)      break;
(21)      else if ACK_APL received
(22)       counter = 0;
(23)      While ( counter < MAX)
(24)         Synchronize clock;
(25)         Change address to new address
(26)         Send JOIN(CNODE) at assigned time slot
(27)         while ( < TTIMEOUT)
(28)         Listen to radio channel
(29)         if ACP_JOIN received
(30)            break;
(31)          else if ACK_JOIN received
(32)            Synchronize clock;
(33)            Send JOIN(CNODE) at assigned time slot
(34)         if (network joined)
(35)         Break;
(36)         if ( TTIMEOUT)
(37)          counter++;
(38)   if (network joined)
(39)       Update system parameters;
(40)       break;
(41)    else if (RF channel is unavailable)
(42)    If RF channel == MAX_RF_CHANNEL
(43)      Halt application.
(44)    else
(45)      RF channel++;
(46)      continue;
(47) while (1)
(48)      Sleep;
(49)     Wake up for RF packet receiving or system event
(50)     if time == T_ACK_POLL // time for sending ack-synchronization      
(51)       if data needs to be sent
(52)     Send ACK_POLL_DATA(CNODE);
(53)    else
(54)     Send ACK_POLL (CNODE);
(55)     else if received RF packet
(56)      Unpack the packet, extract source address NODEA;
(57)      if packet type == POLL
(58)       Synchronize clock;
(59)       TOUT_NODE = 0; //clear timeout counter of the node
(60)      else if packet type == DATA_REVED
(61)          Clear sent data information;
(62)      else if packet type == QueryP2P // voice communication inquiry
(63)          …; // more voice communication details please browse the appendix.
(64)    else if packet type == audio data
(65)         Packet processing; // please browse the appendix.
(66)    else if KEY pressed
(67)          Response to KEY press;
(68)    else if time == T_CHECK_NODE // CNODE status
(69)          If TOUT_NODE > TOUTMAX
(70)           reset application;
(71)     else…
(72)         …;