-
Notifications
You must be signed in to change notification settings - Fork 0
/
smarteverything-hello-world.ino
69 lines (65 loc) · 1.18 KB
/
smarteverything-hello-world.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
61
62
63
64
65
66
67
68
69
#include <Arduino.h>
#include <Wire.h>
#define DELAY 600000
void setup() {
SerialUSB.begin(115200);
SigFox.begin(19200);
delay(500);
blink();
}
void loop() {
resetLEDs();
ledBlueLight(HIGH);
// put your main code here, to run repeatedly:
bool success;
success = sendSigfox("CAFE");
ledBlueLight(LOW);
if (success){
ledGreenLight(HIGH);
}
else{
ledRedLight(HIGH);
}
delay(2000);
resetLEDs();
delay(DELAY);
}
bool sendSigfox(String frame){
String status = "";
char output;
SerialUSB.print("AT$SF=");
SerialUSB.println(frame);
SigFox.print("AT$SF=");
SigFox.print(frame);
SigFox.print("\r");
while (!SigFox.available());
while(SigFox.available()){
output = (char)SigFox.read();
status += output;
SerialUSB.println(output);
delay(10);
}
SerialUSB.print("Status \t");
SerialUSB.println(status);
if (status == "OK\r"){
//Success :)
return true;
}
else{
return false;
}
delay(DELAY);
}
void resetLEDs(){
ledRedLight(LOW);
ledGreenLight(LOW);
ledBlueLight(LOW);
}
void blink(){
ledRedLight(HIGH);
delay(500);
ledRedLight(LOW);
delay(500);
ledGreenLight(HIGH);
delay(500);
}