// 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
// before transfert, check these things:
// have all the librairies needed installed on your machine
// changed the SS port for ethernet 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<SPI.h> // to communicate using spi (required for our shields)
#include<LoRa.h> // to use the LoRa shield
#include<LoRa.h> // to use the LoRa shield
#include<Ethernet.h> // to use the ethernet shield
#include<Ethernet.h> // to use the ethernet shield
#include<SD.h> // to use a SD card
#include<SD.h> // to use a SD card
#include<CModemLoRa.h> // to use personalised LoRa class
#include<CModemLoRa.h> // to use personalised LoRa class
#include<CProtocol12Bytes.h> // to use our protocol
#include<CProtocol12Bytes.h> // to use our protocol
#define LENMAX 80 // maximum size for the LoRa frame
#define LENMAX 80 // maximum size for the LoRa frame
#define Serial SerialUSB // serial out on the M0 use a different function
#define Serial SerialUSB // serial out on the M0 use a different function
CModemLoRathisLoRa;// create object for personnalizeed LoRa class
CModemLoRathisLoRa;// create object for personnalizeed LoRa class
CProtocol12Bytesprotocol;// create object to store data using our protocol
CProtocol12Bytesprotocol;// create object to store data using our protocol
FilewebFile;// variable for the file containing the webpage
FilewebFile;// variable for the file containing the webpage
// 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,0xFF,0xFD};// set the mac address
bytemac[]={0xDE,0xAD,0xBE,0xEF,0xFF,0xFD};// set the mac address
IPAddressip(192,1,1,150);// set the IP address for the ethernet shield, overwise the librairy use DHCP
IPAddressip(192,1,1,150);// 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(){
voidsetup(){
Serial.begin(9600);
Serial.begin(9600);
while(!Serial);// wait for serial to initialize
while(!Serial);// wait for serial to initialize
Serial.println("LoRa Gateway");// display on serial the name of the device
Serial.println("LoRa Gateway");// display on serial the name of the device
thisLoRa.begin();// initialise LoRa
thisLoRa.begin();// initialise LoRa
//Ethernet.begin(mac, ip); // initialize Ethernet shield using the set mac adress and set IP
//Ethernet.begin(mac, ip); // initialize Ethernet shield using the set mac adress and set IP and DHCP for the rest
Ethernet.begin(mac);// initialize Ethernet shield uding the set mac and DHCP for the IP
Ethernet.begin(mac);// initialize Ethernet shield uding the set mac and DHCP for the rest
server.begin();// initialize WebServer part of the librairy
server.begin();// initialize WebServer part of the librairy
Serial.print("server is at ");
Serial.print("server is at ");
Serial.println(Ethernet.localIP());// display on serial the IP you can find the webpage
Serial.println(Ethernet.localIP());// display on serial the IP you can find the webpage