OK. I trying to make multhops. I have three arduinos UNO.
I calling them ard_5 (id = 2), ard_8 (id = 1) and ard_3 (id = 3).
So, if you look on my first post you'll se that I put my beacon.ccp code.
Now everything on every code that had "int " or "short" I changed for "byte".
Good news!!! I am getting 2#1#0 at my first hop from ard_5 arduino to ard_8!!!
Like this ard_8 (2#1#0) -> ard_5(2#1#0) -> ard_5(3#1#0)-> ard_x(3#1#0), that is:
ard_8 just send, ard_5 receives from ard_8 and send for ard_x changing the destination, but keeping the source.
Howerver, with ard_x, I am getting like this ( 13448#88787#7878)
ard_8
#include <Service.h>
#include <Beacon.h>
//Arduino 08 -> ard_8 -> Somente envia!!!
Beacon beacon;
Service service;
// Identidade dos Arduinos
byte ard_8 = 1; //Arduino 08
byte ard_5 = 2; //Arduino 05
byte ard_x = 3; //arduino X
void setup() {
// comunicação XBEE a taxa de 9600 bps
Serial.begin(9600);
}
void loop() {
beacon = Beacon(ard_5, ard_8, 0);
service.enviaBeacon(beacon);
delay(2000);
}
ard_5
#include <Beacon.h>
#include <Service.h>
Beacon beacon;
Beacon recebe;
Service service;
byte ard_8 = 1; //Arduino 08
byte ard_5 = 2; //Arduino 05
byte ard_x = 3; //arduino X
void setup() {
Serial.begin(9600);
}
void loop() {
recebe = service.recebeBeacon(ard_5);
if (recebe.getDhost() == ard_5){
delay(2000);
//byte i = recebe.getSALTO()+1;
beacon = Beacon(recebe.getDhost(), recebe.getShost(), recebe.getSALTO());
service.converteBeaconParaArrayChar(beacon);
if (recebe.getDhost() == ard_5){
Serial.println("Ponto N");
beacon = Beacon(ard_x, ard_8,recebe.getSALTO() );
service.enviaBeacon(beacon);
}
}
}
ard_x
#include <Service.h>
#include <Beacon.h>
Service service;
Beacon beacon;
Beacon recebe;
byte ard_8 = 1; //Arduino 08
byte ard_5 = 2; //Arduino 05
byte ard_x = 3; //arduino X
//int led = 13;
void setup() {
Serial.begin(9600);
// pinMode(led, OUTPUT);
}
void loop() {
recebe = service.recebeBeacon(ard_x);
if (recebe.getDhost() == ard_x){
delay(2000);
beacon = Beacon(recebe.getDhost(), recebe.getShost(), recebe.getSALTO());
service.converteBeaconParaArrayChar(beacon);
}
One more thing, I changed my while from method converteArrayCharParaBeacon to:
byte i=0;
byte vet[3];
Beacon beacon;
for (i=0; i <= 2; i++){
vet[i] = msg[2 * i] - '0';
i++;
}
Do you see any mistake?