changed structure

This commit is contained in:
Flavien Haas 2018-05-02 10:41:24 +02:00
parent 64e57e41a2
commit 772b4e334d
2 changed files with 13 additions and 9 deletions

View File

@ -1,14 +1,18 @@
#include <SPI.h>
#include <LoRa.h> // si ce n'est déjà fait, importez la librairie LoRa via le gestionnaire de bibliothèque
struct message { // frame structure
#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
};
} trame;
trame message;
void setup(){
Serial.begin(9600);
@ -23,8 +27,6 @@ void setup(){
void loop() {
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
@ -35,7 +37,7 @@ void loop() {
message.D3 = '0'+ (N/1 )%10;
LoRa.beginPacket(false);
LoRa.write( (uint8_t*)&message, sizeof(message));
LoRa.write( (uint8_t*)&message, sizeof(message)); //envoi de la structure message et de sa taille
LoRa.endPacket();
delay(5000);
delay(3000);
}//loop()

View File

@ -16,14 +16,16 @@ byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; // set the mac addre
EthernetServer server(80); // initialize the EthernetServer library, using port 80 (default fot HTTP)
struct message { // frame structure
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
};
} trame;
trame message;
void setup(){
Serial.begin(9600);