update protocol default MESSAGE_TTL | fix node.send_message() to send before printing | fix node.manage_message() to use same packet to re-send the received message packet

This commit is contained in:
Adrien Marquès 2018-12-11 13:33:51 +01:00
parent a4eef60636
commit 8b669af363
2 changed files with 12 additions and 13 deletions

View File

@ -59,18 +59,17 @@ void send_data(){
send.setDist(dist);
send.setTTL(MESSAGE_TTL);
char data[64] = {0};
strcpy(data, "https://git.xdrm.io");
sprintf(data, "%d has: dist %d / wave %d", SENDERID, dist, wave_id);
send.setData(data);
// 2. broadcast
xbee.broadcast(send);
// 2. debug
screen.clear();
screen.printfn(0, "msg[%3d/%3d] %3d", send.getDist(), send.getTTL(), send.getSize());
screen.printfn_overflow(1, "%s", (char*) send.getData());
delay(1000);
// 3. send
xbee.broadcast(send);
screen.printfn(1, "sent ");
delay(500);
}
@ -129,11 +128,11 @@ void manage_message(){
}
// propagation
send.setOpcode(OPCODE_MESSAGE);
send.setTTL(recv.getTTL()-1);
send.setDist(dist);
send.setData(recv.getData());
// send.setOpcode(OPCODE_MESSAGE);
recv.setTTL(recv.getTTL()-1);
recv.setDist(dist);
// send.setData(recv.getData());
screen.printfn(1, "msg[%3d/%3d] %3d", send.getDist(), send.getTTL(), send.getSize());
xbee.broadcast(send);
screen.printfn(1, "msg[%3d/%3d] %3d", recv.getDist(), recv.getTTL(), recv.getSize());
xbee.broadcast(recv);
}

View File

@ -5,7 +5,7 @@
#define DISCOVER_TTL 5000
#define SENDERID 42
#define MESSAGE_TTL 10
#define MESSAGE_TTL 3
#define OPCODE_DISCOVER 0
#define OPCODE_MESSAGE 1