claudioalves wrote:Thanks for your answer Stevech.
What I'm trying to implement is this: install a ZigBee coordinator (The most capable device, the coordinator forms the root of the network tree and might bridge to other networks. There is exactly one ZigBee coordinator in each network), a ZigBee Router (to passing data from other devices) and ZigBee End Device (Contains just enough functionality to talk to the parent node that cannot relay data from other devices). I need to create a network (star topology its a good idea), where its possible to send/receive data from any XBee (making some hops if necessary) to the main computer, where will get all the information. To do this, I need to make a code in C language. Do you have any idea if exist some code made for this situation? I remember you that all the code is "installed" in a atmega168 micro.
First of all I'm assuming your going to be using AT mode rather than API mode to pass serial(?) data to/from the Xbees
I don't know why you want to make life difficult for yourself. Install the coordinator firmware on the xbee connected to the PC then install the Router firmware on the other Xbees. Set the network and channel for all of them to be the same. The meshing happens automatically, ie if a node can't see the coordinator directly it'll use one of the nodes it can see to hop from.
Then in its simplest form this is what will happen:
1) if the coordinator sends data, each of the xbee nodes will receive it
2) if an xbee node sends data the coordinator will receive it.
You don't need to code any of this yourself.
You can configure the coordinator to address each xbee node individually if you want in which case all you need to do is concentrate on your PC application/code.
I use the default mechanism to retrieve sensor data from 1-wire devices around my home. The command is issued from the coordinator and the xbee nodes reply with all the 1-wire devices they have + the data reading. There are a couple of nodes that can't see the coordinator directly but their data gets through via one of the other nodes.