opportunistic-xbee/xbee_wrapper.h

50 lines
917 B
C++

#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
#define XBWSEND_NONEAREST 3
#define RX_NONE_RESPONSE 0
class XBeeWrapper{
private:
XBee xbee;
Node node;
uint8_t rssi = 255;
uint8_t addrType = RX_NONE_RESPONSE;
uint64_t msb = 0;
uint64_t lsb = 0;
public:
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);
// tries to send to the nearest node (of a lower level)
uint32_t sendToNearest(Packet& pkt);
};
#endif