opportunistic-xbee/xbee_wrapper.h

50 lines
917 B
C
Raw Normal View History

#ifndef _WBEE_WRAPPER_H_
#define _WBEE_WRAPPER_H_
#include <Wire.h>
#include <XBee.h>
#include "protocol.h"
#include "packet.h"
#define XBWRECV_OK 0
#define XBWRECV_NONE 1
#define XBWRECV_ERROR 2
#define XBWSEND_OK 0
#define XBWSEND_ERROR 1
#define XBWSEND_UNKNOWN 2
2018-12-13 14:39:03 +00:00
#define XBWSEND_NONEAREST 3
2018-12-13 14:39:03 +00:00
#define RX_NONE_RESPONSE 0
class XBeeWrapper{
private:
XBee xbee;
2018-12-13 14:39:03 +00:00
Node node;
uint8_t rssi = 255;
uint8_t addrType = RX_NONE_RESPONSE;
uint64_t msb = 0;
uint64_t lsb = 0;
public:
2018-12-13 14:39:03 +00:00
XBeeWrapper(Node &node);
// initialises the XBee interface
void begin(const unsigned long baud);
// tries to extract a received packet
uint8_t receive(Packet& pkt);
// tries to broadcast a packet
uint8_t broadcast(Packet& pkt);
2018-12-13 14:39:03 +00:00
// tries to send to the nearest node (of a lower level)
uint32_t sendToNearest(Packet& pkt);
};
2018-12-13 14:39:03 +00:00
#endif