@ -0,0 +1,8 @@
|
||||
{{layout "fluid"}}
|
||||
{{#zone "title"}}
|
||||
WSO2 DC | FireAlarm
|
||||
{{/zone}}
|
||||
{{#zone "body"}}
|
||||
{{unit "appbar"}}
|
||||
{{unit "digitaldisplay"}}
|
||||
{{/zone}}
|
@ -0,0 +1,80 @@
|
||||
{{#zone "main"}}
|
||||
<div class="container container-bg white-bg">
|
||||
<div class=" margin-top-double">
|
||||
<div class="row row padding-top-double padding-bottom-double margin-bottom-double">
|
||||
<div class="col-lg-12 margin-top-double">
|
||||
<h1 class="grey ">Digital Display</h1>
|
||||
<hr>
|
||||
<p class="margin-bottom-double light-grey ">Connect your Digital Display device
|
||||
to the WSO2 device cloud. </p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row margin-bottom-double">
|
||||
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-4 padding-top">
|
||||
<img src="{{self.publicURL}}/images/digital_display.png" class="img-responsive">
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6 col-md-8 col-lg-8 padding-top">
|
||||
<h2 class="uppercase">Ingredients</h2>
|
||||
<hr>
|
||||
<p class="grey margin-top">Hardware Requirements </p>
|
||||
<br><br>
|
||||
<span class="fw-stack fw-lg margin-right">
|
||||
<i class="fw fw-ring fw-stack-2x"> </i>
|
||||
<i class="fw fw-right-arrow-2 fw-stack-1x"></i>
|
||||
</span>Arduino Uno<br><br>
|
||||
<span class="fw-stack fw-lg margin-right">
|
||||
<i class="fw fw-ring fw-stack-2x"> </i>
|
||||
<i class="fw fw-right-arrow-2 fw-stack-1x"></i>
|
||||
</span>Arduino Ethernet / WiFi Shield
|
||||
<br /><br />
|
||||
<form method="POST" class="float-left margin-right"
|
||||
action="{{sketchPath}}">
|
||||
<input type="hidden" name="deviceType" value="digitaldisplay" />
|
||||
<input type="hidden" name="sketchType" value="digitaldisplay" />
|
||||
<button class="blue-btn" type="submit">Download DEB
|
||||
</button>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<div class ="col-xs-12 col-sm-6 col-md-3 col-lg-12 padding-double grey-bg ">
|
||||
<h2 class="uppercase">Prepare</h2><hr>
|
||||
<p class="grey margin-top">Get your device ready </p>
|
||||
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom ">
|
||||
<span class="circle">01 </span> <span class="padding-left"> Mount the Ethernet / Wifi shield on the Arduino Uno device.</span>
|
||||
</div>
|
||||
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom">
|
||||
<span class="circle">02 </span> <span class="padding-left"> Mount the Ethernet / Wifi shield on the Arduino Uno device.</span>
|
||||
</div>
|
||||
<div class="margin-doubles padding-top-double margin-bottom-double light-grey margin-left-double margin-bottom">
|
||||
<span class="circle">03 </span> <span class="padding-left"> Mount the Ethernet / Wifi shield on the Arduino Uno device.</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row row padding-top-double padding-bottom-double margin-bottom-double ">
|
||||
<div class="col-lg-12 margin-top-double">
|
||||
<h2 class="uppercase ">Connect (Quickstart)</h2>
|
||||
<hr>
|
||||
<p class="margin-bottom-double light-grey ">Internet of Things Foundation Quickstart connection </p>
|
||||
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom ">
|
||||
<span class="circle">01 </span> <span class="padding-left">Use the following command to download the installer from GitHub:</span><br>
|
||||
</div>
|
||||
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom ">
|
||||
<span class="circle">02 </span> <span class="padding-left">Download the Sketch installer from the Arduino website http://arduino.cc/en/Main/Software</span><br>
|
||||
</div>
|
||||
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom ">
|
||||
<span class="circle">03 </span> <span class="padding-left"> Install the Sketch program</span><br>
|
||||
</div>
|
||||
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom ">
|
||||
<span class="circle">04 </span> <span class="padding-left">Use the Sketch program to open the samples code samples/quickstart/quickstart.ino</span><br>
|
||||
</div>
|
||||
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom ">
|
||||
<span class="circle">05 </span> <span class="padding-left">View the lower part of the Sketch pad window to check that the COM connection is shown as active</span><br>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/zone}}
|
||||
{{#zone "topCss"}}
|
||||
<link href="{{self.publicURL}}/css/fontwso2.css" rel="stylesheet">
|
||||
<link href="{{self.publicURL}}/css/fontwso2-extend.css" rel="stylesheet">
|
||||
{{/zone}}
|
@ -0,0 +1,4 @@
|
||||
function onRequest(context){
|
||||
context.sketchPath = "api/device/sketch";
|
||||
return context;
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"predicate": "false"
|
||||
}
|
After Width: | Height: | Size: 119 KiB |
After Width: | Height: | Size: 90 KiB |
@ -1,80 +1,89 @@
|
||||
{{#zone "topCss"}}
|
||||
<link href="{{self.publicURL}}/css/nv.d3.css" rel="stylesheet"/>
|
||||
<link href="{{self.publicURL}}/css/daterangepicker.css" rel="stylesheet"/>
|
||||
{{/zone}}
|
||||
{{#zone "topJs"}}
|
||||
<!-- -->
|
||||
<script src="{{self.publicURL}}/js/d3.min.js"></script>
|
||||
<script src="{{self.publicURL}}/js/nv.d3.js"></script>
|
||||
<script src="{{self.publicURL}}/js/stream_layers.js"></script>
|
||||
<script src="{{self.publicURL}}/js/moment.min.js"></script>
|
||||
<script src="{{self.publicURL}}/js/jquery.daterangepicker.js"></script>
|
||||
{{/zone}}
|
||||
{{#zone "main"}}
|
||||
<div class="container container-bg white-bg">
|
||||
<div class="container container-bg white-bg">
|
||||
<div class=" margin-top-double">
|
||||
<div class="row row padding-top-double padding-bottom-double margin-bottom-double ">
|
||||
<div class="row row padding-top-double padding-bottom-double margin-bottom-double">
|
||||
<div class="col-lg-12 margin-top-double">
|
||||
<h1 class="grey ">Sense Bot</h1>
|
||||
<h1 class="grey ">Sensebot</h1>
|
||||
<hr>
|
||||
<p class="margin-bottom-double light-grey ">Connect your Sensebot
|
||||
to the WSO2 device cloud. </p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row margin-bottom-double">
|
||||
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-4 padding-top">
|
||||
<img src="{{self.publicURL}}/images/sensebot.png" class="img-responsive">
|
||||
</div>
|
||||
<div class="row float-right margin-top">
|
||||
<div class="right margin-right">
|
||||
<p style="color:#000;float:left;margin-top:25px">Device Id:</p>
|
||||
<input class="margin-right" id="device_id" value="" style="margin-top:
|
||||
20px" />
|
||||
<input class="right margin-right" id="date-range1" size="60" value="" style="margin-top: 20px">
|
||||
<button type="button" id="btn-draw-graphs" class="btn btn-primary" style="margin-top: 20px">
|
||||
Draw Graphs
|
||||
<div class="col-xs-12 col-sm-6 col-md-8 col-lg-8 padding-top">
|
||||
<h2 class="uppercase">Ingredients</h2>
|
||||
<hr>
|
||||
<p class="grey margin-top">Hardware Requirements </p>
|
||||
<br><br>
|
||||
<span class="fw-stack fw-lg margin-right">
|
||||
<i class="fw fw-ring fw-stack-2x"> </i>
|
||||
<i class="fw fw-right-arrow-2 fw-stack-1x"></i>
|
||||
</span>Arduino Uno<br><br>
|
||||
<span class="fw-stack fw-lg margin-right">
|
||||
<i class="fw fw-ring fw-stack-2x"> </i>
|
||||
<i class="fw fw-right-arrow-2 fw-stack-1x"></i>
|
||||
</span>Arduino Ethernet / WiFi Shield
|
||||
<br /><br />
|
||||
<form method="POST" class="float-left margin-right"
|
||||
action="{{sketchPath}}">
|
||||
<input type="hidden" name="deviceType" value="sensebot" />
|
||||
<input type="hidden" name="sketchType" value="sensebot_wifi" />
|
||||
<button class="blue-btn" type="submit">Create Sketch for
|
||||
Wifi
|
||||
</button>
|
||||
</form>
|
||||
<form method="POST" class="form-login-box float-left"
|
||||
action="{{sketchPath}}">
|
||||
<input type="hidden" name="deviceType" value="sensebot" />
|
||||
<input type="hidden" name="sketchType" value="sensebot" />
|
||||
<button class="blue-btn margin-right" type="submit">Create
|
||||
Sketch
|
||||
for Ethernet</button>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<div class ="col-xs-12 col-sm-6 col-md-3 col-lg-12 padding-double grey-bg ">
|
||||
<h2 class="uppercase">Prepare</h2><hr>
|
||||
<p class="grey margin-top">Get your device ready </p>
|
||||
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom ">
|
||||
<span class="circle">01 </span> <span class="padding-left"> Mount the Ethernet / Wifi shield on the Arduino Uno device.</span>
|
||||
</div>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
<div class="row margin-double">
|
||||
<div class="chart1">
|
||||
<h2 class="grey ">Temperature</h2>
|
||||
<hr>
|
||||
<svg></svg>
|
||||
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom">
|
||||
<span class="circle">02 </span> <span class="padding-left"> Mount the Ethernet / Wifi shield on the Arduino Uno device.</span>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="margin-doubles padding-top-double margin-bottom-double light-grey margin-left-double margin-bottom">
|
||||
<span class="circle">03 </span> <span class="padding-left"> Mount the Ethernet / Wifi shield on the Arduino Uno device.</span>
|
||||
</div>
|
||||
<div class="row margin-double padding-double "></div>
|
||||
<!--<div class="row margin-double">-->
|
||||
<!--<div class="chart2">-->
|
||||
<!--<h2 class="grey ">Light</h2>-->
|
||||
<!--<hr>-->
|
||||
<!--<svg></svg>-->
|
||||
<!--</div>-->
|
||||
<!--<hr>-->
|
||||
<!--</div>-->
|
||||
<div class="row margin-double">
|
||||
<div class="chart3">
|
||||
<h2 class="grey ">Motion</h2>
|
||||
<hr>
|
||||
<svg></svg>
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
<div class="row margin-double">
|
||||
<div class="chart4">
|
||||
<h2 class="grey ">Sonar</h2>
|
||||
<div class="row row padding-top-double padding-bottom-double margin-bottom-double ">
|
||||
<div class="col-lg-12 margin-top-double">
|
||||
<h2 class="uppercase ">Connect (Quickstart)</h2>
|
||||
<hr>
|
||||
<svg></svg>
|
||||
<p class="margin-bottom-double light-grey ">Internet of Things Foundation Quickstart connection </p>
|
||||
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom ">
|
||||
<span class="circle">01 </span> <span class="padding-left">Use the following command to download the installer from GitHub:</span><br>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom ">
|
||||
<span class="circle">02 </span> <span class="padding-left">Download the Sketch installer from the Arduino website http://arduino.cc/en/Main/Software</span><br>
|
||||
</div>
|
||||
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom ">
|
||||
<span class="circle">03 </span> <span class="padding-left"> Install the Sketch program</span><br>
|
||||
</div>
|
||||
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom ">
|
||||
<span class="circle">04 </span> <span class="padding-left">Use the Sketch program to open the samples code samples/quickstart/quickstart.ino</span><br>
|
||||
</div>
|
||||
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom ">
|
||||
<span class="circle">05 </span> <span class="padding-left">View the lower part of the Sketch pad window to check that the COM connection is shown as active</span><br>
|
||||
</div>
|
||||
<!-- TODO : Move these scripts to a bottomJs zone.
|
||||
When they are moved the script tags get repeated for some reason :-(
|
||||
-->
|
||||
<script src="{{self.publicURL}}/js/graph_util.js"></script>
|
||||
<script src="{{self.publicURL}}/js/bulb.js"></script>
|
||||
<script src="{{self.publicURL}}/js/temperature_graph.js"></script>
|
||||
<script src="{{self.publicURL}}/js/light_graph.js"></script>
|
||||
<script src="{{self.publicURL}}/js/motion_graph.js"></script>
|
||||
<script src="{{self.publicURL}}/js/sonar_graph.js"></script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/zone}}
|
||||
{{#zone "topCss"}}
|
||||
<link href="{{self.publicURL}}/css/fontwso2.css" rel="stylesheet">
|
||||
<link href="{{self.publicURL}}/css/fontwso2-extend.css" rel="stylesheet">
|
||||
{{/zone}}
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"predicate": "true"
|
||||
"predicate": "false"
|
||||
}
|
Before Width: | Height: | Size: 516 B After Width: | Height: | Size: 516 B |
Before Width: | Height: | Size: 451 B After Width: | Height: | Size: 451 B |
Before Width: | Height: | Size: 650 B After Width: | Height: | Size: 650 B |
Before Width: | Height: | Size: 373 B After Width: | Height: | Size: 373 B |
@ -0,0 +1,80 @@
|
||||
{{#zone "topCss"}}
|
||||
<link href="{{self.publicURL}}/css/nv.d3.css" rel="stylesheet"/>
|
||||
<link href="{{self.publicURL}}/css/daterangepicker.css" rel="stylesheet"/>
|
||||
{{/zone}}
|
||||
{{#zone "topJs"}}
|
||||
<!-- -->
|
||||
<script src="{{self.publicURL}}/js/d3.min.js"></script>
|
||||
<script src="{{self.publicURL}}/js/nv.d3.js"></script>
|
||||
<script src="{{self.publicURL}}/js/stream_layers.js"></script>
|
||||
<script src="{{self.publicURL}}/js/moment.min.js"></script>
|
||||
<script src="{{self.publicURL}}/js/jquery.daterangepicker.js"></script>
|
||||
{{/zone}}
|
||||
{{#zone "main"}}
|
||||
<div class="container container-bg white-bg">
|
||||
<div class=" margin-top-double">
|
||||
<div class="row row padding-top-double padding-bottom-double margin-bottom-double ">
|
||||
<div class="col-lg-12 margin-top-double">
|
||||
<h1 class="grey ">Sense Bot</h1>
|
||||
<hr>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row float-right margin-top">
|
||||
<div class="right margin-right">
|
||||
<p style="color:#000;float:left;margin-top:25px">Device Id:</p>
|
||||
<input class="margin-right" id="device_id" value="" style="margin-top:
|
||||
20px" />
|
||||
<input class="right margin-right" id="date-range1" size="60" value="" style="margin-top: 20px">
|
||||
<button type="button" id="btn-draw-graphs" class="btn btn-primary" style="margin-top: 20px">
|
||||
Draw Graphs
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
<div class="row margin-double">
|
||||
<div class="chart1">
|
||||
<h2 class="grey ">Temperature</h2>
|
||||
<hr>
|
||||
<svg></svg>
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
<div class="row margin-double padding-double "></div>
|
||||
<!--<div class="row margin-double">-->
|
||||
<!--<div class="chart2">-->
|
||||
<!--<h2 class="grey ">Light</h2>-->
|
||||
<!--<hr>-->
|
||||
<!--<svg></svg>-->
|
||||
<!--</div>-->
|
||||
<!--<hr>-->
|
||||
<!--</div>-->
|
||||
<div class="row margin-double">
|
||||
<div class="chart3">
|
||||
<h2 class="grey ">Motion</h2>
|
||||
<hr>
|
||||
<svg></svg>
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
<div class="row margin-double">
|
||||
<div class="chart4">
|
||||
<h2 class="grey ">Sonar</h2>
|
||||
<hr>
|
||||
<svg></svg>
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- TODO : Move these scripts to a bottomJs zone.
|
||||
When they are moved the script tags get repeated for some reason :-(
|
||||
-->
|
||||
<script src="{{self.publicURL}}/js/graph_util.js"></script>
|
||||
<script src="{{self.publicURL}}/js/bulb.js"></script>
|
||||
<script src="{{self.publicURL}}/js/temperature_graph.js"></script>
|
||||
<script src="{{self.publicURL}}/js/light_graph.js"></script>
|
||||
<script src="{{self.publicURL}}/js/motion_graph.js"></script>
|
||||
<script src="{{self.publicURL}}/js/sonar_graph.js"></script>
|
||||
{{/zone}}
|
@ -0,0 +1,4 @@
|
||||
function onRequest(context){
|
||||
context.sketchPath = "api/device/sketch";
|
||||
return context;
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"predicate": "true"
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
byte mac[6] = { 0x90, 0xA2, 0xDA, 0x0D, 0x30, 0xD7}; //mac - 90a2da0d30d7
|
||||
byte dns2[] = { 8, 8, 8, 8 };
|
||||
byte subnet[] = { 255, 255, 255, 0 };
|
||||
byte gateway[] = { 192, 168, 1, 1 };
|
||||
|
||||
byte deviceIP[4] = { 192, 168, 1, 219 };
|
||||
byte server[4] = { 192, 168, 1, 216 };
|
||||
|
||||
String connecting = "connecting.... ";
|
||||
|
||||
void connectHttp() {
|
||||
if(DEBUG) Serial.println("-------------------------------");
|
||||
|
||||
Ethernet.begin(mac, deviceIP, dns2, gateway, subnet);
|
||||
delay(2000);
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.print("My IP: ");
|
||||
Serial.println(Ethernet.localIP());
|
||||
}
|
||||
|
||||
connecting += httpClient.connect(server, SERVICE_PORT);
|
||||
delay(2000);
|
||||
if(DEBUG) Serial.println(connecting);
|
||||
|
||||
if (httpClient.connected()) {
|
||||
if(DEBUG) Serial.println("connected");
|
||||
} else {
|
||||
if(DEBUG) Serial.println("connection failed");
|
||||
|
||||
while(!httpClient.connected()){
|
||||
if(DEBUG) Serial.println("retrying to connect......");
|
||||
httpClient.connect(server, SERVICE_PORT);
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
if(DEBUG) Serial.println("connected to server!");
|
||||
}
|
||||
if(DEBUG) Serial.println("-------------------------------");
|
||||
}
|
||||
|
||||
|
||||
void setupResource(){
|
||||
String hostIP = getHostIP(server);
|
||||
String port = String(SERVICE_PORT);
|
||||
|
||||
host = "Host: " + hostIP + ":" + port;
|
||||
if(DEBUG) Serial.println(host);
|
||||
|
||||
jsonPayLoad = String(OWNER_JSON);
|
||||
jsonPayLoad += String(DEVICE_OWNER);
|
||||
jsonPayLoad += String(DEVICE_ID_JSON);
|
||||
jsonPayLoad += String(DEVICE_ID);
|
||||
jsonPayLoad += String(REPLY_JSON);
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.print("JSON Payload: ");
|
||||
Serial.println(jsonPayLoad);
|
||||
Serial.println("-------------------------------");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String getMyIP(){
|
||||
String myIP = "";
|
||||
myIP = String(Ethernet.localIP()[0]);
|
||||
|
||||
for ( int index = 1; index < 4; index++) {
|
||||
myIP += "." + String(Ethernet.localIP()[index]);
|
||||
}
|
||||
return myIP;
|
||||
}
|
||||
|
||||
|
||||
String getHostIP(byte server[4]){
|
||||
String hostIP = String(server[0]);
|
||||
|
||||
for ( int index = 1; index < 4; index++) {
|
||||
hostIP += "." + String(server[index]);
|
||||
}
|
||||
|
||||
return hostIP;
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
#ifndef FireAlarmEthernetAgent_H
|
||||
#define FireAlarmEthernetAgent_H
|
||||
|
||||
#if (ARDUINO >= 100)
|
||||
#include "Arduino.h"
|
||||
#else
|
||||
#include "WProgram.h"
|
||||
#endif
|
||||
|
||||
#define HTTP_POST "POST"
|
||||
#define HTTP_GET "GET"
|
||||
#define HTTP_VERSION "HTTP/1.1"
|
||||
#define HTTP_CONTENT_TYPE "Content-Type: application/json"
|
||||
#define HTTP_CONTENT_LEN "Content-Length: "
|
||||
|
||||
#define DEVICE_OWNER "${DEVICE_OWNER}" //"Smeansbeer"
|
||||
#define DEVICE_ID "${DEVICE_ID}" //"vbhenqyt85yq"
|
||||
#define DEVICE_TOKEN "${DEVICE_TOKEN}"
|
||||
|
||||
#define PUSH_ALARM_DATA "pushalarmdata"
|
||||
#define READ_CONTROLS "readcontrols/"
|
||||
#define REPLY "reply"
|
||||
|
||||
#define OWNER_JSON "{\"owner\":\""
|
||||
#define DEVICE_ID_JSON "\",\"deviceId\":\""
|
||||
#define REPLY_JSON "\",\"replyMessage\":\""
|
||||
#define TIME_JSON "\",\"time\":\""
|
||||
#define KEY_JSON "\",\"key\":\""
|
||||
#define VALUE_JSON "\",\"value\":\""
|
||||
#define END_JSON "\"}"
|
||||
|
||||
#define SERVICE_PORT 9763
|
||||
#define SERVICE_EPOINT "/firealarm/controller/"
|
||||
// pushalarmdata - application/json - {"owner":"","deviceId":"","replyMessage":"","time":"","key":"","value":""}
|
||||
// readcontrols/{owner}/{deviceId}
|
||||
// reply - application/json - {"owner":"","deviceId":"","replyMessage":""}
|
||||
|
||||
#define TEMP_PIN 3
|
||||
#define BULB_PIN 4
|
||||
#define FAN_PIN 5
|
||||
|
||||
#define DEBUG false
|
||||
#define POLL_INTERVAL 1000
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -0,0 +1,143 @@
|
||||
#include "FireAlarmEthernetAgent.h"
|
||||
|
||||
#include <Ethernet.h>
|
||||
#include <SPI.h>
|
||||
#include "dht.h"
|
||||
|
||||
/**********************************************************************************************
|
||||
0. Check with a sample Ethernet code of the Ethernet library to ensure that the sheild is working
|
||||
1. Set the ip of the server(byte array below) where the Web-Rest API for the FireAlarm is running
|
||||
2. Check whether the "SERVICE_EPOINT" is correct in the 'FireAlarmWifiAgent.h' file
|
||||
3. Check whether the "SERVICE_PORT" is the same (9763) for the server running. Change it if needed
|
||||
4. Check whether the pins have been attached accordingly in the Arduino
|
||||
5. Check whether all reqquired pins are added to the 'digitalPins' array
|
||||
***********************************************************************************************/
|
||||
|
||||
int digitalPins[] = { TEMP_PIN, BULB_PIN, FAN_PIN };
|
||||
int analogPins[] = { 0, 1, 2, 3, 4, 5 };
|
||||
|
||||
EthernetClient httpClient;
|
||||
String host, jsonPayLoad, replyMsg;
|
||||
|
||||
void setup() {
|
||||
if(DEBUG) Serial.begin(9600);
|
||||
pinMode(BULB_PIN, OUTPUT);
|
||||
pinMode(FAN_PIN, OUTPUT);
|
||||
connectHttp();
|
||||
setupResource();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (httpClient.connected()) {
|
||||
pushDigitalPinData();
|
||||
// pushData(); // Use this method to batch all data together and send in one call
|
||||
|
||||
delay(POLL_INTERVAL);
|
||||
|
||||
String responseMsg = readControls();
|
||||
int index = responseMsg.lastIndexOf(":");
|
||||
int newLine = responseMsg.lastIndexOf("\n");
|
||||
String subStrn = responseMsg.substring(index + 1);
|
||||
|
||||
if (subStrn.equals("IN")) {
|
||||
responseMsg = responseMsg.substring(newLine + 1, index);
|
||||
if (responseMsg.equals("TEMPERATURE")) {
|
||||
replyMsg = "Temperature is " + String(getTemperature()) + "C.";
|
||||
reply(replyMsg);
|
||||
} else if (responseMsg.equals("BULB")) {
|
||||
replyMsg = "Bulb was switched " + switchBulb();
|
||||
} else if (responseMsg.equals("FAN")) {
|
||||
replyMsg = "Bulb was switched " + switchFan();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(DEBUG) {
|
||||
Serial.println("client not found...");
|
||||
Serial.println("disconnecting.");
|
||||
}
|
||||
httpClient.stop();
|
||||
connectHttp();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String getDataType(int pin){
|
||||
switch(pin){
|
||||
case TEMP_PIN:
|
||||
return "Temperature";
|
||||
case BULB_PIN:
|
||||
return "Bulb";
|
||||
case FAN_PIN:
|
||||
return "Fan";
|
||||
default:
|
||||
return String(pin);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
String switchBulb() {
|
||||
if (digitalRead(BULB_PIN) == HIGH) {
|
||||
digitalWrite(BULB_PIN, LOW);
|
||||
return "OFF";
|
||||
} else {
|
||||
digitalWrite(BULB_PIN, HIGH);
|
||||
return "ON";
|
||||
}
|
||||
}
|
||||
|
||||
String switchFan() {
|
||||
if (digitalRead(FAN_PIN) == HIGH) {
|
||||
digitalWrite(FAN_PIN, LOW);
|
||||
return "OFF";
|
||||
} else {
|
||||
digitalWrite(FAN_PIN, HIGH);
|
||||
return "ON";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
double getTemperature(){
|
||||
dht DHT;
|
||||
if(DEBUG) {
|
||||
Serial.println("-------------------------------");
|
||||
Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)");
|
||||
Serial.print("DHT11, \t");
|
||||
}
|
||||
|
||||
int chk = DHT.read11(TEMP_PIN);
|
||||
switch (chk)
|
||||
{
|
||||
case DHTLIB_OK:
|
||||
if(DEBUG) Serial.print("OK,\t");
|
||||
break;
|
||||
case DHTLIB_ERROR_CHECKSUM:
|
||||
if(DEBUG) Serial.print("Checksum error,\t");
|
||||
break;
|
||||
case DHTLIB_ERROR_TIMEOUT:
|
||||
if(DEBUG) Serial.print("Time out error,\t");
|
||||
break;
|
||||
case DHTLIB_ERROR_CONNECT:
|
||||
if(DEBUG) Serial.print("Connect error,\t");
|
||||
break;
|
||||
case DHTLIB_ERROR_ACK_L:
|
||||
if(DEBUG) Serial.print("Ack Low error,\t");
|
||||
break;
|
||||
case DHTLIB_ERROR_ACK_H:
|
||||
if(DEBUG) Serial.print("Ack High error,\t");
|
||||
break;
|
||||
default:
|
||||
if(DEBUG) Serial.print("Unknown error,\t");
|
||||
break;
|
||||
}
|
||||
|
||||
// DISPLAY DATA
|
||||
if(DEBUG) {
|
||||
Serial.print("\t");
|
||||
Serial.print(DHT.temperature, 1);
|
||||
Serial.print(",\t\t");
|
||||
Serial.println(DHT.humidity, 1);
|
||||
Serial.println("-------------------------------");
|
||||
}
|
||||
return DHT.temperature;
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
String readControls() {
|
||||
String responseMsg;
|
||||
String resource = " " + String(SERVICE_EPOINT) + String(READ_CONTROLS) + String(DEVICE_OWNER) + "/" + String(DEVICE_ID) + " ";
|
||||
|
||||
httpClient.print(HTTP_GET);
|
||||
httpClient.print(resource);
|
||||
httpClient.println(HTTP_VERSION);
|
||||
httpClient.println(host);
|
||||
httpClient.println();
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.print(HTTP_GET);
|
||||
Serial.print(resource);
|
||||
Serial.println(HTTP_VERSION);
|
||||
Serial.println(host);
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
delay(1000);
|
||||
|
||||
while (httpClient.available()) {
|
||||
char response = httpClient.read();
|
||||
responseMsg += response;
|
||||
}
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.print(responseMsg);
|
||||
Serial.println();
|
||||
Serial.println("-------------------------------");
|
||||
}
|
||||
delay(1000);
|
||||
return responseMsg;
|
||||
}
|
||||
|
||||
void reply(String replyMsg) {
|
||||
String resource = " " + String(SERVICE_EPOINT) + String(REPLY) + " ";
|
||||
String payLoad = jsonPayLoad + replyMsg + String(END_JSON);
|
||||
|
||||
httpClient.print(HTTP_POST);
|
||||
httpClient.print(resource);
|
||||
httpClient.println(HTTP_VERSION);
|
||||
httpClient.println(host);
|
||||
httpClient.println(HTTP_CONTENT_TYPE);
|
||||
httpClient.print(HTTP_CONTENT_LEN);
|
||||
httpClient.println(payLoad.length());
|
||||
httpClient.println();
|
||||
httpClient.println(payLoad);
|
||||
httpClient.println();
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.print(HTTP_POST);
|
||||
Serial.print(resource);
|
||||
Serial.println(HTTP_VERSION);
|
||||
Serial.println(host);
|
||||
Serial.println(HTTP_CONTENT_TYPE);
|
||||
Serial.print(HTTP_CONTENT_LEN);
|
||||
Serial.println(payLoad.length());
|
||||
Serial.println();
|
||||
Serial.println(payLoad);
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
delay(1000);
|
||||
|
||||
while (httpClient.available()) {
|
||||
char response = httpClient.read();
|
||||
if(DEBUG) Serial.print(response);
|
||||
}
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.println();
|
||||
Serial.println("-------------------------------");
|
||||
}
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,199 @@
|
||||
|
||||
/**********************************************************************************************
|
||||
This method will traverse the array of digital pins and batch the data from the those pins together.
|
||||
It makes a single call to the server and sends all pin values as a batch.
|
||||
Server dis-assembles it accordingly and makes multiple publish calls for each sensor type.
|
||||
***********************************************************************************************/
|
||||
|
||||
void pushData(){
|
||||
String resource = " " + String(SERVICE_EPOINT) + String(PUSH_ALARM_DATA) + " ";
|
||||
String payLoad = jsonPayLoad + "DigitalPinData";
|
||||
payLoad = payLoad + String(TIME_JSON) + "9999";
|
||||
payLoad = payLoad + String(KEY_JSON) + "Data";
|
||||
payLoad += String(VALUE_JSON);
|
||||
|
||||
for ( int pin = 0; pin < (sizeof(digitalPins)/sizeof(int)); pin++) {
|
||||
if ( digitalPins[pin] == TEMP_PIN ) {
|
||||
payLoad += String(getTemperature());
|
||||
} else if ( digitalRead(digitalPins[pin]) == HIGH ) {
|
||||
payLoad += "ON";
|
||||
} else if ( digitalRead(digitalPins[pin]) == LOW ) {
|
||||
payLoad += "OFF";
|
||||
}
|
||||
|
||||
if ( ((sizeof(digitalPins)/sizeof(int)) - 1) != pin ) {
|
||||
payLoad += "-";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
payLoad = payLoad + String(END_JSON);
|
||||
|
||||
if(DEBUG) Serial.println(payLoad);
|
||||
|
||||
httpClient.print(HTTP_POST);
|
||||
httpClient.print(resource);
|
||||
httpClient.println(HTTP_VERSION);
|
||||
httpClient.println(host);
|
||||
httpClient.println(HTTP_CONTENT_TYPE);
|
||||
httpClient.print(HTTP_CONTENT_LEN);
|
||||
httpClient.println(payLoad.length());
|
||||
httpClient.println();
|
||||
httpClient.println(payLoad);
|
||||
httpClient.println();
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.print(HTTP_POST);
|
||||
Serial.print(resource);
|
||||
Serial.println(HTTP_VERSION);
|
||||
Serial.println(host);
|
||||
Serial.println(HTTP_CONTENT_TYPE);
|
||||
Serial.print(HTTP_CONTENT_LEN);
|
||||
Serial.println(payLoad.length());
|
||||
Serial.println();
|
||||
Serial.println(payLoad);
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
delay(1000);
|
||||
|
||||
while (httpClient.available()) {
|
||||
char response = httpClient.read();
|
||||
if(DEBUG) Serial.print(response);
|
||||
}
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.println();
|
||||
Serial.println("-------------------------------");
|
||||
}
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
/**********************************************************************************************
|
||||
This method will traverse the array of digital pins and publish the data from the those pins.
|
||||
It differs from the above method such that the pin data is published one after the other in
|
||||
seperate calls to the server
|
||||
***********************************************************************************************/
|
||||
|
||||
|
||||
void pushDigitalPinData(){
|
||||
for ( int pin = 0; pin < (sizeof(digitalPins)/sizeof(int)); pin++) {
|
||||
String resource = " " + String(SERVICE_EPOINT) + String(PUSH_ALARM_DATA) + " ";
|
||||
|
||||
String payLoad = jsonPayLoad + "DigitalPinData";
|
||||
payLoad = payLoad + String(TIME_JSON) + "9999";
|
||||
payLoad = payLoad + String(KEY_JSON) + getDataType(digitalPins[pin]);
|
||||
payLoad += String(VALUE_JSON);
|
||||
|
||||
|
||||
if ( digitalPins[pin] == TEMP_PIN ) {
|
||||
payLoad += String(getTemperature());
|
||||
} else if ( digitalRead(digitalPins[pin]) == HIGH ) {
|
||||
payLoad += "ON";
|
||||
} else if ( digitalRead(digitalPins[pin]) == LOW ) {
|
||||
payLoad += "OFF";
|
||||
}
|
||||
|
||||
payLoad = payLoad + String(END_JSON);
|
||||
|
||||
if(DEBUG) Serial.println(payLoad);
|
||||
|
||||
httpClient.print(HTTP_POST);
|
||||
httpClient.print(resource);
|
||||
httpClient.println(HTTP_VERSION);
|
||||
httpClient.println(host);
|
||||
httpClient.println(HTTP_CONTENT_TYPE);
|
||||
httpClient.print(HTTP_CONTENT_LEN);
|
||||
httpClient.println(payLoad.length());
|
||||
httpClient.println();
|
||||
httpClient.println(payLoad);
|
||||
httpClient.println();
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.print(HTTP_POST);
|
||||
Serial.print(resource);
|
||||
Serial.println(HTTP_VERSION);
|
||||
Serial.println(host);
|
||||
Serial.println(HTTP_CONTENT_TYPE);
|
||||
Serial.print(HTTP_CONTENT_LEN);
|
||||
Serial.println(payLoad.length());
|
||||
Serial.println();
|
||||
Serial.println(payLoad);
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
delay(1000);
|
||||
|
||||
while (httpClient.available()) {
|
||||
char response = httpClient.read();
|
||||
if(DEBUG) Serial.print(response);
|
||||
}
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.println();
|
||||
Serial.println("-------------------------------");
|
||||
}
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************************************************************************
|
||||
Only required for cases of reading analog pin values.
|
||||
An int Array of analog pins that needs to be read has to be initialised.
|
||||
This method will traverse the array and publish the data from the selected pins
|
||||
***********************************************************************************************/
|
||||
|
||||
|
||||
void pushAnalogPinData(){
|
||||
for ( int pin = 0; pin < (sizeof(analogPins)/sizeof(int)); pin++) {
|
||||
String resource = " " + String(SERVICE_EPOINT) + String(PUSH_ALARM_DATA) + " ";
|
||||
|
||||
String payLoad = jsonPayLoad + "AnalogPinData";
|
||||
payLoad = payLoad + String(TIME_JSON) + "9999";
|
||||
payLoad = payLoad + String(KEY_JSON) + getDataType(analogPins[pin]);
|
||||
payLoad = payLoad + String(VALUE_JSON) + analogRead(analogPins[pin]);
|
||||
payLoad = payLoad + String(END_JSON);
|
||||
|
||||
if(DEBUG) Serial.println(payLoad);
|
||||
|
||||
httpClient.print(HTTP_POST);
|
||||
httpClient.print(resource);
|
||||
httpClient.println(HTTP_VERSION);
|
||||
httpClient.println(host);
|
||||
httpClient.println(HTTP_CONTENT_TYPE);
|
||||
httpClient.print(HTTP_CONTENT_LEN);
|
||||
httpClient.println(payLoad.length());
|
||||
httpClient.println();
|
||||
httpClient.println(payLoad);
|
||||
httpClient.println();
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.print(HTTP_POST);
|
||||
Serial.print(resource);
|
||||
Serial.println(HTTP_VERSION);
|
||||
Serial.println(host);
|
||||
Serial.println(HTTP_CONTENT_TYPE);
|
||||
Serial.print(HTTP_CONTENT_LEN);
|
||||
Serial.println(payLoad.length());
|
||||
Serial.println();
|
||||
Serial.println(payLoad);
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
delay(1000);
|
||||
|
||||
while (httpClient.available()) {
|
||||
char response = httpClient.read();
|
||||
if(DEBUG) Serial.print(response);
|
||||
}
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.println();
|
||||
Serial.println("-------------------------------");
|
||||
}
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,2 @@
|
||||
templates=FireAlarmEthernetAgent.h
|
||||
zipfilename=Arduino.zip
|
@ -0,0 +1,3 @@
|
||||
DEVICE_OWNER= ${DEVICE_OWNER}
|
||||
DEVICE_ID= ${DEVICE_ID}
|
||||
DEVICE_TOKEN= ${DEVICE_TOKEN}
|
@ -0,0 +1,2 @@
|
||||
templates=DigitalDisplay.txt
|
||||
zipfilename=DigitalDisplay.zip
|
@ -0,0 +1,83 @@
|
||||
byte mac[6] = { 0x90, 0xA2, 0xDA, 0x0D, 0x30, 0xD7}; //mac - 90a2da0d30d7
|
||||
byte dns2[] = { 8, 8, 8, 8 };
|
||||
byte subnet[] = { 255, 255, 255, 0 };
|
||||
byte gateway[] = { 192, 168, 1, 1 };
|
||||
|
||||
byte deviceIP[4] = { 192, 168, 1, 219 };
|
||||
byte server[4] = { 192, 168, 1, 216 };
|
||||
|
||||
String connecting = "connecting.... ";
|
||||
|
||||
void connectHttp() {
|
||||
if(DEBUG) Serial.println("-------------------------------");
|
||||
|
||||
Ethernet.begin(mac, deviceIP, dns2, gateway, subnet);
|
||||
delay(2000);
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.print("My IP: ");
|
||||
Serial.println(Ethernet.localIP());
|
||||
}
|
||||
|
||||
connecting += httpClient.connect(server, SERVICE_PORT);
|
||||
delay(2000);
|
||||
if(DEBUG) Serial.println(connecting);
|
||||
|
||||
if (httpClient.connected()) {
|
||||
if(DEBUG) Serial.println("connected");
|
||||
} else {
|
||||
if(DEBUG) Serial.println("connection failed");
|
||||
|
||||
while(!httpClient.connected()){
|
||||
if(DEBUG) Serial.println("retrying to connect......");
|
||||
httpClient.connect(server, SERVICE_PORT);
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
if(DEBUG) Serial.println("connected to server!");
|
||||
}
|
||||
if(DEBUG) Serial.println("-------------------------------");
|
||||
}
|
||||
|
||||
|
||||
void setupResource(){
|
||||
String hostIP = getHostIP(server);
|
||||
String port = String(SERVICE_PORT);
|
||||
|
||||
host = "Host: " + hostIP + ":" + port;
|
||||
if(DEBUG) Serial.println(host);
|
||||
|
||||
jsonPayLoad = String(OWNER_JSON);
|
||||
jsonPayLoad += String(DEVICE_OWNER);
|
||||
jsonPayLoad += String(DEVICE_ID_JSON);
|
||||
jsonPayLoad += String(DEVICE_ID);
|
||||
jsonPayLoad += String(REPLY_JSON);
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.print("JSON Payload: ");
|
||||
Serial.println(jsonPayLoad);
|
||||
Serial.println("-------------------------------");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String getMyIP(){
|
||||
String myIP = "";
|
||||
myIP = String(Ethernet.localIP()[0]);
|
||||
|
||||
for ( int index = 1; index < 4; index++) {
|
||||
myIP += "." + String(Ethernet.localIP()[index]);
|
||||
}
|
||||
return myIP;
|
||||
}
|
||||
|
||||
|
||||
String getHostIP(byte server[4]){
|
||||
String hostIP = String(server[0]);
|
||||
|
||||
for ( int index = 1; index < 4; index++) {
|
||||
hostIP += "." + String(server[index]);
|
||||
}
|
||||
|
||||
return hostIP;
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
#ifndef FireAlarmEthernetAgent_H
|
||||
#define FireAlarmEthernetAgent_H
|
||||
|
||||
#if (ARDUINO >= 100)
|
||||
#include "Arduino.h"
|
||||
#else
|
||||
#include "WProgram.h"
|
||||
#endif
|
||||
|
||||
#define HTTP_POST "POST"
|
||||
#define HTTP_GET "GET"
|
||||
#define HTTP_VERSION "HTTP/1.1"
|
||||
#define HTTP_CONTENT_TYPE "Content-Type: application/json"
|
||||
#define HTTP_CONTENT_LEN "Content-Length: "
|
||||
|
||||
#define DEVICE_OWNER "${DEVICE_OWNER}" //"Smeansbeer"
|
||||
#define DEVICE_ID "${DEVICE_ID}" //"vbhenqyt85yq"
|
||||
#define DEVICE_TOKEN "${DEVICE_TOKEN}"
|
||||
|
||||
#define PUSH_ALARM_DATA "pushalarmdata"
|
||||
#define READ_CONTROLS "readcontrols/"
|
||||
#define REPLY "reply"
|
||||
|
||||
#define OWNER_JSON "{\"owner\":\""
|
||||
#define DEVICE_ID_JSON "\",\"deviceId\":\""
|
||||
#define REPLY_JSON "\",\"replyMessage\":\""
|
||||
#define TIME_JSON "\",\"time\":\""
|
||||
#define KEY_JSON "\",\"key\":\""
|
||||
#define VALUE_JSON "\",\"value\":\""
|
||||
#define END_JSON "\"}"
|
||||
|
||||
#define SERVICE_PORT 9763
|
||||
#define SERVICE_EPOINT "/firealarm/controller/"
|
||||
// pushalarmdata - application/json - {"owner":"","deviceId":"","replyMessage":"","time":"","key":"","value":""}
|
||||
// readcontrols/{owner}/{deviceId}
|
||||
// reply - application/json - {"owner":"","deviceId":"","replyMessage":""}
|
||||
|
||||
#define TEMP_PIN 3
|
||||
#define BULB_PIN 4
|
||||
#define FAN_PIN 5
|
||||
|
||||
#define DEBUG false
|
||||
#define POLL_INTERVAL 1000
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -0,0 +1,143 @@
|
||||
#include "FireAlarmEthernetAgent.h"
|
||||
|
||||
#include <Ethernet.h>
|
||||
#include <SPI.h>
|
||||
#include "dht.h"
|
||||
|
||||
/**********************************************************************************************
|
||||
0. Check with a sample Ethernet code of the Ethernet library to ensure that the sheild is working
|
||||
1. Set the ip of the server(byte array below) where the Web-Rest API for the FireAlarm is running
|
||||
2. Check whether the "SERVICE_EPOINT" is correct in the 'FireAlarmWifiAgent.h' file
|
||||
3. Check whether the "SERVICE_PORT" is the same (9763) for the server running. Change it if needed
|
||||
4. Check whether the pins have been attached accordingly in the Arduino
|
||||
5. Check whether all reqquired pins are added to the 'digitalPins' array
|
||||
***********************************************************************************************/
|
||||
|
||||
int digitalPins[] = { TEMP_PIN, BULB_PIN, FAN_PIN };
|
||||
int analogPins[] = { 0, 1, 2, 3, 4, 5 };
|
||||
|
||||
EthernetClient httpClient;
|
||||
String host, jsonPayLoad, replyMsg;
|
||||
|
||||
void setup() {
|
||||
if(DEBUG) Serial.begin(9600);
|
||||
pinMode(BULB_PIN, OUTPUT);
|
||||
pinMode(FAN_PIN, OUTPUT);
|
||||
connectHttp();
|
||||
setupResource();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (httpClient.connected()) {
|
||||
pushDigitalPinData();
|
||||
// pushData(); // Use this method to batch all data together and send in one call
|
||||
|
||||
delay(POLL_INTERVAL);
|
||||
|
||||
String responseMsg = readControls();
|
||||
int index = responseMsg.lastIndexOf(":");
|
||||
int newLine = responseMsg.lastIndexOf("\n");
|
||||
String subStrn = responseMsg.substring(index + 1);
|
||||
|
||||
if (subStrn.equals("IN")) {
|
||||
responseMsg = responseMsg.substring(newLine + 1, index);
|
||||
if (responseMsg.equals("TEMPERATURE")) {
|
||||
replyMsg = "Temperature is " + String(getTemperature()) + "C.";
|
||||
reply(replyMsg);
|
||||
} else if (responseMsg.equals("BULB")) {
|
||||
replyMsg = "Bulb was switched " + switchBulb();
|
||||
} else if (responseMsg.equals("FAN")) {
|
||||
replyMsg = "Bulb was switched " + switchFan();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(DEBUG) {
|
||||
Serial.println("client not found...");
|
||||
Serial.println("disconnecting.");
|
||||
}
|
||||
httpClient.stop();
|
||||
connectHttp();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String getDataType(int pin){
|
||||
switch(pin){
|
||||
case TEMP_PIN:
|
||||
return "Temperature";
|
||||
case BULB_PIN:
|
||||
return "Bulb";
|
||||
case FAN_PIN:
|
||||
return "Fan";
|
||||
default:
|
||||
return String(pin);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
String switchBulb() {
|
||||
if (digitalRead(BULB_PIN) == HIGH) {
|
||||
digitalWrite(BULB_PIN, LOW);
|
||||
return "OFF";
|
||||
} else {
|
||||
digitalWrite(BULB_PIN, HIGH);
|
||||
return "ON";
|
||||
}
|
||||
}
|
||||
|
||||
String switchFan() {
|
||||
if (digitalRead(FAN_PIN) == HIGH) {
|
||||
digitalWrite(FAN_PIN, LOW);
|
||||
return "OFF";
|
||||
} else {
|
||||
digitalWrite(FAN_PIN, HIGH);
|
||||
return "ON";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
double getTemperature(){
|
||||
dht DHT;
|
||||
if(DEBUG) {
|
||||
Serial.println("-------------------------------");
|
||||
Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)");
|
||||
Serial.print("DHT11, \t");
|
||||
}
|
||||
|
||||
int chk = DHT.read11(TEMP_PIN);
|
||||
switch (chk)
|
||||
{
|
||||
case DHTLIB_OK:
|
||||
if(DEBUG) Serial.print("OK,\t");
|
||||
break;
|
||||
case DHTLIB_ERROR_CHECKSUM:
|
||||
if(DEBUG) Serial.print("Checksum error,\t");
|
||||
break;
|
||||
case DHTLIB_ERROR_TIMEOUT:
|
||||
if(DEBUG) Serial.print("Time out error,\t");
|
||||
break;
|
||||
case DHTLIB_ERROR_CONNECT:
|
||||
if(DEBUG) Serial.print("Connect error,\t");
|
||||
break;
|
||||
case DHTLIB_ERROR_ACK_L:
|
||||
if(DEBUG) Serial.print("Ack Low error,\t");
|
||||
break;
|
||||
case DHTLIB_ERROR_ACK_H:
|
||||
if(DEBUG) Serial.print("Ack High error,\t");
|
||||
break;
|
||||
default:
|
||||
if(DEBUG) Serial.print("Unknown error,\t");
|
||||
break;
|
||||
}
|
||||
|
||||
// DISPLAY DATA
|
||||
if(DEBUG) {
|
||||
Serial.print("\t");
|
||||
Serial.print(DHT.temperature, 1);
|
||||
Serial.print(",\t\t");
|
||||
Serial.println(DHT.humidity, 1);
|
||||
Serial.println("-------------------------------");
|
||||
}
|
||||
return DHT.temperature;
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
String readControls() {
|
||||
String responseMsg;
|
||||
String resource = " " + String(SERVICE_EPOINT) + String(READ_CONTROLS) + String(DEVICE_OWNER) + "/" + String(DEVICE_ID) + " ";
|
||||
|
||||
httpClient.print(HTTP_GET);
|
||||
httpClient.print(resource);
|
||||
httpClient.println(HTTP_VERSION);
|
||||
httpClient.println(host);
|
||||
httpClient.println();
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.print(HTTP_GET);
|
||||
Serial.print(resource);
|
||||
Serial.println(HTTP_VERSION);
|
||||
Serial.println(host);
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
delay(1000);
|
||||
|
||||
while (httpClient.available()) {
|
||||
char response = httpClient.read();
|
||||
responseMsg += response;
|
||||
}
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.print(responseMsg);
|
||||
Serial.println();
|
||||
Serial.println("-------------------------------");
|
||||
}
|
||||
delay(1000);
|
||||
return responseMsg;
|
||||
}
|
||||
|
||||
void reply(String replyMsg) {
|
||||
String resource = " " + String(SERVICE_EPOINT) + String(REPLY) + " ";
|
||||
String payLoad = jsonPayLoad + replyMsg + String(END_JSON);
|
||||
|
||||
httpClient.print(HTTP_POST);
|
||||
httpClient.print(resource);
|
||||
httpClient.println(HTTP_VERSION);
|
||||
httpClient.println(host);
|
||||
httpClient.println(HTTP_CONTENT_TYPE);
|
||||
httpClient.print(HTTP_CONTENT_LEN);
|
||||
httpClient.println(payLoad.length());
|
||||
httpClient.println();
|
||||
httpClient.println(payLoad);
|
||||
httpClient.println();
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.print(HTTP_POST);
|
||||
Serial.print(resource);
|
||||
Serial.println(HTTP_VERSION);
|
||||
Serial.println(host);
|
||||
Serial.println(HTTP_CONTENT_TYPE);
|
||||
Serial.print(HTTP_CONTENT_LEN);
|
||||
Serial.println(payLoad.length());
|
||||
Serial.println();
|
||||
Serial.println(payLoad);
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
delay(1000);
|
||||
|
||||
while (httpClient.available()) {
|
||||
char response = httpClient.read();
|
||||
if(DEBUG) Serial.print(response);
|
||||
}
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.println();
|
||||
Serial.println("-------------------------------");
|
||||
}
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,199 @@
|
||||
|
||||
/**********************************************************************************************
|
||||
This method will traverse the array of digital pins and batch the data from the those pins together.
|
||||
It makes a single call to the server and sends all pin values as a batch.
|
||||
Server dis-assembles it accordingly and makes multiple publish calls for each sensor type.
|
||||
***********************************************************************************************/
|
||||
|
||||
void pushData(){
|
||||
String resource = " " + String(SERVICE_EPOINT) + String(PUSH_ALARM_DATA) + " ";
|
||||
String payLoad = jsonPayLoad + "DigitalPinData";
|
||||
payLoad = payLoad + String(TIME_JSON) + "9999";
|
||||
payLoad = payLoad + String(KEY_JSON) + "Data";
|
||||
payLoad += String(VALUE_JSON);
|
||||
|
||||
for ( int pin = 0; pin < (sizeof(digitalPins)/sizeof(int)); pin++) {
|
||||
if ( digitalPins[pin] == TEMP_PIN ) {
|
||||
payLoad += String(getTemperature());
|
||||
} else if ( digitalRead(digitalPins[pin]) == HIGH ) {
|
||||
payLoad += "ON";
|
||||
} else if ( digitalRead(digitalPins[pin]) == LOW ) {
|
||||
payLoad += "OFF";
|
||||
}
|
||||
|
||||
if ( ((sizeof(digitalPins)/sizeof(int)) - 1) != pin ) {
|
||||
payLoad += "-";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
payLoad = payLoad + String(END_JSON);
|
||||
|
||||
if(DEBUG) Serial.println(payLoad);
|
||||
|
||||
httpClient.print(HTTP_POST);
|
||||
httpClient.print(resource);
|
||||
httpClient.println(HTTP_VERSION);
|
||||
httpClient.println(host);
|
||||
httpClient.println(HTTP_CONTENT_TYPE);
|
||||
httpClient.print(HTTP_CONTENT_LEN);
|
||||
httpClient.println(payLoad.length());
|
||||
httpClient.println();
|
||||
httpClient.println(payLoad);
|
||||
httpClient.println();
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.print(HTTP_POST);
|
||||
Serial.print(resource);
|
||||
Serial.println(HTTP_VERSION);
|
||||
Serial.println(host);
|
||||
Serial.println(HTTP_CONTENT_TYPE);
|
||||
Serial.print(HTTP_CONTENT_LEN);
|
||||
Serial.println(payLoad.length());
|
||||
Serial.println();
|
||||
Serial.println(payLoad);
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
delay(1000);
|
||||
|
||||
while (httpClient.available()) {
|
||||
char response = httpClient.read();
|
||||
if(DEBUG) Serial.print(response);
|
||||
}
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.println();
|
||||
Serial.println("-------------------------------");
|
||||
}
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
/**********************************************************************************************
|
||||
This method will traverse the array of digital pins and publish the data from the those pins.
|
||||
It differs from the above method such that the pin data is published one after the other in
|
||||
seperate calls to the server
|
||||
***********************************************************************************************/
|
||||
|
||||
|
||||
void pushDigitalPinData(){
|
||||
for ( int pin = 0; pin < (sizeof(digitalPins)/sizeof(int)); pin++) {
|
||||
String resource = " " + String(SERVICE_EPOINT) + String(PUSH_ALARM_DATA) + " ";
|
||||
|
||||
String payLoad = jsonPayLoad + "DigitalPinData";
|
||||
payLoad = payLoad + String(TIME_JSON) + "9999";
|
||||
payLoad = payLoad + String(KEY_JSON) + getDataType(digitalPins[pin]);
|
||||
payLoad += String(VALUE_JSON);
|
||||
|
||||
|
||||
if ( digitalPins[pin] == TEMP_PIN ) {
|
||||
payLoad += String(getTemperature());
|
||||
} else if ( digitalRead(digitalPins[pin]) == HIGH ) {
|
||||
payLoad += "ON";
|
||||
} else if ( digitalRead(digitalPins[pin]) == LOW ) {
|
||||
payLoad += "OFF";
|
||||
}
|
||||
|
||||
payLoad = payLoad + String(END_JSON);
|
||||
|
||||
if(DEBUG) Serial.println(payLoad);
|
||||
|
||||
httpClient.print(HTTP_POST);
|
||||
httpClient.print(resource);
|
||||
httpClient.println(HTTP_VERSION);
|
||||
httpClient.println(host);
|
||||
httpClient.println(HTTP_CONTENT_TYPE);
|
||||
httpClient.print(HTTP_CONTENT_LEN);
|
||||
httpClient.println(payLoad.length());
|
||||
httpClient.println();
|
||||
httpClient.println(payLoad);
|
||||
httpClient.println();
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.print(HTTP_POST);
|
||||
Serial.print(resource);
|
||||
Serial.println(HTTP_VERSION);
|
||||
Serial.println(host);
|
||||
Serial.println(HTTP_CONTENT_TYPE);
|
||||
Serial.print(HTTP_CONTENT_LEN);
|
||||
Serial.println(payLoad.length());
|
||||
Serial.println();
|
||||
Serial.println(payLoad);
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
delay(1000);
|
||||
|
||||
while (httpClient.available()) {
|
||||
char response = httpClient.read();
|
||||
if(DEBUG) Serial.print(response);
|
||||
}
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.println();
|
||||
Serial.println("-------------------------------");
|
||||
}
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************************************************************************
|
||||
Only required for cases of reading analog pin values.
|
||||
An int Array of analog pins that needs to be read has to be initialised.
|
||||
This method will traverse the array and publish the data from the selected pins
|
||||
***********************************************************************************************/
|
||||
|
||||
|
||||
void pushAnalogPinData(){
|
||||
for ( int pin = 0; pin < (sizeof(analogPins)/sizeof(int)); pin++) {
|
||||
String resource = " " + String(SERVICE_EPOINT) + String(PUSH_ALARM_DATA) + " ";
|
||||
|
||||
String payLoad = jsonPayLoad + "AnalogPinData";
|
||||
payLoad = payLoad + String(TIME_JSON) + "9999";
|
||||
payLoad = payLoad + String(KEY_JSON) + getDataType(analogPins[pin]);
|
||||
payLoad = payLoad + String(VALUE_JSON) + analogRead(analogPins[pin]);
|
||||
payLoad = payLoad + String(END_JSON);
|
||||
|
||||
if(DEBUG) Serial.println(payLoad);
|
||||
|
||||
httpClient.print(HTTP_POST);
|
||||
httpClient.print(resource);
|
||||
httpClient.println(HTTP_VERSION);
|
||||
httpClient.println(host);
|
||||
httpClient.println(HTTP_CONTENT_TYPE);
|
||||
httpClient.print(HTTP_CONTENT_LEN);
|
||||
httpClient.println(payLoad.length());
|
||||
httpClient.println();
|
||||
httpClient.println(payLoad);
|
||||
httpClient.println();
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.print(HTTP_POST);
|
||||
Serial.print(resource);
|
||||
Serial.println(HTTP_VERSION);
|
||||
Serial.println(host);
|
||||
Serial.println(HTTP_CONTENT_TYPE);
|
||||
Serial.print(HTTP_CONTENT_LEN);
|
||||
Serial.println(payLoad.length());
|
||||
Serial.println();
|
||||
Serial.println(payLoad);
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
delay(1000);
|
||||
|
||||
while (httpClient.available()) {
|
||||
char response = httpClient.read();
|
||||
if(DEBUG) Serial.print(response);
|
||||
}
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.println();
|
||||
Serial.println("-------------------------------");
|
||||
}
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,2 @@
|
||||
templates=FireAlarmEthernetAgent.h
|
||||
zipfilename=SensebotEthernetAgent.zip
|
@ -0,0 +1,150 @@
|
||||
/**********************************************************************************************
|
||||
Use the below variables when required to set a static IP for the WifiSheild
|
||||
***********************************************************************************************/
|
||||
// byte dns2[] = { 8, 8, 8, 8 };
|
||||
// byte subnet[] = { 255, 255, 255, 0 };
|
||||
// byte gateway[] = { 10, 100, 9, 254 };
|
||||
// byte deviceIP[4] = { 10, 100, 9, 9 };
|
||||
// byte gateway[] = { 192, 168, 1, 1 };
|
||||
// byte deviceIP[4] = { 192, 168, 1, 219 };
|
||||
|
||||
// uint32_t ip, ddns, ssubnet, ggateway;
|
||||
|
||||
// byte mac[6] = { 0xC0, 0x4A, 0x00, 0x1A, 0x08, 0xDA }; //mac - c0:4a:00:1a:08:da
|
||||
// c0:4a:00:1a:03:f8
|
||||
// b8:27:eb:88:37:7a
|
||||
String connecting = "connecting.... ";
|
||||
|
||||
void connectHttp() {
|
||||
/* Initialise the module */
|
||||
if(DEBUG) Serial.println(F("\nInitializing..."));
|
||||
if (!cc3000.begin())
|
||||
{
|
||||
if(DEBUG) Serial.println(F("Couldn't begin()! Check your wiring?"));
|
||||
while(1);
|
||||
}
|
||||
|
||||
// if( cc3000.setMacAddress(mac) ) { // Set your own mac and print it to re-check
|
||||
// uint8_t address[6];
|
||||
// cc3000.getMacAddress(address);
|
||||
// if(DEBUG){
|
||||
// Serial.print(address[0], HEX); Serial.print(":");
|
||||
// Serial.print(address[1], HEX); Serial.print(":");
|
||||
// Serial.print(address[2], HEX); Serial.print(":");
|
||||
// Serial.print(address[3], HEX); Serial.print(":");
|
||||
// Serial.print(address[4], HEX); Serial.print(":");
|
||||
// Serial.println(address[5], HEX);
|
||||
// }
|
||||
// }
|
||||
|
||||
/**********************************************************************************************
|
||||
Only required if using static IP for the WifiSheild
|
||||
***********************************************************************************************/
|
||||
|
||||
// ip = cc3000.IP2U32(deviceIP[0], deviceIP[1], deviceIP[2], deviceIP[3]);
|
||||
// ddns = cc3000.IP2U32(dns2[0], dns2[1], dns2[2], dns2[3]);
|
||||
// ssubnet = cc3000.IP2U32(subnet[0], subnet[1], subnet[2], subnet[3]);
|
||||
// ggateway = cc3000.IP2U32(gateway[0], gateway[1], gateway[2], gateway[3]);
|
||||
// cc3000.setStaticIPAddress(ip, ssubnet, ggateway, ddns); // required for setting static IP
|
||||
|
||||
/***********************************************************************************************/
|
||||
|
||||
sserver = cc3000.IP2U32(server[0], server[1], server[2], server[3]);
|
||||
|
||||
if(CON_DEBUG) {
|
||||
Serial.print(F("\nAttempting to connect to "));
|
||||
Serial.println(WLAN_SSID);
|
||||
}
|
||||
|
||||
if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
|
||||
if(CON_DEBUG) Serial.println(F("Failed!"));
|
||||
while(1);
|
||||
}
|
||||
|
||||
if(CON_DEBUG) Serial.println(F("Connected to Wifi network!"));
|
||||
|
||||
if(CON_DEBUG) Serial.println(F("Request DHCP"));
|
||||
while (!cc3000.checkDHCP())
|
||||
{
|
||||
delay(100); // ToDo: Insert a DHCP timeout!
|
||||
}
|
||||
|
||||
/* Display the IP address DNS, Gateway, etc. */
|
||||
while (! displayConnectionDetails()) {
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
pushClient = cc3000.connectTCP(sserver, SERVICE_PORT); //SERVICE_PORT
|
||||
if (pushClient.connected()) {
|
||||
if(CON_DEBUG) Serial.println("PushClient Connected to server");
|
||||
} else {
|
||||
cc3000.disconnect();
|
||||
if(CON_DEBUG) Serial.println(F("PushClient Connection failed"));
|
||||
}
|
||||
|
||||
|
||||
pollClient = cc3000.connectTCP(sserver, SERVICE_PORT); //SERVICE_PORT
|
||||
if (pollClient.connected()) {
|
||||
if(CON_DEBUG) Serial.println("PollClient Connected to server");
|
||||
} else {
|
||||
cc3000.disconnect();
|
||||
if(CON_DEBUG) Serial.println(F("PollClient Connection failed"));
|
||||
}
|
||||
|
||||
if(CON_DEBUG) Serial.println(F("-------------------------------------"));
|
||||
}
|
||||
|
||||
|
||||
void setupResource(){
|
||||
String hostIP = getHostIP(server);
|
||||
String port = String(SERVICE_PORT);
|
||||
|
||||
host = "Host: " + hostIP + ":" + port;
|
||||
if(DEBUG) Serial.println(host);
|
||||
|
||||
jsonPayLoad = "{\"owner\":\"";
|
||||
jsonPayLoad += String(DEVICE_OWNER);
|
||||
jsonPayLoad += "\",\"deviceId\":\"";
|
||||
jsonPayLoad += String(DEVICE_ID);
|
||||
jsonPayLoad += "\",\"reply\":\"";
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.print("JSON Payload: ");
|
||||
Serial.println(jsonPayLoad);
|
||||
Serial.println("-------------------------------");
|
||||
}
|
||||
}
|
||||
|
||||
String getHostIP(byte server[4]){
|
||||
String hostIP = String(server[0]);
|
||||
|
||||
for ( int index = 1; index < 4; index++) {
|
||||
hostIP += "." + String(server[index]);
|
||||
}
|
||||
|
||||
return hostIP;
|
||||
}
|
||||
|
||||
|
||||
bool displayConnectionDetails(void)
|
||||
{
|
||||
uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;
|
||||
|
||||
if(!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv))
|
||||
{
|
||||
if(DEBUG) Serial.println(F("Unable to retrieve the IP Address!\r\n"));
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(CON_DEBUG) {
|
||||
Serial.print(F("\nIP Addr: ")); cc3000.printIPdotsRev(ipAddress);
|
||||
Serial.print(F("\nNetmask: ")); cc3000.printIPdotsRev(netmask);
|
||||
Serial.print(F("\nGateway: ")); cc3000.printIPdotsRev(gateway);
|
||||
Serial.print(F("\nDHCPsrv: ")); cc3000.printIPdotsRev(dhcpserv);
|
||||
Serial.print(F("\nDNSserv: ")); cc3000.printIPdotsRev(dnsserv);
|
||||
Serial.println();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
#ifndef FireAlarmWifiAgent_H
|
||||
#define FireAlarmWifiAgent_H
|
||||
|
||||
#if (ARDUINO >= 100)
|
||||
#include "Arduino.h"
|
||||
#else
|
||||
#include "WProgram.h"
|
||||
#endif
|
||||
|
||||
// These are the interrupt and control pins
|
||||
#define ADAFRUIT_CC3000_IRQ 3 // MUST be an interrupt pin!
|
||||
// These can be any two pins
|
||||
#define ADAFRUIT_CC3000_VBAT 5
|
||||
#define ADAFRUIT_CC3000_CS 10
|
||||
|
||||
#define WLAN_SSID "YourAP-SSID" // cannot be longer than 32 characters!
|
||||
#define WLAN_PASS "Your-Password"
|
||||
|
||||
#define WLAN_SECURITY WLAN_SEC_WPA2
|
||||
// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
|
||||
#define IDLE_TIMEOUT_MS 3000
|
||||
|
||||
#define DEVICE_OWNER "${DEVICE_OWNER}" //"SHABIRMEAN"
|
||||
#define DEVICE_ID "${DEVICE_ID}" //"vbhenqyt85yq"
|
||||
#define DEVICE_TOKEN "${DEVICE_TOKEN}"
|
||||
|
||||
|
||||
#define SERVICE_PORT 9763
|
||||
#define SERVICE_EPOINT "/firealarm/controller/"
|
||||
// pushalarmdata - application/json - {"owner":"","deviceId":"","replyMessage":"","time":"","key":"","value":""}
|
||||
// readcontrols/{owner}/{deviceId}
|
||||
// reply - application/json - {"owner":"","deviceId":"","replyMessage":""}
|
||||
|
||||
#define TEMP_PIN 6
|
||||
#define BULB_PIN 7
|
||||
#define FAN_PIN 8
|
||||
|
||||
#define POLL_INTERVAL 1000
|
||||
#define DEBUG false
|
||||
#define CON_DEBUG true
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -0,0 +1,156 @@
|
||||
#include "FireAlarmWifiAgent.h"
|
||||
|
||||
#include <Adafruit_CC3000.h>
|
||||
#include <SPI.h>
|
||||
#include "dht.h"
|
||||
#include <pt.h>
|
||||
|
||||
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
|
||||
SPI_CLOCK_DIVIDER); // you can change this clock speed
|
||||
|
||||
Adafruit_CC3000_Client pushClient;
|
||||
Adafruit_CC3000_Client pollClient;
|
||||
static struct pt pushThread;
|
||||
|
||||
uint32_t sserver;
|
||||
|
||||
/**********************************************************************************************
|
||||
0. Check with a sample Wifi code of the Adafruit_CC3000 library to ensure that the sheild is working
|
||||
1. Set the ip of the server(byte array below) where the Web-Rest API for the FireAlarm is running
|
||||
2. Check whether the "SERVICE_EPOINT" is correct in the 'FireAlarmWifiAgent.h' file
|
||||
3. Check whether the "SERVICE_PORT" is the same (9763) for the server running. Change it if needed
|
||||
4. Check whether the pins have been attached accordingly in the Arduino
|
||||
5. Check whether all reqquired pins are added to the 'digitalPins' array
|
||||
***********************************************************************************************/
|
||||
|
||||
byte server[4] = { 10, 100, 7, 38 };
|
||||
|
||||
int digitalPins[] = { TEMP_PIN, BULB_PIN, FAN_PIN };
|
||||
String host, jsonPayLoad, replyMsg;
|
||||
String responseMsg, subStrn;
|
||||
|
||||
void setup() {
|
||||
if(true) Serial.begin(115200);
|
||||
pinMode(BULB_PIN, OUTPUT);
|
||||
pinMode(FAN_PIN, OUTPUT);
|
||||
|
||||
PT_INIT(&pushThread);
|
||||
|
||||
connectHttp();
|
||||
setupResource();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (pushClient.connected() && pollClient.connected()) {
|
||||
pushData(); // batches all the required pin values together and pushes once
|
||||
|
||||
// pushDigitalPinData(); // pushes pin data via multiple calls with a single pin data per call
|
||||
// protothread1(&pushThread, 1000); // Pushes data and waits for control signals to be received
|
||||
delay(POLL_INTERVAL);
|
||||
|
||||
boolean valid = readControls();
|
||||
|
||||
if (!valid) {
|
||||
if (responseMsg.equals("TEMPERATURE")) {
|
||||
int temperature = (uint8_t)getTemperature();
|
||||
replyMsg = "Temperature is " + String(temperature) + " C";
|
||||
reply();
|
||||
} else if (responseMsg.equals("BULB")) {
|
||||
replyMsg = "Bulb was switched " + switchBulb();
|
||||
} else if (responseMsg.equals("FAN")) {
|
||||
replyMsg = "Buzzer was switched " + switchFan();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(DEBUG) {
|
||||
Serial.println("client not found...");
|
||||
Serial.println("disconnecting.");
|
||||
}
|
||||
pushClient.close();
|
||||
pollClient.close();
|
||||
cc3000.disconnect();
|
||||
|
||||
connectHttp();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String switchBulb() {
|
||||
if (digitalRead(BULB_PIN) == HIGH) {
|
||||
digitalWrite(BULB_PIN, LOW);
|
||||
return "OFF";
|
||||
} else {
|
||||
digitalWrite(BULB_PIN, HIGH);
|
||||
return "ON";
|
||||
}
|
||||
}
|
||||
|
||||
String switchFan() {
|
||||
if (digitalRead(FAN_PIN) == HIGH) {
|
||||
digitalWrite(FAN_PIN, LOW);
|
||||
return "OFF";
|
||||
} else {
|
||||
digitalWrite(FAN_PIN, HIGH);
|
||||
return "ON";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
double getTemperature(){
|
||||
dht DHT;
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.println("-------------------------------");
|
||||
Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)");
|
||||
Serial.print("DHT11, \t");
|
||||
}
|
||||
int chk = DHT.read11(TEMP_PIN);
|
||||
switch (chk)
|
||||
{
|
||||
case DHTLIB_OK:
|
||||
if(DEBUG) Serial.print("OK,\t");
|
||||
break;
|
||||
case DHTLIB_ERROR_CHECKSUM:
|
||||
if(DEBUG) Serial.print("Checksum error,\t");
|
||||
break;
|
||||
case DHTLIB_ERROR_TIMEOUT:
|
||||
if(DEBUG) Serial.print("Time out error,\t");
|
||||
break;
|
||||
case DHTLIB_ERROR_CONNECT:
|
||||
if(DEBUG) Serial.print("Connect error,\t");
|
||||
break;
|
||||
case DHTLIB_ERROR_ACK_L:
|
||||
if(DEBUG) Serial.print("Ack Low error,\t");
|
||||
break;
|
||||
case DHTLIB_ERROR_ACK_H:
|
||||
if(DEBUG) Serial.print("Ack High error,\t");
|
||||
break;
|
||||
default:
|
||||
if(DEBUG) Serial.print("Unknown error,\t");
|
||||
break;
|
||||
}
|
||||
|
||||
// DISPLAY DATA
|
||||
if(DEBUG) {
|
||||
Serial.print("\t");
|
||||
Serial.print(DHT.temperature, 1);
|
||||
Serial.print(",\t\t");
|
||||
Serial.println(DHT.humidity, 1);
|
||||
Serial.println("-------------------------------");
|
||||
}
|
||||
return DHT.temperature;
|
||||
}
|
||||
|
||||
|
||||
static int protothread1(struct pt *pt, int interval) {
|
||||
static unsigned long timestamp = 0;
|
||||
PT_BEGIN(pt);
|
||||
while(1) { // never stop
|
||||
/* each time the function it is checked whether any control signals are sent
|
||||
* if so exit this proto thread
|
||||
*/
|
||||
PT_WAIT_UNTIL(pt, readControls() );
|
||||
pushData();
|
||||
}
|
||||
PT_END(pt);
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
boolean readControls() {
|
||||
// String responseMsg;
|
||||
|
||||
pollClient.fastrprint(F("GET "));
|
||||
pollClient.fastrprint(SERVICE_EPOINT); pollClient.fastrprint(F("readcontrols/"));
|
||||
pollClient.fastrprint(DEVICE_OWNER); pollClient.fastrprint(F("/")); pollClient.fastrprint(DEVICE_ID);
|
||||
pollClient.fastrprint(F(" HTTP/1.1")); pollClient.fastrprint(F("\n"));
|
||||
pollClient.fastrprint(host.c_str()); pollClient.fastrprint(F("\n"));
|
||||
pollClient.println();
|
||||
|
||||
delay(1000);
|
||||
|
||||
if (true) {
|
||||
while (pollClient.available()) {
|
||||
char response = pollClient.read();
|
||||
responseMsg += response;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int index = responseMsg.lastIndexOf(":");
|
||||
int newLine = responseMsg.lastIndexOf("\n");
|
||||
subStrn = responseMsg.substring(index + 1);
|
||||
responseMsg = responseMsg.substring(newLine + 1, index);
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.print(responseMsg);
|
||||
Serial.println();
|
||||
Serial.println("-------------------------------");
|
||||
}
|
||||
|
||||
|
||||
if (subStrn.equals("IN")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void reply() {
|
||||
String payLoad = replyMsg + "\"}";
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.print(jsonPayLoad); Serial.println(payLoad);
|
||||
}
|
||||
|
||||
pollClient.fastrprint(F("POST "));
|
||||
pollClient.fastrprint(SERVICE_EPOINT); pollClient.fastrprint(F("reply"));
|
||||
pollClient.fastrprint(F(" HTTP/1.1")); pollClient.fastrprint(F("\n"));
|
||||
pollClient.fastrprint(host.c_str()); pollClient.fastrprint(F("\n"));
|
||||
pollClient.fastrprint(F("Content-Type: application/json")); pollClient.fastrprint(F("\n"));
|
||||
pollClient.fastrprint(F("Content-Length: "));
|
||||
|
||||
int payLength = jsonPayLoad.length() + payLoad.length();
|
||||
|
||||
pollClient.fastrprint(String(payLength).c_str()); pollClient.fastrprint(F("\n"));
|
||||
pollClient.fastrprint(F("\n"));
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.print("POST ");
|
||||
Serial.print(SERVICE_EPOINT); Serial.print("reply");
|
||||
Serial.print(" HTTP/1.1"); Serial.println();
|
||||
Serial.print(host); Serial.println();
|
||||
Serial.print("Content-Type: application/json"); Serial.println();
|
||||
Serial.print("Content-Length: ");
|
||||
Serial.print(payLength); Serial.println();
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
int chunkSize = 50;
|
||||
|
||||
for (int i = 0; i < jsonPayLoad.length(); i++) {
|
||||
if ( (i+1)*chunkSize > jsonPayLoad.length()) {
|
||||
pollClient.print(jsonPayLoad.substring(i*chunkSize, jsonPayLoad.length()));
|
||||
if(DEBUG) Serial.print(jsonPayLoad.substring(i*chunkSize, jsonPayLoad.length()));
|
||||
i = jsonPayLoad.length();
|
||||
} else {
|
||||
pollClient.print(jsonPayLoad.substring(i*chunkSize, (i+1)*chunkSize));
|
||||
if(DEBUG) Serial.print(jsonPayLoad.substring(i*chunkSize, (i+1)*chunkSize));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < payLoad.length(); i++) {
|
||||
if ( (i+1)*chunkSize > payLoad.length()) {
|
||||
pollClient.print(payLoad.substring(i*chunkSize, payLoad.length()));
|
||||
if(DEBUG) Serial.print(payLoad.substring(i*chunkSize, payLoad.length()));
|
||||
i = payLoad.length();
|
||||
} else {
|
||||
pollClient.print(payLoad.substring(i*chunkSize, (i+1)*chunkSize));
|
||||
if(DEBUG) Serial.print(payLoad.substring(i*chunkSize, (i+1)*chunkSize));
|
||||
}
|
||||
}
|
||||
|
||||
pollClient.fastrprint(F("\n"));
|
||||
if(DEBUG) Serial.println();
|
||||
|
||||
delay(1000);
|
||||
|
||||
if(true) {
|
||||
while (pollClient.available()) {
|
||||
char response = pollClient.read();
|
||||
if(DEBUG) Serial.print(response);
|
||||
}
|
||||
}
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.println();
|
||||
Serial.println("-------------------------------");
|
||||
}
|
||||
|
||||
payLoad = "";
|
||||
// delay(1000);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,279 @@
|
||||
|
||||
/**********************************************************************************************
|
||||
This method will traverse the array of digital pins and batch the data from the those pins together.
|
||||
It makes a single call to the server and sends all pin values as a batch.
|
||||
Server dis-assembles it accordingly and makes multiple publish calls for each sensor type.
|
||||
***********************************************************************************************/
|
||||
|
||||
void pushData(){
|
||||
String payLoad = "Data";
|
||||
payLoad = payLoad + "\",\"value\":\"";
|
||||
|
||||
for ( int pin = 0; pin < (sizeof(digitalPins)/sizeof(int)); pin++) {
|
||||
if ( digitalPins[pin] == TEMP_PIN ) {
|
||||
int temperature = (uint8_t)getTemperature();
|
||||
payLoad += temperature;
|
||||
} else if ( digitalRead(digitalPins[pin]) == HIGH ) {
|
||||
payLoad += "ON";
|
||||
} else if ( digitalRead(digitalPins[pin]) == LOW ) {
|
||||
payLoad += "OFF";
|
||||
}
|
||||
|
||||
if ( ((sizeof(digitalPins)/sizeof(int)) - 1) != pin ) {
|
||||
payLoad += "-";
|
||||
}
|
||||
|
||||
}
|
||||
payLoad += "\"}";
|
||||
|
||||
pushClient.fastrprint(F("POST "));
|
||||
pushClient.fastrprint(SERVICE_EPOINT); pushClient.fastrprint(F("pushalarmdata"));
|
||||
pushClient.fastrprint(F(" HTTP/1.1")); pushClient.fastrprint(F("\n"));
|
||||
pushClient.fastrprint(host.c_str()); pushClient.fastrprint(F("\n"));
|
||||
pushClient.fastrprint(F("Content-Type: application/json")); pushClient.fastrprint(F("\n"));
|
||||
pushClient.fastrprint(F("Content-Length: "));
|
||||
|
||||
int payLength = jsonPayLoad.length() + payLoad.length();
|
||||
|
||||
pushClient.fastrprint(String(payLength).c_str()); pushClient.fastrprint(F("\n"));
|
||||
pushClient.fastrprint(F("\n"));
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.print("POST ");
|
||||
Serial.print(SERVICE_EPOINT); Serial.print("pushalarmdata");
|
||||
Serial.print(" HTTP/1.1"); Serial.println();
|
||||
Serial.print(host); Serial.println();
|
||||
Serial.print("Content-Type: application/json"); Serial.println();
|
||||
Serial.print("Content-Length: ");
|
||||
Serial.print(payLength); Serial.println();
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
int chunkSize = 50;
|
||||
|
||||
for (int i = 0; i < jsonPayLoad.length(); i++) {
|
||||
if ( (i+1)*chunkSize > jsonPayLoad.length()) {
|
||||
pushClient.print(jsonPayLoad.substring(i*chunkSize, jsonPayLoad.length()));
|
||||
if(DEBUG) Serial.print(jsonPayLoad.substring(i*chunkSize, jsonPayLoad.length()));
|
||||
i = jsonPayLoad.length();
|
||||
} else {
|
||||
pushClient.print(jsonPayLoad.substring(i*chunkSize, (i+1)*chunkSize));
|
||||
if(DEBUG) Serial.print(jsonPayLoad.substring(i*chunkSize, (i+1)*chunkSize));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < payLoad.length(); i++) {
|
||||
if ( (i+1)*chunkSize > payLoad.length()) {
|
||||
pushClient.print(payLoad.substring(i*chunkSize, payLoad.length()));
|
||||
if(DEBUG) Serial.print(payLoad.substring(i*chunkSize, payLoad.length()));
|
||||
i = payLoad.length();
|
||||
} else {
|
||||
pushClient.print(payLoad.substring(i*chunkSize, (i+1)*chunkSize));
|
||||
if(DEBUG) Serial.print(payLoad.substring(i*chunkSize, (i+1)*chunkSize));
|
||||
}
|
||||
}
|
||||
|
||||
pushClient.fastrprint(F("\n"));
|
||||
if(DEBUG) Serial.println();
|
||||
|
||||
delay(1000);
|
||||
|
||||
if(true) {
|
||||
while (pushClient.available()) {
|
||||
char response = pushClient.read();
|
||||
if(DEBUG) Serial.print(response);
|
||||
}
|
||||
}
|
||||
|
||||
if(DEBUG) {
|
||||
Serial.println();
|
||||
Serial.println("-------------------------------");
|
||||
}
|
||||
|
||||
payLoad = "";
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************************************
|
||||
This method will traverse the array of digital pins and publish the data from the those pins.
|
||||
It differs from the above method such that the pin data is published one after the other in
|
||||
seperate calls to the server
|
||||
***********************************************************************************************/
|
||||
|
||||
|
||||
//void pushDigitalPinData(){
|
||||
// for ( int pin = 0; pin < (sizeof(digitalPins)/sizeof(int)); pin++) {
|
||||
// String payLoad = getDataType(digitalPins[pin]);
|
||||
// payLoad = payLoad + "\",\"value\":\"";
|
||||
//
|
||||
// if ( digitalPins[pin] == TEMP_PIN ) {
|
||||
// int temperature = (uint8_t)getTemperature();
|
||||
// payLoad += temperature;
|
||||
// } else if ( digitalRead(digitalPins[pin]) == HIGH ) {
|
||||
// payLoad += "ON";
|
||||
// } else if ( digitalRead(digitalPins[pin]) == LOW ) {
|
||||
// payLoad += "OFF";
|
||||
// }
|
||||
//
|
||||
// payLoad += "\"}";
|
||||
//
|
||||
// pushClient.fastrprint(F("POST "));
|
||||
// pushClient.fastrprint(SERVICE_EPOINT); pushClient.fastrprint(F("pushalarmdata"));
|
||||
// pushClient.fastrprint(F(" HTTP/1.1")); pushClient.fastrprint(F("\n"));
|
||||
// pushClient.fastrprint(host.c_str()); pushClient.fastrprint(F("\n"));
|
||||
// pushClient.fastrprint(F("Content-Type: application/json")); pushClient.fastrprint(F("\n"));
|
||||
// pushClient.fastrprint(F("Content-Length: "));
|
||||
//
|
||||
// int payLength = jsonPayLoad.length() + payLoad.length();
|
||||
//
|
||||
// pushClient.fastrprint(String(payLength).c_str()); pushClient.fastrprint(F("\n"));
|
||||
// pushClient.fastrprint(F("\n"));
|
||||
//
|
||||
// if(DEBUG) {
|
||||
// Serial.print("POST ");
|
||||
// Serial.print(SERVICE_EPOINT); Serial.print("pushalarmdata");
|
||||
// Serial.print(" HTTP/1.1"); Serial.println();
|
||||
// Serial.print(host); Serial.println();
|
||||
// Serial.print("Content-Type: application/json"); Serial.println();
|
||||
// Serial.print("Content-Length: ");
|
||||
// Serial.print(payLength); Serial.println();
|
||||
// Serial.println();
|
||||
// }
|
||||
//
|
||||
// int chunkSize = 50;
|
||||
//
|
||||
// for (int i = 0; i < jsonPayLoad.length(); i++) {
|
||||
// if ( (i+1)*chunkSize > jsonPayLoad.length()) {
|
||||
// pushClient.print(jsonPayLoad.substring(i*chunkSize, jsonPayLoad.length()));
|
||||
// if(DEBUG) Serial.print(jsonPayLoad.substring(i*chunkSize, jsonPayLoad.length()));
|
||||
// i = jsonPayLoad.length();
|
||||
// } else {
|
||||
// pushClient.print(jsonPayLoad.substring(i*chunkSize, (i+1)*chunkSize));
|
||||
// if(DEBUG) Serial.print(jsonPayLoad.substring(i*chunkSize, (i+1)*chunkSize));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// for (int i = 0; i < payLoad.length(); i++) {
|
||||
// if ( (i+1)*chunkSize > payLoad.length()) {
|
||||
// pushClient.print(payLoad.substring(i*chunkSize, payLoad.length()));
|
||||
// if(DEBUG) Serial.print(payLoad.substring(i*chunkSize, payLoad.length()));
|
||||
// i = payLoad.length();
|
||||
// } else {
|
||||
// pushClient.print(payLoad.substring(i*chunkSize, (i+1)*chunkSize));
|
||||
// if(DEBUG) Serial.print(payLoad.substring(i*chunkSize, (i+1)*chunkSize));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// pushClient.fastrprint(F("\n"));
|
||||
// if(DEBUG) Serial.println();
|
||||
//
|
||||
// delay(1000);
|
||||
//
|
||||
// if(true) {
|
||||
// while (pushClient.available()) {
|
||||
// char response = pushClient.read();
|
||||
// if(DEBUG) Serial.print(response);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(DEBUG) {
|
||||
// Serial.println();
|
||||
// Serial.println("-------------------------------");
|
||||
// }
|
||||
//
|
||||
// payLoad = "";
|
||||
//// delay(1000);
|
||||
// }
|
||||
//}
|
||||
|
||||
/**********************************************************************************************
|
||||
Only required for cases of reading analog pin values.
|
||||
An int Array of analog pins that needs to be read has to be initialised.
|
||||
This method will traverse the array and publish the data from the selected pins
|
||||
***********************************************************************************************/
|
||||
|
||||
//void pushAnalogPinData(){
|
||||
// for ( int pin = 0; pin < (sizeof(analogPins)/sizeof(int)); pin++) {
|
||||
// String payLoad = jsonPayLoad + "AnalogPinData";
|
||||
// payLoad = payLoad + "\",\"time\":\"" + "9999";
|
||||
// payLoad = payLoad + "\",\"key\":\"" + getDataType(analogPins[pin]);
|
||||
// payLoad = payLoad + "\",\"value\":\"" + analogRead(analogPins[pin]);
|
||||
// payLoad = payLoad + "\"}";
|
||||
//
|
||||
// pushClient.fastrprint(F("POST "));
|
||||
// pushClient.fastrprint(SERVICE_EPOINT); pushClient.fastrprint(F("pushalarmdata"));
|
||||
// pushClient.fastrprint(F(" HTTP/1.1")); pushClient.fastrprint(F("\n"));
|
||||
// pushClient.fastrprint(host.c_str()); pushClient.fastrprint(F("\n"));
|
||||
// pushClient.fastrprint(F("Content-Type: application/json")); pushClient.fastrprint(F("\n"));
|
||||
// pushClient.fastrprint(F("Content-Length: "));
|
||||
//
|
||||
// int payLength = payLoad.length();
|
||||
//
|
||||
// pushClient.fastrprint(String(payLength).c_str()); pushClient.fastrprint(F("\n"));
|
||||
// pushClient.fastrprint(F("\n"));
|
||||
//
|
||||
// if(DEBUG) {
|
||||
// Serial.print("POST ");
|
||||
// Serial.print(SERVICE_EPOINT); Serial.print("pushalarmdata");
|
||||
// Serial.print(" HTTP/1.1"); Serial.println();
|
||||
// Serial.print(host); Serial.println();
|
||||
// Serial.print("Content-Type: application/json"); Serial.println();
|
||||
// Serial.print("Content-Length: ");
|
||||
// Serial.print(payLength); Serial.println();
|
||||
// Serial.println();
|
||||
// }
|
||||
//
|
||||
// int chunkSize = 50;
|
||||
//
|
||||
// for (int i = 0; i < payLength; i++) {
|
||||
// if ( (i+1)*chunkSize > payLength) {
|
||||
// pushClient.print(payLoad.substring(i*chunkSize, payLength));
|
||||
// if(DEBUG) Serial.print(payLoad.substring(i*chunkSize, payLength));
|
||||
// i = payLength;
|
||||
// } else {
|
||||
// pushClient.print(payLoad.substring(i*chunkSize, (i+1)*chunkSize));
|
||||
// if(DEBUG) Serial.print(payLoad.substring(i*chunkSize, (i+1)*chunkSize));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// pushClient.fastrprint(F("\n"));
|
||||
// if(DEBUG) Serial.println();
|
||||
//
|
||||
// delay(1000);
|
||||
//
|
||||
// if(true) {
|
||||
// while (pushClient.available()) {
|
||||
// char response = pushClient.read();
|
||||
// if(DEBUG) Serial.print(response);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(DEBUG) {
|
||||
// Serial.println();
|
||||
// Serial.println("-------------------------------");
|
||||
// }
|
||||
//
|
||||
// payLoad = "";
|
||||
// delay(1000);
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
String getDataType(int pin){
|
||||
switch(pin){
|
||||
case TEMP_PIN:
|
||||
return "TEMP";
|
||||
case BULB_PIN:
|
||||
return "BULB";
|
||||
case FAN_PIN:
|
||||
return "FAN";
|
||||
default:
|
||||
return String(pin);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,2 @@
|
||||
templates=FireAlarmWifiAgent.h
|
||||
zipfilename=SensebotWifiAgent.zip
|