Atmel AVR2070 Manual De Usuario

Descargar
Página de 93
 
50 
AVR2070 
8240B-AVR-06/09 
The flowchart shown in Figure B-5 shows how the RUM protocol routes packets.  
Most of this processing occurs in the macRouteData() function. The flowchart shows 
that just a few simple rules are needed to route packets to their destination. 
B.2 RUM API 
An application talks to the MAC by using a few function calls in the MAC, and the 
MAC communicates events back to the application by calling pre-defined callback 
functions. The relevant MAC functions and the callback functions are listed in the 
header file system.h. 
B.2.1 Coordinator commands 
•  macFindClearChannel() is called on startup. The new coordinator node 
finds a clear channel by doing an energy scan and finding the quietest 
channel. Alternatively, a pre-defined channel can be set in PAN_CHANNEL. 
•  appClearChanFound() is called when the scan is complete. The coordinator 
chooses a channel and PAN ID by calling macStartCoord(), and is then 
ready for operation. 
When the coordinator receives a beacon request, it calls sendBeaconFrame(), which 
sends a beacon back to the requester. 
When the coordinator receives an association request, it calls 
macAssociationResponse(), which stores the new node's information in the 
coordinator's network table, and issues an association response frame. 
B.2.2 Router and end node commands 
On the router/end node side, several functions are called in sequence associate to 
the network. The timing of these calls are regulated by the MAC's timer module, by 
making calls to macSetAlarm(). 
•  macInit() is called to initialize the radio and the MAC. 
•  macScan() is then called to search for a network to join. This causes the 
node to send out beacon request nodes on every channel, and to record the 
beacons it gets back. The best node is chosen. 
•  appScanConfirm() is called when the scan is complete. If the scan was 
successful, then appScanConfirm calls appAssociate, which in turn calls ... 
•  macAssociate() - this sends an association request to the coordinator 
(sometimes via intermediate nodes), and processes an association response 
packet with ... 
•  appAssociateConfirm() is called when the node either associates 
successfully, or times out waiting to associate. 
•  After the nodes have associated the macConfig.associated flag is set to true 
and, all nodes communicate using the same functions: 
•  macDataRequest() is called by the sending node, or macPing() is called to 
ping another node. The MAC calls back to either appPacketSendSucceed() 
or appPacketSendFailed(). 
•  macDataIndication() is called by the MAC if a packet is received that is 
addressed to this node.