forked from obycode/DSCAlarmSmartThings
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from d8adrvn/reconfigure-hardware
Reconfigure hardware
- Loading branch information
Showing
22 changed files
with
6,189 additions
and
658 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
12 |
1,809 changes: 1,809 additions & 0 deletions
1,809
.../libraries/SmartThings/.svn/pristine/0e/0eb452a4be6c8c2d4845966392f7c93532d1ab83.svn-base
Large diffs are not rendered by default.
Oops, something went wrong.
164 changes: 164 additions & 0 deletions
164
.../libraries/SmartThings/.svn/pristine/3b/3b72cff67002f5fee09b849ca61e5c5add6a4966.svn-base
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
//***************************************************************************** | ||
/// @file | ||
/// @brief | ||
/// Arduino SmartThings Shield LED Example with Network Status | ||
/// @note | ||
/// ______________ | ||
/// | | | ||
/// | SW[] | | ||
/// |[]RST | | ||
/// | AREF |-- | ||
/// | GND |-- | ||
/// | 13 |--X LED | ||
/// | 12 |-- | ||
/// | 11 |-- | ||
/// --| 3.3V 10 |-- | ||
/// --| 5V 9 |-- | ||
/// --| GND 8 |-- | ||
/// --| GND | | ||
/// --| Vin 7 |-- | ||
/// | 6 |-- | ||
/// --| A0 5 |-- | ||
/// --| A1 ( ) 4 |-- | ||
/// --| A2 3 |--X THING_RX | ||
/// --| A3 ____ 2 |--X THING_TX | ||
/// --| A4 | | 1 |-- | ||
/// --| A5 | | 0 |-- | ||
/// |____| |____| | ||
/// |____| | ||
/// | ||
//***************************************************************************** | ||
#include <SoftwareSerial.h> //TODO need to set due to some weird wire language linker, should we absorb this whole library into smartthings | ||
#include <SmartThings.h> | ||
|
||
//***************************************************************************** | ||
// Pin Definitions | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ||
// V V V V V V V V V V V V V V V V V V V V V V V V V V V V V | ||
//***************************************************************************** | ||
#define PIN_LED 13 | ||
#define PIN_THING_RX 3 | ||
#define PIN_THING_TX 2 | ||
|
||
//***************************************************************************** | ||
// Global Variables | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ||
// V V V V V V V V V V V V V V V V V V V V V V V V V V V V V | ||
//***************************************************************************** | ||
SmartThingsCallout_t messageCallout; // call out function forward decalaration | ||
SmartThings smartthing(PIN_THING_RX, PIN_THING_TX, messageCallout); // constructor | ||
|
||
bool isDebugEnabled; // enable or disable debug in this example | ||
int stateLED; // state to track last set value of LED | ||
int stateNetwork; // state of the network | ||
|
||
//***************************************************************************** | ||
// Local Functions | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ||
// V V V V V V V V V V V V V V V V V V V V V V V V V V V V V V | ||
//***************************************************************************** | ||
void on() | ||
{ | ||
stateLED = 1; // save state as 1 (on) | ||
digitalWrite(PIN_LED, HIGH); // turn LED on | ||
smartthing.shieldSetLED(0, 0, 2); | ||
smartthing.send("on"); // send message to cloud | ||
} | ||
|
||
//***************************************************************************** | ||
void off() | ||
{ | ||
stateLED = 0; // set state to 0 (off) | ||
digitalWrite(PIN_LED, LOW); // turn LED off | ||
smartthing.shieldSetLED(0, 0, 0); | ||
smartthing.send("off"); // send message to cloud | ||
} | ||
|
||
//***************************************************************************** | ||
void setNetworkStateLED() | ||
{ | ||
SmartThingsNetworkState_t tempState = smartthing.shieldGetLastNetworkState(); | ||
if (tempState != stateNetwork) | ||
{ | ||
switch (tempState) | ||
{ | ||
case STATE_NO_NETWORK: | ||
if (isDebugEnabled) Serial.println("NO_NETWORK"); | ||
smartthing.shieldSetLED(2, 0, 0); // red | ||
break; | ||
case STATE_JOINING: | ||
if (isDebugEnabled) Serial.println("JOINING"); | ||
smartthing.shieldSetLED(2, 0, 0); // red | ||
break; | ||
case STATE_JOINED: | ||
if (isDebugEnabled) Serial.println("JOINED"); | ||
smartthing.shieldSetLED(0, 0, 0); // off | ||
break; | ||
case STATE_JOINED_NOPARENT: | ||
if (isDebugEnabled) Serial.println("JOINED_NOPARENT"); | ||
smartthing.shieldSetLED(2, 0, 2); // purple | ||
break; | ||
case STATE_LEAVING: | ||
if (isDebugEnabled) Serial.println("LEAVING"); | ||
smartthing.shieldSetLED(2, 0, 0); // red | ||
break; | ||
default: | ||
case STATE_UNKNOWN: | ||
if (isDebugEnabled) Serial.println("UNKNOWN"); | ||
smartthing.shieldSetLED(0, 2, 0); // green | ||
break; | ||
} | ||
stateNetwork = tempState; | ||
} | ||
} | ||
|
||
//***************************************************************************** | ||
// API Functions | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ||
// V V V V V V V V V V V V V V V V V V V V V V V V V V V V V V | ||
//***************************************************************************** | ||
void setup() | ||
{ | ||
// setup default state of global variables | ||
isDebugEnabled = true; | ||
stateLED = 0; // matches state of hardware pin set below | ||
stateNetwork = STATE_JOINED; // set to joined to keep state off if off | ||
|
||
// setup hardware pins | ||
pinMode(PIN_LED, OUTPUT); // define PIN_LED as an output | ||
digitalWrite(PIN_LED, LOW); // set value to LOW (off) to match stateLED=0 | ||
|
||
if (isDebugEnabled) | ||
{ // setup debug serial port | ||
Serial.begin(9600); // setup serial with a baud rate of 9600 | ||
Serial.println("setup.."); // print out 'setup..' on start | ||
} | ||
} | ||
|
||
//***************************************************************************** | ||
void loop() | ||
{ | ||
// run smartthing logic | ||
smartthing.run(); | ||
setNetworkStateLED(); | ||
} | ||
|
||
//***************************************************************************** | ||
void messageCallout(String message) | ||
{ | ||
// if debug is enabled print out the received message | ||
if (isDebugEnabled) | ||
{ | ||
Serial.print("Received message: '"); | ||
Serial.print(message); | ||
Serial.println("' "); | ||
} | ||
|
||
// if message contents equals to 'on' then call on() function | ||
// else if message contents equals to 'off' then call off() function | ||
if (message.equals("on")) | ||
{ | ||
on(); | ||
} | ||
else if (message.equals("off")) | ||
{ | ||
off(); | ||
} | ||
} | ||
|
36 changes: 36 additions & 0 deletions
36
.../libraries/SmartThings/.svn/pristine/3d/3d706401033c22a264b629acb73a32b3543cb77c.svn-base
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
-------------------------------------------------------------------------------------------------- | ||
| Setup Instructions | | ||
-------------------------------------------------------------------------------------------------- | ||
1) Copy the entire SmartThings directory into the 'libraries' directory in your sketchbook location. | ||
Windows: 'My Documents\Arduino\libraries\SmartThings' | ||
OSX: '~/Documents/Arduino/libraries/SmartThings' | ||
|
||
-------------------------------------------------------------------------------------------------- | ||
| Notes | | ||
-------------------------------------------------------------------------------------------------- | ||
|
||
|
||
-------------------------------------------------------------------------------------------------- | ||
| ChangeLog: | | ||
-------------------------------------------------------------------------------------------------- | ||
01/11/2015 (v0.0.6) do + Added Hardware Serial Constructor | ||
+ Added support for Leonardo and MEGA | ||
~ Performance improvements | ||
~ Significant SRAM memory optimizations (minimum ~175 bytes, up to 430 bytes) | ||
02/11/2012 (v0.0.5) db + shieldGetLastNetworkStatus to public Class | ||
+ example/stLEDwithNetworkStatus | ||
~ renamed SmartThingsLED to stLED | ||
+ ascii diagram for each example documenting pins & usage | ||
02/08/2012 (v0.0.4) db + Add docs/Doxygen | ||
+ Begin Framework for working on Leonardo (incomplete) | ||
~ Minor format cleanup | ||
02/08/2012 (v0.0.3) db ! Fixed regression in last commit with rgb | ||
02/07/2012 (v0.0.2) db ! Fixed typo in send functions | ||
! Changed write to print for maximal compatibility with serial code | ||
dm ! Point Library to Absolute Path, Add documentation | ||
02/06/2012 (v0.0.1) db ! Lowered Baud to 2400 due to softwareSerial rxBuffer size issue | ||
+ Add shield Commands(SetLED, Leave, Find, NetworkStatus) | ||
+ Updated Example to also SetLED with on/off control | ||
+ Add Doxygen comments & Version to Lib | ||
02/04/2012 (unversioned) db + Initial Commit (currently depends on SoftwareSerial) | ||
|
18 changes: 18 additions & 0 deletions
18
.../libraries/SmartThings/.svn/pristine/56/56de6cf6d71cce67afae28f6240c38326ef41d55.svn-base
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
####################################### | ||
# Data Types | ||
####################################### | ||
SmartThings KEYWORD1 | ||
SmartThingsCallout_t KEYWORD1 | ||
SmartThingsNetworkState_t KEYWORD1 | ||
SmartThingsSerialType_t KEYWORD1 | ||
|
||
####################################### | ||
# Public Methods / Functions | ||
####################################### | ||
run KEYWORD2 | ||
send KEYWORD2 | ||
shieldSetLED KEYWORD2 | ||
shieldFindNetwork KEYWORD2 | ||
shieldLeaveNetwork KEYWORD2 | ||
shieldGetLastNetworkState KEYWORD2 | ||
shieldGetNetworkState KEYWORD2 |
Oops, something went wrong.