Maniacbug's RF24 arduino library ported to mbed. Tested, it works for Nucleo F411

Dependents:   RF24Network_Send RF24Network_Receive maple_chotobot_rf_motores Thesis_Verzender ... more

Committer:
akashvibhute
Date:
Mon Jul 06 05:11:06 2015 +0000
Revision:
0:c3db0798d9aa
Child:
2:a5f8e04bd02b
working RF24Network maniacbug library; tested on nucleo f411

Who changed what in which revision?

UserRevisionLine numberNew contents of line
akashvibhute 0:c3db0798d9aa 1 /*
akashvibhute 0:c3db0798d9aa 2 Copyright (C) 2011 James Coliz, Jr. <maniacbug@ymail.com>
akashvibhute 0:c3db0798d9aa 3
akashvibhute 0:c3db0798d9aa 4 This program is free software; you can redistribute it and/or
akashvibhute 0:c3db0798d9aa 5 modify it under the terms of the GNU General Public License
akashvibhute 0:c3db0798d9aa 6 version 2 as published by the Free Software Foundation.
akashvibhute 0:c3db0798d9aa 7 */
akashvibhute 0:c3db0798d9aa 8
akashvibhute 0:c3db0798d9aa 9 #ifndef __RF24NETWORK_H__
akashvibhute 0:c3db0798d9aa 10 #define __RF24NETWORK_H__
akashvibhute 0:c3db0798d9aa 11
akashvibhute 0:c3db0798d9aa 12 /**
akashvibhute 0:c3db0798d9aa 13 * @file RF24Network.h
akashvibhute 0:c3db0798d9aa 14 *
akashvibhute 0:c3db0798d9aa 15 * Class declaration for RF24Network
akashvibhute 0:c3db0798d9aa 16 */
akashvibhute 0:c3db0798d9aa 17
akashvibhute 0:c3db0798d9aa 18 #include <stddef.h>
akashvibhute 0:c3db0798d9aa 19 #include <stdint.h>
akashvibhute 0:c3db0798d9aa 20
akashvibhute 0:c3db0798d9aa 21 class RF24;
akashvibhute 0:c3db0798d9aa 22
akashvibhute 0:c3db0798d9aa 23 /**
akashvibhute 0:c3db0798d9aa 24 * Header which is sent with each message
akashvibhute 0:c3db0798d9aa 25 *
akashvibhute 0:c3db0798d9aa 26 * The frame put over the air consists of this header and a message
akashvibhute 0:c3db0798d9aa 27 */
akashvibhute 0:c3db0798d9aa 28 struct RF24NetworkHeader
akashvibhute 0:c3db0798d9aa 29 {
akashvibhute 0:c3db0798d9aa 30 uint16_t from_node; /**< Logical address where the message was generated */
akashvibhute 0:c3db0798d9aa 31 uint16_t to_node; /**< Logical address where the message is going */
akashvibhute 0:c3db0798d9aa 32 uint16_t id; /**< Sequential message ID, incremented every message */
akashvibhute 0:c3db0798d9aa 33 unsigned char type; /**< Type of the packet. 0-127 are user-defined types, 128-255 are reserved for system */
akashvibhute 0:c3db0798d9aa 34 unsigned char reserved; /**< Reserved for future use */
akashvibhute 0:c3db0798d9aa 35
akashvibhute 0:c3db0798d9aa 36 static uint16_t next_id; /**< The message ID of the next message to be sent */
akashvibhute 0:c3db0798d9aa 37
akashvibhute 0:c3db0798d9aa 38 /**
akashvibhute 0:c3db0798d9aa 39 * Default constructor
akashvibhute 0:c3db0798d9aa 40 *
akashvibhute 0:c3db0798d9aa 41 * Simply constructs a blank header
akashvibhute 0:c3db0798d9aa 42 */
akashvibhute 0:c3db0798d9aa 43 RF24NetworkHeader() {}
akashvibhute 0:c3db0798d9aa 44
akashvibhute 0:c3db0798d9aa 45 /**
akashvibhute 0:c3db0798d9aa 46 * Send constructor
akashvibhute 0:c3db0798d9aa 47 *
akashvibhute 0:c3db0798d9aa 48 * Use this constructor to create a header and then send a message
akashvibhute 0:c3db0798d9aa 49 *
akashvibhute 0:c3db0798d9aa 50 * @code
akashvibhute 0:c3db0798d9aa 51 * RF24NetworkHeader header(recipient_address,'t');
akashvibhute 0:c3db0798d9aa 52 * network.write(header,&message,sizeof(message));
akashvibhute 0:c3db0798d9aa 53 * @endcode
akashvibhute 0:c3db0798d9aa 54 *
akashvibhute 0:c3db0798d9aa 55 * @param _to The logical node address where the message is going
akashvibhute 0:c3db0798d9aa 56 * @param _type The type of message which follows. Only 0-127 are allowed for
akashvibhute 0:c3db0798d9aa 57 * user messages.
akashvibhute 0:c3db0798d9aa 58 */
akashvibhute 0:c3db0798d9aa 59 RF24NetworkHeader(uint16_t _to, unsigned char _type = 0): to_node(_to), id(next_id++), type(_type&0x7f) {}
akashvibhute 0:c3db0798d9aa 60
akashvibhute 0:c3db0798d9aa 61 /**
akashvibhute 0:c3db0798d9aa 62 * Create debugging string
akashvibhute 0:c3db0798d9aa 63 *
akashvibhute 0:c3db0798d9aa 64 * Useful for debugging. Dumps all members into a single string, using
akashvibhute 0:c3db0798d9aa 65 * internal static memory. This memory will get overridden next time
akashvibhute 0:c3db0798d9aa 66 * you call the method.
akashvibhute 0:c3db0798d9aa 67 *
akashvibhute 0:c3db0798d9aa 68 * @return String representation of this object
akashvibhute 0:c3db0798d9aa 69 */
akashvibhute 0:c3db0798d9aa 70 const char* toString(void) const;
akashvibhute 0:c3db0798d9aa 71 };
akashvibhute 0:c3db0798d9aa 72
akashvibhute 0:c3db0798d9aa 73 /**
akashvibhute 0:c3db0798d9aa 74 * Network Layer for RF24 Radios
akashvibhute 0:c3db0798d9aa 75 *
akashvibhute 0:c3db0798d9aa 76 * This class implements an OSI Network Layer using nRF24L01(+) radios driven
akashvibhute 0:c3db0798d9aa 77 * by RF24 library.
akashvibhute 0:c3db0798d9aa 78 */
akashvibhute 0:c3db0798d9aa 79
akashvibhute 0:c3db0798d9aa 80 class RF24Network
akashvibhute 0:c3db0798d9aa 81 {
akashvibhute 0:c3db0798d9aa 82 public:
akashvibhute 0:c3db0798d9aa 83 /**
akashvibhute 0:c3db0798d9aa 84 * Construct the network
akashvibhute 0:c3db0798d9aa 85 *
akashvibhute 0:c3db0798d9aa 86 * @param _radio The underlying radio driver instance
akashvibhute 0:c3db0798d9aa 87 *
akashvibhute 0:c3db0798d9aa 88 */
akashvibhute 0:c3db0798d9aa 89 RF24Network( RF24& _radio );
akashvibhute 0:c3db0798d9aa 90
akashvibhute 0:c3db0798d9aa 91 /**
akashvibhute 0:c3db0798d9aa 92 * Bring up the network
akashvibhute 0:c3db0798d9aa 93 *
akashvibhute 0:c3db0798d9aa 94 * @warning Be sure to 'begin' the radio first.
akashvibhute 0:c3db0798d9aa 95 *
akashvibhute 0:c3db0798d9aa 96 * @param _channel The RF channel to operate on
akashvibhute 0:c3db0798d9aa 97 * @param _node_address The logical address of this node
akashvibhute 0:c3db0798d9aa 98 */
akashvibhute 0:c3db0798d9aa 99 void begin(uint8_t _channel, uint16_t _node_address );
akashvibhute 0:c3db0798d9aa 100
akashvibhute 0:c3db0798d9aa 101 /**
akashvibhute 0:c3db0798d9aa 102 * Main layer loop
akashvibhute 0:c3db0798d9aa 103 *
akashvibhute 0:c3db0798d9aa 104 * This function must be called regularly to keep the layer going. This is where all
akashvibhute 0:c3db0798d9aa 105 * the action happens!
akashvibhute 0:c3db0798d9aa 106 */
akashvibhute 0:c3db0798d9aa 107 void update(void);
akashvibhute 0:c3db0798d9aa 108
akashvibhute 0:c3db0798d9aa 109 /**
akashvibhute 0:c3db0798d9aa 110 * Test whether there is a message available for this node
akashvibhute 0:c3db0798d9aa 111 *
akashvibhute 0:c3db0798d9aa 112 * @return Whether there is a message available for this node
akashvibhute 0:c3db0798d9aa 113 */
akashvibhute 0:c3db0798d9aa 114 bool available(void);
akashvibhute 0:c3db0798d9aa 115
akashvibhute 0:c3db0798d9aa 116 /**
akashvibhute 0:c3db0798d9aa 117 * Read the next available header
akashvibhute 0:c3db0798d9aa 118 *
akashvibhute 0:c3db0798d9aa 119 * Reads the next available header without advancing to the next
akashvibhute 0:c3db0798d9aa 120 * incoming message. Useful for doing a switch on the message type
akashvibhute 0:c3db0798d9aa 121 *
akashvibhute 0:c3db0798d9aa 122 * If there is no message available, the header is not touched
akashvibhute 0:c3db0798d9aa 123 *
akashvibhute 0:c3db0798d9aa 124 * @param[out] header The header (envelope) of the next message
akashvibhute 0:c3db0798d9aa 125 */
akashvibhute 0:c3db0798d9aa 126 void peek(RF24NetworkHeader& header);
akashvibhute 0:c3db0798d9aa 127
akashvibhute 0:c3db0798d9aa 128 /**
akashvibhute 0:c3db0798d9aa 129 * Read a message
akashvibhute 0:c3db0798d9aa 130 *
akashvibhute 0:c3db0798d9aa 131 * @param[out] header The header (envelope) of this message
akashvibhute 0:c3db0798d9aa 132 * @param[out] message Pointer to memory where the message should be placed
akashvibhute 0:c3db0798d9aa 133 * @param maxlen The largest message size which can be held in @p message
akashvibhute 0:c3db0798d9aa 134 * @return The total number of bytes copied into @p message
akashvibhute 0:c3db0798d9aa 135 */
akashvibhute 0:c3db0798d9aa 136 size_t read(RF24NetworkHeader& header, void* message, size_t maxlen);
akashvibhute 0:c3db0798d9aa 137
akashvibhute 0:c3db0798d9aa 138 /**
akashvibhute 0:c3db0798d9aa 139 * Send a message
akashvibhute 0:c3db0798d9aa 140 *
akashvibhute 0:c3db0798d9aa 141 * @param[in,out] header The header (envelope) of this message. The critical
akashvibhute 0:c3db0798d9aa 142 * thing to fill in is the @p to_node field so we know where to send the
akashvibhute 0:c3db0798d9aa 143 * message. It is then updated with the details of the actual header sent.
akashvibhute 0:c3db0798d9aa 144 * @param message Pointer to memory where the message is located
akashvibhute 0:c3db0798d9aa 145 * @param len The size of the message
akashvibhute 0:c3db0798d9aa 146 * @return Whether the message was successfully received
akashvibhute 0:c3db0798d9aa 147 */
akashvibhute 0:c3db0798d9aa 148 bool write(RF24NetworkHeader& header,const void* message, size_t len);
akashvibhute 0:c3db0798d9aa 149
akashvibhute 0:c3db0798d9aa 150 protected:
akashvibhute 0:c3db0798d9aa 151 void open_pipes(void);
akashvibhute 0:c3db0798d9aa 152 uint16_t find_node( uint16_t current_node, uint16_t target_node );
akashvibhute 0:c3db0798d9aa 153 bool write(uint16_t);
akashvibhute 0:c3db0798d9aa 154 bool write_to_pipe( uint16_t node, uint8_t pipe );
akashvibhute 0:c3db0798d9aa 155 bool enqueue(void);
akashvibhute 0:c3db0798d9aa 156
akashvibhute 0:c3db0798d9aa 157 bool is_direct_child( uint16_t node );
akashvibhute 0:c3db0798d9aa 158 bool is_descendant( uint16_t node );
akashvibhute 0:c3db0798d9aa 159 uint16_t direct_child_route_to( uint16_t node );
akashvibhute 0:c3db0798d9aa 160 uint8_t pipe_to_descendant( uint16_t node );
akashvibhute 0:c3db0798d9aa 161 void setup_address(void);
akashvibhute 0:c3db0798d9aa 162
akashvibhute 0:c3db0798d9aa 163 private:
akashvibhute 0:c3db0798d9aa 164 RF24& radio; /**< Underlying radio driver, provides link/physical layers */
akashvibhute 0:c3db0798d9aa 165 uint16_t node_address; /**< Logical node address of this unit, 1 .. UINT_MAX */
akashvibhute 0:c3db0798d9aa 166 const static int frame_size = 32; /**< How large is each frame over the air */
akashvibhute 0:c3db0798d9aa 167 uint8_t frame_buffer[frame_size]; /**< Space to put the frame that will be sent/received over the air */
akashvibhute 0:c3db0798d9aa 168 uint8_t frame_queue[5*frame_size]; /**< Space for a small set of frames that need to be delivered to the app layer */
akashvibhute 0:c3db0798d9aa 169 uint8_t* next_frame; /**< Pointer into the @p frame_queue where we should place the next received frame */
akashvibhute 0:c3db0798d9aa 170
akashvibhute 0:c3db0798d9aa 171 uint16_t parent_node; /**< Our parent's node address */
akashvibhute 0:c3db0798d9aa 172 uint8_t parent_pipe; /**< The pipe our parent uses to listen to us */
akashvibhute 0:c3db0798d9aa 173 uint16_t node_mask; /**< The bits which contain signfificant node address information */
akashvibhute 0:c3db0798d9aa 174 uint8_t min(uint8_t, uint8_t);
akashvibhute 0:c3db0798d9aa 175 };
akashvibhute 0:c3db0798d9aa 176
akashvibhute 0:c3db0798d9aa 177 /**
akashvibhute 0:c3db0798d9aa 178 * @example helloworld_tx.pde
akashvibhute 0:c3db0798d9aa 179 *
akashvibhute 0:c3db0798d9aa 180 * Simplest possible example of using RF24Network. Put this sketch
akashvibhute 0:c3db0798d9aa 181 * on one node, and helloworld_rx.pde on the other. Tx will send
akashvibhute 0:c3db0798d9aa 182 * Rx a nice message every 2 seconds which rx will print out for us.
akashvibhute 0:c3db0798d9aa 183 */
akashvibhute 0:c3db0798d9aa 184
akashvibhute 0:c3db0798d9aa 185 /**
akashvibhute 0:c3db0798d9aa 186 * @example helloworld_rx.pde
akashvibhute 0:c3db0798d9aa 187 *
akashvibhute 0:c3db0798d9aa 188 * Simplest possible example of using RF24Network. Put this sketch
akashvibhute 0:c3db0798d9aa 189 * on one node, and helloworld_tx.pde on the other. Tx will send
akashvibhute 0:c3db0798d9aa 190 * Rx a nice message every 2 seconds which rx will print out for us.
akashvibhute 0:c3db0798d9aa 191 */
akashvibhute 0:c3db0798d9aa 192
akashvibhute 0:c3db0798d9aa 193 /**
akashvibhute 0:c3db0798d9aa 194 * @example meshping.pde
akashvibhute 0:c3db0798d9aa 195 *
akashvibhute 0:c3db0798d9aa 196 * Example of pinging across a mesh network
akashvibhute 0:c3db0798d9aa 197 * Using this sketch, each node will send a ping to the base every
akashvibhute 0:c3db0798d9aa 198 * few seconds. The RF24Network library will route the message across
akashvibhute 0:c3db0798d9aa 199 * the mesh to the correct node.
akashvibhute 0:c3db0798d9aa 200 */
akashvibhute 0:c3db0798d9aa 201
akashvibhute 0:c3db0798d9aa 202 /**
akashvibhute 0:c3db0798d9aa 203 * @example sensornet.pde
akashvibhute 0:c3db0798d9aa 204 *
akashvibhute 0:c3db0798d9aa 205 * Example of a sensor network.
akashvibhute 0:c3db0798d9aa 206 * This sketch demonstrates how to use the RF24Network library to
akashvibhute 0:c3db0798d9aa 207 * manage a set of low-power sensor nodes which mostly sleep but
akashvibhute 0:c3db0798d9aa 208 * awake regularly to send readings to the base.
akashvibhute 0:c3db0798d9aa 209 */
akashvibhute 0:c3db0798d9aa 210 /**
akashvibhute 0:c3db0798d9aa 211 * @mainpage Network Layer for RF24 Radios
akashvibhute 0:c3db0798d9aa 212 *
akashvibhute 0:c3db0798d9aa 213 * This class implements an <a href="http://en.wikipedia.org/wiki/Network_layer">OSI Network Layer</a> using nRF24L01(+) radios driven
akashvibhute 0:c3db0798d9aa 214 * by the <a href="http://maniacbug.github.com/RF24/">RF24</a> library.
akashvibhute 0:c3db0798d9aa 215 *
akashvibhute 0:c3db0798d9aa 216 * @section Purpose Purpose/Goal
akashvibhute 0:c3db0798d9aa 217 *
akashvibhute 0:c3db0798d9aa 218 * Create an alternative to ZigBee radios for Arduino communication.
akashvibhute 0:c3db0798d9aa 219 *
akashvibhute 0:c3db0798d9aa 220 * Xbees are excellent little radios, backed up by a mature and robust standard
akashvibhute 0:c3db0798d9aa 221 * protocol stack. They are also expensive.
akashvibhute 0:c3db0798d9aa 222 *
akashvibhute 0:c3db0798d9aa 223 * For many Arduino uses, they seem like overkill. So I am working to build
akashvibhute 0:c3db0798d9aa 224 * an alternative using nRF24L01 radios. Modules are available for less than
akashvibhute 0:c3db0798d9aa 225 * $6 from many sources. With the RF24Network layer, I hope to cover many
akashvibhute 0:c3db0798d9aa 226 * common communication scenarios.
akashvibhute 0:c3db0798d9aa 227 *
akashvibhute 0:c3db0798d9aa 228 * Please see the @ref Zigbee page for a comparison against the ZigBee protocols
akashvibhute 0:c3db0798d9aa 229 *
akashvibhute 0:c3db0798d9aa 230 * @section Features Features
akashvibhute 0:c3db0798d9aa 231 *
akashvibhute 0:c3db0798d9aa 232 * The layer provides:
akashvibhute 0:c3db0798d9aa 233 * @li Host Addressing. Each node has a logical address on the local network.
akashvibhute 0:c3db0798d9aa 234 * @li Message Forwarding. Messages can be sent from one node to any other, and
akashvibhute 0:c3db0798d9aa 235 * this layer will get them there no matter how many hops it takes.
akashvibhute 0:c3db0798d9aa 236 * @li Ad-hoc Joining. A node can join a network without any changes to any
akashvibhute 0:c3db0798d9aa 237 * existing nodes.
akashvibhute 0:c3db0798d9aa 238 *
akashvibhute 0:c3db0798d9aa 239 * The layer does not (yet) provide:
akashvibhute 0:c3db0798d9aa 240 * @li Fragmentation/reassembly. Ability to send longer messages and put them
akashvibhute 0:c3db0798d9aa 241 * all back together before exposing them up to the app.
akashvibhute 0:c3db0798d9aa 242 * @li Power-efficient listening. It would be useful for nodes who are listening
akashvibhute 0:c3db0798d9aa 243 * to sleep for extended periods of time if they could know that they would miss
akashvibhute 0:c3db0798d9aa 244 * no traffic.
akashvibhute 0:c3db0798d9aa 245 * @li Dynamic address assignment.
akashvibhute 0:c3db0798d9aa 246 *
akashvibhute 0:c3db0798d9aa 247 * @section More How to learn more
akashvibhute 0:c3db0798d9aa 248 *
akashvibhute 0:c3db0798d9aa 249 * @li <a href="http://maniacbug.github.com/RF24/">RF24: Underlying radio driver</a>
akashvibhute 0:c3db0798d9aa 250 * @li <a href="classRF24Network.html">RF24Network Class Documentation</a>
akashvibhute 0:c3db0798d9aa 251 * @li <a href="https://github.com/maniacbug/RF24Network/">Source Code</a>
akashvibhute 0:c3db0798d9aa 252 * @li <a href="https://github.com/maniacbug/RF24Network/archives/master">Downloads Page</a>
akashvibhute 0:c3db0798d9aa 253 * @li <a href="examples.html">Examples Page</a>. Start with <a href="helloworld_rx_8pde-example.html">helloworld_rx</a> and <a href="helloworld_tx_8pde-example.html">helloworld_tx</a>.
akashvibhute 0:c3db0798d9aa 254 *
akashvibhute 0:c3db0798d9aa 255 * @section Topology Topology for Mesh Networks using nRF24L01(+)
akashvibhute 0:c3db0798d9aa 256 *
akashvibhute 0:c3db0798d9aa 257 * This network layer takes advantage of the fundamental capability of the nRF24L01(+) radio to
akashvibhute 0:c3db0798d9aa 258 * listen actively to up to 6 other radios at once. The network is arranged in a
akashvibhute 0:c3db0798d9aa 259 * <a href="http://en.wikipedia.org/wiki/Network_Topology#Tree">Tree Topology</a>, where
akashvibhute 0:c3db0798d9aa 260 * one node is the base, and all other nodes are children either of that node, or of another.
akashvibhute 0:c3db0798d9aa 261 * Unlike a true mesh network, multiple nodes are not connected together, so there is only one
akashvibhute 0:c3db0798d9aa 262 * path to any given node.
akashvibhute 0:c3db0798d9aa 263 *
akashvibhute 0:c3db0798d9aa 264 * @section Octal Octal Addressing
akashvibhute 0:c3db0798d9aa 265 *
akashvibhute 0:c3db0798d9aa 266 * Each node must be assigned an 15-bit address by the administrator. This address exactly
akashvibhute 0:c3db0798d9aa 267 * describes the position of the node within the tree. The address is an octal number. Each
akashvibhute 0:c3db0798d9aa 268 * digit in the address represents a position in the tree further from the base.
akashvibhute 0:c3db0798d9aa 269 *
akashvibhute 0:c3db0798d9aa 270 * @li Node 00 is the base node.
akashvibhute 0:c3db0798d9aa 271 * @li Nodes 01-05 are nodes whose parent is the base.
akashvibhute 0:c3db0798d9aa 272 * @li Node 021 is the second child of node 01.
akashvibhute 0:c3db0798d9aa 273 * @li Node 0321 is the third child of node 021, an so on.
akashvibhute 0:c3db0798d9aa 274 * @li The largest node address is 05555, so 3,125 nodes are allowed on a single channel.
akashvibhute 0:c3db0798d9aa 275 *
akashvibhute 0:c3db0798d9aa 276 * @section Routing How routing is handled
akashvibhute 0:c3db0798d9aa 277 *
akashvibhute 0:c3db0798d9aa 278 * When sending a message using RF24Network::write(), you fill in the header with the logical
akashvibhute 0:c3db0798d9aa 279 * node address. The network layer figures out the right path to find that node, and sends
akashvibhute 0:c3db0798d9aa 280 * it through the system until it gets to the right place. This works even if the two nodes
akashvibhute 0:c3db0798d9aa 281 * are far separated, as it will send the message down to the base node, and then back out
akashvibhute 0:c3db0798d9aa 282 * to the final destination.
akashvibhute 0:c3db0798d9aa 283 *
akashvibhute 0:c3db0798d9aa 284 * All of this work is handled by the RF24Network::update() method, so be sure to call it
akashvibhute 0:c3db0798d9aa 285 * regularly or your network will miss packets.
akashvibhute 0:c3db0798d9aa 286 *
akashvibhute 0:c3db0798d9aa 287 * @section Startup Starting up a node
akashvibhute 0:c3db0798d9aa 288 *
akashvibhute 0:c3db0798d9aa 289 * When a node starts up, it only has to contact its parent to establish communication.
akashvibhute 0:c3db0798d9aa 290 * No direct connection to the Base node is needed. This is useful in situations where
akashvibhute 0:c3db0798d9aa 291 * relay nodes are being used to bridge the distance to the base, so leaf nodes are out
akashvibhute 0:c3db0798d9aa 292 * of range of the base.
akashvibhute 0:c3db0798d9aa 293 *
akashvibhute 0:c3db0798d9aa 294 * @section Directionality Directionality
akashvibhute 0:c3db0798d9aa 295 *
akashvibhute 0:c3db0798d9aa 296 * By default all nodes are always listening, so messages will quickly reach
akashvibhute 0:c3db0798d9aa 297 * their destination.
akashvibhute 0:c3db0798d9aa 298 *
akashvibhute 0:c3db0798d9aa 299 * You may choose to sleep any nodes which do not have any active children on the network
akashvibhute 0:c3db0798d9aa 300 * (i.e. leaf nodes). This is useful in a case where
akashvibhute 0:c3db0798d9aa 301 * the leaf nodes are operating on batteries and need to sleep.
akashvibhute 0:c3db0798d9aa 302 * This is useful for a sensor network. The leaf nodes can sleep most of the time, and wake
akashvibhute 0:c3db0798d9aa 303 * every few minutes to send in a reading. However, messages cannot be sent to these
akashvibhute 0:c3db0798d9aa 304 * sleeping nodes.
akashvibhute 0:c3db0798d9aa 305 *
akashvibhute 0:c3db0798d9aa 306 * In the future, I plan to write a system where messages can still be passed upward from
akashvibhute 0:c3db0798d9aa 307 * the base, and get delivered when a sleeping node is ready to receive them. The radio
akashvibhute 0:c3db0798d9aa 308 * and underlying driver support 'ack payloads', which will be a handy mechanism for this.
akashvibhute 0:c3db0798d9aa 309 *
akashvibhute 0:c3db0798d9aa 310 * @page Zigbee Comparison to ZigBee
akashvibhute 0:c3db0798d9aa 311 *
akashvibhute 0:c3db0798d9aa 312 * This network layer is influenced by the design of ZigBee, but does not implement it
akashvibhute 0:c3db0798d9aa 313 * directly.
akashvibhute 0:c3db0798d9aa 314 *
akashvibhute 0:c3db0798d9aa 315 * @section Advantage Which is better?
akashvibhute 0:c3db0798d9aa 316 *
akashvibhute 0:c3db0798d9aa 317 * ZigBee is a much more robust, feature-rich set of protocols, with many different vendors
akashvibhute 0:c3db0798d9aa 318 * providing compatible chips.
akashvibhute 0:c3db0798d9aa 319 *
akashvibhute 0:c3db0798d9aa 320 * RF24Network is cheap. While ZigBee radios are well over $20, nRF24L01 modules can be found
akashvibhute 0:c3db0798d9aa 321 * for under $6. My personal favorite is
akashvibhute 0:c3db0798d9aa 322 * <a href="http://www.mdfly.com/index.php?main_page=product_info&products_id=82">MDFly RF-IS2401</a>.
akashvibhute 0:c3db0798d9aa 323 *
akashvibhute 0:c3db0798d9aa 324 * @section Contrast Similiarities & Differences
akashvibhute 0:c3db0798d9aa 325 *
akashvibhute 0:c3db0798d9aa 326 * Here are some comparisons between RF24Network and ZigBee.
akashvibhute 0:c3db0798d9aa 327 *
akashvibhute 0:c3db0798d9aa 328 * @li Both networks support Star and Tree topologies. Only Zigbee supports a true mesh.
akashvibhute 0:c3db0798d9aa 329 * @li In both networks, only leaf nodes can sleep (see @ref NodeNames).
akashvibhute 0:c3db0798d9aa 330 * @li ZigBee nodes are configured using AT commands, or a separate Windows application.
akashvibhute 0:c3db0798d9aa 331 * RF24 nodes are configured by recompiliing the firmware or writing to EEPROM.
akashvibhute 0:c3db0798d9aa 332 *
akashvibhute 0:c3db0798d9aa 333 * @section NodeNames Node Naming
akashvibhute 0:c3db0798d9aa 334 *
akashvibhute 0:c3db0798d9aa 335 * @li Leaf node: A node at the outer edge of the network with no children. ZigBee calls it
akashvibhute 0:c3db0798d9aa 336 * an End Device node.
akashvibhute 0:c3db0798d9aa 337 * @li Relay node: A node which has both parents and children, and relays messages from one
akashvibhute 0:c3db0798d9aa 338 * to the other. ZigBee calls it a Router.
akashvibhute 0:c3db0798d9aa 339 * @li Base node. The top of the tree node with no parents, only children. Typically this node
akashvibhute 0:c3db0798d9aa 340 * will bridge to another kind of network like Ethernet. ZigBee calls it a Co-ordinator node.
akashvibhute 0:c3db0798d9aa 341 */
akashvibhute 0:c3db0798d9aa 342
akashvibhute 0:c3db0798d9aa 343 #endif // __RF24NETWORK_H__
akashvibhute 0:c3db0798d9aa 344 // vim:ai:cin:sts=2 sw=2 ft=cpp