// to compile as on the diagrams, check that you have changed the SS port as indicated on the README
// before transfert, check that you have changed the SS port as indicated on the README or you will not be able to use the LoRa shield as the same time as the Ethernet shield
#include<SPI.h> // to communicate using spi (required for our shields)
#include<LoRa.h> // to use the LoRa shield
#include"Ethernet.h" // to use the ethernet shield
#include"util.h" // to have the display of the elapsed time
#include<SPI.h> // to communicate using spi (required for our shields)
#include<LoRa.h> // to use the LoRa shield
#include"Ethernet.h" // to use the ethernet shield
#define LENMAX 80 // maximum size for the LoRa frame
#define Serial SerialUSB // serial out on the M0 use a different function
#define LENMAX 80 // maximum size for the LoRa frame
#define Serial SerialUSB // serial out on the M0 use a different function
// void setSPIFrequency(uint32_t frequency); // set the SPI at 8MHz to use logic analyser
// void setSPIFrequency(uint32_t frequency); // set the SPI at 8MHz to use logic analyser
bytemac[]={0xDE,0xAD,0xBE,0xEF,0xFE,0xED};// set the mac address
bytemac[]={0xDE,0xAD,0xBE,0xEF,0xFE,0xED};// set the mac address
//IPAddress ip(10, 0, 0, 49); //set the IP address for the ethernet shield, overwise the librairy use DHCP
//IPAddress ip(10, 0, 0, 49); //set the IP address for the ethernet shield, overwise the librairy use DHCP
EthernetServerserver(80);// initialize the EthernetServer library, using port 80 (default fot HTTP)
EthernetServerserver(80);// initialize the EthernetServer library, using port 80 (default fot HTTP)
voidsetup(){
Serial.begin(9600);
while(!Serial);// wait for serial to initialize
Serial.print("Passerelle LoRa\n");// display on serial the name of the device
while(!Serial);// wait for serial to initialize
Serial.print("Passerelle LoRa\n");// display on serial the name of the device
if(!LoRa.begin(868E6)){
Serial.print("Echec de l'initialisation LoRa !\n");
while(true);}// initialize LoRa shield LoRa at 868 MHz
while(true);}// initialize LoRa shield LoRa at 868 MHz
//Ethernet.begin(mac, ip); // initialize Ethernet shield using the set mac adress and set IP
Ethernet.begin(mac);// initialize Ethernet shield uding the set mac and DHCP for the IP
server.begin();
Serial.print("server is at ");
//Ethernet.begin(mac, ip); // initialize Ethernet shield using the set mac adress and set IP
Ethernet.begin(mac);// initialize Ethernet shield uding the set mac and DHCP for the IP
server.begin();// initialize WebServer part of the librairy
Serial.print("server is at ");// display on serial the IP you can find the webpage
Serial.println(Ethernet.localIP());
}
voidSerialPrintElapsedTime(booleanespaceFinal=true){// to display the elapsed time