opportunistic-xbee/protocol.h

35 lines
840 B
C
Raw Normal View History

#ifndef _PROTOCOL_H_
#define _PROTOCOL_H_
2018-12-02 20:43:59 +00:00
#include <Wire.h>
#define DISCOVER_TTL 5000
#define SENDERID 42
#define MESSAGE_TTL 3
#define OPCODE_DISCOVER 0
#define OPCODE_MESSAGE 1
// discover request (c.f. class node)
#define DISCOVER_SIZE sizeof(uint8_t)*3
struct discover {
uint8_t opcode; // opcode = 0
uint8_t wave; // id de la wave
uint8_t dist; // current node's distance
};
#define MESSAGE_MIN_SIZE sizeof(uint8_t)*5
#define MESSAGE_MAX_SIZE (5 + 255) * sizeof(uint8_t)
2018-12-01 17:36:02 +00:00
struct message {
uint8_t opcode; // opcode = 1
uint8_t sender; // sender id
2018-12-01 17:36:02 +00:00
uint8_t dist; // distance of the last sender
uint8_t ttl; // time to live default = 10
uint8_t size; // size of message in bytes
uint8_t *data; // actual message
};
2018-12-02 20:43:59 +00:00
#define PROTO_SIZE MESSAGE_MAX_SIZE
#endif