-
Notifications
You must be signed in to change notification settings - Fork 0
/
homeeasyhacking.ino
66 lines (52 loc) · 1.3 KB
/
homeeasyhacking.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
/*
* Example program using the HomeEasy class.
*/
#include "HomeEasy.h"
#include <Bridge.h>
#include <Process.h>
#include <HttpClient.h>
HomeEasy homeEasy;
Process script;
String lightson = "on";
String lightsoff = "off";
/**
* Set up the serial interface and the HomeEasy class.
*/
void setup()
{
Serial.begin(9600);
homeEasy = HomeEasy();
Bridge.begin();
//SerialUSB.begin(9600);
//homeEasy.registerSimpleProtocolHandler(printSimpleResult);
//homeEasy.registerAdvancedProtocolHandler(printAdvancedResult);
homeEasy.init();
//while (!SerialUSB);
}
/**
* No processing is required in the loop for receiving.
*/
void loop()
{
delay(1000); //3600000
HttpClient client;
client.get("http://localhost/ascii.txt");
unsigned long sender = 87729750; //20620886
unsigned int recipient = 0;
bool command = true;
bool group = false;
String dataString = "";
while (client.available()) {
char c = client.read();
dataString += c;
if (lightson == dataString) {
Serial.println(c);
command = true;
homeEasy.sendAdvancedProtocolMessage(sender, recipient, command, group);
} else if (lightsoff == dataString) {
Serial.println(c);
command = false;
homeEasy.sendAdvancedProtocolMessage(sender, recipient, command, group);
}
}
}