-
Notifications
You must be signed in to change notification settings - Fork 2
/
centrale.ino
60 lines (53 loc) · 1.38 KB
/
centrale.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <GSM.h>
#define PINNUMBER "1234"
GSM gsmAccess;
GSM_SMS sms;
GSMVoiceCall vcs;
boolean alert = false;
void setup() {
Serial.begin(9600);
Serial1.begin(9600);
boolean notConnected = true;
while (notConnected) {
if (gsmAccess.begin(PINNUMBER) == GSM_READY) {
notConnected = false;
} else {
Serial.println("Not connected");
delay(1000);
}
}
}
void loop() {
while (Serial.available()) {
String data = Serial.readString();
Serial1.print("DM_R1");
Serial.println("DM_R1");
}
while (Serial1.available()) {
Serial.println("Reception <- " + Serial1.readString());
}
}
void sendSms(String msg)
{
sms.beginSMS("0611511932");
sms.print(msg);
sms.endSMS();
}
void callGsm(){
String remoteNumber = "0611511932";
char charbuffer[20];
if (remoteNumber.length() < 20) {
remoteNumber.toCharArray(charbuffer, 20);
if (vcs.voiceCall(charbuffer)) {
while (Serial.read() != '\n' && (vcs.getvoiceCallStatus() == TALKING));
vcs.hangCall();
}
remoteNumber = "";
} else {
Serial.println("That's too long for a phone number. I'm forgetting it");
remoteNumber = "";
}
}
String protocol(String id, String masse, String temperature, String humidity) {
return "D" + id + ";" + masse + ";" + temperature + ";" + humidity;
}