Compare commits
No commits in common. "TestLimitesLoRa" and "master" have entirely different histories.
TestLimite
...
master
3 changed files with 30 additions and 25 deletions
|
@ -2,7 +2,6 @@
|
||||||
#include "sim5215_umts_shield.h"
|
#include "sim5215_umts_shield.h"
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
#include <LoRa.h>
|
#include <LoRa.h>
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
Shield shield(5,3,4);
|
Shield shield(5,3,4);
|
||||||
|
|
||||||
|
@ -10,8 +9,6 @@ const int pinNSS = 10;
|
||||||
const int pinRST = 9;
|
const int pinRST = 9;
|
||||||
const int pinDIO0 = 2;
|
const int pinDIO0 = 2;
|
||||||
|
|
||||||
char num[] = "0659377414";
|
|
||||||
|
|
||||||
struct message {
|
struct message {
|
||||||
int vers;
|
int vers;
|
||||||
int type;
|
int type;
|
||||||
|
@ -39,10 +36,7 @@ void setup() {
|
||||||
// Initialisation de shield
|
// Initialisation de shield
|
||||||
Serial.println("Initialisation shield UMTS");
|
Serial.println("Initialisation shield UMTS");
|
||||||
shield.power_on();
|
shield.power_on();
|
||||||
char pin[] = "0000";
|
shield.init("0000", "mmsbouygtel.com", "", "");
|
||||||
char fournisseur[] = "mmsbouygtel.com";
|
|
||||||
char useless[] = "";
|
|
||||||
shield.init(pin, fournisseur, useless, useless);
|
|
||||||
|
|
||||||
// Initialisation LoRa
|
// Initialisation LoRa
|
||||||
Serial.println("Initialisation LoRa transceiver");
|
Serial.println("Initialisation LoRa transceiver");
|
||||||
|
@ -52,14 +46,6 @@ void setup() {
|
||||||
delay(500);
|
delay(500);
|
||||||
}
|
}
|
||||||
LoRa.setSyncWord(0x12);
|
LoRa.setSyncWord(0x12);
|
||||||
|
|
||||||
// Notification de fin d'initialisation
|
|
||||||
Serial.println("Notification de l'utilisateur");
|
|
||||||
turnOnLed(Red);
|
|
||||||
char message[] = "Gateway initialised";
|
|
||||||
shield.sendTextMessage(num, message);
|
|
||||||
turnOffLed(Red);
|
|
||||||
|
|
||||||
|
|
||||||
// Fin de l'initialisation
|
// Fin de l'initialisation
|
||||||
Serial.println("Initialisation completed");
|
Serial.println("Initialisation completed");
|
||||||
|
@ -76,11 +62,9 @@ void receiveLoRa() {
|
||||||
while (LoRa.available()) {
|
while (LoRa.available()) {
|
||||||
String stringData = LoRa.readString();
|
String stringData = LoRa.readString();
|
||||||
const char* LoRaData = stringData.c_str();
|
const char* LoRaData = stringData.c_str();
|
||||||
int partie_entiere = 0;
|
int partie_entiere;
|
||||||
int partie_decimale = 0;
|
int partie_decimale;
|
||||||
sscanf(LoRaData, "%d-%d-%d-%d.%d", &(msg.vers), &(msg.type), &(msg.cameraId), &partie_entiere, &partie_decimale);
|
sscanf(LoRaData, "%d-%d-%d-%d.%d", &(msg.vers), &(msg.type), &(msg.cameraId), &partie_entiere, &partie_decimale);
|
||||||
msg.vers = 1;
|
|
||||||
msg.type = 2;
|
|
||||||
msg.data = float(partie_entiere) + (float(partie_decimale))/100;
|
msg.data = float(partie_entiere) + (float(partie_decimale))/100;
|
||||||
Serial.print(LoRaData);
|
Serial.print(LoRaData);
|
||||||
Serial.print("");
|
Serial.print("");
|
||||||
|
@ -115,16 +99,36 @@ void processMessage() {
|
||||||
int port = 80;
|
int port = 80;
|
||||||
//Event
|
//Event
|
||||||
if (msg.type == 1) {
|
if (msg.type == 1) {
|
||||||
//Rien
|
char request[150];
|
||||||
|
sprintf(request, "POST /api/cameras/%d/counter HTTP/1.1\r\nHost: rasp.pikouri.fr\r\n\r\n", msg.cameraId);
|
||||||
|
Serial.println(request);
|
||||||
|
turnOnLed(Red);
|
||||||
|
shield.sendTextMessage("0672654516", "[Smart Camera 1] Funny bird detected!");
|
||||||
|
if (shield.sendPOSTrequest(url, port, request, 20000) == 3) {
|
||||||
|
shield.power_on();
|
||||||
|
delay(1000);
|
||||||
|
shield.power_on();
|
||||||
|
shield.init("0000", "mmsbouygtel.com", "", "");
|
||||||
|
} else {
|
||||||
|
Serial.println("Request sent\n\n\n");
|
||||||
|
}
|
||||||
|
turnOffLed(Red);
|
||||||
}
|
}
|
||||||
//Temperature
|
//Temperature
|
||||||
else if (msg.type == 2) {
|
else if (msg.type == 2) {
|
||||||
char message[200];
|
char request[200];
|
||||||
String tempData = String(msg.data);
|
String tempData = String(msg.data);
|
||||||
sprintf(message, "Temperature recue : %s", tempData.c_str());
|
sprintf(request, "POST /api/cameras/%d/temperature HTTP/1.1\r\nHost: rasp.pikouri.fr\r\nContent-Type: application/json\r\nContent-Length: %d\r\n\r\n%s", msg.cameraId, tempData.length(),tempData.c_str());
|
||||||
Serial.println(message);
|
Serial.println(request);
|
||||||
turnOnLed(Red);
|
turnOnLed(Red);
|
||||||
shield.sendTextMessage(num, message);
|
if (shield.sendPOSTrequest(url, port, request, 20000) == 3) {
|
||||||
|
shield.power_on();
|
||||||
|
delay(1000);
|
||||||
|
shield.power_on();
|
||||||
|
shield.init("0000", "mmsbouygtel.com", "", "");
|
||||||
|
} else {
|
||||||
|
Serial.println("Request sent\n\n\n");
|
||||||
|
}
|
||||||
turnOffLed(Red);
|
turnOffLed(Red);
|
||||||
} else {
|
} else {
|
||||||
Serial.print("Type not indentified: ");
|
Serial.print("Type not indentified: ");
|
||||||
|
|
|
@ -24,6 +24,7 @@ int Shield::init(char pin_number[], char apn[], char user_name[], char password[
|
||||||
|
|
||||||
while( (sendATcommand("AT+CREG?", "+CREG: 0,1", 500) || sendATcommand("AT+CREG?", "+CREG: 0,5", 500)) == 0 );
|
while( (sendATcommand("AT+CREG?", "+CREG: 0,1", 500) || sendATcommand("AT+CREG?", "+CREG: 0,5", 500)) == 0 );
|
||||||
|
|
||||||
|
Serial.print("Setting SMS mode...");
|
||||||
sendATcommand("AT+CMGF=1", "OK", 1000); // sets the SMS mode to text
|
sendATcommand("AT+CMGF=1", "OK", 1000); // sets the SMS mode to text
|
||||||
|
|
||||||
// sets APN, user name and password
|
// sets APN, user name and password
|
||||||
|
|
|
@ -15,7 +15,7 @@ const int pinRST = 9;
|
||||||
const int pinDIO0 = 3;
|
const int pinDIO0 = 3;
|
||||||
|
|
||||||
volatile boolean movementState = false;
|
volatile boolean movementState = false;
|
||||||
volatile boolean mesurementState = true;
|
volatile boolean mesurementState = false;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// Initialisation du moniteur série
|
// Initialisation du moniteur série
|
||||||
|
|
Loading…
Reference in a new issue