update main according to lib updates

This commit is contained in:
Adrien Marquès 2018-12-02 21:45:06 +01:00
parent 120a1e56bf
commit 4410b3fd38
1 changed files with 32 additions and 6 deletions

View File

@ -1,17 +1,19 @@
#include <Wire.h> #include <Wire.h>
#include <XBee.h>
#include "protocol.h"
#include <LiquidCrystal_I2C.h> #include <LiquidCrystal_I2C.h>
#include "packet.h" // Packet
#include "xbee_wrapper.h" // WBeeWrapper
#include "protocol.h"
// Peripherals // Peripherals
LiquidCrystal_I2C screen(0x27, 16, 2); LiquidCrystal_I2C screen(0x27, 16, 2);
XBee xbee = XBee(); XBeeWrapper xbee = XBeeWrapper();
// ACTUAL DATA // ACTUAL DATA
uint8_t wave_id = 255; // last wave uint8_t wave_id = 255; // last wave
uint8_t dist = 255; // actual distance uint8_t dist = 255; // actual distance
struct discover dsc = {0,0,0}; struct discover dsc = {0,0,0};
struct message msg = {1, dist, 0, 0, {}}; struct message msg = {1, dist, 0, 0, {}};
Packet pkt;
void setup() { void setup() {
Serial.begin(38400); Serial.begin(38400);
@ -20,8 +22,32 @@ void setup() {
screen.begin(); screen.begin();
screen.backlight(); screen.backlight();
xbee.setSerial(Serial1); xbee.begin(38400);
Serial1.begin(38400);
} }
void loop() {} void loop() {
// 1. ignore if no received data
if( xbee.receive(pkt) == XBWRCV_OK ){
// manage packet
}
// xbee.readPacket();
// if( xbee.getResponse().isAvailable() ){
// if( xbee.getResponse().getApiId() == ZB_RX_RESPONSE ){
// // got a zb rx packet
// // now extract response
// xbee.getResponse().getZBRxResponse(res);
// // get data type (byte 0)
// uint8_t type = res.getData(0)
// res.getBytes()
// analogWrite(dataLed, res.getData(0));
// }
// }
}