From e47b3e72b42435199cbc14ba651fe7469d3070c4 Mon Sep 17 00:00:00 2001 From: flavienhaas Date: Wed, 25 Apr 2018 11:28:25 +0200 Subject: [PATCH] added code --- fakeStation/fakeStation.ino | 42 ++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/fakeStation/fakeStation.ino b/fakeStation/fakeStation.ino index 95c2b6e..670511d 100644 --- a/fakeStation/fakeStation.ino +++ b/fakeStation/fakeStation.ino @@ -1,9 +1,41 @@ -void setup() { - // put your setup code here, to run once: +#include +#include // si ce n'est déjà fait, importez la librairie LoRa via le gestionnaire de bibliothèque -} +struct message { // frame structure + uint16_t ID; // ID + uint16_t TS; // TimeStamp + uint16_t DT; // Data Type + uint16_t D1; // DATA 1 + uint16_t D2; // DATA 2 + uint16_t D3; // DATA 3 +}; + +void setup(){ + Serial.begin(9600); + while (!Serial); + Serial.println("fakeLoRastation"); + // LoRa.setSPIFrequency(4E6); //défaut 8MHz trop rapide pour l'analyseur + if( !LoRa.begin(868E6) ){ + Serial.print("Echec de l'initialisation LoRa !\n"); + while(true); + } +}//setup() void loop() { - // put your main code here, to run repeatedly: + static byte N=0; + static byte + message message = {0}; -} + Serial.print("Envoi du message \"N="); Serial.print(N); Serial.println("\""); + message.ID = 0x30; // n° d'identification de l'émetteur + message.TS = 0x00; + message.DT = 0x00; + message.D1 = '0'+ (N/100)%10; + message.D2 = '0'+ (N/10 )%10; + message.D3 = '0'+ (N/1 )%10; + + LoRa.beginPacket(false); + LoRa.write( (uint8_t*)&message, sizeof(message)); + LoRa.endPacket(); + delay(5000); +}//loop()