Can Someone please Break down the communication between Xbee Series 1 in API Mode? I have the example sketches and the Xbee library for Arduino, but can Someone break down each line and explain to me whats its doing, Home i find out what to put, and what has to come first? I'm trying to establish 2 way communication between 2 Arduinos using Xbee Series 1 2.4Ghz modules in API mode. I plan to have more "router/endpoints" but I want to ask the remote "endpoint" side what a value of a variable is, have it respond, send a command to turn on or off a pin, and then send back the state of the pin. So basically;
B0000000000 is all remote pins on respective arduinos are off.
Coordinator Xbee reads if a web button (on a webpage hosted by the coordinator-side arduino) for each pin was pushed in byte form like so;
B1001000100 (1 = yes, 0 = no)
then the coordinator asks each remote arduino via Xbee in API Mode if their respective push button (one each) were pushed, and stores them like so;
B0010001000
Next, using Bitwise OR math, takes the last 2 sets of bytes of info and processes it like so;
B1001000100
B0010001000
B1011001100
1's = change state
0's = stay state
so from the initial all off state;
B0000000000
becomes;
B1011001100
Now, based on the value of each bit, sends a command to each arduino via API mode Xbee, a command to turn on or turn off each pin (One pin per arduino is assigned as the one being controlled).
the remote arduino (Via API mode Xbee) sends back their (single selected) pin state in a 1 or 0
The coordinator-side Arduino stores those states recieved in a Byte form, and saves it as the new state and turns an indicator light on the webpage (hosted by the coordinator-side arduino) showing the state of each remote pin and saving it as the initial byte of info.
FOR EXAMPLE
initial state =
B0000000000
if web button was pushed
B1000111000
if remote (physical )push button was pressed
B0010011001
Bitwise OR
B1000111000
B0010011001
B1010111001
each one says to change state (from inital)
So,
B0000000000
Becomes
B1010111001
and is saved as new inital state.
inital state is
B1010111001
if web button was pushed
B1000111000
if remote push button was pressed
B0010011001
Bitwise OR
B1000111000
B0010011001
B1010111001
change inital state of;
B1010111001
to
B0000000000
Make sense?