|
|
|
@ -1,15 +1,15 @@
|
|
|
|
|
#include <SPI.h>
|
|
|
|
|
#include <LoRa.h> // si ce n'est déjà fait, importez la librairie LoRa via le gestionnaire de bibliothèque
|
|
|
|
|
#include <LoRa.h>
|
|
|
|
|
|
|
|
|
|
#define Serial SerialUSB
|
|
|
|
|
|
|
|
|
|
typedef struct paquet_LoRa { // 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
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
trame message;
|
|
|
|
@ -26,18 +26,30 @@ void setup(){
|
|
|
|
|
}//setup()
|
|
|
|
|
|
|
|
|
|
void loop() {
|
|
|
|
|
static byte N=0;
|
|
|
|
|
int c=0;
|
|
|
|
|
message.D1=random(0,65535);
|
|
|
|
|
message.D2=random(0,65535);
|
|
|
|
|
message.D3=random(0,65535);
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
String strID = String(message.ID);//0x00
|
|
|
|
|
String strTS = String(message.TS);//0x0000
|
|
|
|
|
String strDT = String(message.DT);//0x0000
|
|
|
|
|
String strD1 = String(message.D1);//0x0000
|
|
|
|
|
String strD2 = String(message.D3);//0x0000
|
|
|
|
|
String strD3 = String(message.D3);//0x0000
|
|
|
|
|
|
|
|
|
|
for(c=0;c<3;c++){
|
|
|
|
|
LoRa.beginPacket(false);
|
|
|
|
|
LoRa.write( (uint8_t*)&message, sizeof(message)); //envoi de la structure message et de sa taille
|
|
|
|
|
LoRa.write( (uint8_t*)&message, sizeof(message));
|
|
|
|
|
Serial.println("\nPacquet envoyé: ");
|
|
|
|
|
Serial.println("ID Passerelle et station envoyés : "+strID);
|
|
|
|
|
Serial.println("Timestamp envoyée: "+strTS);
|
|
|
|
|
Serial.println("Type de données envoyé: "+strDT);
|
|
|
|
|
Serial.println("Champ de données 1 envoyé: "+strD1);
|
|
|
|
|
Serial.println("Champ de données 2 envoyé: "+strD2);
|
|
|
|
|
Serial.println("Champ de données 3 envoyé: "+strD3);
|
|
|
|
|
LoRa.endPacket();
|
|
|
|
|
delay(3000);
|
|
|
|
|
delay(1000);
|
|
|
|
|
}//findufor
|
|
|
|
|
message.TS = message.TS + 1;
|
|
|
|
|
}//loop()
|
|
|
|
|