Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
b8b464b963 |
@ -13,7 +13,6 @@ void setup() {
|
||||
}
|
||||
|
||||
void loop() {
|
||||
//SerialUSB.println("Frame received");
|
||||
int packetSize = thisLoRa.parsePacket();
|
||||
if (packetSize > 0)
|
||||
{
|
||||
|
@ -3,22 +3,24 @@
|
||||
#include <CModemLoRa.h>
|
||||
#include <CProtocol12Bytes.h>
|
||||
|
||||
//#define Serial SerialUSB
|
||||
|
||||
CProtocol12Bytes protocol;
|
||||
CModemLoRa thisLoRa;
|
||||
|
||||
uint16_t incrTS=0x0000;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Serial.println("LoRa Sender");
|
||||
|
||||
SerialUSB.begin(9600);
|
||||
SerialUSB.println("LoRa Sender");
|
||||
thisLoRa.begin();
|
||||
protocol.codeFrame(0x0A,0x00,0x0000,0x00FF,0x5BA2,0x0D4C,0x929A); // Name : LORA-TEST1 or 0x929A for *2
|
||||
|
||||
char pacomeName[] = {'T', 'E', 'S', 'T', '-', 'L', 'O', 'R', 'A', '1'};
|
||||
uint16_t datas[] = {0x0000, 0x0000, 0x0000};
|
||||
|
||||
transform(pacomeName, datas);
|
||||
protocol.codeFrame(0x0B,0x00,0x0000,0x0001,datas[0],datas[1],datas[2]);
|
||||
|
||||
LoRa.beginPacket();
|
||||
LoRa.write((uint8_t*)&protocol, 12); // Send name
|
||||
LoRa.write((uint8_t*)&protocol, 12);
|
||||
LoRa.endPacket();
|
||||
}
|
||||
|
||||
@ -26,32 +28,32 @@ void loop()
|
||||
{
|
||||
protocol.setDataOne((uint16_t)(random(500, 750)));
|
||||
protocol.setDataTwo((uint16_t)(random(40, 60)));
|
||||
protocol.setDataThree((uint16_t)(random(0, 2)));
|
||||
protocol.setDataThree((uint16_t)(random(0, 1)));
|
||||
incrTS = protocol.getTimestampMessage()+1;
|
||||
protocol.setTimestampMessage(incrTS);
|
||||
|
||||
Serial.print("ID = ");
|
||||
Serial.print(protocol.getStationId(),HEX);
|
||||
Serial.println(protocol.getGatewayId(),HEX);
|
||||
Serial.print("TS = ");
|
||||
Serial.println(protocol.getTimestampMessage(),HEX);
|
||||
Serial.print("DT = ");
|
||||
Serial.println(protocol.getDataType(),HEX);
|
||||
Serial.print("D1 = ");
|
||||
Serial.println(protocol.getDataOne(),HEX);
|
||||
Serial.print("D2 = ");
|
||||
Serial.println(protocol.getDataTwo(),HEX);
|
||||
Serial.print("D3 = ");
|
||||
Serial.println(protocol.getDataThree(),HEX);
|
||||
SerialUSB.print("ID = ");
|
||||
SerialUSB.print(protocol.getStationId(),HEX);
|
||||
SerialUSB.println(protocol.getGatewayId(),HEX);
|
||||
SerialUSB.print("TS = ");
|
||||
SerialUSB.println(protocol.getTimestampMessage(),HEX);
|
||||
SerialUSB.print("DT = ");
|
||||
SerialUSB.println(protocol.getDataType(),HEX);
|
||||
SerialUSB.print("D1 = ");
|
||||
SerialUSB.println(protocol.getDataOne(),HEX);
|
||||
SerialUSB.print("D2 = ");
|
||||
SerialUSB.println(protocol.getDataTwo(),HEX);
|
||||
SerialUSB.print("D3 = ");
|
||||
SerialUSB.println(protocol.getDataThree(),HEX);
|
||||
|
||||
for(int i=0; i<3; i++){
|
||||
Serial.println("Frame sent !");
|
||||
SerialUSB.println("Frame sent !");
|
||||
LoRa.beginPacket();
|
||||
LoRa.write((uint8_t*)&protocol, 12);
|
||||
LoRa.endPacket();
|
||||
|
||||
Serial.println("-----------------------------");
|
||||
SerialUSB.println("-----------------------------");
|
||||
delay(4000);
|
||||
}
|
||||
delay(10000);
|
||||
}
|
||||
}
|
||||
|
273
fakeStation/nameFunctions.ino
Normal file
273
fakeStation/nameFunctions.ino
Normal file
@ -0,0 +1,273 @@
|
||||
void transform(char stationName[], uint16_t dataArray[])
|
||||
{
|
||||
// 9 characters on 5 bits
|
||||
// 1 number on 3 bits
|
||||
// Frame : xxxxx|xxx.xx|xxxxx|x.xxxx|xxxx.x|xxxxx|xx.xxx|xxxxx|.xxxxx|xxx
|
||||
|
||||
dataArray[0] = (dataArray[0] << 5) | convertCharacterToNumber(stationName[0]);
|
||||
dataArray[0] = (dataArray[0] << 5) | convertCharacterToNumber(stationName[1]);
|
||||
dataArray[0] = (dataArray[0] << 5) | convertCharacterToNumber(stationName[2]);
|
||||
dataArray[0] = (dataArray[0] << 1) | (convertCharacterToNumber(stationName[3]) >> 4);
|
||||
|
||||
dataArray[1] = (dataArray[1] << 5) | convertCharacterToNumber(stationName[3]);
|
||||
dataArray[1] = (dataArray[1] << 5) | convertCharacterToNumber(stationName[4]);
|
||||
dataArray[1] = (dataArray[1] << 5) | convertCharacterToNumber(stationName[5]);
|
||||
dataArray[1] = (dataArray[1] << 2) | (convertCharacterToNumber(stationName[6]) >> 3);
|
||||
|
||||
dataArray[2] = (dataArray[2] << 5) | convertCharacterToNumber(stationName[6]);
|
||||
dataArray[2] = (dataArray[2] << 5) | convertCharacterToNumber(stationName[7]);
|
||||
dataArray[2] = (dataArray[2] << 5) | convertCharacterToNumber(stationName[8]);
|
||||
dataArray[2] = (dataArray[2] << 3) | convertCharacterNumberToNumber(stationName[9]);
|
||||
}
|
||||
|
||||
uint8_t convertCharacterNumberToNumber(char myCharacter)
|
||||
{
|
||||
switch(myCharacter)
|
||||
{
|
||||
case '0':
|
||||
{
|
||||
return(0);
|
||||
break;
|
||||
}
|
||||
|
||||
case '1':
|
||||
{
|
||||
return(1);
|
||||
break;
|
||||
}
|
||||
|
||||
case '2':
|
||||
{
|
||||
return(2);
|
||||
break;
|
||||
}
|
||||
|
||||
case '3':
|
||||
{
|
||||
return(3);
|
||||
break;
|
||||
}
|
||||
|
||||
case '4':
|
||||
{
|
||||
return(4);
|
||||
break;
|
||||
}
|
||||
|
||||
case '5':
|
||||
{
|
||||
return(5);
|
||||
break;
|
||||
}
|
||||
|
||||
case '6':
|
||||
{
|
||||
return(6);
|
||||
break;
|
||||
}
|
||||
|
||||
case '7':
|
||||
{
|
||||
return(7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t convertCharacterToNumber(char myCharacter)
|
||||
{
|
||||
switch(myCharacter)
|
||||
{
|
||||
case 'A':
|
||||
{
|
||||
return(0);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'B':
|
||||
{
|
||||
return(1);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'C':
|
||||
{
|
||||
return(2);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'D':
|
||||
{
|
||||
return(3);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'E':
|
||||
{
|
||||
return(4);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'F':
|
||||
{
|
||||
return(5);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'G':
|
||||
{
|
||||
return(6);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'H':
|
||||
{
|
||||
return(7);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'I':
|
||||
{
|
||||
return(8);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'J':
|
||||
{
|
||||
return(9);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'K':
|
||||
{
|
||||
return(10);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'L':
|
||||
{
|
||||
return(11);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'M':
|
||||
{
|
||||
return(12);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'N':
|
||||
{
|
||||
return(13);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'O':
|
||||
{
|
||||
return(14);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'P':
|
||||
{
|
||||
return(15);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'Q':
|
||||
{
|
||||
return(16);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'R':
|
||||
{
|
||||
return(17);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'S':
|
||||
{
|
||||
return(18);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'T':
|
||||
{
|
||||
return(19);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'U':
|
||||
{
|
||||
return(20);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'V':
|
||||
{
|
||||
return(21);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'W':
|
||||
{
|
||||
return(22);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'X':
|
||||
{
|
||||
return(23);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'Y':
|
||||
{
|
||||
return(24);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'Z':
|
||||
{
|
||||
return(25);
|
||||
break;
|
||||
}
|
||||
|
||||
case '-':
|
||||
{
|
||||
return(26);
|
||||
break;
|
||||
}
|
||||
|
||||
case '.':
|
||||
{
|
||||
return(27);
|
||||
break;
|
||||
}
|
||||
|
||||
case '/':
|
||||
{
|
||||
return(28);
|
||||
break;
|
||||
}
|
||||
|
||||
case '\rr':
|
||||
{
|
||||
return(29);
|
||||
break;
|
||||
}
|
||||
|
||||
case '(':
|
||||
{
|
||||
return(30);
|
||||
break;
|
||||
}
|
||||
|
||||
case ')':
|
||||
{
|
||||
return(31);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -16,7 +16,12 @@ CProtocol12Bytes protocol; // create object to
|
||||
//File webFile; // variable for the file containing the webpage
|
||||
|
||||
String postData;
|
||||
String row;
|
||||
String tsarray;
|
||||
String oldpostData;
|
||||
|
||||
//Pour comparer les timestamps
|
||||
uint16_t tstamp_old;
|
||||
uint16_t tstamp_now;
|
||||
|
||||
byte mac[] = {0xFA, 0xE3, 0x40, 0xEF, 0xFF, 0xFD}; // set the mac address
|
||||
//IPAddress ip(192, 1, 1, 150); // set the IP address for the ethernet shield, overwise the librairy use DHCP
|
||||
@ -65,8 +70,8 @@ void loop() {
|
||||
if(protocol.getTimestampMessage() == saveIDandTS[numCase])
|
||||
{}
|
||||
else{
|
||||
tstamp_now = protocol.getTimestampMessage();
|
||||
saveIDandTS[numCase] = protocol.getTimestampMessage();
|
||||
row += "<tr><td>" + String(protocol.getStationId())+"</td><td>"+String(protocol.getGatewayId())+"</td><td>"+String(protocol.getTimestampMessage())+"</td><td>" + String(protocol.getDataType())+"</td><td>" + String(protocol.getDataOne())+"</td><td>" + String(protocol.getDataTwo())+"</td><td>" + String(protocol.getDataThree())+"</td></tr>";
|
||||
//post to server
|
||||
EthernetClient postClient;
|
||||
postData = "ID="+String(protocol.getStationId())+"&IDp="+String(protocol.getGatewayId())+"&TS="+String(protocol.getTimestampMessage())+"&DT="+String(protocol.getDataType())+"&D1="+String(protocol.getDataOne())+"&D2="+String(protocol.getDataTwo())+"&D3="+String(protocol.getDataThree());
|
||||
@ -81,28 +86,12 @@ void loop() {
|
||||
postClient.print(postData); // to send the concatenated frame
|
||||
SerialUSB.println("Post to server sent"); // to display the sent frame
|
||||
SerialUSB.println(postData);
|
||||
delay(10);
|
||||
delay(4000);
|
||||
}
|
||||
else{
|
||||
SerialUSB.println("Post failed");
|
||||
SerialUSB.println(" New attempt to POST");
|
||||
if (postClient.connect("btslimayrac.ovh", 80)){
|
||||
postClient.print("POST /weather/formulaire/formulaireCollecteLORA.php HTTP/1.1\n");
|
||||
postClient.print("Host: btslimayrac.ovh\n"); // specifies the Internet host and port number of the resource being requested
|
||||
postClient.print("Connection: close\n"); // header option to signal that the connection will be closed after completion of the response
|
||||
postClient.print("Content-Type: application/x-www-form-urlencoded\n"); // values are encoded in key-value separated by '&', with a '=' between the key and the value
|
||||
postClient.print("Content-Length: "); // indicates the size of the entity-body, in decimal number of bytes
|
||||
postClient.print(postData.length()); // to retrieve the size and send it
|
||||
postClient.print("\n\n");
|
||||
postClient.print(postData); // to send the concatenated frame
|
||||
SerialUSB.println("Post to server sent"); // to display the sent frame
|
||||
SerialUSB.println(postData);
|
||||
delay(10);
|
||||
}
|
||||
else{
|
||||
SerialUSB.println("Post miserably failed, can't connect to btslimayrac.ovh, check your network's settings");
|
||||
}//end of secnd else
|
||||
}//end of first else
|
||||
delay(100);
|
||||
SerialUSB.println("New frame recieved : ");
|
||||
SerialUSB.print("ID = ");
|
||||
SerialUSB.print(protocol.getStationId(),HEX);
|
||||
@ -117,8 +106,6 @@ void loop() {
|
||||
SerialUSB.println(protocol.getDataTwo(),HEX);
|
||||
SerialUSB.print("D3 = ");
|
||||
SerialUSB.println(protocol.getDataThree(),HEX);
|
||||
SerialUSB.print("You can see the web interface at :");
|
||||
SerialUSB.println(Ethernet.localIP());
|
||||
}
|
||||
}//if (packetSize > 0)
|
||||
|
||||
@ -140,7 +127,7 @@ void loop() {
|
||||
serverGateway.println("<!DOCTYPE HTML>");
|
||||
serverGateway.println("<html>");
|
||||
serverGateway.print("<head>");
|
||||
serverGateway.print("<meta http-equiv=\"refresh\" content=\"15\">");
|
||||
serverGateway.print("<meta http-equiv=\"refresh\" content=\"30\">");
|
||||
serverGateway.print("<meta charset=\"utf-8\" />");
|
||||
serverGateway.print("<link href=\"data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAABILAAASCwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZWZmAHV2dgKNjo4Rent7A3JzcwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADhIrAL+/wgCnqKw3zMvMvayoqD0AAAACFRMaAMwAAAAAAAAAAAAAAAAAAAAAAAAA0stPANLLTwLTzFAi08xQPNPMUD3Sy0g6ycWOiq6+tP00gorYHHV1mLO2UDfd01AL08xQAM3ITAAAAAAA0stPANLLTgLTzFBm08xQ3tPMUPTTzFD108xQ9NTKTvZfr4X+ALjJ/zypl/3IxFDw1M1QptPMTxnTzE8AAAAAANPMUADTzFAt08xQ5dPMUP/TzFD/08xQ/9PMUP/UzE//or1g/2O6m/+sx8L/zch6/9LLTv/TzFB80cxUANnNRgDTzFAA08xQTdPMUPvTzFD/08xQ/9PMUP/TzFD/08xQ/9XMTv/RyGH/zMie/8nEbf/TzE//yslZsk+l1AoqmvkK08xQANPMUCvTzFDj08xQ/9PMUP/TzFD/08xQ/9PMUP/TzFD/0stQ/9DJUP/UzE7/1MxP/8HGYogjl/w1KJj2KtLMTwDSy04C08xQYtPMUOLTzFD/08xQ/9PMUP/TzFD/08xQ/9PMUP/UzFD/yc1Z/4TPk/8tv+SjKJf8IymZ9hsAAAAA08xPANPMUgDTzFBS08xQ9dPMUP/TzFD/08xQ/9PMUP/TzFD/1cxO/27Rpf8G1vv/Bs3+8h2p+EwnlPUgAAAAAAAAAADSy1AA0stPCtPMUHPTzFCi08xQ29PMUP/TzFD/1sxO/7/NYf8r1Nz/ANf//wbO/vIZrfhEJZP2JgAAAAAAAAAAAAAAANHKTwDRyk4At6ozANPMUD7UzE+608xQ47HJbfJH0cX/A9b+/wTS/voOwfuUL5z1Jiya9RUAAAAAAAAAAAAAAAAAAAAAAAAAANLLTwA6nuIAW6jDKXiwqkg+rthcC739rgvD/LkUufpoLJ72KTKd9jkxnfYPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGpP8AB+V+hMblP0NKJf4FiuU9TAnlPUoKZf1OyeY9RonmPYSLJv2CwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAI5b2ACSW9gkklvUTH5X2ASKW9h4ml/UGKJn1AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//8AAP4/AAD+HwAAwAcAAIADAACAAwAAgAAAAIAAAACAAAAA4AAAAOAAAADwAAAA/gAAAP4AAAD/gwAA//8AAA==\" rel=\"icon\" type=\"image/x-icon\" />");
|
||||
serverGateway.print("</head>");
|
||||
@ -148,11 +135,10 @@ void loop() {
|
||||
serverGateway.println("html{font-family:\"Trebuchet MS\";text-align:center;background-color:white;color:black}");
|
||||
serverGateway.println("h1{text-align:center;color:red;font-size:72px}");
|
||||
serverGateway.println("h2{text-align:center;color:red;font-size:36px}");
|
||||
serverGateway.println("p{text-align:center;font-size:25px}");
|
||||
serverGateway.println("table,th,td{border:2px outset black;font-size:25px}");
|
||||
serverGateway.println("p{text-align:center;font-size:36px}");
|
||||
serverGateway.println("table,th,td{border:2px outset black;font-size:56px}");
|
||||
serverGateway.println("</style>");
|
||||
serverGateway.println("<h1>IHM Web Passerelle</h1>");
|
||||
serverGateway.println("<p>Dernière trame envoyée</p>");
|
||||
serverGateway.println("<p>ID station : ");
|
||||
serverGateway.print(protocol.getStationId());
|
||||
serverGateway.print("<br />");
|
||||
@ -174,19 +160,19 @@ void loop() {
|
||||
serverGateway.println("Données 3 :");
|
||||
serverGateway.print(protocol.getDataThree());
|
||||
serverGateway.print("</p>");
|
||||
serverGateway.print("<br/><br/>");
|
||||
serverGateway.print("<h2>Historique des dernières trames envoyées :</h2>");
|
||||
serverGateway.print("<br /> <br /> <br /> <br />");
|
||||
serverGateway.print("<h2>20 dernières trames reçues :</h2>");
|
||||
serverGateway.print("<table style=\"width:100%\">");
|
||||
serverGateway.print("<tr>");
|
||||
serverGateway.print("<th>Identifiant station</th>");
|
||||
serverGateway.print("<th>Identifiant passerelle</th>");
|
||||
serverGateway.print("<th>TimeStamp</th>");
|
||||
serverGateway.print("<th>Type de données</th>");
|
||||
serverGateway.print("<th>Donnée 1</th>");
|
||||
serverGateway.print("<th>Donnée 2</th>");
|
||||
serverGateway.print("<th>Donnée 3</th>");
|
||||
serverGateway.print("<th>ID</th>");
|
||||
serverGateway.print("<th>IDp</th>");
|
||||
serverGateway.print("<th>TS</th>");
|
||||
serverGateway.print("<th>DT</th>");
|
||||
serverGateway.print("<th>D1</th>");
|
||||
serverGateway.print("<th>D2</th>");
|
||||
serverGateway.print("<th>D3</th>");
|
||||
serverGateway.print("</tr>");
|
||||
serverGateway.print(row);
|
||||
//serverGateway.print(tsarray);
|
||||
serverGateway.print("</table>");
|
||||
serverGateway.println("</html>");
|
||||
break;
|
||||
@ -204,7 +190,7 @@ void loop() {
|
||||
} // end if (client.available())
|
||||
} // end while (client.connected())
|
||||
delay(1); // give the web browser time to receive the data
|
||||
serverGateway.stop(); // close the connection
|
||||
serverGateway.stop(); // close the connection
|
||||
break;
|
||||
}//end if (serverGateway)
|
||||
}//end void loop
|
||||
|
Loading…
Reference in New Issue
Block a user