Using XBee library from Andrew Rapp.
I need clarification how to send and receive (parse) the content data using this library.
I have been able so far, using API (AP=2) and 16 bit-addressing mode, to establish bi-directional communication between 2 Arduino Uno using XBee Pro.
I have 1 switch and 2 LED on each breadboard attached to the Arduino. Pressing the button on one board turn one LED Off and the other one On. The button number (I only have one for now) is send to the other Arduino using the payload[0].
On the receiving end, a function is called which also turn one LED Off and the other one ON, using data(0).
These data fields "payload" and "data" are exactly the same used by Andrew Rapp in his examples programs Series1_Rx and Series1_Tx.
So far so good, now I am trying to get to my next phase of my project.
Eventually, each station will have 3 switches and 6 LED. These switches will locally or remotely activate a relay (pumps and heating) while the LED will display their status. In addition there will be 3 One Wire Digital Temperature Sensors - DS18B20 and a sensor to see the water level within a tank.
I need to be able to send the following for each transaction (some being real time while other driven by TimeAlarms:
- Type of Data (example button number, temperature or water level)
- The identification of the button or the thermometer
- The value of the reading for the temperature and the thermometer.
I got the impression, from all my reading and poking around , that all data packet (if this is what I should called it) and converted in HEX before sending.
I would appreciate any help, suggestions how to do it. Should I use data structure ? What data type would be appropriate ? If the data have to be send in HEX, how do I parse and reconstruct it at the receiving end ?
While I am asking for help, there is also another challenge that I would like to tackle.
// 16-bit addressing: Enter address of remote XBee, typically the coordinator
// TBD set possible 3 differewnt addresses
uint16_t addr_Central_Station= 0x1111;
Tx16Request tx = Tx16Request(addr_Central_Station, payload, sizeof(payload));
[/endcode]
When sending data, my current program is using "tx" as created above. Is is possible to create multiple instances of this tx. Or variable tx because I will have multiple Station, each one having its own address.