You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
LoRaGateway_BTS2A/fakeStation/fakeStation.ino

81 lines
1.6 KiB
Arduino

7 years ago
#include <SPI.h>
7 years ago
#include <LoRa.h>
7 years ago
typedef struct
{
uint8_t ids = 0x45;
uint8_t idp = 0x00;
uint16_t ts = 0x0000;
uint16_t dt = 0x0001;
uint16_t d1 = 0x0000;
uint16_t d2 = 0x0000;
uint16_t d3 = 0x0000;
}message;
7 years ago
message msg;
7 years ago
7 years ago
void setup() {
7 years ago
SerialUSB.begin(9600);
7 years ago
while (!Serial);
7 years ago
SerialUSB.println("LoRa Sender");
7 years ago
if (!LoRa.begin(868E6))
{
SerialUSB.println("Starting LoRa failed!");
while(1);
7 years ago
}
}
7 years ago
void loop()
{
msg.ts = msg.ts + 1;
msg.d1 = random(20, 40);
msg.d2 = random(40, 60);
msg.d3 = random(0, 100);
SerialUSB.print("ID station : ");
SerialUSB.print(msg.ids, DEC);
SerialUSB.print(", ");
SerialUSB.println(msg.ids, HEX);
SerialUSB.print("ID passerelle : ");
SerialUSB.print(msg.idp, DEC);
SerialUSB.print(", ");
SerialUSB.println(msg.idp, HEX);
SerialUSB.print("Numero de message : ");
SerialUSB.print(msg.ts, DEC);
SerialUSB.print(", ");
SerialUSB.println(msg.ts, HEX);
SerialUSB.print("Type de donne : ");
SerialUSB.print(msg.dt, DEC);
SerialUSB.print(", ");
SerialUSB.println(msg.dt, HEX);
SerialUSB.print("Donnee 1 : ");
SerialUSB.print(msg.d1, DEC);
SerialUSB.print(", ");
SerialUSB.println(msg.d1, HEX);
SerialUSB.print("Donnee 2 : ");
SerialUSB.print(msg.d2, DEC);
SerialUSB.print(", ");
SerialUSB.println(msg.d2, HEX);
7 years ago
SerialUSB.print("Donnee 3 : ");
SerialUSB.print(msg.d3, DEC);
SerialUSB.print(", ");
SerialUSB.println(msg.d3, HEX);
SerialUSB.println(" ");
SerialUSB.println("Sending packet !");
7 years ago
LoRa.beginPacket();
7 years ago
LoRa.write((uint8_t*)&msg, 12);
7 years ago
LoRa.endPacket();
7 years ago
SerialUSB.println("-----------------------------");
delay(4000);
}