(1) Set RF channel = CHANNEL0 |
(2) while (1) |
(3) Check RF channel |
(4) if RF channel is not available |
(5) If RF channel == MAX_RF_CHANNEL |
(6) Halt application. |
(7) else |
(8) RF channel +1; |
(9) continue; |
(10) else |
(11) break; |
(12) while (1) |
(13) Sleep; |
(14) Wake up for RF packet receiving or system event |
(15) if time == T_SENDING_SYNC // time for sending synchronization |
(16) Send POLL(ALL_NODES); |
(17) else if received RF packet |
(18) Unpack the packet, extract source address NODEA; |
(19) If packet type == ACK_POLL |
(20) if the node is synchronized |
(21) TOUT_NODE = 0; // clear timeout counter of the node |
(22) else if packet type == ACK_POLL_DATA |
(23) if the node is synchronized |
(24) TOUT_NODE = 0; |
(25) Send DATA_REVED(NODEA); |
(26) else if packet type == APPLY |
(27) if node-list is not full |
(28) Assign a node number; |
(29) Update node-list; |
(30) Send ACK_APL(NODEA); |
(31) else |
(32) Send DENY(NODEA); |
(33) else if packet type == JOIN |
(34) if node is synchronized |
(35) Update node-list; // node has joined the network by now. |
(36) Send ACP_JOIN(NODEA) |
(37) else |
(38) Send ACK_ JOIN (NODEA); |
(39) else if packet type == QueryPCP or QueryP2P // voice communication inquiry |
(40) extract distinct address NODEB |
(41) If free audio channel >0 |
(42) if (NODEB == CNODE) |
(43) Send ACPPCP(NODEA); |
(44) Start codec; |
(45) Allocate audio channel; |
(46) Start voice communication; |
(47) else if… // more voice communication details, please browse the appendix. |
(48) …; |
(49) else |
(50) Send DENY(NODEA); |
(51) else if packet type == Audio data |
(52) …Packet processing; // please browse the appendix. |
(53) else if KEY pressed |
(54) Response to KEY press; |
(55) else if time == T_CHECK_NODE // check nodes status |
(56) for each node in node-list |
(57) If TOUT_NODE > TOUTMAX |
(58) Delete the node; |
(59) else |
(60) …; |