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

55 lines
1.4 KiB
Arduino

7 years ago
#include <SPI.h>
7 years ago
#include <LoRa.h>
7 years ago
typedef struct{ // frame structure
uint16_t ID = 1025; // ID
uint16_t TS = 0; // TimeStamp
uint16_t DT = 0; // Data Type
uint16_t D1 = 0; // DATA 1
uint16_t D2 = 0; // DATA 2
uint16_t D3 = 0; // DATA 3
}trame;
7 years ago
trame message;
7 years ago
7 years ago
void setup() {
7 years ago
Serial.begin(9600);
7 years ago
while (!Serial);
Serial.println("LoRa Sender");
7 years ago
message.ID = 0x0007;
message.TS = 0x0001;
message.DT = 0x0001;
message.D1 = 0x0026;
7 years ago
message.D2 = 0x0003;
message.D3 = 0x0004;
if (!LoRa.begin(868E6)) {
Serial.println("Starting LoRa failed!");
while (1);
7 years ago
}
}
void loop() {
7 years ago
Serial.print("Sending packet: ");
7 years ago
// send packet
LoRa.beginPacket();
LoRa.write((uint8_t)(message.ID >> 8));
LoRa.write((uint8_t)message.ID);
LoRa.write((uint8_t)(message.TS >> 8));
LoRa.write((uint8_t)message.TS);
LoRa.write((uint8_t)(message.DT >> 8));
LoRa.write((uint8_t)message.DT);
LoRa.write((uint8_t)(message.D1 >> 8));
LoRa.write((uint8_t)message.D1);
LoRa.write((uint8_t)(message.D2 >> 8));
LoRa.write((uint8_t)message.D2);
LoRa.write((uint8_t)(message.D3 >> 8));
LoRa.write((uint8_t)message.D3);
7 years ago
LoRa.endPacket();
7 years ago
delay(3000);
}