Compare commits
1 commit
master
...
TestLimite
Author | SHA1 | Date | |
---|---|---|---|
f5aaa47537 |
3 changed files with 25 additions and 30 deletions
|
@ -2,6 +2,7 @@
|
||||||
#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);
|
||||||
|
|
||||||
|
@ -9,6 +10,8 @@ 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;
|
||||||
|
@ -36,7 +39,10 @@ void setup() {
|
||||||
// Initialisation de shield
|
// Initialisation de shield
|
||||||
Serial.println("Initialisation shield UMTS");
|
Serial.println("Initialisation shield UMTS");
|
||||||
shield.power_on();
|
shield.power_on();
|
||||||
shield.init("0000", "mmsbouygtel.com", "", "");
|
char pin[] = "0000";
|
||||||
|
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");
|
||||||
|
@ -47,6 +53,14 @@ void setup() {
|
||||||
}
|
}
|
||||||
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");
|
||||||
turnOnLed(Green);
|
turnOnLed(Green);
|
||||||
|
@ -62,9 +76,11 @@ 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;
|
int partie_entiere = 0;
|
||||||
int partie_decimale;
|
int partie_decimale = 0;
|
||||||
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("");
|
||||||
|
@ -99,36 +115,16 @@ void processMessage() {
|
||||||
int port = 80;
|
int port = 80;
|
||||||
//Event
|
//Event
|
||||||
if (msg.type == 1) {
|
if (msg.type == 1) {
|
||||||
char request[150];
|
//Rien
|
||||||
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 request[200];
|
char message[200];
|
||||||
String tempData = String(msg.data);
|
String tempData = String(msg.data);
|
||||||
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());
|
sprintf(message, "Temperature recue : %s", tempData.c_str());
|
||||||
Serial.println(request);
|
Serial.println(message);
|
||||||
turnOnLed(Red);
|
turnOnLed(Red);
|
||||||
if (shield.sendPOSTrequest(url, port, request, 20000) == 3) {
|
shield.sendTextMessage(num, message);
|
||||||
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,7 +24,6 @@ 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 = false;
|
volatile boolean mesurementState = true;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// Initialisation du moniteur série
|
// Initialisation du moniteur série
|
||||||
|
|
Loading…
Reference in a new issue