This commit is contained in:
Flavien Haas 2018-06-11 13:27:40 +02:00
parent 355bfe40d9
commit 9cb1ba2fdc
3 changed files with 21 additions and 29 deletions

View File

@ -8,7 +8,6 @@ CProtocol12Bytes protocol;
void setup() {
SerialUSB.begin(9600);
while (!SerialUSB){};
SerialUSB.println("LoRa Receiver");
thisLoRa.begin();
}
@ -17,7 +16,7 @@ void loop() {
int packetSize = thisLoRa.parsePacket();
if (packetSize > 0)
{
thisLoRa.read(&protocol); // objet thislora qui appele classe Lora.h et rempli la stucture de l'objet protocol, ser a allèger -5lignes
thisLoRa.read(&protocol);
SerialUSB.println("Frame received");
delay(100);
SerialUSB.print("ID = ");
@ -34,5 +33,12 @@ void loop() {
SerialUSB.print("D3 = ");
SerialUSB.println(protocol.getDataThree(),HEX);
}
}
// objet thislora qui appele classe Lora.h et rempli la stucture de l'objet protocol, ser a allèger -5lignes

10
WebServer/inde.htm Normal file
View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<title>Arduino SD Card Web Page</title>
</head>
<body>
<h1>Hello from the Arduino SD Card!</h1>
<p>A web page from the Arduino SD card server.</p>
</body>
</html>

View File

@ -7,16 +7,8 @@
#include <CModemLoRa.h> // to use personalised LoRa class
#include <CProtocol12Bytes.h> // to use our protocol
CModemLoRa thisLoRa; // create object for personnalizeed LoRa class
CProtocol12Bytes goodOne; // create object to store data using our protocol
int ts1=0; // for comparing later the LoRa frames using timestamp data
int ts2=0; // for comparing later the LoRa frames using timestamp data
int id1=0; // for comparing later the LoRa frames using ID data
int id2=0; // for comparing later the LoRa frames using ID data
bool readFrameAndCheckID(); // function that compares station's ID
bool readFrameAndCheckTS(); // function that compares frame's TimeStamp
CModemLoRa receiveLoRa; // create object for personnalizeed LoRa class
CProtocol12Bytes goodOne; // create object that will be used to send data using our protocol
void setup(){
Serial.begin(9600);
@ -30,22 +22,6 @@ void loop() {
// frame treatment
while(readFrameAndCheckID() == true){
// post to server
EthernetClient postClient;
String postData = "ID="+String(goodOne.getStationId())+"&IDp="+String(goodOne.getGatewayId())+"&TS="+String(goodOne.getTimestampMessage())+"&DT="+String(goodOne.getDataType())+"&D1="+String(goodOne.getDataOne())+"&D2="+String(goodOne.getDataTwo())+"&D3="+String(goodOne.getDataThree());
if (postClient.connect("btslimayrac.ovh", 80)){
postClient.print("POST /weather/formulaire/formulaireCollecteLORA.php HTTP/1.1\n");
postClient.print("Host: btslimayrac.ovh\n");
postClient.print("Connection: close\n");
postClient.print("Content-Type: application/x-www-form-urlencoded\n");
postClient.print("Content-Length: ");
postClient.print(postData.length());
postClient.print("\n\n");
postClient.print(postData);
Serial.println("Post to server sent");
}
else{
Serial.println("Post failed");
}
}
}// end void loop