Hello,
I have a problem in a XBee project I’m doing. In my program I want to receive some XBee frames from another XBee and save the address in the string “address_tab”. If for example the address of my XBee is 40B29001, I should receive this kind of frame:
7E 0 12 92 0 13 A2 0 40 B2 90 1 40 AE 1 1 0 0 1 2 A5 9
And I want to keep the “40B29001” and save it in my “address_tab” but not in decimal, exactly like this “40B29001”. So if I want to read in my string I will see “40B29001”. But I don’t know exactly how to do that. This is my code:
#include <SPI.h>
byte address;
char address_tab;
void setup() {
Serial.begin(9600);
}
void loop() {
if (Serial.available()>=21) {
if (Serial.read()==0x7E) {
Serial.print("7E");
Serial.print(" ");
ind=0;
for (int i=0; i<7; i++) {
Serial.print(Serial.read(), HEX);
Serial.print(" ");
}
Serial.print("%");
// Address
for (int i=0; i<4; i++) {
address=Serial.read();
address_tab=adress;
Serial.print(address_tab);
Serial.print(" ");
}
Serial.print("%");
for (int i=0; i<10; i++) {
byte discard = Serial.read();
}
Serial.println("");
}
}
}
So I receive something like this:
7E 0 12 92 0 13 A2 0 %@ ± ? %40 AE 1 1 0 0 1 2 A5 9
The thing I want to keep is between the two % symbols. As you can see there are @ ± ?and not the “40B29001” I expected.
Thank’s for you help !