diff --git a/Arduino/Sketches/ST_Anything_Alarm_Panel/ST_Anything_Alarm_Panel.ino b/Arduino/Sketches/ST_Anything_Alarm_Panel/ST_Anything_Alarm_Panel.ino deleted file mode 100644 index 555fbf3f..00000000 --- a/Arduino/Sketches/ST_Anything_Alarm_Panel/ST_Anything_Alarm_Panel.ino +++ /dev/null @@ -1,195 +0,0 @@ -//****************************************************************************************** -// File: ST_Anything_Alarm_Panel.ino -// Authors: Dan G Ogorchock & Daniel J Ogorchock (Father and Son) -// -// Summary: This Arduino Sketch, along with the ST_Anything library and the revised SmartThings -// library, demonstrates the ability of one Arduino + SmartThings Shield to -// implement a multi input/output custom device for integration into SmartThings. -// The ST_Anything library takes care of all of the work to schedule device updates -// as well as all communications with the SmartThings Shield. -// -// ST_Anything_Alarm_Panel implements the following: -// - 10 x Contact Sensor devices (used to monitor magnetic door/windows sensors) -// - 2 x Motion device (used to detect motion) -// - 3 x Smoke Detectors -// - 1 x Siren -// -// During the development of this re-usable library, it became apparent that the -// Arduino UNO R3's very limited 2K of SRAM was very limiting in the number of -// devices that could be implemented simultaneously. A tremendous amount of effort -// has gone into reducing the SRAM usage, including siginificant improvements to -// the SmartThings Arduino library. The SmartThings library was also modified to -// include support for using Hardware Serial port(s) on the UNO, MEGA, and Leonardo. -// During testing, it was determined that the Hardware Serial ports provide much -// better performance and reliability versus the SoftwareSerial library. Also, the -// MEGA 2560's 8K of SRAM is well worth the few extra dollars to save your sanity -// versus always running out of SRAM on the UNO R3. The MEGA 2560 also has 4 Hardware -// serial ports (i.e. UARTS) which makes it very easy to use Hardware Serial instead -// of SoftwareSerial, while still being able to see debug data on the USB serial -// console port (pins 0 & 1). -// -// Note: We did not have a Leonardo for testing, but did fully test on UNO R3 and -// MEGA 2560 using both SoftwareSerial and Hardware Serial communications to the -// Thing Shield. -// -// Change History: -// -// Date Who What -// ---- --- ---- -// 2015-01-03 Dan & Daniel Original Creation -// 2015-01-07 Dan Ogorchock Modified for Door Monitoring and Garage Door Control -// 2015-03-28 Dan Ogorchock Removed RCSwitch #include now that the libraries are split up -// 2015-03-31 Daniel O. Memory optimizations utilizing progmem -// 2015-12-06 Dan Ogorchock Revised to add Smoke Detector Capability -// -//****************************************************************************************** - -//****************************************************************************************** -// SmartThings Library for Arduino Shield -//****************************************************************************************** -#include //Arduino UNO/Leonardo uses SoftwareSerial for the SmartThings Library -#include //Library to provide API to the SmartThings Shield -#include - -//****************************************************************************************** -// ST_Anything Library -//****************************************************************************************** -#include //Constants.h is designed to be modified by the end user to adjust behavior of the ST_Anything library -#include //Generic Device Class, inherited by Sensor and Executor classes -#include //Generic Sensor Class, typically provides data to ST Cloud (e.g. Temperature, Motion, etc...) -#include //Generic Interrupt "Sensor" Class, waits for change of state on digital input -#include //Master Brain of ST_Anything library that ties everything together and performs ST Shield communications - -#include //Implements an Interrupt Sensor (IS) to detect motion via a PIR sensor -#include //Implements an Interrupt Sensor (IS) to monitor the status of a digital input pin -#include //Implements an Interrupt Sensor (IS) to monitor the status of a digital input pin -#include //Implements Executor (EX)as an Alarm Siren capability via a digital output to a relay - -//****************************************************************************************** -//Define which Arduino Pins will be used for each device -// Notes: -Serial Communications Pins are defined in Constants.h (avoid pins 0,1,2,3 -// for inputs and output devices below as they may be used for communications) -// -Always avoid Pin 6 as it is reserved by the SmartThings Shield -// -//****************************************************************************************** -//"RESERVED" pins for SmartThings ThingShield - best to avoid -#define PIN_O_RESERVED 0 //reserved by ThingShield for Serial communications OR USB Serial Monitor -#define PIN_1_RESERVED 1 //reserved by ThingShield for Serial communications OR USB Serial Monitor -#define PIN_2_RESERVED 2 //reserved by ThingShield for Serial communications -#define PIN_3_RESERVED 3 //reserved by ThingShield for Serial communications -#define PIN_6_RESERVED 6 //reserved by ThingShield (possible future use?) - - -//Mmotion Detector Pins -#define PIN_MOTION_1 22 -#define PIN_MOTION_2 23 - -//Contact Sensor Pins -#define PIN_CONTACT_1 26 -#define PIN_CONTACT_2 27 -#define PIN_CONTACT_3 28 -#define PIN_CONTACT_4 29 -#define PIN_CONTACT_5 30 -#define PIN_CONTACT_6 31 -#define PIN_CONTACT_7 32 -#define PIN_CONTACT_8 33 -#define PIN_CONTACT_9 34 -#define PIN_CONTACT_10 35 - -//Smoke Detector Pins -#define PIN_SMOKE_1 40 -#define PIN_SMOKE_2 41 -#define PIN_SMOKE_3 42 - -//Alarm Siren Pin -#define PIN_ALARM 50 - - -//****************************************************************************************** -//Arduino Setup() routine -//****************************************************************************************** -void setup() -{ - //****************************************************************************************** - //Declare each Device that is attached to the Arduino - // Notes: - For each device, there is typically a corresponding "tile" defined in your - // SmartThings DeviceType Groovy code - // - For details on each device's constructor arguments below, please refer to the - // corresponding header (.h) and program (.cpp) files. - // - The name assigned to each device (1st argument below) must match the Groovy - // DeviceType Tile name. - //****************************************************************************************** - - static st::IS_Motion sensor1(F("motion1"), PIN_MOTION_1, HIGH, false); - static st::IS_Motion sensor2(F("motion2"), PIN_MOTION_2, HIGH, false); - - static st::IS_Contact sensor3(F("contact1"), PIN_CONTACT_1, LOW, true, 500); - static st::IS_Contact sensor4(F("contact2"), PIN_CONTACT_2, LOW, true, 500); - static st::IS_Contact sensor5(F("contact3"), PIN_CONTACT_3, LOW, true, 500); - static st::IS_Contact sensor6(F("contact4"), PIN_CONTACT_4, LOW, true, 500); - static st::IS_Contact sensor7(F("contact5"), PIN_CONTACT_5, LOW, true, 500); - static st::IS_Contact sensor8(F("contact6"), PIN_CONTACT_6, LOW, true, 500); - static st::IS_Contact sensor9(F("contact7"), PIN_CONTACT_7, LOW, true, 500); - static st::IS_Contact sensor10(F("contact8"), PIN_CONTACT_8, LOW, true, 500); - static st::IS_Contact sensor11(F("contact9"), PIN_CONTACT_9, LOW, true, 500); - static st::IS_Contact sensor12(F("contact10"), PIN_CONTACT_10, LOW, true, 500); - - static st::IS_Smoke sensor13(F("smoke1"), PIN_SMOKE_1, HIGH, true, 500); - static st::IS_Smoke sensor14(F("smoke2"), PIN_SMOKE_2, HIGH, true, 500); - static st::IS_Smoke sensor15(F("smoke3"), PIN_SMOKE_3, HIGH, true, 500); - - static st::EX_Alarm executor1(F("alarm"), PIN_ALARM, LOW, true); - //***************************************************************************** - // Configure debug print output from each main class - // -Note: Set these to "false" if using Hardware Serial on pins 0 & 1 - // to prevent communication conflicts with the ST Shield communications - //***************************************************************************** - st::Everything::debug=true; - st::Device::debug=true; - st::InterruptSensor::debug=true; - - //***************************************************************************** - //Initialize the "Everything" Class - //***************************************************************************** - st::Everything::init(); - - //***************************************************************************** - //Add each sensor (i.e inputs) to the "Everything" Class - //***************************************************************************** - st::Everything::addSensor(&sensor1); - st::Everything::addSensor(&sensor2); - st::Everything::addSensor(&sensor3); - st::Everything::addSensor(&sensor4); - st::Everything::addSensor(&sensor5); - st::Everything::addSensor(&sensor6); - st::Everything::addSensor(&sensor7); - st::Everything::addSensor(&sensor8); - st::Everything::addSensor(&sensor9); - st::Everything::addSensor(&sensor10); - st::Everything::addSensor(&sensor11); - st::Everything::addSensor(&sensor12); - st::Everything::addSensor(&sensor13); - st::Everything::addSensor(&sensor14); - st::Everything::addSensor(&sensor15); - - //***************************************************************************** - //Add each executor (i.e. ouputs) to the "Everything" Class - //***************************************************************************** - st::Everything::addExecutor(&executor1); - - //***************************************************************************** - //Initialize each of the devices which were added to the Everything Class - //***************************************************************************** - st::Everything::initDevices(); -} - -//****************************************************************************************** -//Arduino Loop() routine -//****************************************************************************************** -void loop() -{ - //***************************************************************************** - //Execute the Everything run method which takes care of "Everything" - //***************************************************************************** - st::Everything::run(); -} diff --git a/Arduino/Sketches/ST_Anything_DS18B20_Temperature/ST_Anything_DS18B20_Temperature.ino b/Arduino/Sketches/ST_Anything_DS18B20_Temperature/ST_Anything_DS18B20_Temperature.ino deleted file mode 100644 index ff6126bb..00000000 --- a/Arduino/Sketches/ST_Anything_DS18B20_Temperature/ST_Anything_DS18B20_Temperature.ino +++ /dev/null @@ -1,138 +0,0 @@ -//****************************************************************************************** -// File: ST_Anything_DS18B20_Temperature.ino -// Authors: Dan G Ogorchock -// -// Summary: This Arduino Sketch, along with the ST_Anything library and the revised SmartThings -// library, demonstrates the ability of one Arduino + SmartThings Shield to -// implement a DS18B20 Temperature Sensor device for integration into SmartThings. -// The ST_Anything library takes care of all of the work to schedule device updates -// as well as all communications with the SmartThings Shield. -// -// During the development of this re-usable library, it became apparent that the -// Arduino UNO R3's very limited 2K of SRAM was very limiting in the number of -// devices that could be implemented simultaneously. A tremendous amount of effort -// has gone into reducing the SRAM usage, including siginificant improvements to -// the SmartThings Arduino library. The SmartThings library was also modified to -// include support for using Hardware Serial port(s) on the UNO, MEGA, and Leonardo. -// During testing, it was determined that the Hardware Serial ports provide much -// better performance and reliability versus the SoftwareSerial library. Also, the -// MEGA 2560's 8K of SRAM is well worth the few extra dollars to save your sanity -// versus always running out of SRAM on the UNO R3. The MEGA 2560 also has 4 Hardware -// serial ports (i.e. UARTS) which makes it very easy to use Hardware Serial instead -// of SoftwareSerial, while still being able to see debug data on the USB serial -// console port (pins 0 & 1). -// -// Note: We did not have a Leonardo for testing, but did fully test on UNO R3 and -// MEGA 2560 using both SoftwareSerial and Hardware Serial communications to the -// Thing Shield. -// -// Change History: -// -// Date Who What -// ---- --- ---- -// 2016-02-19 Dan Ogorchock Created example for Dallas Semiconductor 1-Wire DS18B20 Temperature Sensor -// 2016-02-27 Dan Ogorchock Added support for multiple DS18B20 sensors on single 1-wire network -// -//****************************************************************************************** -//****************************************************************************************** -// SmartThings Library for Arduino Shield -//****************************************************************************************** -#include //Arduino UNO/Leonardo uses SoftwareSerial for the SmartThings Library -#include //Library to provide API to the SmartThings Shield -#include -#include -#include - -#include - -//****************************************************************************************** -// ST_Anything Library -//****************************************************************************************** -#include //Constants.h is designed to be modified by the end user to adjust behavior of the ST_Anything library -#include //Generic Device Class, inherited by Sensor and Executor classes -#include //Generic Sensor Class, typically provides data to ST Cloud (e.g. Temperature, Motion, etc...) -#include //Generic Executor Class, typically receives data from ST Cloud (e.g. Switch) -#include //Generic Interrupt "Sensor" Class, waits for change of state on digital input -#include //Generic Polling "Sensor" Class, polls Arduino pins periodically -#include //Master Brain of ST_Anything library that ties everything together and performs ST Shield communications - -#include //Implement a Polling Sensor (PS) to measure Temperature via DS18B20 - -//****************************************************************************************** -//Define which Arduino Pins will be used for each device -// Notes: -Serial Communications Pins are defined in Constants.h (avoid pins 0,1,2,3 -// for inputs and output devices below as they may be used for communications) -// -Always avoid Pin 6 as it is reserved by the SmartThings Shield -// -//****************************************************************************************** -//"RESERVED" pins for SmartThings ThingShield - best to avoid -#define PIN_O_RESERVED 0 //reserved by ThingShield for Serial communications OR USB Serial Monitor -#define PIN_1_RESERVED 1 //reserved by ThingShield for Serial communications OR USB Serial Monitor -#define PIN_2_RESERVED 2 //reserved by ThingShield for Serial communications -#define PIN_3_RESERVED 3 //reserved by ThingShield for Serial communications -#define PIN_6_RESERVED 6 //reserved by ThingShield (possible future use?) - -#define PIN_DS18B20_Temperature 8 - -//****************************************************************************************** -//Arduino Setup() routine -//****************************************************************************************** -void setup() -{ - //****************************************************************************************** - //Declare each Device that is attached to the Arduino - // Notes: - For each device, there is typically a corresponding "tile" defined in your - // SmartThings DeviceType Groovy code - // - For details on each device's constructor arguments below, please refer to the - // corresponding header (.h) and program (.cpp) files. - // - The name assigned to each device (1st argument below) must match the Groovy - // DeviceType Tile name. - //****************************************************************************************** - //Polling Sensors - static st::PS_DS18B20_Temperature sensor1(F("temperature"), 120, 0, PIN_DS18B20_Temperature, false, 10, 1); - - //Interrupt Sensors - - - //***************************************************************************** - // Configure debug print output from each main class - // -Note: Set these to "false" if using Hardware Serial on pins 0 & 1 - // to prevent communication conflicts with the ST Shield communications - //***************************************************************************** - st::Everything::debug=true; - st::Executor::debug=true; - st::Device::debug=true; - st::PollingSensor::debug=true; - st::InterruptSensor::debug=true; - - //***************************************************************************** - //Initialize the "Everything" Class - //***************************************************************************** - st::Everything::init(); - - //***************************************************************************** - //Add each sensor to the "Everything" Class - //***************************************************************************** - st::Everything::addSensor(&sensor1); - - //***************************************************************************** - //Add each executor to the "Everything" Class - //***************************************************************************** - //st::Everything::addExecutor(&executor1); - - //***************************************************************************** - //Initialize each of the devices which were added to the Everything Class - st::Everything::initDevices(); - //***************************************************************************** -} - -//****************************************************************************************** -//Arduino Loop() routine -//****************************************************************************************** -void loop() -{ - //***************************************************************************** - //Execute the Everything run method which takes care of "Everything" - //***************************************************************************** - st::Everything::run(); -} diff --git a/Arduino/Sketches/ST_Anything_Doors/ST_Anything_Doors.ino b/Arduino/Sketches/ST_Anything_Doors_ThingShield/ST_Anything_Doors_ThingShield.ino similarity index 81% rename from Arduino/Sketches/ST_Anything_Doors/ST_Anything_Doors.ino rename to Arduino/Sketches/ST_Anything_Doors_ThingShield/ST_Anything_Doors_ThingShield.ino index 6c941a81..792386b2 100644 --- a/Arduino/Sketches/ST_Anything_Doors/ST_Anything_Doors.ino +++ b/Arduino/Sketches/ST_Anything_Doors_ThingShield/ST_Anything_Doors_ThingShield.ino @@ -1,5 +1,5 @@ //****************************************************************************************** -// File: ST_Anything_Doors.ino +// File: ST_Anything_Doors_ThingShield.ino // Authors: Dan G Ogorchock & Daniel J Ogorchock (Father and Son) // // Summary: This Arduino Sketch, along with the ST_Anything library and the revised SmartThings @@ -40,16 +40,14 @@ // 2015-01-07 Dan Ogorchock Modified for Door Monitoring and Garage Door Control // 2015-03-28 Dan Ogorchock Removed RCSwitch #include now that the libraries are split up // 2015-03-31 Daniel O. Memory optimizations utilizing progmem +// 2017-02-12 Dan Ogorchock Revised to use the new SMartThings v2.0 library // //****************************************************************************************** //****************************************************************************************** // SmartThings Library for Arduino Shield //****************************************************************************************** -#include //Arduino UNO/Leonardo uses SoftwareSerial for the SmartThings Library -#include //Library to provide API to the SmartThings Shield -#include //DHT Temperature and Humidity Library -#include +#include //Library to provide API to the SmartThings Shield //****************************************************************************************** // ST_Anything Library @@ -97,7 +95,25 @@ #define PIN_CONTACT_KITCHEN_DOOR 12 #define PIN_CONTACT_SIDEGARAGE_DOOR 13 +//If using SoftwareSerial (e.g. Arduino UNO), must define pins for transmit and receive +#define pinRX 3 +#define pinTX 2 +//****************************************************************************************** +//st::Everything::callOnMsgSend() optional callback routine. This is a sniffer to monitor +// data being sent to ST. This allows a user to act on data changes locally within the +// Arduino sktech. +//****************************************************************************************** +void callback(const String &msg) +{ + Serial.print(F("ST_Anything Callback: Sniffed data = ")); + Serial.println(msg); + + //TODO: Add local logic here to take action when a device's value/state is changed + + //Masquerade as the ThingShield to send data to the Arduino, as if from the ST Cloud (uncomment and edit following line) + //st::receiveSmartString("Put your command here!"); //use same strings that the Device Handler would send +} //****************************************************************************************** //Arduino Setup() routine @@ -146,6 +162,23 @@ void setup() //***************************************************************************** //Initialize the "Everything" Class //***************************************************************************** + + //Initialize the optional local callback routine (safe to comment out if not desired) + st::Everything::callOnMsgSend = callback; + + //Create the SmartThings Thingshield Communications Object based on Arduino Model + #if defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_MINI) //Arduino UNO, NANO, MINI + st::Everything::SmartThing = new st::SmartThingsThingShield(pinRX, pinTX, st::receiveSmartString); //Use Software Serial + #elif defined(ARDUINO_AVR_LEONARDO) //Arduino Leonardo + st::Everything::SmartThing = new st::SmartThingsThingShield(&Serial1, st::receiveSmartString); //Use Hardware Serial + #elif defined(ARDUINO_AVR_MEGA) || defined(ARDUINO_AVR_MEGA2560) //Arduino MEGA 1280 or 2560 + st::Everything::SmartThing = new st::SmartThingsThingShield(&Serial3, st::receiveSmartString); //Use Hardware Serial + #else + //assume user is using an UNO for the unknown case + st::Everything::SmartThing = new st::SmartThingsThingShield(pinRX, pinTX, st::receiveSmartString); //Software Serial + #endif + + //Run the Everything class' init() routine which establishes communications with SmartThings st::Everything::init(); //***************************************************************************** @@ -180,4 +213,4 @@ void loop() //Execute the Everything run method which takes care of "Everything" //***************************************************************************** st::Everything::run(); -} +} diff --git a/Arduino/Sketches/ST_Anything_Doors_Windows/ST_Anything_Doors_Windows.ino b/Arduino/Sketches/ST_Anything_Doors_Windows/ST_Anything_Doors_Windows.ino deleted file mode 100644 index 48ae83b9..00000000 --- a/Arduino/Sketches/ST_Anything_Doors_Windows/ST_Anything_Doors_Windows.ino +++ /dev/null @@ -1,177 +0,0 @@ -//****************************************************************************************** -// File: ST_Anything_Doors_Windows.ino -// Authors: Dan G Ogorchock & Daniel J Ogorchock (Father and Son) -// -// Summary: This Arduino Sketch, along with the ST_Anything library and the revised SmartThings -// library, demonstrates the ability of one Arduino + SmartThings Shield to -// implement a multi input/output custom device for integration into SmartThings. -// The ST_Anything library takes care of all of the work to schedule device updates -// as well as all communications with the SmartThings Shield. -// -// ST_Anything_Doors_Example implements the following: -// - 13 x Contact Sensor devices (used to monitor magnetic door/windows sensors) -// - 1 x Motion device (used to detect motion) -// -// During the development of this re-usable library, it became apparent that the -// Arduino UNO R3's very limited 2K of SRAM was very limiting in the number of -// devices that could be implemented simultaneously. A tremendous amount of effort -// has gone into reducing the SRAM usage, including siginificant improvements to -// the SmartThings Arduino library. The SmartThings library was also modified to -// include support for using Hardware Serial port(s) on the UNO, MEGA, and Leonardo. -// During testing, it was determined that the Hardware Serial ports provide much -// better performance and reliability versus the SoftwareSerial library. Also, the -// MEGA 2560's 8K of SRAM is well worth the few extra dollars to save your sanity -// versus always running out of SRAM on the UNO R3. The MEGA 2560 also has 4 Hardware -// serial ports (i.e. UARTS) which makes it very easy to use Hardware Serial instead -// of SoftwareSerial, while still being able to see debug data on the USB serial -// console port (pins 0 & 1). -// -// Note: We did not have a Leonardo for testing, but did fully test on UNO R3 and -// MEGA 2560 using both SoftwareSerial and Hardware Serial communications to the -// Thing Shield. -// -// Change History: -// -// Date Who What -// ---- --- ---- -// 2015-01-03 Dan & Daniel Original Creation -// 2015-01-07 Dan Ogorchock Modified for Door Monitoring and Garage Door Control -// 2015-03-28 Dan Ogorchock Removed RCSwitch #include now that the libraries are split up -// 2015-03-31 Daniel O. Memory optimizations utilizing progmem -// 2015-10-31 Dan Ogorchock Revised for a specific user request -// -//****************************************************************************************** - -//****************************************************************************************** -// SmartThings Library for Arduino Shield -//****************************************************************************************** -#include //Arduino UNO/Leonardo uses SoftwareSerial for the SmartThings Library -#include //Library to provide API to the SmartThings Shield -#include - -//****************************************************************************************** -// ST_Anything Library -//****************************************************************************************** -#include //Constants.h is designed to be modified by the end user to adjust behavior of the ST_Anything library -#include //Generic Device Class, inherited by Sensor and Executor classes -#include //Generic Sensor Class, typically provides data to ST Cloud (e.g. Temperature, Motion, etc...) -#include //Generic Interrupt "Sensor" Class, waits for change of state on digital input -#include //Master Brain of ST_Anything library that ties everything together and performs ST Shield communications - -#include //Implements an Interrupt Sensor (IS) to detect motion via a PIR sensor -#include //Implements an Interrupt Sensor (IS) to monitor the status of a digital input pin - -//****************************************************************************************** -//Define which Arduino Pins will be used for each device -// Notes: -Serial Communications Pins are defined in Constants.h (avoid pins 0,1,2,3 -// for inputs and output devices below as they may be used for communications) -// -Always avoid Pin 6 as it is reserved by the SmartThings Shield -// -//****************************************************************************************** -//"RESERVED" pins for SmartThings ThingShield - best to avoid -#define PIN_O_RESERVED 0 //reserved by ThingShield for Serial communications OR USB Serial Monitor -#define PIN_1_RESERVED 1 //reserved by ThingShield for Serial communications OR USB Serial Monitor -#define PIN_2_RESERVED 2 //reserved by ThingShield for Serial communications -#define PIN_3_RESERVED 3 //reserved by ThingShield for Serial communications -#define PIN_6_RESERVED 6 //reserved by ThingShield (possible future use?) - -//Window Pins -#define PIN_CONTACT_KITCHEN_WINDOW1 4 -#define PIN_CONTACT_KITCHEN_WINDOW2 5 -#define PIN_CONTACT_KITCHEN_WINDOW3 7 -#define PIN_CONTACT_MASTER_WINDOW1 8 -#define PIN_CONTACT_MASTER_WINDOW2 9 -#define PIN_CONTACT_OFFICE_WINDOW1 10 -#define PIN_CONTACT_OFFICE_WINDOW2 11 -#define PIN_CONTACT_GUEST_WINDOW1 12 -#define PIN_CONTACT_GUEST_WINDOW2 13 - - -//House Door Pins -#define PIN_CONTACT_FRONT_DOOR A1 -#define PIN_CONTACT_KITCHEN_DOOR A2 -#define PIN_CONTACT_GARAGE_DOOR A3 -#define PIN_CONTACT_BEDROOM_DOOR A4 - -//motion pins -#define PIN_MOTION A5 - -//****************************************************************************************** -//Arduino Setup() routine -//****************************************************************************************** -void setup() -{ - //****************************************************************************************** - //Declare each Device that is attached to the Arduino - // Notes: - For each device, there is typically a corresponding "tile" defined in your - // SmartThings DeviceType Groovy code - // - For details on each device's constructor arguments below, please refer to the - // corresponding header (.h) and program (.cpp) files. - // - The name assigned to each device (1st argument below) must match the Groovy - // DeviceType Tile name. - //****************************************************************************************** - - static st::IS_Motion sensor1(F("motion"), PIN_MOTION, HIGH, false); - static st::IS_Contact sensor2(F("kitchenWindow1"), PIN_CONTACT_KITCHEN_WINDOW1, LOW, true, 500); - static st::IS_Contact sensor3(F("kitchenWindow2"), PIN_CONTACT_KITCHEN_WINDOW2, LOW, true, 500); - static st::IS_Contact sensor4(F("kitchenWindow3"), PIN_CONTACT_KITCHEN_WINDOW3, LOW, true, 500); - static st::IS_Contact sensor5(F("masterWindow1"), PIN_CONTACT_MASTER_WINDOW1, LOW, true, 500); - static st::IS_Contact sensor6(F("masterWindow2"), PIN_CONTACT_MASTER_WINDOW2, LOW, true, 500); - static st::IS_Contact sensor7(F("officeWindow1"), PIN_CONTACT_OFFICE_WINDOW1, LOW, true, 500); - static st::IS_Contact sensor8(F("officeWindow2"), PIN_CONTACT_OFFICE_WINDOW2, LOW, true, 500); - static st::IS_Contact sensor9(F("guestWindow1"), PIN_CONTACT_GUEST_WINDOW1, LOW, true, 500); - static st::IS_Contact sensor10(F("guestWindow2"), PIN_CONTACT_GUEST_WINDOW2, LOW, true, 500); - static st::IS_Contact sensor11(F("frontDoor"), PIN_CONTACT_FRONT_DOOR, LOW, true, 500); - static st::IS_Contact sensor12(F("kitchenDoor"), PIN_CONTACT_KITCHEN_DOOR, LOW, true, 500); - static st::IS_Contact sensor13(F("garageDoor"), PIN_CONTACT_GARAGE_DOOR, LOW, true, 500); - static st::IS_Contact sensor14(F("bedroomDoor"), PIN_CONTACT_BEDROOM_DOOR, LOW, true, 500); - - //***************************************************************************** - // Configure debug print output from each main class - // -Note: Set these to "false" if using Hardware Serial on pins 0 & 1 - // to prevent communication conflicts with the ST Shield communications - //***************************************************************************** - st::Everything::debug=true; - st::Device::debug=true; - st::InterruptSensor::debug=true; - - //***************************************************************************** - //Initialize the "Everything" Class - //***************************************************************************** - st::Everything::init(); - - //***************************************************************************** - //Add each sensor to the "Everything" Class - //***************************************************************************** - st::Everything::addSensor(&sensor1); - st::Everything::addSensor(&sensor2); - st::Everything::addSensor(&sensor3); - st::Everything::addSensor(&sensor4); - st::Everything::addSensor(&sensor5); - st::Everything::addSensor(&sensor6); - st::Everything::addSensor(&sensor7); - st::Everything::addSensor(&sensor8); - st::Everything::addSensor(&sensor9); - st::Everything::addSensor(&sensor10); - st::Everything::addSensor(&sensor11); - st::Everything::addSensor(&sensor12); - st::Everything::addSensor(&sensor13); - st::Everything::addSensor(&sensor14); - - //***************************************************************************** - //Initialize each of the devices which were added to the Everything Class - //***************************************************************************** - st::Everything::initDevices(); - -} - -//****************************************************************************************** -//Arduino Loop() routine -//****************************************************************************************** -void loop() -{ - //***************************************************************************** - //Execute the Everything run method which takes care of "Everything" - //***************************************************************************** - st::Everything::run(); -} diff --git a/Arduino/Sketches/ST_Anything_Doors_Windows_wCallback/ST_Anything_Doors_Windows_wCallback.ino b/Arduino/Sketches/ST_Anything_Doors_Windows_wCallback/ST_Anything_Doors_Windows_wCallback.ino deleted file mode 100644 index 4f0d9911..00000000 --- a/Arduino/Sketches/ST_Anything_Doors_Windows_wCallback/ST_Anything_Doors_Windows_wCallback.ino +++ /dev/null @@ -1,225 +0,0 @@ -//****************************************************************************************** -// File: ST_Anything_Doors_Windows.ino -// Authors: Dan G Ogorchock & Daniel J Ogorchock (Father and Son) -// -// Summary: This Arduino Sketch, along with the ST_Anything library and the revised SmartThings -// library, demonstrates the ability of one Arduino + SmartThings Shield to -// implement a multi input/output custom device for integration into SmartThings. -// The ST_Anything library takes care of all of the work to schedule device updates -// as well as all communications with the SmartThings Shield. -// -// ST_Anything_Doors_Example implements the following: -// - 13 x Contact Sensor devices (used to monitor magnetic door/windows sensors) -// - 1 x Motion device (used to detect motion) -// -// During the development of this re-usable library, it became apparent that the -// Arduino UNO R3's very limited 2K of SRAM was very limiting in the number of -// devices that could be implemented simultaneously. A tremendous amount of effort -// has gone into reducing the SRAM usage, including siginificant improvements to -// the SmartThings Arduino library. The SmartThings library was also modified to -// include support for using Hardware Serial port(s) on the UNO, MEGA, and Leonardo. -// During testing, it was determined that the Hardware Serial ports provide much -// better performance and reliability versus the SoftwareSerial library. Also, the -// MEGA 2560's 8K of SRAM is well worth the few extra dollars to save your sanity -// versus always running out of SRAM on the UNO R3. The MEGA 2560 also has 4 Hardware -// serial ports (i.e. UARTS) which makes it very easy to use Hardware Serial instead -// of SoftwareSerial, while still being able to see debug data on the USB serial -// console port (pins 0 & 1). -// -// Note: We did not have a Leonardo for testing, but did fully test on UNO R3 and -// MEGA 2560 using both SoftwareSerial and Hardware Serial communications to the -// Thing Shield. -// -// Change History: -// -// Date Who What -// ---- --- ---- -// 2015-01-03 Dan & Daniel Original Creation -// 2015-01-07 Dan Ogorchock Modified for Door Monitoring and Garage Door Control -// 2015-03-28 Dan Ogorchock Removed RCSwitch #include now that the libraries are split up -// 2015-03-31 Daniel O. Memory optimizations utilizing progmem -// 2015-10-31 Dan Ogorchock Revised for a specific user request -// -//****************************************************************************************** - -//****************************************************************************************** -// SmartThings Library for Arduino Shield -//****************************************************************************************** -#include //Arduino UNO/Leonardo uses SoftwareSerial for the SmartThings Library -#include //Library to provide API to the SmartThings Shield -#include - -//****************************************************************************************** -// ST_Anything Library -//****************************************************************************************** -#include //Constants.h is designed to be modified by the end user to adjust behavior of the ST_Anything library -#include //Generic Device Class, inherited by Sensor and Executor classes -#include //Generic Sensor Class, typically provides data to ST Cloud (e.g. Temperature, Motion, etc...) -#include //Generic Interrupt "Sensor" Class, waits for change of state on digital input -#include //Generic Polling "Sensor" Class, polls Arduino pins periodically -#include //Master Brain of ST_Anything library that ties everything together and performs ST Shield communications - -#include //Implements an Interrupt Sensor (IS) to detect motion via a PIR sensor -#include //Implements an Interrupt Sensor (IS) to monitor the status of a digital input pin -#include //Implements an Interrupt Sensor (IS) and Executor to monitor the status of a digital input pin and control a digital output pin - -//****************************************************************************************** -//Define which Arduino Pins will be used for each device -// Notes: -Serial Communications Pins are defined in Constants.h (avoid pins 0,1,2,3 -// for inputs and output devices below as they may be used for communications) -// -Always avoid Pin 6 as it is reserved by the SmartThings Shield -// -//****************************************************************************************** -//"RESERVED" pins for SmartThings ThingShield - best to avoid -#define PIN_O_RESERVED 0 //reserved by ThingShield for Serial communications OR USB Serial Monitor -#define PIN_1_RESERVED 1 //reserved by ThingShield for Serial communications OR USB Serial Monitor -#define PIN_2_RESERVED 2 //reserved by ThingShield for Serial communications -#define PIN_3_RESERVED 3 //reserved by ThingShield for Serial communications -#define PIN_6_RESERVED 6 //reserved by ThingShield (possible future use?) - -//Window Pins -#define PIN_CONTACT_KITCHEN_WINDOW1 4 -#define PIN_CONTACT_KITCHEN_WINDOW2 5 -#define PIN_CONTACT_KITCHEN_WINDOW3 7 -#define PIN_CONTACT_MASTER_WINDOW1 8 -#define PIN_CONTACT_MASTER_WINDOW2 9 -#define PIN_CONTACT_OFFICE_WINDOW1 10 -#define PIN_CONTACT_OFFICE_WINDOW2 11 -#define PIN_CONTACT_GUEST_WINDOW1 12 -#define PIN_CONTACT_GUEST_WINDOW2 13 - - -//House Door Pins -#define PIN_CONTACT_FRONT_DOOR A1 -#define PIN_CONTACT_KITCHEN_DOOR A2 -#define PIN_CONTACT_GARAGE_DOOR A3 -#define PIN_CONTACT_BEDROOM_DOOR A4 - -//Door/Window Chime Pin -#define PIN_RELAY A0 - -//motion pins -#define PIN_MOTION A5 - - - -//****************************************************************************************** -//st::Everything::callOnMsgSend() optional callback routine. This is a sniffer to monitor -// data being sent to ST. This allows a user to act on data changes locally within the -// Arduino sktech. -//****************************************************************************************** -void callback(const String &msg) -{ - Serial.print(F("ST_Anything_wCallback: Sniffed data = ")); - Serial.println(msg); - - //If any door or windows is opened, then start timedRelay output sequence - if (msg.endsWith("open")) - { - //Masquerade as the ThingShield to "send data to the Arduino, as if from the ST Cloud" - st::receiveSmartString("switch on"); //use same strings that the DeviceHandler would send - } - -} - -//****************************************************************************************** -//Arduino Setup() routine -//****************************************************************************************** -void setup() -{ - //****************************************************************************************** - //Declare each Device that is attached to the Arduino - // Notes: - For each device, there is typically a corresponding "tile" defined in your - // SmartThings DeviceType Groovy code - // - For details on each device's constructor arguments below, please refer to the - // corresponding header (.h) and program (.cpp) files. - // - The name assigned to each device (1st argument below) must match the Groovy - // DeviceType Tile name. - //****************************************************************************************** - - static st::IS_Motion sensor1(F("motion"), PIN_MOTION, HIGH, false); - static st::IS_Contact sensor2(F("kitchenWindow1"), PIN_CONTACT_KITCHEN_WINDOW1, LOW, true, 500); - static st::IS_Contact sensor3(F("kitchenWindow2"), PIN_CONTACT_KITCHEN_WINDOW2, LOW, true, 500); - static st::IS_Contact sensor4(F("kitchenWindow3"), PIN_CONTACT_KITCHEN_WINDOW3, LOW, true, 500); - static st::IS_Contact sensor5(F("masterWindow1"), PIN_CONTACT_MASTER_WINDOW1, LOW, true, 500); - static st::IS_Contact sensor6(F("masterWindow2"), PIN_CONTACT_MASTER_WINDOW2, LOW, true, 500); - static st::IS_Contact sensor7(F("officeWindow1"), PIN_CONTACT_OFFICE_WINDOW1, LOW, true, 500); - static st::IS_Contact sensor8(F("officeWindow2"), PIN_CONTACT_OFFICE_WINDOW2, LOW, true, 500); - static st::IS_Contact sensor9(F("guestWindow1"), PIN_CONTACT_GUEST_WINDOW1, LOW, true, 500); - static st::IS_Contact sensor10(F("guestWindow2"), PIN_CONTACT_GUEST_WINDOW2, LOW, true, 500); - static st::IS_Contact sensor11(F("frontDoor"), PIN_CONTACT_FRONT_DOOR, LOW, true, 500); - static st::IS_Contact sensor12(F("kitchenDoor"), PIN_CONTACT_KITCHEN_DOOR, LOW, true, 500); - static st::IS_Contact sensor13(F("garageDoor"), PIN_CONTACT_GARAGE_DOOR, LOW, true, 500); - static st::IS_Contact sensor14(F("bedroomDoor"), PIN_CONTACT_BEDROOM_DOOR, LOW, true, 500); - - - //****************************************************************************************** - // st::S_TimedRelay() constructor requires the following arguments - // - String &name - REQUIRED - the name of the object - must match the Groovy ST_Anything DeviceType tile name - // - byte pinOutput - REQUIRED - the Arduino Pin to be used as a digital output - // - bool startingState - REQUIRED - the value desired for the initial state of the switch. LOW = "off", HIGH = "on" - // - bool invertLogic - REQUIRED - determines whether the Arduino Digital Ouput should use inverted logic - // - long onTime - OPTIONAL - the number of milliseconds to keep the output on, DEFGAULTS to 1000 milliseconds - // - long offTime - OPTIONAL - the number of milliseconds to keep the output off, DEFAULTS to 0 - // - intnumCycles - OPTIONAL - the number of times to repeat the on/off cycle, DEFAULTS to 1 - //****************************************************************************************** - static st::S_TimedRelay sensor15(F("switch"), PIN_RELAY, LOW, true, 1000, 0, 1); - - //***************************************************************************** - // Configure debug print output from each main class - // -Note: Set these to "false" if using Hardware Serial on pins 0 & 1 - // to prevent communication conflicts with the ST Shield communications - //***************************************************************************** - st::Everything::debug=true; - st::Executor::debug=true; - st::Device::debug=true; - st::PollingSensor::debug=true; - st::InterruptSensor::debug=true; - - //***************************************************************************** - // Configure callback function if desired - //***************************************************************************** - st::Everything::callOnMsgSend = callback; - - - //***************************************************************************** - //Initialize the "Everything" Class - //***************************************************************************** - st::Everything::init(); - - //***************************************************************************** - //Add each sensor to the "Everything" Class - //***************************************************************************** - st::Everything::addSensor(&sensor1); - st::Everything::addSensor(&sensor2); - st::Everything::addSensor(&sensor3); - st::Everything::addSensor(&sensor4); - st::Everything::addSensor(&sensor5); - st::Everything::addSensor(&sensor6); - st::Everything::addSensor(&sensor7); - st::Everything::addSensor(&sensor8); - st::Everything::addSensor(&sensor9); - st::Everything::addSensor(&sensor10); - st::Everything::addSensor(&sensor11); - st::Everything::addSensor(&sensor12); - st::Everything::addSensor(&sensor13); - st::Everything::addSensor(&sensor14); - st::Everything::addSensor(&sensor15); - - //***************************************************************************** - //Initialize each of the devices which were added to the Everything Class - //***************************************************************************** - st::Everything::initDevices(); - -} - -//****************************************************************************************** -//Arduino Loop() routine -//****************************************************************************************** -void loop() -{ - //***************************************************************************** - //Execute the Everything run method which takes care of "Everything" - //***************************************************************************** - st::Everything::run(); -} diff --git a/Arduino/Sketches/ST_Anything/ST_Anything.ino b/Arduino/Sketches/ST_Anything_ESP8266WiFi/ST_Anything_ESP8266WiFi.ino similarity index 64% rename from Arduino/Sketches/ST_Anything/ST_Anything.ino rename to Arduino/Sketches/ST_Anything_ESP8266WiFi/ST_Anything_ESP8266WiFi.ino index 00d66b49..bdcb4320 100644 --- a/Arduino/Sketches/ST_Anything/ST_Anything.ino +++ b/Arduino/Sketches/ST_Anything_ESP8266WiFi/ST_Anything_ESP8266WiFi.ino @@ -1,47 +1,25 @@ //****************************************************************************************** -// File: ST_Anything.ino +// File: ST_Anything_ESP8266WiFi.ino // Authors: Dan G Ogorchock & Daniel J Ogorchock (Father and Son) // // Summary: This Arduino Sketch, along with the ST_Anything library and the revised SmartThings -// library, demonstrates the ability of one Arduino + SmartThings Shield to +// library, demonstrates the ability of one NodeMCU ESP8266 to // implement a multi input/output custom device for integration into SmartThings. // The ST_Anything library takes care of all of the work to schedule device updates -// as well as all communications with the SmartThings Shield. -// -// During the development of this re-usable library, it became apparent that the -// Arduino UNO R3's very limited 2K of SRAM was very limiting in the number of -// devices that could be implemented simultaneously. A tremendous amount of effort -// has gone into reducing the SRAM usage, including siginificant improvements to -// the SmartThings Arduino library. The SmartThings library was also modified to -// include support for using Hardware Serial port(s) on the UNO, MEGA, and Leonardo. -// During testing, it was determined that the Hardware Serial ports provide much -// better performance and reliability versus the SoftwareSerial library. Also, the -// MEGA 2560's 8K of SRAM is well worth the few extra dollars to save your sanity -// versus always running out of SRAM on the UNO R3. The MEGA 2560 also has 4 Hardware -// serial ports (i.e. UARTS) which makes it very easy to use Hardware Serial instead -// of SoftwareSerial, while still being able to see debug data on the USB serial -// console port (pins 0 & 1). -// -// Note: We did not have a Leonardo for testing, but did fully test on UNO R3 and -// MEGA 2560 using both SoftwareSerial and Hardware Serial communications to the -// Thing Shield. +// as well as all communications with the NodeMCU ESP8266's WiFi. // // Change History: // // Date Who What // ---- --- ---- // 2015-01-03 Dan & Daniel Original Creation -// 2015-03-28 Dan Ogorchock Removed RCSwitch #include now that the libraries are split up -// 2015-03-31 Daniel O. Memory optimizations utilizing progmem +// 2017-02-12 Dan Ogorchock Revised to use the new SMartThings v2.0 library // //****************************************************************************************** //****************************************************************************************** -// SmartThings Library for Arduino Shield +// SmartThings Library for ESP8266WiFi //****************************************************************************************** -#include //Arduino UNO/Leonardo uses SoftwareSerial for the SmartThings Library -#include //Library to provide API to the SmartThings Shield -#include //DHT Temperature and Humidity Library -#include +#include //****************************************************************************************** // ST_Anything Library @@ -56,37 +34,73 @@ #include //Implements a Polling Sensor (PS) to measure light levels via a photo resistor -#include //Implements a Polling Sensor (PS) to measure Temperature and Humidity via DHT library +#include //Implements a Polling Sensor (PS) to measure Temperature and Humidity via DHT library. #include //Implements a Polling Sensor (PS) to measure presence of water (i.e. leak detector) #include //Implements an Interrupt Sensor (IS) to detect motion via a PIR sensor #include //Implements an Interrupt Sensor (IS) to monitor the status of a digital input pin #include //Implements an Executor (EX) via a digital output to a relay #include //Implements Executor (EX)as an Alarm Siren capability via a digital output to a relay +//****************************************************************************************** +//NodeMCU ESP8266 Pin Definitions (makes it much easier as these match the board markings) +//****************************************************************************************** +#define LED_BUILTIN 16 +#define BUILTIN_LED 16 + +#define D0 16 +#define D1 5 +#define D2 4 +#define D3 0 +#define D4 2 +#define D5 14 +#define D6 12 +#define D7 13 +#define D8 15 +#define D9 3 +#define D10 1 + //****************************************************************************************** //Define which Arduino Pins will be used for each device -// Notes: -Serial Communications Pins are defined in Constants.h (avoid pins 0,1,2,3 -// for inputs and output devices below as they may be used for communications) -// -Always avoid Pin 6 as it is reserved by the SmartThings Shield -// //****************************************************************************************** -//"RESERVED" pins for SmartThings ThingShield - best to avoid -#define PIN_O_RESERVED 0 //reserved by ThingShield for Serial communications OR USB Serial Monitor -#define PIN_1_RESERVED 1 //reserved by ThingShield for Serial communications OR USB Serial Monitor -#define PIN_2_RESERVED 2 //reserved by ThingShield for Serial communications -#define PIN_3_RESERVED 3 //reserved by ThingShield for Serial communications -#define PIN_6_RESERVED 6 //reserved by ThingShield (possible future use?) +#define PIN_WATER A0 //NodeMCU ESP8266 only has one Analog Input Pin 'A0' - used A0 on both for demo only!!! +#define PIN_ILLUMINANCE A0 //NodeMCU ESP8266 only has one Analog Input Pin 'A0' - used A0 on both for demo only!!! -#define PIN_WATER A4 -#define PIN_ILLUMINANCE A5 -#define PIN_MOTION 4 -#define PIN_TEMPERATUREHUMIDITY 5 -#define PIN_SWITCH 8 -#define PIN_ALARM 9 -#define PIN_CONTACT 11 +#define PIN_SWITCH D0 +#define PIN_CONTACT D1 +#define PIN_MOTION D2 +#define PIN_TEMPERATUREHUMIDITY D3 +#define PIN_ALARM D4 +//****************************************************************************************** +//ESP8266 WiFi Information +//****************************************************************************************** +String str_ssid = "yourSSIDhere"; // <---You must edit this line! +String str_password = "yourWiFiPasswordhere"; // <---You must edit this line! +IPAddress ip(192, 168, 1, 201); //Device IP Address // <---You must edit this line! +IPAddress gateway(192, 168, 1, 1); //Router gateway // <---You must edit this line! +IPAddress subnet(255, 255, 255, 0); //LAN subnet mask // <---You must edit this line! +IPAddress dnsserver(192, 168, 1, 1); //DNS server // <---You must edit this line! +const unsigned int serverPort = 8090; // port to run the http server on +// Smartthings Hub Information +IPAddress hubIp(192, 168, 1, 149); // smartthings hub ip // <---You must edit this line! +const unsigned int hubPort = 39500; // smartthings hub port +//****************************************************************************************** +//st::Everything::callOnMsgSend() optional callback routine. This is a sniffer to monitor +// data being sent to ST. This allows a user to act on data changes locally within the +// Arduino sktech. +//****************************************************************************************** +void callback(const String &msg) +{ + Serial.print(F("ST_Anything Callback: Sniffed data = ")); + Serial.println(msg); + + //TODO: Add local logic here to take action when a device's value/state is changed + + //Masquerade as the ThingShield to send data to the Arduino, as if from the ST Cloud (uncomment and edit following line) + //st::receiveSmartString("Put your command here!"); //use same strings that the Device Handler would send +} //****************************************************************************************** //Arduino Setup() routine @@ -106,9 +120,9 @@ void setup() // "temperature" and one for "humidity") //****************************************************************************************** //Polling Sensors - static st::PS_Illuminance sensor1(F("illuminance"), 120, 0, PIN_ILLUMINANCE); + static st::PS_Illuminance sensor1(F("illuminance"), 120, 0, PIN_ILLUMINANCE, 0, 1024, 0, 1000); static st::PS_TemperatureHumidity sensor2(F("temphumid"), 120, 10, PIN_TEMPERATUREHUMIDITY, st::PS_TemperatureHumidity::DHT22); - static st::PS_Water sensor3(F("water"), 60, 20, PIN_WATER); + static st::PS_Water sensor3(F("water"), 60, 20, PIN_WATER, 200); //Interrupt Sensors static st::IS_Motion sensor4(F("motion"), PIN_MOTION, HIGH, false); @@ -128,10 +142,18 @@ void setup() st::Device::debug=true; st::PollingSensor::debug=true; st::InterruptSensor::debug=true; - + //***************************************************************************** //Initialize the "Everything" Class //***************************************************************************** + + //Initialize the optional local callback routine (safe to comment out if not desired) + st::Everything::callOnMsgSend = callback; + + //Create the SmartThings ESP8266WiFi Communications Object + st::Everything::SmartThing = new st::SmartThingsESP8266WiFi(str_ssid, str_password, ip, gateway, subnet, dnsserver, serverPort, hubIp, hubPort, st::receiveSmartString); + + //Run the Everything class' init() routine which establishes WiFi communications with SmartThings Hub st::Everything::init(); //***************************************************************************** @@ -151,8 +173,9 @@ void setup() //***************************************************************************** //Initialize each of the devices which were added to the Everything Class - st::Everything::initDevices(); //***************************************************************************** + st::Everything::initDevices(); + } //****************************************************************************************** diff --git a/Arduino/Sketches/ST_Anything_EthernetW5100/ST_Anything_EthernetW5100.ino b/Arduino/Sketches/ST_Anything_EthernetW5100/ST_Anything_EthernetW5100.ino new file mode 100644 index 00000000..26bc0374 --- /dev/null +++ b/Arduino/Sketches/ST_Anything_EthernetW5100/ST_Anything_EthernetW5100.ino @@ -0,0 +1,195 @@ +//****************************************************************************************** +// File: ST_Anything_EthernetW5100.ino +// Authors: Dan G Ogorchock & Daniel J Ogorchock (Father and Son) +// +// Summary: This Arduino Sketch, along with the ST_Anything library and the revised SmartThings +// library, demonstrates the ability of one Arduino + Ethernet W5100 Shield to +// implement a multi input/output custom device for integration into SmartThings. +// The ST_Anything library takes care of all of the work to schedule device updates +// as well as all communications with the Ethernet W5100 Shield. +// +// During the development of this re-usable library, it became apparent that the +// Arduino UNO R3's very limited 2K of SRAM was very limiting in the number of +// devices that could be implemented simultaneously. A tremendous amount of effort +// has gone into reducing the SRAM usage, including siginificant improvements to +// the SmartThings Arduino library. +// +// Note: We did not have a Leonardo for testing, but did fully test on UNO R3 and +// MEGA 2560 using the Ethernet W5100 Shield. +// +// Change History: +// +// Date Who What +// ---- --- ---- +// 2015-01-03 Dan & Daniel Original Creation +// 2017-02-12 Dan Ogorchock Revised to use the new SMartThings v2.0 library +// +//****************************************************************************************** +//****************************************************************************************** +// SmartThings Library for Arduino Ethernet W5100 Shield +//****************************************************************************************** +#include //Library to provide API to the SmartThings Ethernet W5100 Shield + +//****************************************************************************************** +// ST_Anything Library +//****************************************************************************************** +#include //Constants.h is designed to be modified by the end user to adjust behavior of the ST_Anything library +#include //Generic Device Class, inherited by Sensor and Executor classes +#include //Generic Sensor Class, typically provides data to ST Cloud (e.g. Temperature, Motion, etc...) +#include //Generic Executor Class, typically receives data from ST Cloud (e.g. Switch) +#include //Generic Interrupt "Sensor" Class, waits for change of state on digital input +#include //Generic Polling "Sensor" Class, polls Arduino pins periodically +#include //Master Brain of ST_Anything library that ties everything together and performs ST Shield communications + +#include //Implements a Polling Sensor (PS) to measure light levels via a photo resistor + +#include //Implements a Polling Sensor (PS) to measure Temperature and Humidity via DHT library +#include //Implements a Polling Sensor (PS) to measure presence of water (i.e. leak detector) +#include //Implements an Interrupt Sensor (IS) to detect motion via a PIR sensor +#include //Implements an Interrupt Sensor (IS) to monitor the status of a digital input pin +#include //Implements an Executor (EX) via a digital output to a relay +#include //Implements Executor (EX)as an Alarm Siren capability via a digital output to a relay + +//********************************************************************************************************** +//Define which Arduino Pins will be used for each device +// Notes: Arduino communicates with both the W5100 and SD card using the SPI bus (through the ICSP header). +// This is on digital pins 10, 11, 12, and 13 on the Uno and pins 50, 51, and 52 on the Mega. +// On both boards, pin 10 is used to select the W5100 and pin 4 for the SD card. +// These pins cannot be used for general I/O. On the Mega, the hardware SS pin, 53, +// is not used to select either the W5100 or the SD card, but it must be kept as an output +// or the SPI interface won't work. +// See https://www.arduino.cc/en/Main/ArduinoEthernetShieldV1 for details on the W5100 Sield +//********************************************************************************************************** +//"RESERVED" pins for W5100 Ethernet Shield - best to avoid +#define PIN_1O_RESERVED 10 //reserved by W5100 Shield on both UNO and MEGA +#define PIN_11_RESERVED 11 //reserved by W5100 Shield on UNO +#define PIN_12_RESERVED 12 //reserved by W5100 Shield on UNO +#define PIN_13_RESERVED 13 //reserved by W5100 Shield on UNO +#define PIN_50_RESERVED 50 //reserved by W5100 Shield on MEGA +#define PIN_51_RESERVED 51 //reserved by W5100 Shield on MEGA +#define PIN_52_RESERVED 52 //reserved by W5100 Shield on MEGA +#define PIN_53_RESERVED 53 //reserved by W5100 Shield on MEGA + + +#define PIN_WATER A4 +#define PIN_ILLUMINANCE A5 +#define PIN_TEMPERATUREHUMIDITY 5 +#define PIN_MOTION 6 +#define PIN_CONTACT 7 +#define PIN_SWITCH 8 +#define PIN_ALARM 9 + +//****************************************************************************************** +//W5100 Ethernet Shield Information +//****************************************************************************************** +byte mac[] = {0x01,0x02,0x03,0x04,0x05,0x06}; //physical MAC address, MAKE SURE IT's UNIQUE // <---You must edit this line! +IPAddress ip(192, 168, 1, 200); // Device IP Address // <---You must edit this line! +IPAddress gateway(192, 168, 1, 1); //router gateway // <---You must edit this line! +IPAddress subnet(255, 255, 255, 0); //LAN subnet mask // <---You must edit this line! +IPAddress dnsserver(192, 168, 1, 1); //DNS server // <---You must edit this line! +const unsigned int serverPort = 8090; // port to run the http server on + +// Smartthings hub information +IPAddress hubIp(192,168,1,149); // smartthings hub ip // <---You must edit this line! +const unsigned int hubPort = 39500; // smartthings hub port + +//****************************************************************************************** +//st::Everything::callOnMsgSend() optional callback routine. This is a sniffer to monitor +// data being sent to ST. This allows a user to act on data changes locally within the +// Arduino sktech. +//****************************************************************************************** +void callback(const String &msg) +{ + Serial.print(F("ST_Anything Callback: Sniffed data = ")); + Serial.println(msg); + + //TODO: Add local logic here to take action when a device's value/state is changed + + //Masquerade as the ThingShield to send data to the Arduino, as if from the ST Cloud (uncomment and edit following line) + //st::receiveSmartString("Put your command here!"); //use same strings that the Device Handler would send +} + +//****************************************************************************************** +//Arduino Setup() routine +//****************************************************************************************** +void setup() +{ + //****************************************************************************************** + //Declare each Device that is attached to the Arduino + // Notes: - For each device, there is typically a corresponding "tile" defined in your + // SmartThings DeviceType Groovy code + // - For details on each device's constructor arguments below, please refer to the + // corresponding header (.h) and program (.cpp) files. + // - The name assigned to each device (1st argument below) must match the Groovy + // DeviceType Tile name. (Note: "temphumid" below is the exception to this rule + // as the DHT sensors produce both "temperature" and "humidity". Data from that + // particular sensor is sent to the ST Hub in two separate updates, one for + // "temperature" and one for "humidity") + //****************************************************************************************** + //Polling Sensors + static st::PS_Illuminance sensor1(F("illuminance"), 120, 0, PIN_ILLUMINANCE, 0, 1024, 0, 1000); + static st::PS_TemperatureHumidity sensor2(F("temphumid"), 120, 10, PIN_TEMPERATUREHUMIDITY, st::PS_TemperatureHumidity::DHT22); + static st::PS_Water sensor3(F("water"), 60, 20, PIN_WATER, 200); + + //Interrupt Sensors + static st::IS_Motion sensor4(F("motion"), PIN_MOTION, HIGH, false); + static st::IS_Contact sensor5(F("contact"), PIN_CONTACT, LOW, true); + + //Executors + static st::EX_Switch executor1(F("switch"), PIN_SWITCH, LOW, true); + static st::EX_Alarm executor2(F("alarm"), PIN_ALARM, LOW, true); + + //***************************************************************************** + // Configure debug print output from each main class + //***************************************************************************** + st::Everything::debug=true; + st::Executor::debug=true; + st::Device::debug=true; + st::PollingSensor::debug=true; + st::InterruptSensor::debug=true; + + //***************************************************************************** + //Initialize the "Everything" Class + //***************************************************************************** + + //Initialize the optional local callback routine (safe to comment out if not desired) + st::Everything::callOnMsgSend = callback; + + //Create the SmartThings EthernetW5100 Communications Object + st::Everything::SmartThing = new st::SmartThingsEthernetW5100(mac, ip, gateway, subnet, dnsserver, serverPort, hubIp, hubPort, st::receiveSmartString); + + //Run the Everything class' init() routine which establishes Ethernet communications with the SmartThings Hub + st::Everything::init(); + + //***************************************************************************** + //Add each sensor to the "Everything" Class + //***************************************************************************** + st::Everything::addSensor(&sensor1); + st::Everything::addSensor(&sensor2); + st::Everything::addSensor(&sensor3); + st::Everything::addSensor(&sensor4); + st::Everything::addSensor(&sensor5); + + //***************************************************************************** + //Add each executor to the "Everything" Class + //***************************************************************************** + st::Everything::addExecutor(&executor1); + st::Everything::addExecutor(&executor2); + + //***************************************************************************** + //Initialize each of the devices which were added to the Everything Class + //***************************************************************************** + st::Everything::initDevices(); + +} + +//****************************************************************************************** +//Arduino Loop() routine +//****************************************************************************************** +void loop() +{ + //***************************************************************************** + //Execute the Everything run method which takes care of "Everything" + //***************************************************************************** + st::Everything::run(); +} diff --git a/Arduino/Sketches/ST_Anything_FurnaceAlarm/ST_Anything_FurnaceAlarm.ino b/Arduino/Sketches/ST_Anything_FurnaceAlarm/ST_Anything_FurnaceAlarm.ino deleted file mode 100644 index 5b476075..00000000 --- a/Arduino/Sketches/ST_Anything_FurnaceAlarm/ST_Anything_FurnaceAlarm.ino +++ /dev/null @@ -1,169 +0,0 @@ -//****************************************************************************************** -// File: ST_Anything_FUrnaceAlarm.ino -// Authors: Dan G Ogorchock & Daniel J Ogorchock (Father and Son) -// -// Summary: This Arduino Sketch, along with the ST_Anything library and the revised SmartThings -// library, demonstrates the ability of one Arduino + SmartThings Shield to -// implement a multi input/output custom device for integration into SmartThings. -// The ST_Anything library takes care of all of the work to schedule device updates -// as well as all communications with the SmartThings Shield. -// -// During the development of this re-usable library, it became apparent that the -// Arduino UNO R3's very limited 2K of SRAM was very limiting in the number of -// devices that could be implemented simultaneously. A tremendous amount of effort -// has gone into reducing the SRAM usage, including siginificant improvements to -// the SmartThings Arduino library. The SmartThings library was also modified to -// include support for using Hardware Serial port(s) on the UNO, MEGA, and Leonardo. -// During testing, it was determined that the Hardware Serial ports provide much -// better performance and reliability versus the SoftwareSerial library. Also, the -// MEGA 2560's 8K of SRAM is well worth the few extra dollars to save your sanity -// versus always running out of SRAM on the UNO R3. The MEGA 2560 also has 4 Hardware -// serial ports (i.e. UARTS) which makes it very easy to use Hardware Serial instead -// of SoftwareSerial, while still being able to see debug data on the USB serial -// console port (pins 0 & 1). -// -// Note: We did not have a Leonardo for testing, but did fully test on UNO R3 and -// MEGA 2560 using both SoftwareSerial and Hardware Serial communications to the -// Thing Shield. -// -// Change History: -// -// Date Who What -// ---- --- ---- -// 2015-01-03 Dan & Daniel Original Creation -// 2015-03-10 Dan Modified to monitor furnace alarm -// 2015-03-14 Dan Added LED capability for visual status of the FurnaceAlarm -// 2015-03-31 Daniel O. Memory optimizations utilizing progmem -// -//****************************************************************************************** - -//****************************************************************************************** -// SmartThings Library for Arduino Shield -//****************************************************************************************** -#include //Arduino UNO/Leonardo uses SoftwareSerial for the SmartThings Library -#include //Library to provide API to the SmartThings Shield -#include - -//****************************************************************************************** -// ST_Anything Library -//****************************************************************************************** -#include //Constants.h is designed to be modified by the end user to adjust behavior of the ST_Anything library -#include //Generic Device Class, inherited by Sensor and Executor classes -#include //Generic Sensor Class, typically provides data to ST Cloud (e.g. Temperature, Motion, etc...) -#include //Generic Executor Class, typically receives data from ST Cloud (e.g. Switch) -#include //Generic Interrupt "Sensor" Class, waits for change of state on digital input -#include //Generic Polling "Sensor" Class, polls Arduino pins periodically -#include //Master Brain of ST_Anything library that ties everything together and performs ST Shield communications - -#include //Implements an Interrupt Sensor (IS) to monitor the status of a digital input pin - -//****************************************************************************************** -//Define which Arduino Pins will be used for each device -// Notes: -Serial Communications Pins are defined in Constants.h (avoid pins 0,1,2,3 -// for inputs and output devices below as they may be used for communications) -// -Always avoid Pin 6 as it is reserved by the SmartThings Shield -// -//****************************************************************************************** -//"RESERVED" pins for SmartThings ThingShield - best to avoid -#define PIN_O_RESERVED 0 //reserved by ThingShield for Serial communications OR USB Serial Monitor -#define PIN_1_RESERVED 1 //reserved by ThingShield for Serial communications OR USB Serial Monitor -#define PIN_2_RESERVED 2 //reserved by ThingShield for Serial communications -#define PIN_3_RESERVED 3 //reserved by ThingShield for Serial communications -#define PIN_6_RESERVED 6 //reserved by ThingShield (possible future use?) - -#define PIN_CONTACT 11 - - -//Global Variables -bool lastStatus; //Hold the last status of the Furnace Alarm to prevent updating the LED too frequently -st::IS_Contact *sensor1p; //pointer for use in main loop - -//****************************************************************************************** -//Arduino Setup() routine -//****************************************************************************************** -void setup() -{ - //****************************************************************************************** - //Declare each Device that is attached to the Arduino - // Notes: - For each device, there is typically a corresponding "tile" defined in your - // SmartThings DeviceType Groovy code - // - For details on each device's constructor arguments below, please refer to the - // corresponding header (.h) and program (.cpp) files. - // - The name assigned to each device (1st argument below) must match the Groovy - // DeviceType Tile name. (Note: "temphumid" below is the exception to this rule - // as the DHT sensors produce both "temperature" and "humidity". Data from that - // particular sensor is sent to the ST Shield in two separate updates, one for - // "temperature" and one for "humidity") - //****************************************************************************************** - //Polling Sensors - - //Interrupt Sensors - static st::IS_Contact sensor1(F("contact"), PIN_CONTACT, LOW, true, 20000); - sensor1p=&sensor1; - - //Executors - - - //***************************************************************************** - // Configure debug print output from each main class - // -Note: Set these to "false" if using Hardware Serial on pins 0 & 1 - // to prevent communication conflicts with the ST Shield communications - //***************************************************************************** - st::Everything::debug=true; - st::Executor::debug=true; - st::Device::debug=true; - st::PollingSensor::debug=true; - st::InterruptSensor::debug=true; - - //***************************************************************************** - //Initialize the "Everything" Class - //***************************************************************************** - st::Everything::init(); - - //***************************************************************************** - //Add each sensor to the "Everything" Class - //***************************************************************************** - st::Everything::addSensor(&sensor1); - - //***************************************************************************** - //Add each executor to the "Everything" Class - //***************************************************************************** - - //***************************************************************************** - //Initialize each of the devices which were added to the Everything Class - st::Everything::initDevices(); - //***************************************************************************** - - //Set the lastStatus variable to force the LED update the first time through the loop() - lastStatus = !sensor1.getStatus(); - -} - -//****************************************************************************************** -//Arduino Loop() routine -//****************************************************************************************** -void loop() -{ - //***************************************************************************** - //Execute the Everything run method which takes care of "Everything" - //***************************************************************************** - st::Everything::run(); - - //Check to see if the Furnace is in Alarm. If true, set the Smart Thing Shield - //LED to Red. If false, set the LED to Green. - if (sensor1p->getStatus() && !lastStatus) - { - //ALARM!!! (Red) - st::Everything::setLED(2,0,0); - lastStatus = true; - - } - else if (!sensor1p->getStatus() && lastStatus) - { - //NORMAL (Green) - st::Everything::setLED(0,2,0); - lastStatus = false; - } - -} - diff --git a/Arduino/Sketches/ST_Anything_Power/ST_Anything_Power.ino b/Arduino/Sketches/ST_Anything_Power/ST_Anything_Power.ino deleted file mode 100644 index 52580dec..00000000 --- a/Arduino/Sketches/ST_Anything_Power/ST_Anything_Power.ino +++ /dev/null @@ -1,156 +0,0 @@ -//****************************************************************************************** -// File: ST_Anything_Power.ino -// Authors: Dan G Ogorchock & Daniel J Ogorchock (Father and Son) -// -// Summary: This Arduino Sketch, along with the ST_Anything library and the revised SmartThings -// library, demonstrates the ability of one Arduino + SmartThings Shield to -// implement a pulse counting custom device for integration into SmartThings. It implements -// SmartThings "Power Meter" capability since that is the closest capability to the -// intended use. -// -// The ST_Anything library takes care of all of the work to schedule device updates -// as well as all communications with the SmartThings Shield. -// -// ********** This sketch requires an Arduino MEGA 2560 as it requires an available pin that -// * NOTE! * supports External Hardware Interrupts. Only Pins 21, 20, 19, and 18 on the MEGA -// ********** are valid since Pins 2 and 3 are already used by the SmartThings ThingShield. -// -// -// During the development of this re-usable library, it became apparent that the -// Arduino UNO R3's very limited 2K of SRAM was very limiting in the number of -// devices that could be implemented simultaneously. A tremendous amount of effort -// has gone into reducing the SRAM usage, including siginificant improvements to -// the SmartThings Arduino library. The SmartThings library was also modified to -// include support for using Hardware Serial port(s) on the UNO, MEGA, and Leonardo. -// During testing, it was determined that the Hardware Serial ports provide much -// better performance and reliability versus the SoftwareSerial library. Also, the -// MEGA 2560's 8K of SRAM is well worth the few extra dollars to save your sanity -// versus always running out of SRAM on the UNO R3. The MEGA 2560 also has 4 Hardware -// serial ports (i.e. UARTS) which makes it very easy to use Hardware Serial instead -// of SoftwareSerial, while still being able to see debug data on the USB serial -// console port (pins 0 & 1). -// -// Note: We did not have a Leonardo for testing, but did fully test on UNO R3 and -// MEGA 2560 using both SoftwareSerial and Hardware Serial communications to the -// Thing Shield. -// -// Change History: -// -// Date Who What -// ---- --- ---- -// 2015-01-03 Dan & Daniel Original Creation (ST_Anything demo) -// 2015-03-31 Dan Ogorchock Modified for a Pulse Counter / Energy Meter -// 2015-04-14 Daniel O. Support for memory optimizations -// -//****************************************************************************************** - -//****************************************************************************************** -// SmartThings Library for Arduino Shield -//****************************************************************************************** -#include //Arduino UNO/Leonardo uses SoftwareSerial for the SmartThings Library -#include //Library to provide API to the SmartThings Shield -#include - -//****************************************************************************************** -// ST_Anything Library -//****************************************************************************************** -#include //Constants.h is designed to be modified by the end user to adjust behavior of the ST_Anything library -#include //Generic Device Class, inherited by Sensor and Executor classes -#include //Generic Sensor Class, typically provides data to ST Cloud (e.g. Temperature, Motion, etc...) -#include //Generic Executor Class, typically receives data from ST Cloud (e.g. Switch) -#include //Generic Interrupt "Sensor" Class, waits for change of state on digital input -#include //Generic Polling "Sensor" Class, polls Arduino pins periodically -#include //Master Brain of ST_Anything library that ties everything together and performs ST Shield communications - -#include //Implements a Polling Sensor (PS) to measure pulse counts via HW Interrupt - -//****************************************************************************************** -//Define which Arduino Pins will be used for each device -// Notes: -Serial Communications Pins are defined in Constants.h (avoid pins 0,1,2,3 -// for inputs and output devices below as they may be used for communications) -// -Always avoid Pin 6 as it is reserved by the SmartThings Shield -// -//****************************************************************************************** -//"RESERVED" pins for SmartThings ThingShield - best to avoid -#define PIN_O_RESERVED 0 //reserved by ThingShield for Serial communications OR USB Serial Monitor -#define PIN_1_RESERVED 1 //reserved by ThingShield for Serial communications OR USB Serial Monitor -#define PIN_2_RESERVED 2 //reserved by ThingShield for Serial communications -#define PIN_3_RESERVED 3 //reserved by ThingShield for Serial communications -#define PIN_6_RESERVED 6 //reserved by ThingShield (possible future use?) - -//User defintions -#define PULSE_PIN 21 //Must use Pin 21, 20, 19, or 18 as these corrspond to Interrupts 2, 3, 4, 5 respectively -#define PULSE_POLL_INTRVL 30 //Polling Interval in seconds (how often to send data to SmartThings) -#define PULSE_POLL_OFFSET 0 //Polling Offset in seconds (phasing time shift offset to prevent all sensors sending at once) -#define PULSE_INTTYPE FALLING //Interrupt Type (FALLING, RISING, CHANGE) -#define PULE_INPUTMODE INPUT_PULLUP //Input Mode for the interrupt pin (INPUT_PULLUP, INPUT) -#define PULSE_SLOPE 1.0 //Linear conversion slope (eng units = PULSE_SLOPE * counts + PULSE_OFFSET) -#define PULSE_OFFSET 0.0 //Linear conversion offset (eng units = PULSE_SLOPE * counts + PULSE_OFFSET) - - -//****************************************************************************************** -//Arduino Setup() routine -//****************************************************************************************** -void setup() -{ - //****************************************************************************************** - //Declare each Device that is attached to the Arduino - // Notes: - For each device, there is typically a corresponding "tile" defined in your - // SmartThings DeviceType Groovy code - // - For details on each device's constructor arguments below, please refer to the - // corresponding header (.h) and program (.cpp) files. - // - The name assigned to each device (1st argument below) must match the Groovy - // DeviceType Tile name. (Note: "temphumid" below is the exception to this rule - // as the DHT sensors produce both "temperature" and "humidity". Data from that - // particular sensor is sent to the ST Shield in two separate updates, one for - // "temperature" and one for "humidity") - //****************************************************************************************** - //Polling Sensors - static st::PS_PulseCounter sensor1(F("power"), PULSE_POLL_INTRVL, PULSE_POLL_OFFSET, PULSE_PIN, PULSE_INTTYPE, PULE_INPUTMODE, PULSE_SLOPE, PULSE_OFFSET); - - //Interrupt Sensors - - //Executors - - //***************************************************************************** - // Configure debug print output from each main class - // -Note: Set these to "false" if using Hardware Serial on pins 0 & 1 - // to prevent communication conflicts with the ST Shield communications - //***************************************************************************** - st::Everything::debug=true; - st::Executor::debug=true; - st::Device::debug=true; - st::PollingSensor::debug=true; - st::InterruptSensor::debug=true; - - //***************************************************************************** - //Initialize the "Everything" Class - //***************************************************************************** - st::Everything::init(); - - //***************************************************************************** - //Add each sensor to the "Everything" Class - //***************************************************************************** - st::Everything::addSensor(&sensor1); - - - //***************************************************************************** - //Add each executor to the "Everything" Class - //***************************************************************************** - - //***************************************************************************** - //Initialize each of the devices which were added to the Everything Class - st::Everything::initDevices(); - //***************************************************************************** -} - -//****************************************************************************************** -//Arduino Loop() routine -//****************************************************************************************** -void loop() -{ - //***************************************************************************** - //Execute the Everything run method which takes care of "Everything" - //***************************************************************************** - st::Everything::run(); -} diff --git a/Arduino/Sketches/ST_Anything_RCSwitch/ST_Anything_RCSwitch.ino b/Arduino/Sketches/ST_Anything_RCSwitch/ST_Anything_RCSwitch.ino deleted file mode 100644 index 654e24f5..00000000 --- a/Arduino/Sketches/ST_Anything_RCSwitch/ST_Anything_RCSwitch.ino +++ /dev/null @@ -1,133 +0,0 @@ -//****************************************************************************************** -// File: ST_Anything_RCSwitch.ino -// Authors: Dan G Ogorchock -// -// Summary: This Arduino Sketch, along with the ST_Anything library and the revised SmartThings -// library, demonstrates the ability of one Arduino + SmartThings Shield to -// implement an RCSwitch device which can be mapped back to a SmartThings "Switch" -// -// During the development of this re-usable library, it became apparent that the -// Arduino UNO R3's very limited 2K of SRAM was very limiting in the number of -// devices that could be implemented simultaneously. A tremendous amount of effort -// has gone into reducing the SRAM usage, including siginificant improvements to -// the SmartThings Arduino library. The SmartThings library was also modified to -// include support for using Hardware Serial port(s) on the UNO, MEGA, and Leonardo. -// During testing, it was determined that the Hardware Serial ports provide much -// better performance and reliability versus the SoftwareSerial library. Also, the -// MEGA 2560's 8K of SRAM is well worth the few extra dollars to save your sanity -// versus always running out of SRAM on the UNO R3. The MEGA 2560 also has 4 Hardware -// serial ports (i.e. UARTS) which makes it very easy to use Hardware Serial instead -// of SoftwareSerial, while still being able to see debug data on the USB serial -// console port (pins 0 & 1). -// -// Change History: -// -// Date Who What -// ---- --- ---- -// 2015-01-03 Dan & Daniel Original Creation -// 2015-01-26 Dan Added RCSwitch support/example -// 2015-01-30 Dan Cleaned up specificailly for RCSwitch use exclusively for size -// 2015-03-31 Daniel O. Memory optimizations utilizing progmem -// -//****************************************************************************************** - -//****************************************************************************************** -// SmartThings Library for Arduino Shield -//****************************************************************************************** -#include //Arduino UNO/Leonardo uses SoftwareSerial for the SmartThings Library -#include //Library to provide API to the SmartThings Shield -#include //Library to provide support for RCSwitch devices -#include - -//****************************************************************************************** -// ST_Anything Library -//****************************************************************************************** -#include //Constants.h is designed to be modified by the end user to adjust behavior of the ST_Anything library -#include //Generic Device Class, inherited by Sensor and Executor classes -#include //Generic Sensor Class, typically provides data to ST Cloud (e.g. Temperature, Motion, etc...) -#include //Generic Executor Class, typically receives data from ST Cloud (e.g. Switch) -#include //Master Brain of ST_Anything library that ties everything together and performs ST Shield communications - -#include //Implements the Executor (EX) as an RCSwitch object - -//****************************************************************************************** -//Define which Arduino Pins will be used for each device -// Notes: -Serial Communications Pins are defined in Constants.h (avoid pins 0,1,2,3 -// for inputs and output devices below as they may be used for communications) -// -Always avoid Pin 6 as it is reserved by the SmartThings Shield -// -//****************************************************************************************** -//"RESERVED" pins for SmartThings ThingShield - best to avoid -#define PIN_O_RESERVED 0 //reserved by ThingShield for Serial communications OR USB Serial Monitor -#define PIN_1_RESERVED 1 //reserved by ThingShield for Serial communications OR USB Serial Monitor -#define PIN_2_RESERVED 2 //reserved by ThingShield for Serial communications -#define PIN_3_RESERVED 3 //reserved by ThingShield for Serial communications -#define PIN_6_RESERVED 6 //reserved by ThingShield (possible future use?) - -#define PIN_RCSWITCH 12 - - -//****************************************************************************************** -//Arduino Setup() routine -//****************************************************************************************** -void setup() -{ - //****************************************************************************************** - //Declare each Device that is attached to the Arduino - // Notes: - For each device, there is typically a corresponding "tile" defined in your - // SmartThings DeviceType Groovy code - // - For details on each device's constructor arguments below, please refer to the - // main comments in the corresponding header (.h) and program (.cpp) files. - // - The name assigned to each device (1st argument below) must match the Groovy - // DeviceType Tile name in your custom DeviceType code. - //****************************************************************************************** - //Polling Sensors - - //Interrupt Sensors - - //Executors - static st::EX_RCSwitch executor1(F("rcswitch1"), PIN_RCSWITCH, 35754004, 26, 18976788, 26); - static st::EX_RCSwitch executor2(F("rcswitch2"), PIN_RCSWITCH, 35751956, 26, 18974740, 26); - static st::EX_RCSwitch executor3(F("rcswitch3"), PIN_RCSWITCH, 35756052, 26, 18978836, 26); - - //***************************************************************************** - // Configure debug print output from each main class - // -Note: Set these to "false" if using Hardware Serial on pins 0 & 1 - // to prevent communication conflicts with the ST Shield communications - //***************************************************************************** - st::Everything::debug=true; - st::Executor::debug=true; - st::Device::debug=true; - - //***************************************************************************** - //Initialize the "Everything" Class - //***************************************************************************** - st::Everything::init(); - - //***************************************************************************** - //Add each sensor to the "Everything" Class - //***************************************************************************** - - //***************************************************************************** - //Add each executor to the "Everything" Class - //***************************************************************************** - st::Everything::addExecutor(&executor1); - st::Everything::addExecutor(&executor2); - st::Everything::addExecutor(&executor3); - - //***************************************************************************** - //Initialize each of the devices which were added to the Everything Class - st::Everything::initDevices(); - //***************************************************************************** -} - -//****************************************************************************************** -//Arduino Loop() routine -//****************************************************************************************** -void loop() -{ - //***************************************************************************** - //Execute the Everything run method which takes care of "Everything" - //***************************************************************************** - st::Everything::run(); -} diff --git a/Arduino/Sketches/ST_Anything_Relays/ST_Anything_Relays.ino b/Arduino/Sketches/ST_Anything_Relays/ST_Anything_Relays.ino deleted file mode 100644 index 9f25ef60..00000000 --- a/Arduino/Sketches/ST_Anything_Relays/ST_Anything_Relays.ino +++ /dev/null @@ -1,276 +0,0 @@ -//****************************************************************************************** -// File: ST_Anything_Relays.ino -// Authors: Dan G Ogorchock -// -// Summary: This Arduino Sketch, along with the ST_Anything library and the revised SmartThings -// library, demonstrates the ability of one Arduino + SmartThings Shield to -// implement 16 Relays which can be mapped back to a SmartThings "Switches" -// -// This version also includes support for 16 local pushbuttons that can be used to -// toggle the state of any relay (i.e. local control.) Using these pushbuttons -// will still result in the SmartThings cloud being updated via the ThingShield. -// NOTE: The pushbutton feature is entirely encapsulated within this sketch. -// None of the ST_Anything libraries were changed to implement this feature. -// -// During the development of this re-usable library, it became apparent that the -// Arduino UNO R3's very limited 2K of SRAM was very limiting in the number of -// devices that could be implemented simultaneously. A tremendous amount of effort -// has gone into reducing the SRAM usage, including siginificant improvements to -// the SmartThings Arduino library. The SmartThings library was also modified to -// include support for using Hardware Serial port(s) on the UNO, MEGA, and Leonardo. -// During testing, it was determined that the Hardware Serial ports provide much -// better performance and reliability versus the SoftwareSerial library. Also, the -// MEGA 2560's 8K of SRAM is well worth the few extra dollars to save your sanity -// versus always running out of SRAM on the UNO R3. The MEGA 2560 also has 4 Hardware -// serial ports (i.e. UARTS) which makes it very easy to use Hardware Serial instead -// of SoftwareSerial, while still being able to see debug data on the USB serial -// console port (pins 0 & 1). -// -// Change History: -// -// Date Who What -// ---- --- ---- -// 2015-01-03 Dan & Daniel Original Creation -// 2015-03-27 Dan Ogorchock Modified for 16 Relay + 16 Pushbuttons Design -// 2015-03-31 Daniel O. Memory optimizations utilizing progmem -// -//****************************************************************************************** - -//****************************************************************************************** -// SmartThings Library for Arduino Shield -//****************************************************************************************** -#include //Arduino UNO/Leonardo uses SoftwareSerial for the SmartThings Library -#include //Library to provide API to the SmartThings Shield -#include - -//****************************************************************************************** -// ST_Anything Library -//****************************************************************************************** -#include //Constants.h is designed to be modified by the end user to adjust behavior of the ST_Anything library -#include //Generic Device Class, inherited by Sensor and Executor classes -#include //Generic Sensor Class, typically provides data to ST Cloud (e.g. Temperature, Motion, etc...) -#include //Generic Executor Class, typically receives data from ST Cloud (e.g. Switch) -#include //Master Brain of ST_Anything library that ties everything together and performs ST Shield communications - -#include //Implements an Executor (EX) via a digital output to a relay - -//****************************************************************************************** -//Define which Arduino Pins will be used for each device -// Notes: -Serial Communications Pins are defined in Constants.h (avoid pins 0,1,2,3 -// for inputs and output devices below as they may be used for communications) -// -Always avoid Pin 6 as it is reserved by the SmartThings Shield -// -//****************************************************************************************** -//"RESERVED" pins for SmartThings ThingShield - best to avoid -#define PIN_O_RESERVED 0 //reserved by ThingShield for Serial communications OR USB Serial Monitor -#define PIN_1_RESERVED 1 //reserved by ThingShield for Serial communications OR USB Serial Monitor -#define PIN_2_RESERVED 2 //reserved by ThingShield for Serial communications -#define PIN_3_RESERVED 3 //reserved by ThingShield for Serial communications -#define PIN_6_RESERVED 6 //reserved by ThingShield (possible future use?) - - -#define PIN_RELAY1 22 -#define PIN_RELAY2 23 -#define PIN_RELAY3 24 -#define PIN_RELAY4 25 -#define PIN_RELAY5 26 -#define PIN_RELAY6 27 -#define PIN_RELAY7 28 -#define PIN_RELAY8 29 -#define PIN_RELAY9 30 -#define PIN_RELAY10 31 -#define PIN_RELAY11 32 -#define PIN_RELAY12 33 -#define PIN_RELAY13 34 -#define PIN_RELAY14 35 -#define PIN_RELAY15 36 -#define PIN_RELAY16 37 - -//---Begin Push Button declarations--- -#define MAX_PUSHBUTTONS 16 -#define MIN_DEBOUNCE_TIME 50 //push-buttons must be held for 50ms to prevent chattering input - -#define PIN_BUTTON1 38 -#define PIN_BUTTON2 39 -#define PIN_BUTTON3 40 -#define PIN_BUTTON4 41 -#define PIN_BUTTON5 42 -#define PIN_BUTTON6 43 -#define PIN_BUTTON7 44 -#define PIN_BUTTON8 45 -#define PIN_BUTTON9 46 -#define PIN_BUTTON10 47 -#define PIN_BUTTON11 48 -#define PIN_BUTTON12 49 -#define PIN_BUTTON13 50 -#define PIN_BUTTON14 51 -#define PIN_BUTTON15 52 -#define PIN_BUTTON16 53 - -byte nBtnIndex; //Index Variable -bool nCurrentVal; //temp variable -String strCommand; -byte nBtnVals[MAX_PUSHBUTTONS][2]; //Array of current[0] and last[1] values of the pushbuttons -byte nBtnPins[MAX_PUSHBUTTONS] = {PIN_BUTTON1, PIN_BUTTON2, PIN_BUTTON3, PIN_BUTTON4, - PIN_BUTTON5, PIN_BUTTON6, PIN_BUTTON7, PIN_BUTTON8, - PIN_BUTTON9, PIN_BUTTON10, PIN_BUTTON11, PIN_BUTTON12, - PIN_BUTTON13, PIN_BUTTON14, PIN_BUTTON15, PIN_BUTTON16}; -unsigned long lngBtnLastMillis[MAX_PUSHBUTTONS]; //needed to properly debounce the pushbutton inputs -st::EX_Switch* swArray[MAX_PUSHBUTTONS]; //need an array of the executors so we can togle the correct one -//---End Push Button declarations--- - - -//****************************************************************************************** -//Arduino Setup() routine -//****************************************************************************************** -void setup() -{ - //****************************************************************************************** - //Declare each Device that is attached to the Arduino - // Notes: - For each device, there is typically a corresponding "tile" defined in your - // SmartThings DeviceType Groovy code - // - For details on each device's constructor arguments below, please refer to the - // main comments in the corresponding header (.h) and program (.cpp) files. - // - The name assigned to each device (1st argument below) must match the Groovy - // DeviceType Tile name in your custom DeviceType code. - //****************************************************************************************** - //Polling Sensors - - //Interrupt Sensors - - //Executors - - //EX_Switch arguments(name, pin, starting state, invert logic) change last 2 args as needed for your application - static st::EX_Switch executor1(F("switch1"), PIN_RELAY1, LOW, false); - static st::EX_Switch executor2(F("switch2"), PIN_RELAY2, LOW, false); - static st::EX_Switch executor3(F("switch3"), PIN_RELAY3, LOW, false); - static st::EX_Switch executor4(F("switch4"), PIN_RELAY4, LOW, false); - static st::EX_Switch executor5(F("switch5"), PIN_RELAY5, LOW, false); - static st::EX_Switch executor6(F("switch6"), PIN_RELAY6, LOW, false); - static st::EX_Switch executor7(F("switch7"), PIN_RELAY7, LOW, false); - static st::EX_Switch executor8(F("switch8"), PIN_RELAY8, LOW, false); - static st::EX_Switch executor9(F("switch9"), PIN_RELAY9, LOW, false); - static st::EX_Switch executor10(F("switch10"), PIN_RELAY10, LOW, false); - static st::EX_Switch executor11(F("switch11"), PIN_RELAY11, LOW, false); - static st::EX_Switch executor12(F("switch12"), PIN_RELAY12, LOW, false); - static st::EX_Switch executor13(F("switch13"), PIN_RELAY13, LOW, false); - static st::EX_Switch executor14(F("switch14"), PIN_RELAY14, LOW, false); - static st::EX_Switch executor15(F("switch15"), PIN_RELAY15, LOW, false); - static st::EX_Switch executor16(F("switch16"), PIN_RELAY16, LOW, false); - - //***************************************************************************** - // Configure debug print output from each main class - // -Note: Set these to "false" if using Hardware Serial on pins 0 & 1 - // to prevent communication conflicts with the ST Shield communications - //***************************************************************************** - st::Everything::debug=true; - st::Executor::debug=true; - st::Device::debug=true; - - //***************************************************************************** - //Initialize the "Everything" Class - //***************************************************************************** - st::Everything::init(); - - //***************************************************************************** - //Add each sensor to the "Everything" Class - //***************************************************************************** - - //***************************************************************************** - //Add each executor to the "Everything" Class - //***************************************************************************** - st::Everything::addExecutor(&executor1); - st::Everything::addExecutor(&executor2); - st::Everything::addExecutor(&executor3); - st::Everything::addExecutor(&executor4); - st::Everything::addExecutor(&executor5); - st::Everything::addExecutor(&executor6); - st::Everything::addExecutor(&executor7); - st::Everything::addExecutor(&executor8); - st::Everything::addExecutor(&executor9); - st::Everything::addExecutor(&executor10); - st::Everything::addExecutor(&executor11); - st::Everything::addExecutor(&executor12); - st::Everything::addExecutor(&executor13); - st::Everything::addExecutor(&executor14); - st::Everything::addExecutor(&executor15); - st::Everything::addExecutor(&executor16); - - //***************************************************************************** - //Initialize each of the devices which were added to the Everything Class - //***************************************************************************** - st::Everything::initDevices(); - - //***************************************************************************** - //Add User Customized Setup Code Here (instead of modifying standard library files) - //***************************************************************************** - //---Begin Push Button initialization section--- - swArray[0]=&executor1; - swArray[1]=&executor2; - swArray[2]=&executor3; - swArray[3]=&executor4; - swArray[4]=&executor5; - swArray[5]=&executor6; - swArray[6]=&executor7; - swArray[7]=&executor8; - swArray[8]=&executor9; - swArray[9]=&executor10; - swArray[10]=&executor11; - swArray[11]=&executor12; - swArray[12]=&executor13; - swArray[13]=&executor14; - swArray[14]=&executor15; - swArray[15]=&executor16; - - //Allocate strCommand buffer one time to prevent Heap Fragmentation. - strCommand.reserve(20); - - //Configure input pins for hardwired pusbuttons AND read initial values - for (nBtnIndex=0; nBtnIndex < MAX_PUSHBUTTONS; nBtnIndex++) { - pinMode(nBtnPins[nBtnIndex], INPUT_PULLUP); - nBtnVals[nBtnIndex][0] = digitalRead(nBtnPins[nBtnIndex]); // read the input pin - nBtnVals[nBtnIndex][1] = nBtnVals[nBtnIndex][0]; - lngBtnLastMillis[nBtnIndex] = 0; //initialize times to zero - } - //---End Push Button initialization section--- -} - -//****************************************************************************************** -//Arduino Loop() routine -//****************************************************************************************** -void loop() -{ - //***************************************************************************** - //Execute the Everything run method which takes care of "Everything" - //***************************************************************************** - st::Everything::run(); - - //***************************************************************************** - //Add User Customized Loop Code Here (instead of modifying standard library files) - //***************************************************************************** - - //---Begin Push Button execution section--- - //Loop through the pushbutton array - for (nBtnIndex=0; nBtnIndex < MAX_PUSHBUTTONS; nBtnIndex++) - { - nCurrentVal = digitalRead(nBtnPins[nBtnIndex]); // read the input pin - if (nCurrentVal != nBtnVals[nBtnIndex][1]) // only act if the button changed state - { - lngBtnLastMillis[nBtnIndex] = millis(); //keep track of when the button changed state - } - if ((millis() - lngBtnLastMillis[nBtnIndex] >= MIN_DEBOUNCE_TIME) && (nBtnVals[nBtnIndex][0] != nCurrentVal)) - { - nBtnVals[nBtnIndex][0] = nCurrentVal; //keep current value for proper debounce logic - if (nCurrentVal == LOW) //only care if the button is pressed (change LOW to HIGH if logic reversed) - { - strCommand = swArray[nBtnIndex]->getName() + " " + (swArray[nBtnIndex]->getStatus()== HIGH?"off":"on"); - Serial.print(F("Pushbutton: ")); - Serial.println(strCommand); - swArray[nBtnIndex]->beSmart(strCommand); //Call the beSmart function of the proper executor object to either turn on or off the relay - strCommand.remove(0); //clear the strCommand buffer - } - } - nBtnVals[nBtnIndex][1] = nCurrentVal; //keep last value for proper debounce logic - } - //---End Push Button execution section--- -} diff --git a/Arduino/Sketches/ST_Anything_Switch_Dimmer/ST_Anything_Switch_Dimmer.ino b/Arduino/Sketches/ST_Anything_Switch_Dimmer/ST_Anything_Switch_Dimmer.ino deleted file mode 100644 index 139c3cff..00000000 --- a/Arduino/Sketches/ST_Anything_Switch_Dimmer/ST_Anything_Switch_Dimmer.ino +++ /dev/null @@ -1,137 +0,0 @@ -//****************************************************************************************** -// File: ST_Anything_Switch_Dimmer.ino -// Authors: Dan G Ogorchock -// -// Summary: This Arduino Sketch, along with the ST_Anything library and the revised SmartThings -// library, demonstrates the ability of one Arduino + SmartThings Shield to -// implement a Switch with Dimming capability custom device for integration into SmartThings. -// The ST_Anything library takes care of all of the work to schedule device updates -// as well as all communications with the SmartThings Shield. -// -// During the development of this re-usable library, it became apparent that the -// Arduino UNO R3's very limited 2K of SRAM was very limiting in the number of -// devices that could be implemented simultaneously. A tremendous amount of effort -// has gone into reducing the SRAM usage, including siginificant improvements to -// the SmartThings Arduino library. The SmartThings library was also modified to -// include support for using Hardware Serial port(s) on the UNO, MEGA, and Leonardo. -// During testing, it was determined that the Hardware Serial ports provide much -// better performance and reliability versus the SoftwareSerial library. Also, the -// MEGA 2560's 8K of SRAM is well worth the few extra dollars to save your sanity -// versus always running out of SRAM on the UNO R3. The MEGA 2560 also has 4 Hardware -// serial ports (i.e. UARTS) which makes it very easy to use Hardware Serial instead -// of SoftwareSerial, while still being able to see debug data on the USB serial -// console port (pins 0 & 1). -// -// Note: We did not have a Leonardo for testing, but did fully test on UNO R3 and -// MEGA 2560 using both SoftwareSerial and Hardware Serial communications to the -// Thing Shield. -// -// Change History: -// -// Date Who What -// ---- --- ---- -// 2016-04-30 Dan Ogorchock Original Creation -// -//****************************************************************************************** -//****************************************************************************************** -// SmartThings Library for Arduino Shield -//****************************************************************************************** -#include //Arduino UNO/Leonardo uses SoftwareSerial for the SmartThings Library -#include //Library to provide API to the SmartThings Shield -#include - -//****************************************************************************************** -// ST_Anything Library -//****************************************************************************************** -#include //Constants.h is designed to be modified by the end user to adjust behavior of the ST_Anything library -#include //Generic Device Class, inherited by Sensor and Executor classes -#include //Generic Sensor Class, typically provides data to ST Cloud (e.g. Temperature, Motion, etc...) -#include //Generic Executor Class, typically receives data from ST Cloud (e.g. Switch) -#include //Generic Interrupt "Sensor" Class, waits for change of state on digital input -#include //Generic Polling "Sensor" Class, polls Arduino pins periodically -#include //Master Brain of ST_Anything library that ties everything together and performs ST Shield communications - -#include //Implements an Executor (EX) via a digital output to a relay - -//****************************************************************************************** -//Define which Arduino Pins will be used for each device -// Notes: -Serial Communications Pins are defined in Constants.h (avoid pins 0,1,2,3 -// for inputs and output devices below as they may be used for communications) -// -Always avoid Pin 6 as it is reserved by the SmartThings Shield -// -//****************************************************************************************** -//"RESERVED" pins for SmartThings ThingShield - best to avoid -#define PIN_O_RESERVED 0 //reserved by ThingShield for Serial communications OR USB Serial Monitor -#define PIN_1_RESERVED 1 //reserved by ThingShield for Serial communications OR USB Serial Monitor -#define PIN_2_RESERVED 2 //reserved by ThingShield for Serial communications -#define PIN_3_RESERVED 3 //reserved by ThingShield for Serial communications -#define PIN_6_RESERVED 6 //reserved by ThingShield (possible future use?) - -#define PIN_SWITCH 8 //Digital Output Pin for "Switch" capability - On or Off -#define PIN_LEVEL 9 //Digital Output Pin for Dim "Level" capability - Must be a pin that support PWM!!! - -//****************************************************************************************** -//Arduino Setup() routine -//****************************************************************************************** -void setup() -{ - //****************************************************************************************** - //Declare each Device that is attached to the Arduino - // Notes: - For each device, there is typically a corresponding "tile" defined in your - // SmartThings DeviceType Groovy code - // - For details on each device's constructor arguments below, please refer to the - // corresponding header (.h) and program (.cpp) files. - // - The name assigned to each device (1st argument below) must match the Groovy - // DeviceType Tile name. (Note: "temphumid" below is the exception to this rule - // as the DHT sensors produce both "temperature" and "humidity". Data from that - // particular sensor is sent to the ST Shield in two separate updates, one for - // "temperature" and one for "humidity") - //****************************************************************************************** - //Polling Sensors - - //Interrupt Sensors - - //Executors - static st::EX_Switch_Dim executor1(F("switch"), PIN_SWITCH, PIN_LEVEL, LOW, false); - - //***************************************************************************** - // Configure debug print output from each main class - // -Note: Set these to "false" if using Hardware Serial on pins 0 & 1 - // to prevent communication conflicts with the ST Shield communications - //***************************************************************************** - st::Everything::debug=true; - st::Executor::debug=true; - st::Device::debug=true; - st::PollingSensor::debug=true; - st::InterruptSensor::debug=true; - - //***************************************************************************** - //Initialize the "Everything" Class - //***************************************************************************** - st::Everything::init(); - - //***************************************************************************** - //Add each sensor to the "Everything" Class - //***************************************************************************** - - //***************************************************************************** - //Add each executor to the "Everything" Class - //***************************************************************************** - st::Everything::addExecutor(&executor1); - - //***************************************************************************** - //Initialize each of the devices which were added to the Everything Class - st::Everything::initDevices(); - //***************************************************************************** -} - -//****************************************************************************************** -//Arduino Loop() routine -//****************************************************************************************** -void loop() -{ - //***************************************************************************** - //Execute the Everything run method which takes care of "Everything" - //***************************************************************************** - st::Everything::run(); -} diff --git a/Arduino/Sketches/ST_Anything_Temperatures/ST_Anything_Temperatures.ino b/Arduino/Sketches/ST_Anything_Temperatures/ST_Anything_Temperatures.ino deleted file mode 100644 index 5194ece7..00000000 --- a/Arduino/Sketches/ST_Anything_Temperatures/ST_Anything_Temperatures.ino +++ /dev/null @@ -1,192 +0,0 @@ -//****************************************************************************************** -// File: ST_Anything_Temperatures.ino -// Authors: Dan G Ogorchock -// -// Summary: This Arduino Sketch, along with the ST_Anything library and the revised SmartThings -// library, demonstrates the ability of one Arduino + SmartThings Shield to -// implement a multi input/output custom device for integration into SmartThings. -// The ST_Anything library takes care of all of the work to schedule device updates -// as well as all communications with the SmartThings Shield. -// -// During the development of this re-usable library, it became apparent that the -// Arduino UNO R3's very limited 2K of SRAM was very limiting in the number of -// devices that could be implemented simultaneously. A tremendous amount of effort -// has gone into reducing the SRAM usage, including siginificant improvements to -// the SmartThings Arduino library. The SmartThings library was also modified to -// include support for using Hardware Serial port(s) on the UNO, MEGA, and Leonardo. -// During testing, it was determined that the Hardware Serial ports provide much -// better performance and reliability versus the SoftwareSerial library. Also, the -// MEGA 2560's 8K of SRAM is well worth the few extra dollars to save your sanity -// versus always running out of SRAM on the UNO R3. The MEGA 2560 also has 4 Hardware -// serial ports (i.e. UARTS) which makes it very easy to use Hardware Serial instead -// of SoftwareSerial, while still being able to see debug data on the USB serial -// console port (pins 0 & 1). -// -// Note: We did not have a Leonardo for testing, but did fully test on UNO R3 and -// MEGA 2560 using both SoftwareSerial and Hardware Serial communications to the -// Thing Shield. -// -/// ______________ -/// | | -/// | SW[] | -/// |[]RST | -/// | AREF |-- -/// | GND |-- -/// | 13 |--X Othercrisp DHT -/// | 12 |--X Moistcrisp DHT -/// | 11 |--X Fridge DHT -/// --| 3.3V 10 |--X Freezer DHT -/// --| 5V 9 |--X CS -/// --| GND 8 |--THING_RX ------------------| -/// --| GND | | -/// --| Vin 7 |--X SCLK | -/// | 6 |--reserved by ThingShield | -/// --| A0 5 |--X DO for Broiler MISO | -/// --| A1 ( ) 4 |--X DO for Oven MISO | -/// --| A2 3 |--X THING_RX ----------------| -/// --| A3 ____ 2 |--X THING_TX -/// --| A4 | | 1 |-- -/// --| A5 | | 0 |-- -/// |____| |____| -/// |____| -// -// Change History: -// -// Date Who What -// ---- --- ---- -// 2015-01-03 Dan & Daniel Original Creation -// 2015-03-24 Dan Ogorchock Modified to just monitor multiple DTHT Temp/Humid sensors -// 2015-03-31 Daniel O. Memory optimizations utilizing progmem -// -//****************************************************************************************** - -//****************************************************************************************** -// SmartThings Library for Arduino Shield -//****************************************************************************************** -#include //Arduino UNO/Leonardo uses SoftwareSerial for the SmartThings Library -#include //Library to provide API to the SmartThings Shield -#include //DHT Temperature and Humidity Library (*** Rob Tillaart's version ***) -#include //thermocouple additions -#include //thermocouple additions -#include -//****************************************************************************************** -// ST_Anything Library -//****************************************************************************************** -#include //Constants.h is designed to be modified by the end user to adjust behavior of the ST_Anything library -#include //Generic Device Class, inherited by Sensor and Executor classes -#include //Generic Sensor Class, typically provides data to ST Cloud (e.g. Temperature, Motion, etc...) -#include //Generic Executor Class, typically receives data from ST Cloud (e.g. Switch) -#include //Generic Interrupt "Sensor" Class, waits for change of state on digital input -#include //Generic Polling "Sensor" Class, polls Arduino pins periodically -#include //Master Brain of ST_Anything library that ties everything together and performs ST Shield communications - -#include //Implements a Polling Sensor (PS) to measure Temperature and Humidity via DHT library -#include //Implements a Polling Sensor (PS) to measure Temperature via Adafruit_MAX31855 library - -//****************************************************************************************** -//Define which Arduino Pins will be used for each device -// Notes: -Serial Communications Pins are defined in Constants.h (avoid pins 0,1,2,3 -// for inputs and output devices below as they may be used for communications) -// -Always avoid Pin 6 as it is reserved by the SmartThings Shield -// -//****************************************************************************************** -//"RESERVED" pins for SmartThings ThingShield - best to avoid -#define PIN_O_RESERVED 0 //reserved by ThingShield for Serial communications OR USB Serial Monitor -#define PIN_1_RESERVED 1 //reserved by ThingShield for Serial communications OR USB Serial Monitor -#define PIN_2_RESERVED 2 //reserved by ThingShield for Serial communications -#define PIN_3_RESERVED 3 //reserved by ThingShield for Serial communications -#define PIN_6_RESERVED 6 //reserved by ThingShield (possible future use?) - -//DHT Pin Assignments -#define PIN_TEMPHUMID_FREEZER 10 -#define PIN_TEMPHUMID_FRIDGE 11 -#define PIN_TEMPHUMID_MOISTCRISP 12 -#define PIN_TEMPHUMID_OTHERCRISP 13 - -//Thermocouple Pi Assignments -#define PIN_SCLK 7 -#define PIN_CS 9 -#define PIN_MISO_OVEN 4 -#define PIN_MISO_BROILER 5 - - -//****************************************************************************************** -//Arduino Setup() routine -//****************************************************************************************** -void setup() -{ - //****************************************************************************************** - //Declare each Device that is attached to the Arduino - // Notes: - For each device, there is typically a corresponding "tile" defined in your - // SmartThings DeviceType Groovy code - // - For details on each device's constructor arguments below, please refer to the - // corresponding header (.h) and program (.cpp) files. - // - The name assigned to each device (1st argument below) must match the Groovy - // DeviceType Tile name. (Note: "temphumid" below is the exception to this rule - // as the DHT sensors produce both "temperature" and "humidity". Data from that - // particular sensor is sent to the ST Shield in two separate updates, one for - // "temperature" and one for "humidity") - // - // TODO: Customize based on what devices the user needs attached to the Arduino - // - //****************************************************************************************** - //Polling Sensors - static st::PS_TemperatureHumidity sensor1(F("th_Freezer"), 30, 3, PIN_TEMPHUMID_FREEZER, st::PS_TemperatureHumidity::DHT22, "t_Freezer", "h_Freezer"); - static st::PS_TemperatureHumidity sensor2(F("th_Fridge"), 30, 5, PIN_TEMPHUMID_FRIDGE, st::PS_TemperatureHumidity::DHT22, "t_Fridge", "h_Fridge"); - static st::PS_TemperatureHumidity sensor3(F("th_Moistcrisp"), 30, 7, PIN_TEMPHUMID_MOISTCRISP, st::PS_TemperatureHumidity::DHT22, "t_Moistcrisp", "h_Moistcrisp"); - static st::PS_TemperatureHumidity sensor4(F("th_Othercrisp"), 30, 9, PIN_TEMPHUMID_OTHERCRISP, st::PS_TemperatureHumidity::DHT22, "t_Othercrisp", "h_Othercrisp"); - static st::PS_AdafruitThermocouple sensor5(F("t_Oven"), 10, 0, PIN_SCLK, PIN_CS, PIN_MISO_OVEN); - static st::PS_AdafruitThermocouple sensor6(F("t_Broiler"), 10, 2, PIN_SCLK, PIN_CS, PIN_MISO_BROILER); - - //Interrupt Sensors - - //Executors - - //***************************************************************************** - // Configure debug print output from each main class - // -Note: Set these to "false" if using Hardware Serial on pins 0 & 1 - // to prevent communication conflicts with the ST Shield communications - //***************************************************************************** - st::Everything::debug=true; - st::Executor::debug=true; - st::Device::debug=true; - st::PollingSensor::debug=true; - st::InterruptSensor::debug=true; - - //***************************************************************************** - //Initialize the "Everything" Class - //***************************************************************************** - st::Everything::init(); - - //***************************************************************************** - //Add each sensor to the "Everything" Class - // TODO: Customize based on sensors defined in global section above - //***************************************************************************** - st::Everything::addSensor(&sensor1); - st::Everything::addSensor(&sensor2); - st::Everything::addSensor(&sensor3); - st::Everything::addSensor(&sensor4); - st::Everything::addSensor(&sensor5); - st::Everything::addSensor(&sensor6); - - //***************************************************************************** - //Add each executor to the "Everything" Class - // TODO: Customize based on executors defined in global section above - //***************************************************************************** - - //***************************************************************************** - //Initialize each of the devices which were added to the Everything Class - st::Everything::initDevices(); - //***************************************************************************** -} - -//****************************************************************************************** -//Arduino Loop() routine -//****************************************************************************************** -void loop() -{ - //***************************************************************************** - //Execute the Everything run method which takes care of "Everything" - //***************************************************************************** - st::Everything::run(); -} diff --git a/Arduino/Sketches/ST_Anything_wCallback/ST_Anything_wCallback.ino b/Arduino/Sketches/ST_Anything_ThingShield/ST_Anything_ThingShield.ino similarity index 85% rename from Arduino/Sketches/ST_Anything_wCallback/ST_Anything_wCallback.ino rename to Arduino/Sketches/ST_Anything_ThingShield/ST_Anything_ThingShield.ino index 40e16abd..5b2e84c8 100644 --- a/Arduino/Sketches/ST_Anything_wCallback/ST_Anything_wCallback.ino +++ b/Arduino/Sketches/ST_Anything_ThingShield/ST_Anything_ThingShield.ino @@ -1,5 +1,5 @@ //****************************************************************************************** -// File: ST_Anything_wCallback.ino +// File: ST_Anything_Thingshield.ino // Authors: Dan G Ogorchock & Daniel J Ogorchock (Father and Son) // // Summary: This Arduino Sketch, along with the ST_Anything library and the revised SmartThings @@ -33,17 +33,14 @@ // 2015-01-03 Dan & Daniel Original Creation // 2015-03-28 Dan Ogorchock Removed RCSwitch #include now that the libraries are split up // 2015-03-31 Daniel O. Memory optimizations utilizing progmem -// 2015-08-23 Dan Added optional alarm limit argument to water sensor -// 2015-01-12 Dan & Daniel Added support for local callback function for local processing +// 2015-08-23 Dan Ogorchock Added optional alarm limit argument to water sensor +// 2017-02-12 Dan Ogorchock Revised to use the new SMartThings v2.0 library // //****************************************************************************************** //****************************************************************************************** // SmartThings Library for Arduino Shield //****************************************************************************************** -#include //Arduino UNO/Leonardo uses SoftwareSerial for the SmartThings Library -#include //Library to provide API to the SmartThings Shield -#include //DHT Temperature and Humidity Library -#include +#include //Library to provide API to the SmartThings ThingShield //****************************************************************************************** // ST_Anything Library @@ -87,6 +84,10 @@ #define PIN_ALARM 9 #define PIN_CONTACT 11 +//If using SoftwareSerial (e.g. Arduino UNO), must define pins for transmit and receive +#define pinRX 3 +#define pinTX 2 + //****************************************************************************************** //st::Everything::callOnMsgSend() optional callback routine. This is a sniffer to monitor // data being sent to ST. This allows a user to act on data changes locally within the @@ -94,13 +95,13 @@ //****************************************************************************************** void callback(const String &msg) { - Serial.print(F("ST_Anything_wCallback: Sniffed data = ")); + Serial.print(F("ST_Anything Callback: Sniffed data = ")); Serial.println(msg); //TODO: Add local logic here to take action when a device's value/state is changed - //Masquerade as the ThingShield to send data to the Arduino, as if from the ST Cloud - st::receiveSmartString("Put your command here!"); //use same strings that the DeviceType would send + //Masquerade as the ThingShield to send data to the Arduino, as if from the ST Cloud (uncomment and edit following line) + //st::receiveSmartString("Put your command here!"); //use same strings that the Device Handler would send } //****************************************************************************************** @@ -143,11 +144,27 @@ void setup() st::Device::debug=true; st::PollingSensor::debug=true; st::InterruptSensor::debug=true; - st::Everything::callOnMsgSend = callback; - + //***************************************************************************** //Initialize the "Everything" Class //***************************************************************************** + + //Initialize the optional local callback routine (safe to comment out if not desired) + st::Everything::callOnMsgSend = callback; + + //Create the SmartThings Thingshield Communications Object based on Arduino Model + #if defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_MINI) //Arduino UNO, NANO, MINI + st::Everything::SmartThing = new st::SmartThingsThingShield(pinRX, pinTX, st::receiveSmartString); //Use Software Serial + #elif defined(ARDUINO_AVR_LEONARDO) //Arduino Leonardo + st::Everything::SmartThing = new st::SmartThingsThingShield(&Serial1, st::receiveSmartString); //Use Hardware Serial + #elif defined(ARDUINO_AVR_MEGA) || defined(ARDUINO_AVR_MEGA2560) //Arduino MEGA 1280 or 2560 + st::Everything::SmartThing = new st::SmartThingsThingShield(&Serial3, st::receiveSmartString); //Use Hardware Serial + #else + //assume user is using an UNO for the unknown case + st::Everything::SmartThing = new st::SmartThingsThingShield(pinRX, pinTX, st::receiveSmartString); //Software Serial + #endif + + //Run the Everything class' init() routine which establishes communications with SmartThings st::Everything::init(); //***************************************************************************** @@ -167,8 +184,8 @@ void setup() //***************************************************************************** //Initialize each of the devices which were added to the Everything Class - st::Everything::initDevices(); //***************************************************************************** + st::Everything::initDevices(); } //****************************************************************************************** @@ -180,4 +197,5 @@ void loop() //Execute the Everything run method which takes care of "Everything" //***************************************************************************** st::Everything::run(); + } diff --git a/Arduino/Sketches/ST_Anything_TimedRelay/ST_Anything_TimedRelay.ino b/Arduino/Sketches/ST_Anything_TimedRelay/ST_Anything_TimedRelay.ino deleted file mode 100644 index 9129da97..00000000 --- a/Arduino/Sketches/ST_Anything_TimedRelay/ST_Anything_TimedRelay.ino +++ /dev/null @@ -1,148 +0,0 @@ -//****************************************************************************************** -// File: ST_Anything_TimedRelay.ino -// Authors: Dan G Ogorchock & Daniel J Ogorchock (Father and Son) -// -// Summary: This Arduino Sketch, along with the ST_Anything library and the revised SmartThings -// library, demonstrates the ability of one Arduino + SmartThings Shield to -// implement a multi input/output custom device for integration into SmartThings. -// The ST_Anything library takes care of all of the work to schedule device updates -// as well as all communications with the SmartThings Shield. -// -// ST_Anything_TimedRelay implements the following: -// - 1 x Timed Relay device -// -// During the development of this re-usable library, it became apparent that the -// Arduino UNO R3's very limited 2K of SRAM was very limiting in the number of -// devices that could be implemented simultaneously. A tremendous amount of effort -// has gone into reducing the SRAM usage, including siginificant improvements to -// the SmartThings Arduino library. The SmartThings library was also modified to -// include support for using Hardware Serial port(s) on the UNO, MEGA, and Leonardo. -// During testing, it was determined that the Hardware Serial ports provide much -// better performance and reliability versus the SoftwareSerial library. Also, the -// MEGA 2560's 8K of SRAM is well worth the few extra dollars to save your sanity -// versus always running out of SRAM on the UNO R3. The MEGA 2560 also has 4 Hardware -// serial ports (i.e. UARTS) which makes it very easy to use Hardware Serial instead -// of SoftwareSerial, while still being able to see debug data on the USB serial -// console port (pins 0 & 1). -// -// Note: We did not have a Leonardo for testing, but did fully test on UNO R3 and -// MEGA 2560 using both SoftwareSerial and Hardware Serial communications to the -// Thing Shield. -// -// Change History: -// -// Date Who What -// ---- --- ---- -// 2015-12-29 Dan Ogorchock Original Creation -// -//****************************************************************************************** - -//****************************************************************************************** -// SmartThings Library for Arduino Shield -//****************************************************************************************** -#include //Arduino UNO/Leonardo uses SoftwareSerial for the SmartThings Library -#include //Library to provide API to the SmartThings Shield -#include - -//****************************************************************************************** -// ST_Anything Library -//****************************************************************************************** -#include //Constants.h is designed to be modified by the end user to adjust behavior of the ST_Anything library -#include //Generic Device Class, inherited by Sensor and Executor classes -#include //Generic Sensor Class, typically provides data to ST Cloud (e.g. Temperature, Motion, etc...) -#include //Generic Interrupt "Sensor" Class, waits for change of state on digital input -#include //Generic Polling "Sensor" Class, polls Arduino pins periodically -#include //Master Brain of ST_Anything library that ties everything together and performs ST Shield communications - -#include //Implements an Interrupt Sensor (IS) and Executor to monitor the status of a digital input pin and control a digital output pin - -//****************************************************************************************** -//Define which Arduino Pins will be used for each device -// Notes: -Serial Communications Pins are defined in Constants.h (avoid pins 0,1,2,3 -// for inputs and output devices below as they may be used for communications) -// -Always avoid Pin 6 as it is reserved by the SmartThings Shield -// -//****************************************************************************************** -//"RESERVED" pins for SmartThings ThingShield - best to avoid -#define PIN_O_RESERVED 0 //reserved by ThingShield for Serial communications OR USB Serial Monitor -#define PIN_1_RESERVED 1 //reserved by ThingShield for Serial communications OR USB Serial Monitor -#define PIN_2_RESERVED 2 //reserved by ThingShield for Serial communications -#define PIN_3_RESERVED 3 //reserved by ThingShield for Serial communications -#define PIN_6_RESERVED 6 //reserved by ThingShield (possible future use?) - -//Relay Pin -#define PIN_RELAY 9 - -//****************************************************************************************** -//Arduino Setup() routine -//****************************************************************************************** -void setup() -{ - //****************************************************************************************** - //Declare each Device that is attached to the Arduino - // Notes: - For each device, there is typically a corresponding "tile" defined in your - // SmartThings DeviceType Groovy code - // - For details on each device's constructor arguments below, please refer to the - // corresponding header (.h) and program (.cpp) files. - // - The name assigned to each device (1st argument below) must match the Groovy - // DeviceType Tile name. (Note: "temphumid" below is the exception to this rule - // as the DHT sensors produce both "temperature" and "humidity". Data from that - // particular sensor is sent to the ST Shield in two separate updates, one for - // "temperature" and one for "humidity") - //****************************************************************************************** - - //Sensors - //****************************************************************************************** - // st::S_TimedRelay() constructor requires the following arguments - // - String &name - REQUIRED - the name of the object - must match the Groovy ST_Anything DeviceType tile name - // - byte pinOutput - REQUIRED - the Arduino Pin to be used as a digital output - // - bool startingState - REQUIRED - the value desired for the initial state of the switch. LOW = "off", HIGH = "on" - // - bool invertLogic - REQUIRED - determines whether the Arduino Digital Ouput should use inverted logic - // - long onTime - OPTIONAL - the number of milliseconds to keep the output on, DEFGAULTS to 1000 milliseconds - // - long offTime - OPTIONAL - the number of milliseconds to keep the output off, DEFAULTS to 0 - // - intnumCycles - OPTIONAL - the number of ON/OFF Cycles required, DEFAULTS to 1 - //****************************************************************************************** - static st::S_TimedRelay sensor1(F("switch"), PIN_RELAY, LOW, true, 500, 500, 3); - - - //***************************************************************************** - // Configure debug print output from each main class - // -Note: Set these to "false" if using Hardware Serial on pins 0 & 1 - // to prevent communication conflicts with the ST Shield communications - //***************************************************************************** - st::Everything::debug=true; - st::Executor::debug=true; - st::Device::debug=true; - //st::PollingSensor::debug=true; - //st::InterruptSensor::debug=true; - - //***************************************************************************** - //Initialize the "Everything" Class - //***************************************************************************** - st::Everything::init(); - - //***************************************************************************** - //Add each sensor to the "Everything" Class - //***************************************************************************** - st::Everything::addSensor(&sensor1); - - //***************************************************************************** - //Add each executor to the "Everything" Class - //***************************************************************************** - - //***************************************************************************** - //Initialize each of the devices which were added to the Everything Class - st::Everything::initDevices(); - //***************************************************************************** -} - -//****************************************************************************************** -//Arduino Loop() routine -//****************************************************************************************** -void loop() -{ - //***************************************************************************** - //Execute the Everything run method which takes care of "Everything" - //***************************************************************************** - st::Everything::run(); -} diff --git a/Arduino/Sketches/ThingShield_to_RS232_Bridge/ThingShield_to_RS232_Bridge.ino b/Arduino/Sketches/ThingShield_to_RS232_Bridge/ThingShield_to_RS232_Bridge.ino deleted file mode 100644 index efae2aff..00000000 --- a/Arduino/Sketches/ThingShield_to_RS232_Bridge/ThingShield_to_RS232_Bridge.ino +++ /dev/null @@ -1,86 +0,0 @@ -//***************************************************************************** -// Arduino SmartThings Shield / RS232 Shield Bridge example -// -// Written by Dan Ogorchock on 2015-10-16 -// -//***************************************************************************** -#include //Must use version from ST_Anything GitHub Repository for HW Serial Support - -//***************************************************************************** -// Note: Pins 2/3 are reserved for use by the SmartThings ThingShield -// Pins 4/5 are reserved for use by the RS2323 Shield -//***************************************************************************** -SmartThingsCallout_t messageCallout; // call out function forward decalaration -SmartThings smartthing(HW_SERIAL3, messageCallout); // Hardware Serial constructor - -void setup() -{ - Serial.begin(9600); //setup console serial with a baud rate of 9600 - Serial.println(F("HW 'Serial' setup..")); - Serial2.begin(9600); //setup RS232 serial with a baud rate of 9600 - Serial2.println(F("HW 'RS232' Setup...")); -} - -void loop() -{ - //Run the ThingShield - smartthing.run(); - - //Read the RS232 port and forward data to ThingShield - if (Serial2.available()>0) - { - String rs232String = Serial2.readString(); - rs232String.trim(); - Serial.print(F("RS232 Data = ")); - Serial.println(rs232String); - smartthing.send(rs232String); - } -} - -void messageCallout(String message) -{ - message.trim(); //Ignore the periodic ' ' sent - if (message.length() > 0) //from the ThingShield - { - Serial.print(F("ThingShield data = ")); - Serial.println(message); - //Forward ThingShield message to the RS232 port - Serial2.println(message); - - if (message.equals(F("hello"))) //Sample Code for visual effect :) - { - hello(); - } - } -} - -void hello() -{ - Serial.println("brobasaur"); - smartthing.send("colors!"); - smartthing.shieldSetLED(1, 0, 0); - delay(200); - smartthing.shieldSetLED(0, 1, 0); - delay(200); - smartthing.shieldSetLED(0, 0, 1); - delay(200); - smartthing.shieldSetLED(1, 1, 0); - delay(200); - smartthing.shieldSetLED(1, 1, 1); - delay(200); - smartthing.shieldSetLED(1, 0, 1); - delay(200); - smartthing.shieldSetLED(0, 1, 1); - delay(200); - smartthing.shieldSetLED(3, 2, 1); - delay(200); - smartthing.shieldSetLED(1, 2, 3); - delay(200); - smartthing.shieldSetLED(2, 2, 4); - delay(200); - smartthing.shieldSetLED(4, 3, 1); - delay(200); - smartthing.shieldSetLED(0, 0, 0); - smartthing.send(F("fancy")); -} - diff --git a/Arduino/libraries/DHT/dht.cpp b/Arduino/libraries/DHT/dht.cpp index a40e47c4..cf8081db 100644 --- a/Arduino/libraries/DHT/dht.cpp +++ b/Arduino/libraries/DHT/dht.cpp @@ -1,24 +1,11 @@ // // FILE: dht.cpp // AUTHOR: Rob Tillaart -// VERSION: 0.1.20 +// VERSION: 0.1.13 // PURPOSE: DHT Temperature & Humidity Sensor library for Arduino // URL: http://arduino.cc/playground/Main/DHTLib // // HISTORY: -// 0.1.20 Reduce footprint (34 bytes) by using int8_t as error codes. -// (thanks to chaveiro) -// 0.1.19 masking error for DHT11 - FIXED (thanks Richard for noticing) -// 0.1.18 version 1.16/17 broke the DHT11 - FIXED -// 0.1.17 replaced micros() with adaptive loopcount -// removed DHTLIB_INVALID_VALUE -// added DHTLIB_ERROR_CONNECT -// added DHTLIB_ERROR_ACK_L DHTLIB_ERROR_ACK_H -// 0.1.16 masking unused bits (less errors); refactored bits[] -// 0.1.15 reduced # micros calls 2->1 in inner loop. -// 0.1.14 replace digital read with faster (~3x) code -// => more robust low MHz machines. -// // 0.1.13 fix negative temperature // 0.1.12 support DHT33 and DHT44 initial version // 0.1.11 renamed DHTLIB_TIMEOUT @@ -32,7 +19,7 @@ // 0.1.03 added error values for temp and humidity when read failed // 0.1.02 added error codes // 0.1.01 added support for Arduino 1.0, fixed typos (31/12/2011) -// 0.1.00 by Rob Tillaart (01/04/2011) +// 0.1.0 by Rob Tillaart (01/04/2011) // // inspired by DHT11 library // @@ -46,14 +33,20 @@ // PUBLIC // -int8_t dht::read11(uint8_t pin) +// return values: +// DHTLIB_OK +// DHTLIB_ERROR_CHECKSUM +// DHTLIB_ERROR_TIMEOUT +int dht::read11(uint8_t pin) { // READ VALUES - int8_t result = _readSensor(pin, DHTLIB_DHT11_WAKEUP, DHTLIB_DHT11_LEADING_ZEROS); - - // these bits are always zero, masking them reduces errors. - bits[0] &= 0x7F; - bits[2] &= 0x7F; + int rv = _readSensor(pin, DHTLIB_DHT11_WAKEUP); + if (rv != DHTLIB_OK) + { + humidity = DHTLIB_INVALID_VALUE; // invalid value, or is NaN prefered? + temperature = DHTLIB_INVALID_VALUE; // invalid value + return rv; + } // CONVERT AND STORE humidity = bits[0]; // bits[1] == 0; @@ -62,21 +55,26 @@ int8_t dht::read11(uint8_t pin) // TEST CHECKSUM // bits[1] && bits[3] both 0 uint8_t sum = bits[0] + bits[2]; - if (bits[4] != sum) - { - return DHTLIB_ERROR_CHECKSUM; - } - return result; + if (bits[4] != sum) return DHTLIB_ERROR_CHECKSUM; + + return DHTLIB_OK; } -int8_t dht::read(uint8_t pin) + +// return values: +// DHTLIB_OK +// DHTLIB_ERROR_CHECKSUM +// DHTLIB_ERROR_TIMEOUT +int dht::read(uint8_t pin) { // READ VALUES - int8_t result = _readSensor(pin, DHTLIB_DHT_WAKEUP, DHTLIB_DHT_LEADING_ZEROS); - - // these bits are always zero, masking them reduces errors. - bits[0] &= 0x03; - bits[2] &= 0x83; + int rv = _readSensor(pin, DHTLIB_DHT_WAKEUP); + if (rv != DHTLIB_OK) + { + humidity = DHTLIB_INVALID_VALUE; // invalid value, or is NaN prefered? + temperature = DHTLIB_INVALID_VALUE; // invalid value + return rv; // propagate error value + } // CONVERT AND STORE humidity = word(bits[0], bits[1]) * 0.1; @@ -92,7 +90,7 @@ int8_t dht::read(uint8_t pin) { return DHTLIB_ERROR_CHECKSUM; } - return result; + return DHTLIB_OK; } ///////////////////////////////////////////////////// @@ -100,95 +98,66 @@ int8_t dht::read(uint8_t pin) // PRIVATE // -int8_t dht::_readSensor(uint8_t pin, uint8_t wakeupDelay, uint8_t leadingZeroBits) +// return values: +// DHTLIB_OK +// DHTLIB_ERROR_TIMEOUT +int dht::_readSensor(uint8_t pin, uint8_t wakeupDelay) { // INIT BUFFERVAR TO RECEIVE DATA uint8_t mask = 128; uint8_t idx = 0; - uint8_t data = 0; - uint8_t state = LOW; - uint8_t pstate = LOW; - uint16_t zeroLoop = DHTLIB_TIMEOUT; - uint16_t delta = 0; - - leadingZeroBits = 40 - leadingZeroBits; // reverse counting... - - // replace digitalRead() with Direct Port Reads. - // reduces footprint ~100 bytes => portability issue? - // direct port read is about 3x faster - uint8_t bit = digitalPinToBitMask(pin); - uint8_t port = digitalPinToPort(pin); - volatile uint8_t *PIR = portInputRegister(port); + // EMPTY BUFFER + for (uint8_t i = 0; i < 5; i++) bits[i] = 0; // REQUEST SAMPLE pinMode(pin, OUTPUT); - digitalWrite(pin, LOW); // T-be + digitalWrite(pin, LOW); delay(wakeupDelay); - digitalWrite(pin, HIGH); // T-go + digitalWrite(pin, HIGH); + delayMicroseconds(40); pinMode(pin, INPUT); - uint16_t loopCount = DHTLIB_TIMEOUT * 2; // 200uSec max - // while(digitalRead(pin) == HIGH) - while ((*PIR & bit) != LOW ) - { - if (--loopCount == 0) return DHTLIB_ERROR_CONNECT; - } - // GET ACKNOWLEDGE or TIMEOUT - loopCount = DHTLIB_TIMEOUT; - // while(digitalRead(pin) == LOW) - while ((*PIR & bit) == LOW ) // T-rel + uint16_t loopCnt = DHTLIB_TIMEOUT; + while(digitalRead(pin) == LOW) { - if (--loopCount == 0) return DHTLIB_ERROR_ACK_L; + if (--loopCnt == 0) return DHTLIB_ERROR_TIMEOUT; } - loopCount = DHTLIB_TIMEOUT; - // while(digitalRead(pin) == HIGH) - while ((*PIR & bit) != LOW ) // T-reh + loopCnt = DHTLIB_TIMEOUT; + while(digitalRead(pin) == HIGH) { - if (--loopCount == 0) return DHTLIB_ERROR_ACK_H; + if (--loopCnt == 0) return DHTLIB_ERROR_TIMEOUT; } - loopCount = DHTLIB_TIMEOUT; - // READ THE OUTPUT - 40 BITS => 5 BYTES - for (uint8_t i = 40; i != 0; ) + for (uint8_t i = 40; i != 0; i--) { - // WAIT FOR FALLING EDGE - state = (*PIR & bit); - if (state == LOW && pstate != LOW) + loopCnt = DHTLIB_TIMEOUT; + while(digitalRead(pin) == LOW) { - if (i > leadingZeroBits) // DHT22 first 6 bits are all zero !! DHT11 only 1 - { - zeroLoop = min(zeroLoop, loopCount); - delta = (DHTLIB_TIMEOUT - zeroLoop)/4; - } - else if ( loopCount <= (zeroLoop - delta) ) // long -> one - { - data |= mask; - } - mask >>= 1; - if (mask == 0) // next byte - { - mask = 128; - bits[idx] = data; - idx++; - data = 0; - } - // next bit - --i; - - // reset timeout flag - loopCount = DHTLIB_TIMEOUT; + if (--loopCnt == 0) return DHTLIB_ERROR_TIMEOUT; } - pstate = state; - // Check timeout - if (--loopCount == 0) + + uint32_t t = micros(); + + loopCnt = DHTLIB_TIMEOUT; + while(digitalRead(pin) == HIGH) { - return DHTLIB_ERROR_TIMEOUT; + if (--loopCnt == 0) return DHTLIB_ERROR_TIMEOUT; } + if ((micros() - t) > 40) + { + bits[idx] |= mask; + } + mask >>= 1; + if (mask == 0) // next byte? + { + mask = 128; + idx++; + } } pinMode(pin, OUTPUT); digitalWrite(pin, HIGH); diff --git a/Arduino/libraries/DHT/dht.h b/Arduino/libraries/DHT/dht.h index 134ab9c8..a2f72bd5 100644 --- a/Arduino/libraries/DHT/dht.h +++ b/Arduino/libraries/DHT/dht.h @@ -1,7 +1,7 @@ // // FILE: dht.h // AUTHOR: Rob Tillaart -// VERSION: 0.1.20 +// VERSION: 0.1.13 // PURPOSE: DHT Temperature & Humidity Sensor library for Arduino // URL: http://arduino.cc/playground/Main/DHTLib // @@ -14,32 +14,26 @@ #if ARDUINO < 100 #include -#include // fix for broken pre 1.0 version - TODO TEST #else #include #endif -#define DHT_LIB_VERSION "0.1.20" +#define DHT_LIB_VERSION "0.1.13" -#define DHTLIB_OK 0 -#define DHTLIB_ERROR_CHECKSUM -1 -#define DHTLIB_ERROR_TIMEOUT -2 -#define DHTLIB_ERROR_CONNECT -3 -#define DHTLIB_ERROR_ACK_L -4 -#define DHTLIB_ERROR_ACK_H -5 +#define DHTLIB_OK 0 +#define DHTLIB_ERROR_CHECKSUM -1 +#define DHTLIB_ERROR_TIMEOUT -2 +#define DHTLIB_INVALID_VALUE -999 -#define DHTLIB_DHT11_WAKEUP 18 -#define DHTLIB_DHT_WAKEUP 1 +#define DHTLIB_DHT11_WAKEUP 18 +#define DHTLIB_DHT_WAKEUP 1 -#define DHTLIB_DHT11_LEADING_ZEROS 1 -#define DHTLIB_DHT_LEADING_ZEROS 6 - -// max timeout is 100 usec. -// For a 16 Mhz proc 100 usec is 1600 clock cycles -// loops using DHTLIB_TIMEOUT use at least 4 clock cycli +// max timeout is 100usec. +// For a 16Mhz proc that is max 1600 clock cycles +// loops using TIMEOUT use at least 4 clock cycli // so 100 us takes max 400 loops // so by dividing F_CPU by 40000 we "fail" as fast as possible -#define DHTLIB_TIMEOUT 400 // (F_CPU/40000) +#define DHTLIB_TIMEOUT (F_CPU/40000) class dht { @@ -48,23 +42,20 @@ class dht // DHTLIB_OK // DHTLIB_ERROR_CHECKSUM // DHTLIB_ERROR_TIMEOUT - // DHTLIB_ERROR_CONNECT - // DHTLIB_ERROR_ACK_L - // DHTLIB_ERROR_ACK_H - int8_t read11(uint8_t pin); - int8_t read(uint8_t pin); + int read11(uint8_t pin); + int read(uint8_t pin); - inline int8_t read21(uint8_t pin) { return read(pin); }; - inline int8_t read22(uint8_t pin) { return read(pin); }; - inline int8_t read33(uint8_t pin) { return read(pin); }; - inline int8_t read44(uint8_t pin) { return read(pin); }; + inline int read21(uint8_t pin) { return read(pin); }; + inline int read22(uint8_t pin) { return read(pin); }; + inline int read33(uint8_t pin) { return read(pin); }; + inline int read44(uint8_t pin) { return read(pin); }; double humidity; double temperature; private: uint8_t bits[5]; // buffer to receive data - int8_t _readSensor(uint8_t pin, uint8_t wakeupDelay, uint8_t leadingZeroBits); + int _readSensor(uint8_t pin, uint8_t wakeupDelay); }; #endif // diff --git a/Arduino/libraries/DHT/examples/dht11_test/dht11_test.ino b/Arduino/libraries/DHT/examples/dht11_test/dht11_test.ino index 41956118..9308139c 100644 --- a/Arduino/libraries/DHT/examples/dht11_test/dht11_test.ino +++ b/Arduino/libraries/DHT/examples/dht11_test/dht11_test.ino @@ -1,4 +1,3 @@ - // // FILE: dht11_test.ino // AUTHOR: Rob Tillaart @@ -41,15 +40,6 @@ void loop() case DHTLIB_ERROR_TIMEOUT: Serial.print("Time out error,\t"); break; - case DHTLIB_ERROR_CONNECT: - Serial.print("Connect error,\t"); - break; - case DHTLIB_ERROR_ACK_L: - Serial.print("Ack Low error,\t"); - break; - case DHTLIB_ERROR_ACK_H: - Serial.print("Ack High error,\t"); - break; default: Serial.print("Unknown error,\t"); break; diff --git a/Arduino/libraries/DHT/examples/dht21_test/dht21_test.ino b/Arduino/libraries/DHT/examples/dht21_test/dht21_test.ino deleted file mode 100644 index f9336a9e..00000000 --- a/Arduino/libraries/DHT/examples/dht21_test/dht21_test.ino +++ /dev/null @@ -1,66 +0,0 @@ - -// -// FILE: dht21_test.ino -// AUTHOR: Rob Tillaart -// VERSION: 0.1.02 -// PURPOSE: DHT library test sketch for DHT21 && Arduino -// URL: -// -// Released to the public domain -// - -#include - -dht DHT; - -#define DHT21_PIN 5 - -void setup() -{ - Serial.begin(115200); - Serial.println("DHT TEST PROGRAM "); - Serial.print("LIBRARY VERSION: "); - Serial.println(DHT_LIB_VERSION); - Serial.println(); - Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)"); -} - -void loop() -{ - // READ DATA - Serial.print("DHT21, \t"); - int chk = DHT.read21(DHT21_PIN); - switch (chk) - { - case DHTLIB_OK: - Serial.print("OK,\t"); - break; - case DHTLIB_ERROR_CHECKSUM: - Serial.print("Checksum error,\t"); - break; - case DHTLIB_ERROR_TIMEOUT: - Serial.print("Time out error,\t"); - break; - case DHTLIB_ERROR_CONNECT: - Serial.print("Connect error,\t"); - break; - case DHTLIB_ERROR_ACK_L: - Serial.print("Ack Low error,\t"); - break; - case DHTLIB_ERROR_ACK_H: - Serial.print("Ack High error,\t"); - break; - default: - Serial.print("Unknown error,\t"); - break; - } - // DISPLAY DATA - Serial.print(DHT.humidity, 1); - Serial.print(",\t"); - Serial.println(DHT.temperature, 1); - - delay(2000); -} -// -// END OF FILE -// \ No newline at end of file diff --git a/Arduino/libraries/DHT/examples/dht22_test/dht22_test.ino b/Arduino/libraries/DHT/examples/dht22_test/dht22_test.ino index 3cd8b951..0c7cbfae 100644 --- a/Arduino/libraries/DHT/examples/dht22_test/dht22_test.ino +++ b/Arduino/libraries/DHT/examples/dht22_test/dht22_test.ino @@ -65,18 +65,6 @@ void loop() stat.time_out++; Serial.print("Time out error,\t"); break; - case DHTLIB_ERROR_CONNECT: - stat.connect++; - Serial.print("Connect error,\t"); - break; - case DHTLIB_ERROR_ACK_L: - stat.ack_l++; - Serial.print("Ack Low error,\t"); - break; - case DHTLIB_ERROR_ACK_H: - stat.ack_h++; - Serial.print("Ack High error,\t"); - break; default: stat.unknown++; Serial.print("Unknown error,\t"); diff --git a/Arduino/libraries/DHT/examples/dht33_test/dht33_test.ino b/Arduino/libraries/DHT/examples/dht33_test/dht33_test.ino deleted file mode 100644 index d02198fc..00000000 --- a/Arduino/libraries/DHT/examples/dht33_test/dht33_test.ino +++ /dev/null @@ -1,74 +0,0 @@ -// -// FILE: dht33_test.ino -// AUTHOR: Rob Tillaart -// VERSION: 0.1.01 -// PURPOSE: DHT library test sketch for DHT33 && Arduino -// URL: -// -// Released to the public domain -// - -#include - -dht DHT; - -#define DHT33_PIN 5 - -void setup() -{ - Serial.begin(115200); - Serial.println("DHT TEST PROGRAM "); - Serial.print("LIBRARY VERSION: "); - Serial.println(DHT_LIB_VERSION); - Serial.println(); - Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)\tTime (us)"); -} - -void loop() -{ - // READ DATA - Serial.print("DHT33, \t"); - - uint32_t start = micros(); - int chk = DHT.read33(DHT33_PIN); - uint32_t stop = micros(); - - switch (chk) - { - case DHTLIB_OK: - Serial.print("OK,\t"); - break; - case DHTLIB_ERROR_CHECKSUM: - Serial.print("Checksum error,\t"); - break; - case DHTLIB_ERROR_TIMEOUT: - Serial.print("Time out error,\t"); - break; - case DHTLIB_ERROR_CONNECT: - Serial.print("Connect error,\t"); - break; - case DHTLIB_ERROR_ACK_L: - Serial.print("Ack Low error,\t"); - break; - case DHTLIB_ERROR_ACK_H: - Serial.print("Ack High error,\t"); - break; - default: - Serial.print("Unknown error,\t"); - break; - } - // DISPLAY DATA - Serial.print(DHT.humidity, 1); - Serial.print(",\t"); - Serial.print(DHT.temperature, 1); - Serial.print(",\t"); - Serial.print(stop - start); - Serial.println(); - - // FOR UNO + DHT33 400ms SEEMS TO BE MINIMUM DELAY BETWEEN SENSOR READS, - // ADJUST TO YOUR NEEDS - delay(1000); -} -// -// END OF FILE -// \ No newline at end of file diff --git a/Arduino/libraries/DHT/examples/dht44_test/dht44_test.ino b/Arduino/libraries/DHT/examples/dht44_test/dht44_test.ino deleted file mode 100644 index 93db583c..00000000 --- a/Arduino/libraries/DHT/examples/dht44_test/dht44_test.ino +++ /dev/null @@ -1,75 +0,0 @@ -// -// FILE: dht44_test.ino -// AUTHOR: Rob Tillaart -// VERSION: 0.1.01 -// PURPOSE: DHT library test sketch for DHT44 && Arduino -// URL: -// -// Released to the public domain -// - -#include - -dht DHT; - -#define DHT44_PIN 5 - -void setup() -{ - Serial.begin(115200); - Serial.println("DHT TEST PROGRAM "); - Serial.print("LIBRARY VERSION: "); - Serial.println(DHT_LIB_VERSION); - Serial.println(); - Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)\tTime (us)"); -} - -void loop() -{ - // READ DATA - Serial.print("DHT44, \t"); - - uint32_t start = micros(); - int chk = DHT.read44(DHT44_PIN); - uint32_t stop = micros(); - - switch (chk) - { - case DHTLIB_OK: - Serial.print("OK,\t"); - break; - case DHTLIB_ERROR_CHECKSUM: - Serial.print("Checksum error,\t"); - break; - case DHTLIB_ERROR_TIMEOUT: - Serial.print("Time out error,\t"); - break; - case DHTLIB_ERROR_CONNECT: - Serial.print("Connect error,\t"); - break; - case DHTLIB_ERROR_ACK_L: - Serial.print("Ack Low error,\t"); - break; - case DHTLIB_ERROR_ACK_H: - Serial.print("Ack High error,\t"); - break; - default: - Serial.print("Unknown error,\t"); - break; - } - // DISPLAY DATA - Serial.print(DHT.humidity, 1); - Serial.print(",\t"); - Serial.print(DHT.temperature, 1); - Serial.print(",\t"); - Serial.print(stop - start); - Serial.println(); - - // FOR UNO + DHT44 500ms SEEMS TO BE MINIMUM DELAY BETWEEN SENSOR READS, - // ADJUST TO YOUR NEEDS - - delay(1000); -} -// -// END OF FILE -// \ No newline at end of file diff --git a/Arduino/libraries/DHT/examples/dht_test1/dht_test1.ino b/Arduino/libraries/DHT/examples/dht_test1/dht_test1.ino deleted file mode 100644 index fc71cf87..00000000 --- a/Arduino/libraries/DHT/examples/dht_test1/dht_test1.ino +++ /dev/null @@ -1,136 +0,0 @@ -// -// FILE: dht_test.ino -// AUTHOR: Rob Tillaart -// VERSION: 0.1.08 -// PURPOSE: DHT Temperature & Humidity Sensor library for Arduino -// URL: http://arduino.cc/playground/Main/DHTLib -// -// Released to the public domain -// - -#include - -dht DHT; - -#define DHT11_PIN 4 -#define DHT21_PIN 5 -#define DHT22_PIN 6 - -void setup() -{ - Serial.begin(115200); - Serial.println("DHT TEST PROGRAM "); - Serial.print("LIBRARY VERSION: "); - Serial.println(DHT_LIB_VERSION); - Serial.println(); - Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)"); -} - -void loop() -{ - // READ DATA - Serial.print("DHT22, \t"); - int chk = DHT.read22(DHT22_PIN); - switch (chk) - { - case DHTLIB_OK: - Serial.print("OK,\t"); - break; - case DHTLIB_ERROR_CHECKSUM: - Serial.print("Checksum error,\t"); - break; - case DHTLIB_ERROR_TIMEOUT: - Serial.print("Time out error,\t"); - break; - case DHTLIB_ERROR_CONNECT: - Serial.print("Connect error,\t"); - break; - case DHTLIB_ERROR_ACK_L: - Serial.print("Ack Low error,\t"); - break; - case DHTLIB_ERROR_ACK_H: - Serial.print("Ack High error,\t"); - break; - default: - Serial.print("Unknown error,\t"); - break; - } - // DISPLAY DATA - Serial.print(DHT.humidity, 1); - Serial.print(",\t"); - Serial.println(DHT.temperature, 1); - - delay(1000); - - - // READ DATA - Serial.print("DHT21, \t"); - chk = DHT.read21(DHT21_PIN); - switch (chk) - { - case DHTLIB_OK: - Serial.print("OK,\t"); - break; - case DHTLIB_ERROR_CHECKSUM: - Serial.print("Checksum error,\t"); - break; - case DHTLIB_ERROR_TIMEOUT: - Serial.print("Time out error,\t"); - break; - case DHTLIB_ERROR_CONNECT: - Serial.print("Connect error,\t"); - break; - case DHTLIB_ERROR_ACK_L: - Serial.print("Ack Low error,\t"); - break; - case DHTLIB_ERROR_ACK_H: - Serial.print("Ack High error,\t"); - break; - default: - Serial.print("Unknown error,\t"); - break; - } - // DISPLAY DATA - Serial.print(DHT.humidity, 1); - Serial.print(",\t"); - Serial.println(DHT.temperature, 1); - - delay(1000); - - // READ DATA - Serial.print("DHT11, \t"); - chk = DHT.read11(DHT11_PIN); - switch (chk) - { - case DHTLIB_OK: - Serial.print("OK,\t"); - break; - case DHTLIB_ERROR_CHECKSUM: - Serial.print("Checksum error,\t"); - break; - case DHTLIB_ERROR_TIMEOUT: - Serial.print("Time out error,\t"); - break; - case DHTLIB_ERROR_CONNECT: - Serial.print("Connect error,\t"); - break; - case DHTLIB_ERROR_ACK_L: - Serial.print("Ack Low error,\t"); - break; - case DHTLIB_ERROR_ACK_H: - Serial.print("Ack High error,\t"); - break; - default: - Serial.print("Unknown error,\t"); - break; - } - // DISPLAY DATA - Serial.print(DHT.humidity,1); - Serial.print(",\t"); - Serial.println(DHT.temperature,1); - - delay(1000); -} -// -// END OF FILE -// \ No newline at end of file diff --git a/Arduino/libraries/DHT/examples/dht_tuning/dht_tuning.ino b/Arduino/libraries/DHT/examples/dht_tuning/dht_tuning.ino deleted file mode 100644 index 9c99ffbb..00000000 --- a/Arduino/libraries/DHT/examples/dht_tuning/dht_tuning.ino +++ /dev/null @@ -1,78 +0,0 @@ -// -// FILE: dht_tuning.ino -// AUTHOR: Rob Tillaart -// VERSION: 0.1.00 -// PURPOSE: DHT test sketch for DHT22 && Arduino => find minimum time between reads -// URL: -// -// Released to the public domain -// - -#include - -dht DHT; - -#define DHT22_PIN 5 - -void setup() -{ - Serial.begin(115200); - Serial.println("DHT TEST PROGRAM "); - Serial.print("LIBRARY VERSION: "); - Serial.println(DHT_LIB_VERSION); - Serial.println(); - Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)\tTime (us)"); -} - -int del = 500; - -void loop() -{ - // READ DATA - Serial.print("DHT22, \t"); - - uint32_t start = micros(); - int chk = DHT.read22(DHT22_PIN); - uint32_t stop = micros(); - - switch (chk) - { - case DHTLIB_OK: - Serial.print("OK,\t"); - del -= 10; - break; - case DHTLIB_ERROR_CHECKSUM: - Serial.print("Checksum error,\t"); - break; - case DHTLIB_ERROR_TIMEOUT: - Serial.print("Time out error,\t"); - del += 10; - break; - case DHTLIB_ERROR_CONNECT: - Serial.print("Connect error,\t"); - break; - case DHTLIB_ERROR_ACK_L: - Serial.print("Ack Low error,\t"); - break; - case DHTLIB_ERROR_ACK_H: - Serial.print("Ack High error,\t"); - break; - default: - Serial.print("Unknown error,\t"); - break; - } - // DISPLAY DATA - Serial.print(DHT.humidity, 1); - Serial.print(",\t"); - Serial.print(DHT.temperature, 1); - Serial.print(",\t"); - Serial.print(stop - start); - Serial.print(",\t"); - Serial.print(del); - Serial.println(); - - delay(del); -} -// -// END OF FILE -// \ No newline at end of file diff --git a/Arduino/libraries/DHT/examples/readme.txt b/Arduino/libraries/DHT/examples/readme.txt new file mode 100644 index 00000000..deb168cd --- /dev/null +++ b/Arduino/libraries/DHT/examples/readme.txt @@ -0,0 +1,2 @@ +2015-08-20 these examples are retrofitted from version 0.1.20 which supports more errors. + diff --git a/Arduino/libraries/DHT/library.json b/Arduino/libraries/DHT/library.json new file mode 100644 index 00000000..d04d56b0 --- /dev/null +++ b/Arduino/libraries/DHT/library.json @@ -0,0 +1,23 @@ +{ + "name": "DHTStable", + "keywords": "DHT11 DHT22 DHT33 DHT44 AM2301 AM2302 AM2303", + "description": "Stable version of the library for DHT Temperature & Humidity Sensor.", + "authors": + [ + { + "name": "Rob Tillaart", + "email": "Rob.Tillaart@gmail.com", + "maintainer": true + } + ], + "repository": + { + "type": "git", + "url": "https://github.com/RobTillaart/Arduino.git" + }, + "frameworks": "arduino", + "platforms": "atmelavr", + "export": { + "include": "libraries/DHTstable" + } +} diff --git a/Arduino/libraries/DHT/library.properties b/Arduino/libraries/DHT/library.properties new file mode 100644 index 00000000..ed4907b2 --- /dev/null +++ b/Arduino/libraries/DHT/library.properties @@ -0,0 +1,9 @@ +name=DHTStable +version=0.1.13 +author=Rob Tillaart +maintainer=Rob Tillaart +sentence=Stable version of library for DHT Temperature & Humidity Sensor +paragraph= +category=Sensors +url=https://github.com/RobTillaart/Arduino/Libraries/ +architectures=* \ No newline at end of file diff --git a/Arduino/libraries/DHT/readme.txt b/Arduino/libraries/DHT/readme.txt index 7f034904..a6de886c 100644 --- a/Arduino/libraries/DHT/readme.txt +++ b/Arduino/libraries/DHT/readme.txt @@ -1,28 +1,13 @@ -The DHT11, 21, 22, 33 and 44 are relative inexpensive sensors for measuring temperature and humidity. -This library can be used for reading both values from these DHT sensors. -The DHT11 only returns integers (e.g. 20) and does not support negative values. -The others are quite similar and provide one decimal digit (e.g. 20.2) -The hardware pins of the sensors and handshake are identical so ideal to combine in one lib. +This is the 0.1.13 version of the DHTlib. +This version is stable for both ARM and AVR. -The library (0.1.13 version) is confirmed to work on: +You can use most examples from https://github.com/RobTillaart/Arduino/tree/master/libraries/DHTlib/examples -UNO (tested myself) -2009 (tested myself) -MEGA2560 -DUE -attiny85 @8MHz -Digistump Digix @ 84 MHz +update 2015-10-12: +For multithreading environments for Arduino one could replace + delay(wakeupDelay); +with + delayMicroseconds(wakeupDelay * 1000UL); +see also - https://github.com/RobTillaart/Arduino/pull/25 - -More information - http://playground.arduino.cc//Main/DHTLib - - -Notes: -version 0.1.13 is the last stable version for both AVR and ARM - -version 0.1.14 and up are not compatible anymore with pre 1.0 Arduino -version 0.1.14 and up have breaking changes wrt ARM based arduino's e.g DUE. -version 0.1.15 is stable version for AVR only -version 0.1.16 and 0.1.17 have breaking changes for DHT11 -version 0.1.18 works again for DHT11 (avr only) -version 0.1.19 fixed masking bug DHT11 (avr only) -version 0.1.20 Reduce footprint (34 bytes) by using int8_t as error codes. (thanks to chaveiro) diff --git a/Arduino/libraries/ST_Anything/Constants.h b/Arduino/libraries/ST_Anything/Constants.h index f6bc557a..7a97a73b 100644 --- a/Arduino/libraries/ST_Anything/Constants.h +++ b/Arduino/libraries/ST_Anything/Constants.h @@ -38,13 +38,14 @@ // Added DISABLE_REFRESH feature - commented out by default. Allows user to disable the automatic refresh feature as it can interfere with normal operations. // Adjusted MAX Sensor and Executor counts for the Arduino MEGA to allow 16 relay system to function properly. // 2016-06-04 Dan Ogorchock Added improved support for Arduino Leonardo +// 2017-02-07 Dan Ogorchock Added support for new SmartThings v2.0 library (ThingShield, W5100, ESP8266) // //****************************************************************************************** #ifndef ST_CONSTANTS_H #define ST_CONSTANTS_H -#include "Arduino.h" +//#include "Arduino.h" #include "SmartThings.h" //#define ENABLE_SERIAL //If uncommented, will allow you to type in commands via the Arduino Serial Console Window (useful for debugging) @@ -97,45 +98,45 @@ namespace st static const bool WAIT_FOR_JOIN_AT_START = true; //Select whether to use Hardware or Software Serial Communications - will result in the correct SmartThings constructor being called in Everything.cpp - #if defined(BOARD_UNO) - #define ST_SOFTWARE_SERIAL //Use Software Serial for UNO by default - //#define ST_HARDWARE_SERIAL - #elif defined(BOARD_MEGA) || defined(BOARD_LEONARDO) - //#define ST_SOFTWARE_SERIAL - #define ST_HARDWARE_SERIAL //Use Hardware Serial for MEGA or LEONARDO by default - #else - #define ST_SOFTWARE_SERIAL - //#define ST_HARDWARE_SERIAL - #endif + //#if defined(BOARD_UNO) + // #define ST_SOFTWARE_SERIAL //Use Software Serial for UNO by default + // //#define ST_HARDWARE_SERIAL + //#elif defined(BOARD_MEGA) || defined(BOARD_LEONARDO) + // //#define ST_SOFTWARE_SERIAL + // #define ST_HARDWARE_SERIAL //Use Hardware Serial for MEGA or LEONARDO by default + //#else + // #define ST_SOFTWARE_SERIAL + // //#define ST_HARDWARE_SERIAL + //#endif //--- //--- if using SoftwareSerial //--- -set the following based on the pins you desire //--- -NOTE: you must use the SoftwareSerial version of the SmartThings Constructor //--- - #if defined(BOARD_UNO) - static const uint8_t pinRX = 3; //Rx Pin3 - works for UNO R3, but not for Leonardo or Mega - #else - static const uint8_t pinRX = 10; //Rx Pin10 - works for Leonardo or Mega - You MUST jumper Pin10 to Pin3 - do not use Pin3 or Pin10 in your sketch! - #endif - - static const uint8_t pinTX = 2; //Tx Pin2 - works for UNO R3, Leonardo, and Mega + //#if defined(BOARD_UNO) + // static const uint8_t pinRX = 3; //Rx Pin3 - works for UNO R3, but not for Leonardo or Mega + //#else + // static const uint8_t pinRX = 10; //Rx Pin10 - works for Leonardo or Mega - You MUST jumper Pin10 to Pin3 - do not use Pin3 or Pin10 in your sketch! + //#endif + // + // static const uint8_t pinTX = 2; //Tx Pin2 - works for UNO R3, Leonardo, and Mega //--- //--- if using Hardware Serial //--- -set the following based on the pins you desire (HW_SERIAL, Mega Only(HW_SERIAL1, HW_SERIAL2, HW_SERIAL3)) //--- -NOTE: you must use the HardwareSerial version of the SmartThings Constructor //--- - #if defined(BOARD_UNO) - static const SmartThingsSerialType_t SERIAL_TYPE = HW_SERIAL; //UNO - You MUST move ThingShield switch to D0/D1 position after loading program and then reset the Arduino - #elif defined(BOARD_LEONARDO) - static const SmartThingsSerialType_t SERIAL_TYPE = HW_SERIAL1; //Leonardo - You MUST move ThingShield switch to D0/D1 position - #elif defined(BOARD_MEGA) - //static const SmartThingsSerialType_t SERIAL_TYPE = HW_SERIAL; //MEGA - You MUST move ThingShield switch to D0/D1 position after loading program and then reset the Arduino - //static const SmartThingsSerialType_t SERIAL_TYPE = HW_SERIAL1; //MEGA - You MUST jumper Pin18 to Pin2 AND Pin19 to Pin3 - do not use Pin2 or Pin3 in your sketch! - //static const SmartThingsSerialType_t SERIAL_TYPE = HW_SERIAL2; //MEGA - You MUST jumper Pin16 to Pin2 AND Pin17 to Pin3 - do not use Pin2 or Pin3 in your sketch! - static const SmartThingsSerialType_t SERIAL_TYPE = HW_SERIAL3; //MEGA - You MUST jumper Pin14 to Pin2 AND Pin15 to Pin3 - do not use Pin2 or Pin3 in your sketch! - #endif + //#if defined(BOARD_UNO) + // static const SmartThingsSerialType_t SERIAL_TYPE = HW_SERIAL; //UNO - You MUST move ThingShield switch to D0/D1 position after loading program and then reset the Arduino + //#elif defined(BOARD_LEONARDO) + // static const SmartThingsSerialType_t SERIAL_TYPE = HW_SERIAL1; //Leonardo - You MUST move ThingShield switch to D0/D1 position + //#elif defined(BOARD_MEGA) + // //static const SmartThingsSerialType_t SERIAL_TYPE = HW_SERIAL; //MEGA - You MUST move ThingShield switch to D0/D1 position after loading program and then reset the Arduino + // //static const SmartThingsSerialType_t SERIAL_TYPE = HW_SERIAL1; //MEGA - You MUST jumper Pin18 to Pin2 AND Pin19 to Pin3 - do not use Pin2 or Pin3 in your sketch! + // //static const SmartThingsSerialType_t SERIAL_TYPE = HW_SERIAL2; //MEGA - You MUST jumper Pin16 to Pin2 AND Pin17 to Pin3 - do not use Pin2 or Pin3 in your sketch! + // static const SmartThingsSerialType_t SERIAL_TYPE = HW_SERIAL3; //MEGA - You MUST jumper Pin14 to Pin2 AND Pin15 to Pin3 - do not use Pin2 or Pin3 in your sketch! + //#endif // ------------------------------------------------------------------------------- }; } diff --git a/Arduino/libraries/ST_Anything/Device.h b/Arduino/libraries/ST_Anything/Device.h index a744a7de..5eca76be 100644 --- a/Arduino/libraries/ST_Anything/Device.h +++ b/Arduino/libraries/ST_Anything/Device.h @@ -19,7 +19,7 @@ #define ST_DEVICE_H #include -#include +//#include namespace st { diff --git a/Arduino/libraries/ST_Anything/Everything.cpp b/Arduino/libraries/ST_Anything/Everything.cpp index 44eaeeb6..6f2e906e 100644 --- a/Arduino/libraries/ST_Anything/Everything.cpp +++ b/Arduino/libraries/ST_Anything/Everything.cpp @@ -20,59 +20,20 @@ // 2015-01-10 Dan Ogorchock Minor improvements to support Door Control Capability // 2015-03-14 Dan Ogorchock Added public setLED() function to control ThingShield LED // 2015-03-28 Dan Ogorchock Added throttling capability to sendStrings to improve success rate of ST Cloud getting the data ("SENDSTRINGS_INTERVAL" is in CONSTANTS.H) -// +// 2017-02-07 Dan Ogorchock Added support for new SmartThings v2.0 library (ThingShield, W5100, ESP8266) // //****************************************************************************************** -#include -#include +//#include +//#include #include "Everything.h" -int freeRam(); //freeRam() function prototype - useful in determining how much SRAM is available on Arduino +long freeRam(); //freeRam() function prototype - useful in determining how much SRAM is available on Arduino namespace st { //private - void Everything::updateNetworkState() //get the current zigbee network status of the ST Shield - { - #ifndef DISABLE_SMARTTHINGS - SmartThingsNetworkState_t tempState = SmartThing.shieldGetLastNetworkState(); - if (tempState != stNetworkState) - { - switch (tempState) - { - case STATE_NO_NETWORK: - if (debug) Serial.println(F("Everything: NO_NETWORK")); - SmartThing.shieldSetLED(2, 0, 0); // red - break; - case STATE_JOINING: - if (debug) Serial.println(F("Everything: JOINING")); - SmartThing.shieldSetLED(2, 0, 0); // red - break; - case STATE_JOINED: - if (debug) Serial.println(F("Everything: JOINED")); - SmartThing.shieldSetLED(0, 0, 0); // off - break; - case STATE_JOINED_NOPARENT: - if (debug) Serial.println(F("Everything: JOINED_NOPARENT")); - SmartThing.shieldSetLED(2, 0, 2); // purple - break; - case STATE_LEAVING: - if (debug) Serial.println(F("Everything: LEAVING")); - SmartThing.shieldSetLED(2, 0, 0); // red - break; - default: - case STATE_UNKNOWN: - if (debug) Serial.println(F("Everything: UNKNOWN")); - SmartThing.shieldSetLED(0, 2, 0); // green - break; - } - stNetworkState = tempState; - } - #endif - } - void Everything::updateSensors() { for(unsigned int index=0; indexsend(Return_String.substring(0, index)); sendstringsLastMillis = millis(); #endif #if defined(ENABLE_SERIAL) && defined(DISABLE_SMARTTHINGS) @@ -162,19 +123,7 @@ namespace st } #ifndef DISABLE_SMARTTHINGS - if(Constants::WAIT_FOR_JOIN_AT_START) //WAIT_FOR_JOIN_AT_START is set in Constants.h - { - while(stNetworkState!=STATE_JOINED) - { - updateNetworkState(); - SmartThing.run(); - } - } - else - { - updateNetworkState(); - SmartThing.run(); - } + SmartThing->init(); #endif @@ -222,8 +171,7 @@ namespace st updateSensors(); //call each st::Sensor object to refresh data #ifndef DISABLE_SMARTTHINGS - SmartThing.run(); //call the ST Shield Library to receive any data from the ST Hub - updateNetworkState(); //call the ST Shield Library to update the current zigbee network status between the Shield and Hub + SmartThing->run(); //call the ST Shield Library to receive any data from the ST Hub #endif #if defined(ENABLE_SERIAL) @@ -375,6 +323,7 @@ namespace st } //initialize static members + st::SmartThings* Everything::SmartThing=0; //initialize pointer to null String Everything::Return_String; Sensor* Everything::m_Sensors[Constants::MAX_SENSOR_COUNT]; Executor* Everything::m_Executors[Constants::MAX_EXECUTOR_COUNT]; @@ -382,30 +331,38 @@ namespace st byte Everything::m_nExecutorCount=0; unsigned long Everything::lastmillis=0; unsigned long Everything::refLastMillis=0; - unsigned long Everything::sendstringsLastMillis = 0; + unsigned long Everything::sendstringsLastMillis=0; bool Everything::debug=false; - byte Everything::bTimersPending = 0; //initialize variable - void (*Everything::callOnMsgSend)(const String &msg) = 0; //initialize this callback function to null + byte Everything::bTimersPending=0; //initialize variable + void (*Everything::callOnMsgSend)(const String &msg)=0; //initialize this callback function to null //SmartThings static members - #ifndef DISABLE_SMARTTHINGS - // Please refer to Constants.h for settings that affect whether a board uses SoftwareSerial or Hardware Serial calls - #if defined(ST_SOFTWARE_SERIAL) //use Software Serial - SmartThings Everything::SmartThing(Constants::pinRX, Constants::pinTX, receiveSmartString); - #elif defined(ST_HARDWARE_SERIAL) //use Hardware Serial - SmartThings Everything::SmartThing(Constants::SERIAL_TYPE, receiveSmartString); - #endif + //#ifndef DISABLE_SMARTTHINGS + // // Please refer to Constants.h for settings that affect whether a board uses SoftwareSerial or Hardware Serial calls + // #if defined(ST_SOFTWARE_SERIAL) //use Software Serial + // SmartThingsThingShield Everything::SmartThing(Constants::pinRX, Constants::pinTX, receiveSmartString); + // #elif defined(ST_HARDWARE_SERIAL) //use Hardware Serial + // SmartThingsThingShield Everything::SmartThing(Constants::SERIAL_TYPE, receiveSmartString); + // #endif - SmartThingsNetworkState_t Everything::stNetworkState=(SmartThingsNetworkState_t)99; //bogus value for first pass through Everything::updateNetworkState() - #endif + // SmartThingsNetworkState_t Everything::stNetworkState=(SmartThingsNetworkState_t)99; //bogus value for first pass through Everything::updateNetworkState() + //#endif } //freeRam() function - useful in determining how much SRAM is available on Arduino -int freeRam() +long freeRam() { - extern int __heap_start, *__brkval; - int v; - return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); +#if defined(ARDUINO_ARCH_AVR) + extern int __heap_start, *__brkval; + int v; + return (int)&v - (__brkval == 0 ? (int)&__heap_start : (int)__brkval); +#elif defined(ARDUINO_ARCH_ESP8266) + return ESP.getFreeHeap(); +#else + return -1; +#endif // ! + + } diff --git a/Arduino/libraries/ST_Anything/Everything.h b/Arduino/libraries/ST_Anything/Everything.h index d7e0a6ca..fabb87bf 100644 --- a/Arduino/libraries/ST_Anything/Everything.h +++ b/Arduino/libraries/ST_Anything/Everything.h @@ -22,15 +22,14 @@ // 2015-01-10 Dan Ogorchock Minor improvements to support Door Control Capability // 2015-03-14 Dan Ogorchock Added public setLED() function to control ThingShield LED // 2015-03-28 Dan Ogorchock Added throttling capability to sendStrings to improve success rate of ST Cloud getting the data ("SENDSTRINGS_INTERVAL" is in CONSTANTS.H) - -// +// 2017-02-07 Dan Ogorchock Added support for new SmartThings v2.0 library (ThingShield, W5100, ESP8266) // //****************************************************************************************** #ifndef ST_EVERYTHING_H #define ST_EVERYTHING_H -#include "Arduino.h" +//#include "Arduino.h" #include "Constants.h" #include "Sensor.h" #include "Executor.h" @@ -50,14 +49,10 @@ namespace st static Executor* m_Executors[Constants::MAX_EXECUTOR_COUNT]; //array of Executor objects that st::Everything will keep track of static byte m_nExecutorCount;//number of st::Executor objects added to st::Everything in your sketch Setup() routine - //SmartThings Object - #ifndef DISABLE_SMARTTHINGS - static SmartThings SmartThing; //SmartThings Shield Library object - #endif - static SmartThingsNetworkState_t stNetworkState; + //static SmartThingsNetworkState_t stNetworkState; - static void updateNetworkState(); //keeps track of the current ST Shield to Hub network status + //static void updateNetworkState(); //keeps track of the current ST Shield to Hub network status static void updateSensors(); //simply calls update on all the sensors static void sendStrings(); //sends all updates from the devices in Return_String static unsigned long sendstringsLastMillis; //keep track of how long since last time we sent data to ST Cloud, to enable throttling @@ -92,15 +87,18 @@ namespace st static bool debug; //debug flag to determine if debug print statements are executed - set value in your sketch's setup() routine static void (*callOnMsgSend)(const String &msg); //If this function pointer is assigned, the function it points to will be called upon every time a string is sent to the cloud. - - friend SmartThingsCallout_t receiveSmartString; //callback function to act on data received from SmartThings Shield - called from SmartThings Shield Library - - //SmartThings Object #ifndef DISABLE_SMARTTHINGS - static void setLED(uint8_t red, uint8_t green, uint8_t blue) {SmartThing.shieldSetLED(red, green, blue);} + static st::SmartThings* SmartThing; //SmartThings Shield Library object #endif + + friend SmartThingsCallout_t receiveSmartString; //callback function to act on data received from SmartThings Shield - called from SmartThings Shield Library + + //SmartThings Object + //#ifndef DISABLE_SMARTTHINGS + // static void setLED(uint8_t red, uint8_t green, uint8_t blue) {SmartThing.shieldSetLED(red, green, blue);} + //#endif }; } #endif diff --git a/Arduino/libraries/ST_Anything_TemperatureHumidity/PS_TemperatureHumidity.cpp b/Arduino/libraries/ST_Anything_TemperatureHumidity/PS_TemperatureHumidity.cpp index a638ed82..72b547fa 100644 --- a/Arduino/libraries/ST_Anything_TemperatureHumidity/PS_TemperatureHumidity.cpp +++ b/Arduino/libraries/ST_Anything_TemperatureHumidity/PS_TemperatureHumidity.cpp @@ -145,21 +145,21 @@ namespace st Serial.println(F("PS_TemperatureHumidity: DHT Time out error")); } break; - case DHTLIB_ERROR_CONNECT: - if (st::PollingSensor::debug) { - Serial.println(F("PS_TemperatureHumidity: DHT Connect error")); - } - break; - case DHTLIB_ERROR_ACK_L: - if (st::PollingSensor::debug) { - Serial.println(F("PS_TemperatureHumidity: DHT Ack Low error")); - } - break; - case DHTLIB_ERROR_ACK_H: - if (st::PollingSensor::debug) { - Serial.println(F("PS_TemperatureHumidity: DHT Ack High error")); - } - break; + //case DHTLIB_ERROR_CONNECT: + // if (st::PollingSensor::debug) { + // Serial.println(F("PS_TemperatureHumidity: DHT Connect error")); + // } + // break; + //case DHTLIB_ERROR_ACK_L: + // if (st::PollingSensor::debug) { + // Serial.println(F("PS_TemperatureHumidity: DHT Ack Low error")); + // } + // break; + //case DHTLIB_ERROR_ACK_H: + // if (st::PollingSensor::debug) { + // Serial.println(F("PS_TemperatureHumidity: DHT Ack High error")); + // } + // break; default: if (st::PollingSensor::debug) { Serial.println(F("PS_TemperatureHumidity: DHT Unknown error")); diff --git a/Arduino/libraries/SmartThings/README.md b/Arduino/libraries/SmartThings/README.md new file mode 100644 index 00000000..1a31d34c --- /dev/null +++ b/Arduino/libraries/SmartThings/README.md @@ -0,0 +1,140 @@ +History: +- v2.0 2017-02-11 Initial Release + +SmartThings v2.x +================ +This is a new version of the old SmartThings Arduino Library created by SmartThings for use with their Zigbee-based ThingShield. Recently, SmartThings has decided to no longer produce nor support the ThingShield. In an attempt to provide the Maker Community with alternatives, I decided to re-architect the C++ Class hierarchy of the SmartThings library to include continued support for the old ThingShield, as well as adding new support for the Arduino Ethernet W5100 shield and the NodeMCU ESP8266 boards. This allows users three options for connecting their DIY projects to SmartThings. + +This library currently implements the following C++ Classes and associated constructors: +-st::SmartThings (base class, not to be used in your sketch!) + -st::SmartThingsThingShield (use this class "#include Examples->SmartThings + - Select the example sketch that matches your hardware + - Select File->Save As and select your "Sketches" folder, and click "Save" + - If using W5100 or ESP8266, find the lines of the Sketch where it says "<---You must edit this line!" + - The Arduino must be assigned a static TCP/IP address, Gateway, DNS, Subnet Mask, MAC Address (W5100 only), SSID + Password (ESP8266 only) + - *** NOTE: If using the W5100 Shield, YOU MUST ASSIGN IT A UNIQUE MAC ADDRESS in the sketch!!! *** + - Your IDE Serial Monitor Window should be set to 9600 baud + - With the Serial Monitor windows open, load your sketch and whatch the output + - If using an ESP8266 board, the MAC Address will be printed out in the serial monitor window. Write this down as you will need it to configure the Device using your ST App on your phone. + +##SmartThings IDE Device Handler Installation Instructions +- Create an account and/or log into the SmartThings Developers Web IDE. + +Arduino/ThingShield +- If using a ThingShield, join it to the SmartThings hub by using the ST App on your phone - Add new device +- Install the ThingShield example Device Handler + - Click on "My Device Handlers" from the navigation menu. + - Click on "+ New Device Handler" button. + - Select the "From Code" Tab near the top of the page + - Paste the code from the `On_Off_LED_ThingShield.device.groovy` file from the `..Arduino\libraries\SmartThings\extras` folder + - Click on "Create" near the bottom of the page. + - Click on "Save" in the IDE. + - Click on "Publish" -> "For Me" in the IDE. + - Click on "My Devices" from navigation menu + - Select your "Arduino ThingShield" device from the list + - Click the Edit button at the bottom of the screen + - Change the Type to "On/Off ThingShield" + - Click the Update button at the bottom of the screen + - On your phone, you should now see a device that has simple On/Off tile + +Ethernet Arduino/W5100 or NodeMCU ESP8266 +- Install the Ethernet example Device Handler + - Click on "+ New Device Handler" button. + - Select the "From Code" Tab near the top of the page + - Paste the code from the `On_Off_LED_Ethernet.device.groovy` file from the `..Arduino\libraries\SmartThings\extras` folder + - Click on "Create" near the bottom of the page. + - Click on "Save" in the IDE. + - Click on "Publish" -> "For Me" in the IDE. + - Click on "My Devices" from navigation menu + - Click on the "+ New Device" button + - Enter a "Name" (whatever you like) + - Enter a "Label" (whatever you like) + - Change the Type to "On/Off Ethernet" + - Change "Version" to "Published" + - Select your "Location" + - Select your "Hub" + - Click "Create" + - On your phone, you should now see a device that has simple "On/Off" tile and a "Configure" tile + - One your phone, after selecting the new device, click on the settings icon (small gear in top right corner) + - Enter your Arduino or ESP8266 device's TCP/IP Address, Port, and MAC Address (you should already know these from when you configured your sketch) + - Click "Done" + +. +. +. + +###WARNING - Geeky Material Ahead!!! + +. +. +. + +The following applies only to using the ThingShield! + +If you want to use the new SmartThings v2.x libary with your existing ThingShield sketches (or to just learn more about how all this stuff works, keep reading...) + +Remember to "#include " to use the new v2.x SmartThings library with the ThingShield. + +The Arduino UNO uses the SoftwareSerial library constructor since the UNO has only one Hardware UART port ("Serial") which is used by the USB port for programming and debugging. +Arduino UNO R3 SoftwareSerial: +- Use the NEW SoftwareSerial constructor passing in pinRX=3 and pinTX=2 + - st::SmartThingsThingShield(uint8_t pinRX, uint8_t pinTX, SmartThingsCallout_t *callout) call. +- Make sure the ThingShield's switch in the "D2/D3" position +- Be certain to not use Pins 2 & 3 in your Arduino sketch for I/O since they are electrically connected to the ThingShield. Pin6 is also reserved by the ThingShield. Best to avoid using it. Also, pins 0 & 1 are used for USB communications, so do not use them if possible. + +The new v2.x SmartThings ThingShield library automatically disables support for Software Serial if using a Leonardo or MEGA based Arduino board. + +The Arduino MEGA 2560 must use HardwareSerial "Serial1, Serial2, or Serial3" for communications with the ThingShield. +MEGA 2560 Hardware Serial: +- Use the new Hardware Serial constructor passing in a pointer to a Hardware Serial device (&Serial1, &Serial2, &Serial3) + - definition st::SmartThingsThingShield(HardwareSerial* serial, SmartThingsCallout_t *callout); + - sample st::SmartThingsThingShield(&Serial3, callout); +- Make sure the ThingShield's switch in the "D2/D3" position +- Be certain to not use Pins 2 & 3 in your Arduino sketch for I/O since they are electrically connected to the ThingShield. Pin6 is also reserved by the ThingShield. Best to avoid using it. +- On the MEGA, Serial1 uses pins 18/19, Serial2 uses pins 16/17, and Serial3 uses pins 14/15 +- You will need to wire the MEGA's HardwareSerial port's pins to pins 2 & 3 on the ThingShield. For example, using Serial3, wire Pin 2 to Pin 14 AND Pin3 to Pin 15. + +The Arduino Leonardo must use HardwareSerial "Serial1" for communications with the ThingShield. +Leonardo Hardware Serial: +- Use the new Hardware Serial constructor passing in a pointer to a Hardware Serial device (&Serial1) + - definition st::SmartThingsThingShield(HardwareSerial* serial, SmartThingsCallout_t *callout); + - sample st::SmartThingsThingShield(&Serial1, callout); +- Make sure the ThingShield's switch in the "D0/D1" position +- Be certain to not use Pins 0 & 1 in your Arduino sketch for I/O since they are electrically connected to the ThingShield. Pin6 is also reserved by the ThingShield. Best to avoid using it. + + + diff --git a/Arduino/libraries/SmartThings/SmartThings.cpp b/Arduino/libraries/SmartThings/SmartThings.cpp index cb34ec79..f9e0864f 100644 --- a/Arduino/libraries/SmartThings/SmartThings.cpp +++ b/Arduino/libraries/SmartThings/SmartThings.cpp @@ -1,690 +1,33 @@ //******************************************************************************* -/// @file -/// @brief -/// SmartThings Arduino Library -/// @section License -/// (C) Copyright 2013 Physical Graph -/// -/// Updates by Daniel Ogorchock 12/30/2014 - Arduino Mega 2560 HW Serial support -/// -Numerous performance and size optimizations (helpful on UNO with only 2K SRAM) -/// -Arduino UNO should use the SoftwareSerial library Constructor since the UNO has -/// only one Hardware UART port ("Serial") which is used by the USB port for -/// programming and debugging typically. UNO can use the Hardware "Serial" -/// if desired, but USB programming and debug will be troublesome. -/// Leonardo and Mega can use SoftwareSerial BUT cannot use Pin3 for Rx - use -/// Pin10 for Rx and add jumper from Pin10 to Pin3. -/// -Arduino LEONARDO should use the Hardware Serial Constructor since it has 1 UART -/// separate from the USB port. "Serial1" port uses pins 0(Rx) and 1(Tx). -/// -Arduino MEGA should use the Hardware Serial Constructor since it has 4 UARTs. -/// "Serial3" port uses pins 14(Tx) and 15(Rx). Wire Pin14 to Pin2 and Pin15 to Pin3. -/// -Be certain to not use Pins 2 & 3 in your Arduino sketch for I/O since they are -/// electrically connected to the ThingShield if set to D2/D3. -/// -Note - Pin6 is reserved by the ThingShield as well. Best to avoid using it. -/// -The SoftwareSerial library has the following known limitations: -/// - If using multiple software serial ports, only one can receive data at a time. -/// - Not all pins on the Mega and Mega 2560 support change interrupts, so only -/// the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, -/// A8(62), A9(63), A10(64), A11(65), A12(66), A13(67), A14(68), A15(69). -/// - Not all pins on the Leonardo and Micro support change interrupts, so only -/// the following can be used for RX : 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI). -/// -2016-06-04 Dan Ogorchock Added improved support for Arduino Leonardo +// SmartThings Arduino Library Base Class +// +// License +// (C) Copyright 2017 Dan Ogorchock +// +// History +// 2017-02-04 Dan Ogorchock Created //******************************************************************************* #include -//***************************************************************************** -void SmartThings::debugPrintBuffer(String prefix, uint8_t * pBuf, uint_fast8_t nBuf) +namespace st { - if (_isDebugEnabled) + //******************************************************************************* + // SmartThings Constructor + //******************************************************************************* + SmartThings::SmartThings(SmartThingsCallout_t *callout, String shieldType, bool enableDebug) : + _calloutFunction(callout), + _shieldType(shieldType), + _isDebugEnabled(enableDebug) { - Serial.print(prefix); - for (uint_fast8_t i = 0; i < nBuf; i++) - { - Serial.print(char(pBuf[i])); - } - Serial.println(); - } -} - -//***************************************************************************** -bool SmartThings::isRxLine(uint8_t * pLine) -{ - // line starts with "T00000000:RX" - //int validRxLineLength = 12; // TODO: What is a real value for this length? - - // return line.length > validRxLineLength && line[0] == 'T' && line[9] = ':' && line[10] == 'R' && line[11] == 'X'; - return ((pLine[0] == 'T') && (pLine[9] == ':') && (pLine[10] == 'R') && (pLine[11] == 'X')); -} -//******************************************************************************* -bool SmartThings::isAsciiHex(uint8_t ascii) -{ - bool retVal = false; - if ( - ((ascii >= 'A') && (ascii <= 'F')) || - ((ascii >= 'a') && (ascii <= 'f')) || - ((ascii >= '0') && (ascii <= '9')) - ) - { - retVal = true; } - return retVal; -} - -//******************************************************************************* -/// @note this function doesn't check for hex validity before converting -//******************************************************************************* -uint8_t SmartThings::asciiToHexU8(uint8_t pAscii[2]) -{ - uint8_t hex; - hex = ((pAscii[0] - (((pAscii[0] >> 6) & 0x1) * 0x37)) & 0xF); - hex <<= 4; - hex |= ((pAscii[1] - (((pAscii[1] >> 6) & 0x1) * 0x37)) & 0xF); - return hex; -} - -//***************************************************************************** -uint_fast8_t SmartThings::translatePayload(uint8_t *pBuf, uint_fast8_t nBuf) -{ - uint_fast8_t payloadLength = 0; // return value - uint_fast8_t payloadStart = 0; - uint_fast8_t payloadEnd = 0; - - uint_fast8_t i; - - // find [ ] message from the back of the message - for (i = nBuf - 1; i > 0; i--) - { - if (pBuf[i] == ']') - { - payloadEnd = i; - } - else if (pBuf[i] == '[') - { - payloadStart = i; - break; - } - } - - - if (_isDebugEnabled) - { - Serial.print(F("payload start: ")); - Serial.print(payloadStart); - Serial.print(F(" end: ")); - Serial.print(payloadEnd); - Serial.print(F(" : ")); - for (i = payloadStart + 1; i < payloadEnd; i++) - { - Serial.print(pBuf[i]); - Serial.print(' '); - } - Serial.println(); - } - - // int expectedPayloadLength = (payloadEnd - payloadStart) / 3; // TODO: Verify this, but 2 chars for byte and 1 for space char - // char payloadString[expectedPayloadLength]; - if ((payloadStart != 0) && (payloadEnd != 0) && (payloadEnd - payloadStart > 4) && (pBuf[payloadStart + 1] == '0') && (pBuf[payloadStart + 2] == 'A')) - { // if valid message then parse - i = payloadStart + 4; // start+3 should be ' ' - while (i < payloadEnd) - { - if (pBuf[i] != ' ') - { - if (isAsciiHex(pBuf[i]) && isAsciiHex(pBuf[i + 1])) - { - pBuf[payloadLength++] = asciiToHexU8(&(pBuf[i++])); - } - } - i++; - } - } - - pBuf[payloadLength] = 0x0; // null-terminate the string - return payloadLength; -} - -//***************************************************************************** -void SmartThings::_process(void) -{ - uint32_t nowMilliseconds = millis(); - - if ((nowMilliseconds < _lastShieldMS) || ((nowMilliseconds - _lastShieldMS) > 5000)) - { - _shieldGetNetworkInfo(); - _lastShieldMS = nowMilliseconds; - } - else if ((_networkState == STATE_JOINED) && - ((nowMilliseconds < _lastPingMS) || ((nowMilliseconds - _lastPingMS) > 60000))) - { // ping every minutes or on rollover - send("ping"); - _lastPingMS = nowMilliseconds; - } - - // check for return character -} -//***************************************************************************** -void SmartThings::handleLine(void) -{ - if (_nBufRX > 0) + //***************************************************************************** + //SmartThings::~SmartThings() + //***************************************************************************** + SmartThings::~SmartThings() { - if (isRxLine(_pBufRX)) - { - debugPrintBuffer("->| ", _pBufRX, _nBufRX); - { - //char messageBuf[255]; // TODO: Figure this out - uint_fast8_t messageBufLength = translatePayload(_pBufRX, _nBufRX); - - if (messageBufLength > 0) - { - debugPrintBuffer("->| payload :: ", (uint8_t *)_pBufRX, messageBufLength); - - _calloutFunction(String((char *)_pBufRX)); // call out to main application - // that.handleSmartThingMessage(message); - } - else - { - debugPrintBuffer("->| no payload from :: ", _pBufRX, _nBufRX); - } - } - } - else - { //XXX Totally slapped together since this is temp-- will go away with command set change - uint_fast8_t i = 0; - bool found = false; - if (_nBufRX >= 32) //netinfo:0022A3000000B675,E30E,02 - { - while (i < _nBufRX) - { - if ( - (_pBufRX[i] == 'n') && - (_pBufRX[i + 1] == 'e') && - (_pBufRX[i + 2] == 't') && - (_pBufRX[i + 3] == 'i') && - (_pBufRX[i + 4] == 'n') && - (_pBufRX[i + 5] == 'f') && - (_pBufRX[i + 6] == 'o') && - (_pBufRX[i + 7] == ':') && - (_pBufRX[i + 24] == ',') && - (_pBufRX[i + 29] == ',') - ) - { - // parse off EUI - if ( - isAsciiHex(_pBufRX[i + 8]) && - isAsciiHex(_pBufRX[i + 9]) && - isAsciiHex(_pBufRX[i + 10]) && - isAsciiHex(_pBufRX[i + 11]) && - isAsciiHex(_pBufRX[i + 12]) && - isAsciiHex(_pBufRX[i + 13]) && - isAsciiHex(_pBufRX[i + 14]) && - isAsciiHex(_pBufRX[i + 15]) && - isAsciiHex(_pBufRX[i + 16]) && - isAsciiHex(_pBufRX[i + 17]) && - isAsciiHex(_pBufRX[i + 18]) && - isAsciiHex(_pBufRX[i + 19]) && - isAsciiHex(_pBufRX[i + 20]) && - isAsciiHex(_pBufRX[i + 21]) && - isAsciiHex(_pBufRX[i + 22]) && - isAsciiHex(_pBufRX[i + 23]) && - - isAsciiHex(_pBufRX[i + 25]) && - isAsciiHex(_pBufRX[i + 26]) && - isAsciiHex(_pBufRX[i + 27]) && - isAsciiHex(_pBufRX[i + 28]) && - - isAsciiHex(_pBufRX[i + 30]) && - isAsciiHex(_pBufRX[i + 31]) - ) - { - uint8_t tempNetStat = asciiToHexU8(&(_pBufRX[i + 30])); - if (tempNetStat <= STATE_LEAVING) // make sure it maps to the enum - { - _networkState = (SmartThingsNetworkState_t)tempNetStat; - _nodeID = asciiToHexU8(&(_pBufRX[i + 25])); - _nodeID <<= 8; - _nodeID |= asciiToHexU8(&(_pBufRX[i + 27])); - - _eui64[7] = asciiToHexU8(&(_pBufRX[i + 8])); - _eui64[6] = asciiToHexU8(&(_pBufRX[i + 10])); - _eui64[5] = asciiToHexU8(&(_pBufRX[i + 12])); - _eui64[4] = asciiToHexU8(&(_pBufRX[i + 14])); - _eui64[3] = asciiToHexU8(&(_pBufRX[i + 16])); - _eui64[2] = asciiToHexU8(&(_pBufRX[i + 18])); - _eui64[1] = asciiToHexU8(&(_pBufRX[i + 20])); - _eui64[0] = asciiToHexU8(&(_pBufRX[i + 22])); - - debugPrintBuffer(" |~> ", &(_pBufRX[i]), 32); - found = true; - } - } - } - i++; - } - } - if (found == false) - debugPrintBuffer("->| IGNORING :: ", _pBufRX, _nBufRX); - } - _nBufRX = 0; } -} -//***************************************************************************** -void SmartThings::_shieldGetNetworkInfo(void) -{ - st_print(F("custom netinfo\n")); - if (_isDebugEnabled) - { - Serial.print(F(" |<~ custom netinfo\n")); - } } - -//***************************************************************************** -// Thing API | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -// 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 V V V -//***************************************************************************** - -// SoftwareSerial Constructor -#ifndef DISABLE_SOFTWARESERIAL -SmartThings::SmartThings(uint8_t pinRX, uint8_t pinTX, SmartThingsCallout_t *callout, String shieldType, bool enableDebug) : - _SerialPort(SW_SERIAL), - _calloutFunction(callout), - _isDebugEnabled(enableDebug), - _lastPingMS(0xFFFFFF00), - _lastShieldMS(0xFFFFFF00), - _networkState(STATE_UNKNOWN), - _nBufRX(0) -{ - //Removed for now to save SRAM space - Not sure why ST included this as it is never used in the library - //uint_fast8_t i = shieldType.length(); - //if (i > 32) - // i = 32; - //_shieldTypeLen = i; - - //while (i--) - //{ - // _shieldTypeBuf[i] = (uint8_t)shieldType[i]; - //} - _mySerial = new SoftwareSerial(pinRX, pinTX); - st_begin(2400); -} -#endif -//Hardware Serial Constructor -SmartThings::SmartThings(SmartThingsSerialType_t hwSerialPort, SmartThingsCallout_t *callout, String shieldType, bool enableDebug) : - _SerialPort(hwSerialPort), - _calloutFunction(callout), - _isDebugEnabled(hwSerialPort != HW_SERIAL ? enableDebug : false), //Do not allow debug print statements if using Hardware Serial (pins 0,1) for ST Communications - _lastPingMS(0xFFFFFF00), - _lastShieldMS(0xFFFFFF00), - _networkState(STATE_UNKNOWN), - _nBufRX(0) -{ - //Removed for now to save SRAM space - Not sure why ST included this as it is never used in the library - //uint_fast8_t i = shieldType.length(); - //if (i > 32) - // i = 32; - //_shieldTypeLen = i; - - //while (i--) - //{ - // _shieldTypeBuf[i] = (uint8_t)shieldType[i]; - //} - - st_begin(2400); -} - -//***************************************************************************** -//SmartThings::~SmartThings() -SmartThings::~SmartThings() -{ -} - -//***************************************************************************** -void SmartThings::run(void) -{ - uint8_t readByte; - - while ((_nBufRX < SMARTTHINGS_RX_BUFFER_SIZE) && st_available()) - { - - readByte = st_read(); - - if ((readByte == 0x0D) || (readByte == 0x0A)) - { // handle data from SmartThing Hub line-by-line, execute user's callback function for each line - handleLine(); - } - else - { - // keep track of everything that comes in until we reach a newline - // TODO(cwvh): validate bufferlength 1988-10-19 - //if (_nBufRX > 200) - // panic("too many characters!"); - _pBufRX[_nBufRX++] = readByte; - } - - } - _process(); -} - -//***************************************************************************** -void SmartThings::send(String message) -{ - // e.g. thing.print("raw 0x0 {00 00 0A 0A 62 75 74 74 6f 6e 20 64 6f 77 6e }"); - st_print(F("raw 0x0 { 00 00 0A 0A ")); - - if (_isDebugEnabled) - { - Serial.print(F("<-| raw 0x0 { 00 00 0A 0A ")); - } - - for (int i = 0; i < message.length(); i++) - { - //char c = message[i]; - - st_print(message[i], HEX); - st_print(' '); - - if (_isDebugEnabled) - { - Serial.print(message[i], HEX); - Serial.print(' '); - } - } - - st_print(F("}\nsend 0x0 1 1\n")); - - if (_isDebugEnabled) - { - Serial.print(F("}\nsend 0x0 1 1\n")); - } -} - -//***************************************************************************** -void SmartThings::shieldSetLED(uint8_t red, uint8_t green, uint8_t blue) -{ - if (red > 9) red = 9; - if (green > 9) green = 9; - if (blue > 9) blue = 9; - - st_print(F("custom rgb ")); - st_write((red + '0')); - st_print(' '); - st_write((green + '0')); - st_print(' '); - st_write((blue + '0')); - st_print(F(" \n")); - - if (_isDebugEnabled) - { - Serial.print(F(" |<~ custom rgb ")); - Serial.write(red + '0'); - Serial.print(' '); - Serial.write(green + '0'); - Serial.print(' '); - Serial.write(blue + '0'); - Serial.print(F(" \n")); - } -} - - -//***************************************************************************** -SmartThingsNetworkState_t SmartThings::shieldGetLastNetworkState(void) -{ - return _networkState; -} - -//***************************************************************************** -SmartThingsNetworkState_t SmartThings::shieldGetNetworkState(void) -{ - _shieldGetNetworkInfo(); - return _networkState; -} - -//***************************************************************************** -uint16_t SmartThings::shieldGetNodeID(void) -{ - _shieldGetNetworkInfo(); - return _nodeID; -} - -//***************************************************************************** -void SmartThings::shieldGetEUI64(uint8_t eui[8]) -{ - _shieldGetNetworkInfo(); - { - uint_fast8_t i = 7; - do - { - eui[i] = _eui64[i]; - } while (i--); - } -} - -//***************************************************************************** -void SmartThings::shieldFindNetwork(void) -{ - st_print(F("custom find\n")); - - if (_isDebugEnabled) - { - Serial.print(F(" |<~ custom find\n")); - - } -} - -//***************************************************************************** -void SmartThings::shieldLeaveNetwork(void) -{ - st_print(F("custom leave\n")); - - - if (_isDebugEnabled) - { - Serial.print(F(" |<~ custom leave\n")); - } -} - -//***************************************************************************** -void SmartThings::st_begin(long baudRate) -{ - switch (_SerialPort) { -#ifndef DISABLE_SOFTWARESERIAL - case SW_SERIAL: - _mySerial->begin(baudRate); -#endif - case HW_SERIAL: - Serial.end(); - Serial.begin(baudRate); - break; -#if (BOARD_TYPE == BOARD_TYPE_MEGA) || (BOARD_TYPE == BOARD_TYPE_LEONARDO) - case HW_SERIAL1: - Serial1.end(); - Serial1.begin(baudRate); - break; -#endif -#if (BOARD_TYPE == BOARD_TYPE_MEGA) - case HW_SERIAL2: - Serial2.end(); - Serial2.begin(baudRate); - break; - case HW_SERIAL3: - Serial3.end(); - Serial3.begin(baudRate); - break; -#endif - } -} -//***************************************************************************** -int SmartThings::st_available() -{ - switch (_SerialPort) { -#ifndef DISABLE_SOFTWARESERIAL - case SW_SERIAL: - return _mySerial->available(); -#endif - case HW_SERIAL: - return Serial.available(); - break; -#if (BOARD_TYPE == BOARD_TYPE_MEGA) || (BOARD_TYPE == BOARD_TYPE_LEONARDO) - case HW_SERIAL1: - return Serial1.available(); - break; -#endif -#if (BOARD_TYPE == BOARD_TYPE_MEGA) - case HW_SERIAL2: - return Serial2.available(); - break; - case HW_SERIAL3: - return Serial3.available(); - break; -#endif - default: - return 0; - } -} -//***************************************************************************** -int SmartThings::st_read() -{ - switch (_SerialPort) { -#ifndef DISABLE_SOFTWARESERIAL - case SW_SERIAL: - return _mySerial->read(); -#endif - case HW_SERIAL: - return Serial.read(); - break; -#if (BOARD_TYPE == BOARD_TYPE_MEGA) || (BOARD_TYPE == BOARD_TYPE_LEONARDO) - case HW_SERIAL1: - return Serial1.read(); - break; -#endif -#if (BOARD_TYPE == BOARD_TYPE_MEGA) - case HW_SERIAL2: - return Serial2.read(); - break; - case HW_SERIAL3: - return Serial3.read(); - break; -#endif - default: - return 0; - } -} -//***************************************************************************** -long SmartThings::st_print(String str) -{ - switch (_SerialPort) { -#ifndef DISABLE_SOFTWARESERIAL - case SW_SERIAL: - return _mySerial->print(str); -#endif - case HW_SERIAL: - return Serial.print(str); - break; -#if (BOARD_TYPE == BOARD_TYPE_MEGA) || (BOARD_TYPE == BOARD_TYPE_LEONARDO) - case HW_SERIAL1: - return Serial1.print(str); - break; -#endif -#if (BOARD_TYPE == BOARD_TYPE_MEGA) - case HW_SERIAL2: - return Serial2.print(str); - break; - case HW_SERIAL3: - return Serial3.print(str); - break; -#endif - default: - return 0; - } -} - -//***************************************************************************** -long SmartThings::st_print(char c) -{ - switch (_SerialPort) { -#ifndef DISABLE_SOFTWARESERIAL - case SW_SERIAL: - return _mySerial->print(c); -#endif - case HW_SERIAL: - return Serial.print(c); - break; -#if (BOARD_TYPE == BOARD_TYPE_MEGA) || (BOARD_TYPE == BOARD_TYPE_LEONARDO) - case HW_SERIAL1: - return Serial1.print(c); - break; -#endif -#if (BOARD_TYPE == BOARD_TYPE_MEGA) - case HW_SERIAL2: - return Serial2.print(c); - break; - case HW_SERIAL3: - return Serial3.print(c); - break; -#endif - default: - return 0; - - } -} - -//***************************************************************************** -long SmartThings::st_print(char c, int i) -{ - switch (_SerialPort) { -#ifndef DISABLE_SOFTWARESERIAL - case SW_SERIAL: - return _mySerial->print(c, i); -#endif - case HW_SERIAL: - return Serial.print(c, i); - break; -#if (BOARD_TYPE == BOARD_TYPE_MEGA) || (BOARD_TYPE == BOARD_TYPE_LEONARDO) - case HW_SERIAL1: - return Serial1.print(c, i); - break; -#endif -#if (BOARD_TYPE == BOARD_TYPE_MEGA) - case HW_SERIAL2: - return Serial2.print(c, i); - break; - case HW_SERIAL3: - return Serial3.print(c, i); - break; -#endif - default: - return 0; - } -} - -//***************************************************************************** -byte SmartThings::st_write(uint8_t i) -{ - switch (_SerialPort) { -#ifndef DISABLE_SOFTWARESERIAL - case SW_SERIAL: - return _mySerial->write(i); -#endif - case HW_SERIAL: - return Serial.write(i); - break; -#if (BOARD_TYPE == BOARD_TYPE_MEGA) || (BOARD_TYPE == BOARD_TYPE_LEONARDO) - case HW_SERIAL1: - return Serial1.write(i); - break; -#endif -#if (BOARD_TYPE == BOARD_TYPE_MEGA) - case HW_SERIAL2: - return Serial2.write(i); - break; - case HW_SERIAL3: - return Serial3.write(i); - break; -#endif - default: - return 0; - } -} - diff --git a/Arduino/libraries/SmartThings/SmartThings.h b/Arduino/libraries/SmartThings/SmartThings.h index e53e845b..3281fa54 100644 --- a/Arduino/libraries/SmartThings/SmartThings.h +++ b/Arduino/libraries/SmartThings/SmartThings.h @@ -1,235 +1,61 @@ //******************************************************************************* -/// @file -/// @brief -/// SmartThings Arduino Library -/// @section License -/// (C) Copyright 2013 Physical Graph -/// -/// Updates by Daniel Ogorchock 12/30/2014 - Arduino Mega 2560 HW Serial support -/// -Numerous performance and size optimizations (helpful on UNO with only 2K SRAM) -/// -Arduino UNO should use the SoftwareSerial library Constructor since the UNO has -/// only one Hardware UART port ("Serial") which is used by the USB port for -/// programming and debugging typically. UNO can use the Hardware "Serial" -/// if desired, but USB programming and debug will be troublesome. -/// Leonardo and Mega can use SoftwareSerial BUT cannot use Pin3 for Rx - use -/// Pin10 for Rx and add jumper from Pin10 to Pin3. -/// -Arduino LEONARDO should use the Hardware Serial Constructor since it has 1 UART -/// separate from the USB port. "Serial1" port uses pins 0(Rx) and 1(Tx). -/// -Arduino MEGA should use the Hardware Serial Constructor since it has 4 UARTs. -/// "Serial3" port uses pins 14(Tx) and 15(Rx). Wire Pin14 to Pin2 and Pin15 to Pin3. -/// -Be certain to not use Pins 2 & 3 in your Arduino sketch for I/O since they are -/// electrically connected to the ThingShield if set to D2/D3. -/// -Note - Pin6 is reserved by the ThingShield as well. Best to avoid using it. -/// -The SoftwareSerial library has the following known limitations: -/// - If using multiple software serial ports, only one can receive data at a time. -/// - Not all pins on the Mega and Mega 2560 support change interrupts, so only -/// the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, -/// A8(62), A9(63), A10(64), A11(65), A12(66), A13(67), A14(68), A15(69). -/// - Not all pins on the Leonardo and Micro support change interrupts, so only -/// the following can be used for RX : 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI). -/// -2016-06-04 Dan Ogorchock Added improved support for Arduino Leonardo -//******************************************************************************* -#ifndef __SMARTTHINGS_H__ +// SmartThings Arduino Library Base Class +// +// License +// (C) Copyright 2017 Dan Ogorchock +// +// History +// 2017-02-04 Dan Ogorchock Created +//******************************************************************************* +#ifndef __SMARTTHINGS_H__ #define __SMARTTHINGS_H__ -//******************************************************************************* -#define BOARD_TYPE_UNO 0 -#define BOARD_TYPE_LEONARDO 1 -#define BOARD_TYPE_MEGA 2 -//******************************************************************************* - -#include #include //******************************************************************************* -// Set the correct board type automatically -//******************************************************************************* -#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega328P__) -#define BOARD_TYPE BOARD_TYPE_UNO -//#define DISABLE_SOFTWARESERIAL // uncomment to disable SoftwareSerial to save some program space if neccessary while using HW Serial -#elif defined(__AVR_ATmega32U4__) -#define BOARD_TYPE BOARD_TYPE_LEONARDO -#define DISABLE_SOFTWARESERIAL //Assume HW Serial is being used. Saves some program space while using HW Serial -#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) -#define BOARD_TYPE BOARD_TYPE_MEGA -#define DISABLE_SOFTWARESERIAL //Assume HW Serial is being used. Saves some program space while using HW Serial -#else //assume user is using an UNO for the unknown case -#define BOARD_TYPE BOARD_TYPE_UNO -//#define DISABLE_SOFTWARESERIAL // uncomment to disable SoftwareSerial to save some program space if neccessary while using HW Serial -#endif - -#ifndef DISABLE_SOFTWARESERIAL -#include -#endif -//******************************************************************************* - -//******************************************************************************* -/// @brief SmartThings Arduino Library Version -//******************************************************************************* -#define SMARTTHINGSLIB_VERSION_MAJOR 0 -#define SMARTTHINGSLIB_VERSION_MINOR 0 -#define SMARTTHINGSLIB_VERSION_BUILD 6 - -#define SMARTTHINGSLIB_VERSION \ - (((SMARTTHINGSLIB_VERSION_MAJOR & 0xFF) << 24) | \ - ((SMARTTHINGSLIB_VERSION_MINOR & 0xFF) << 16) | \ - (SMARTTHINGSLIB_VERSION_BUILD & 0xFFFF)) - -//******************************************************************************* -#define SMARTTHINGS_RX_BUFFER_SIZE 256 // if > 255: change _nBufRX to u16 -#define SMARTTHINGS_SHIELDTYPE_SIZE 32 // if > 255: change _shieldTypeLen to u16 - -//******************************************************************************* -/// @brief Callout Function Definition for Messages Received over ZigBee Network +// Callout Function Definition for Messages Received from SmartThings //******************************************************************************* typedef void SmartThingsCallout_t(String message); -//******************************************************************************* -/// @brief ZigBee Network State Definition -//******************************************************************************* -typedef enum -{ - STATE_NO_NETWORK, - STATE_JOINING, - STATE_JOINED, - STATE_JOINED_NOPARENT, - STATE_LEAVING, - STATE_UNKNOWN -} SmartThingsNetworkState_t; - -//******************************************************************************* -/// @brief Serial Communication Type Definition -//******************************************************************************* -typedef enum -{ - SW_SERIAL, - HW_SERIAL, - HW_SERIAL1, - HW_SERIAL2, - HW_SERIAL3 -} SmartThingsSerialType_t; - -//******************************************************************************* - -class SmartThings +namespace st { -private: -#ifndef DISABLE_SOFTWARESERIAL - SoftwareSerial* _mySerial; -#endif - SmartThingsSerialType_t _SerialPort; - SmartThingsCallout_t *_calloutFunction; - bool _isDebugEnabled; - uint32_t _lastPingMS; - uint32_t _lastShieldMS; - - SmartThingsNetworkState_t _networkState; - uint8_t _eui64[8]; - uint16_t _nodeID; - - //Removed for now to save SRAM space - Not sure why ST included this as it is never used in the library - //uint8_t _shieldTypeBuf[SMARTTHINGS_SHIELDTYPE_SIZE]; - //uint8_t _shieldTypeLen; - - uint8_t _pBufRX[SMARTTHINGS_RX_BUFFER_SIZE]; - uint_fast8_t _nBufRX; - - void _shieldGetNetworkInfo(void); - void _process(void); - - void debugPrintBuffer(String prefix, uint8_t * pBuf, uint_fast8_t nBuf); - bool isRxLine(uint8_t * pLine); - bool isAsciiHex(uint8_t ascii); - uint8_t asciiToHexU8(uint8_t pAscii[2]); - uint_fast8_t translatePayload(uint8_t *pBuf, uint_fast8_t nBuf); - void handleLine(void); - void st_begin(long); - int st_available(); - int st_read(); - long st_print(String); - long st_print(char); - long st_print(char, int); - byte st_write(uint8_t); - - -public: - //******************************************************************************* - /// @brief SmartThings SoftwareSerial Constructor - /// @param[in] pinRX - Receive Pin for the SoftwareSerial Port to the Arduino - /// @param[in] pinTX - Transmit Pin for the SoftwareSerial Port to the Arduino - /// @param[in] callout - Set the Callout Function that is called on Msg Reception - /// @param[in] shieldType (optional) - Set the Reported SheildType to the Server - /// @param[in] enableDebug (optional) - Enable internal Library debug - //******************************************************************************* -#ifndef DISABLE_SOFTWARESERIAL - SmartThings(uint8_t pinRX, uint8_t pinTX, SmartThingsCallout_t *callout, String shieldType = "GenericShield", bool enableDebug = false); -#endif - //******************************************************************************* - /// @brief SmartThings HardwareSerial Constructor - /// @param[in] hwSerialPort - enum of Hardware Serial Port to the Arduino - /// @param[in] callout - Set the Callout Function that is called on Msg Reception - /// @param[in] shieldType (optional) - Set the Reported SheildType to the Server - /// @param[in] enableDebug (optional) - Enable internal Library debug - //******************************************************************************* - SmartThings(SmartThingsSerialType_t hwSerialPort, SmartThingsCallout_t *callout, String shieldType = "GenericShield", bool enableDebug = false); - - //******************************************************************************* - /// @brief Descructor - //******************************************************************************* - ~SmartThings(); - - //******************************************************************************* - /// @brief Run SmartThings Library - //******************************************************************************* - void run(void); + class SmartThings + { + private: - //******************************************************************************* - /// @brief Send Message out over ZigBee to the Hub - /// @param[in] message to send - //******************************************************************************* - void send(String message); + protected: + SmartThingsCallout_t *_calloutFunction; + bool _isDebugEnabled; + String _shieldType; - //******************************************************************************* - /// @brief Set SmartThings Shield MultiColor LED - /// @param[in] red: intensity {0=off to 9=max} - /// @param[in] green: intensity {0=off to 9=max} - /// @param[in] blue: intensity {0=off to 9=max} - //******************************************************************************* - void shieldSetLED(uint8_t red, uint8_t green, uint8_t blue); + public: - //******************************************************************************* - /// @brief Get Last Read Shield State - /// @return Last Read Network State - //******************************************************************************* - SmartThingsNetworkState_t shieldGetLastNetworkState(void); + //******************************************************************************* + // SmartThings Constructor + //******************************************************************************* + SmartThings(SmartThingsCallout_t *callout, String shieldType = "Unknown", bool enableDebug = false); - //******************************************************************************* - /// @brief Get Last Read Shield State and Trigger Refresh of Network Info - /// @return Last Read Network State - //******************************************************************************* - SmartThingsNetworkState_t shieldGetNetworkState(void); + //******************************************************************************* + // SmartThings Destructor + //******************************************************************************* + virtual ~SmartThings(); - //******************************************************************************* - /// @brief Get Last Read NodeID and Trigger Refresh of Network Info - /// @return Last Read NodeID - //******************************************************************************* - uint16_t shieldGetNodeID(void); + //******************************************************************************* + /// Initialize SmartThings Library + //******************************************************************************* + virtual void init(void) = 0; //all derived classes must implement this pure virtual function - //******************************************************************************* - /// @brief Get Last Read EUI64 and Trigger Refresh of Network Info - /// @return Last Read EUI64 - //******************************************************************************* - void shieldGetEUI64(uint8_t eui[8]); + //******************************************************************************* + /// Run SmartThings Library + //******************************************************************************* + virtual void run(void) = 0; //all derived classes must implement this pure virtual function - //******************************************************************************* - /// @brief Find and Join a Network - //******************************************************************************* - void shieldFindNetwork(void); + //******************************************************************************* + /// Send Message to the Hub + //******************************************************************************* + virtual void send(String message) = 0; //all derived classes must implement this pure virtual function - //******************************************************************************* - /// @brief Leave the Current ZigBee Network - //******************************************************************************* - void shieldLeaveNetwork(void); -}; + }; +} #endif diff --git a/Arduino/libraries/SmartThings/SmartThingsESP8266WiFi.cpp b/Arduino/libraries/SmartThings/SmartThingsESP8266WiFi.cpp new file mode 100644 index 00000000..e79e5d59 --- /dev/null +++ b/Arduino/libraries/SmartThings/SmartThingsESP8266WiFi.cpp @@ -0,0 +1,188 @@ +//******************************************************************************* +// SmartThings NodeMCU ESP8266 Wifi Library +// +// License +// (C) Copyright 2017 Dan Ogorchock +// +// History +// 2017-02-10 Dan Ogorchock Created +//******************************************************************************* +#if defined ARDUINO_ARCH_ESP8266 + +#include "SmartThingsESP8266WiFi.h" + +namespace st +{ + //******************************************************************************* + // SmartThingsESP8266WiFI Constructor + //******************************************************************************* + SmartThingsESP8266WiFi::SmartThingsESP8266WiFi(String ssid, String password, IPAddress localIP, IPAddress localGateway, IPAddress localSubnetMask, IPAddress localDNSServer, uint16_t serverPort, IPAddress hubIP, uint16_t hubPort, SmartThingsCallout_t *callout, String shieldType, bool enableDebug) : + SmartThingsEthernet(localIP, localGateway, localSubnetMask, localDNSServer, serverPort, hubIP, hubPort, callout, shieldType, enableDebug), + st_server(serverPort) + { + ssid.toCharArray(st_ssid, sizeof(st_ssid)); + password.toCharArray(st_password, sizeof(st_password)); + } + + + //***************************************************************************** + //SmartThingsESP8266WiFI::~SmartThingsESP8266WiFI() + //***************************************************************************** + SmartThingsESP8266WiFi::~SmartThingsESP8266WiFi() + { + + } + + //******************************************************************************* + /// Initialize SmartThingsESP8266WiFI Library + //******************************************************************************* + void SmartThingsESP8266WiFi::init(void) + { + // Connect to WiFi network + WiFi.begin(st_ssid, st_password); + WiFi.config(st_localIP, st_localGateway, st_localSubnetMask, st_localDNSServer); + + while (WiFi.status() != WL_CONNECTED) + { + delay(2000); + if (_isDebugEnabled) + { + Serial.println(F("")); + Serial.println(F("Waiting for WiFi to connect")); + } + } + + st_server.begin(); + + Serial.print(F("MAC Address = ")); + Serial.println(WiFi.macAddress()); + + if (_isDebugEnabled) + { + Serial.println(F("")); + Serial.print(F("SSID = ")); + Serial.println(st_ssid); + Serial.print(F("PASSWORD = ")); + Serial.println(st_password); + //Serial.print(F("MAC Address = ")); + //Serial.println(WiFi.macAddress()); + Serial.print(F("hubIP = ")); + Serial.println(st_hubIP); + Serial.print(F("hubPort = ")); + Serial.println(st_hubPort); + + //Serial.println(F("SmartThingsESP8266WiFI: Intialized")); + } + Serial.println(F("SmartThingsESP8266WiFI: Intialized")); + } + + //***************************************************************************** + // Run SmartThingsESP8266WiFI Library + //***************************************************************************** + void SmartThingsESP8266WiFi::run(void) + { + String readString; + String tempString; + WiFiClient client = st_server.available(); + if (client) { + boolean currentLineIsBlank = true; + while (client.connected()) { + if (client.available()) { + char c = client.read(); + //read char by char HTTP request + if (readString.length() < 100) { + //store characters to string + readString += c; + } + if (c == '\n' && currentLineIsBlank) { + //now output HTML data header + tempString = readString.substring(readString.indexOf('/') + 1, readString.indexOf('?')); + + if (tempString.length() > 0) { + client.println(F("HTTP/1.1 200 OK")); //send new page + if (_isDebugEnabled) + { + Serial.print(F("Handling request from ST. tempString = ")); + Serial.println(tempString); + } + _calloutFunction(tempString); + } + else { + client.println(F("HTTP/1.1 204 No Content")); + client.println(); + client.println(); + if (_isDebugEnabled) + { + Serial.println(F("No Valid Data Received")); + } + } + break; + } + if (c == '\n') { + // you're starting a new line + currentLineIsBlank = true; + } + else if (c != '\r') { + // you've gotten a character on the current line + currentLineIsBlank = false; + } + } + } + readString = ""; + tempString = ""; + + delay(1); + //stopping client + client.stop(); + } + } + + //******************************************************************************* + /// Send Message out over Ethernet to the Hub + //******************************************************************************* + void SmartThingsESP8266WiFi::send(String message) + { + if (st_client.connect(st_hubIP, st_hubPort)) + { + st_client.println(F("POST / HTTP/1.1")); + st_client.print(F("HOST: ")); + st_client.print(st_hubIP); + st_client.print(F(":")); + st_client.println(st_hubPort); + //st_client.println(message); + + st_client.println(F("CONTENT-TYPE: text")); + st_client.print(F("CONTENT-LENGTH: ")); + st_client.println(message.length()); + st_client.println(); + st_client.println(message); + } + else + { + //connection failed; + if (_isDebugEnabled) + { + Serial.print(F("")); + Serial.println(F("SmartThingsESP8266WiFi::send() - Ethernet Connection Failed")); + Serial.print(F("hubIP = ")); + Serial.print(st_hubIP); + Serial.print(F(" ")); + Serial.print(F("hubPort = ")); + Serial.println(st_hubPort); + } + } + + // read any data returned from the POST + while (st_client.connected() && !st_client.available()) delay(1); //waits for data + while (st_client.connected() || st_client.available()) //connected or data available + { + char c = st_client.read(); + } + + delay(1); + st_client.stop(); + } + +} + +#endif \ No newline at end of file diff --git a/Arduino/libraries/SmartThings/SmartThingsESP8266WiFi.h b/Arduino/libraries/SmartThings/SmartThingsESP8266WiFi.h new file mode 100644 index 00000000..39d1577e --- /dev/null +++ b/Arduino/libraries/SmartThings/SmartThingsESP8266WiFi.h @@ -0,0 +1,75 @@ +//******************************************************************************* +// SmartThings Arduino ESP8266 Wifi Library +// +// License +// (C) Copyright 2017 Dan Ogorchock +// +// History +// 2017-02-05 Dan Ogorchock Created +//******************************************************************************* +#if defined ARDUINO_ARCH_ESP8266 + +#ifndef __SMARTTHINGSESP8266WIFI_H__ +#define __SMARTTHINGSESP8266WIFI_H__ + +#include "SmartThingsEthernet.h" + +//******************************************************************************* +// Using ESP8266 WiFi +//******************************************************************************* +#include + +namespace st +{ + class SmartThingsESP8266WiFi: public SmartThingsEthernet + { + private: + //ESP8266 WiFi Specific + char st_ssid[50]; + char st_password[50]; + WiFiServer st_server; //server + WiFiClient st_client; //client + + public: + + //******************************************************************************* + /// @brief SmartThings ESP8266 WiFi Constructor + /// @param[in] ssid - Wifi Network SSID + /// @param[in] password - Wifi Network Password + /// @param[in] localIP - TCP/IP Address of the Arduino + /// @param[in] localGateway - TCP/IP Gateway Address of local LAN (your Router's LAN Address) + /// @param[in] localSubnetMask - Subnet Mask of the Arduino + /// @param[in] localDNSServer - DNS Server + /// @param[in] serverPort - TCP/IP Port of the Arduino + /// @param[in] hubIP - TCP/IP Address of the ST Hub + /// @param[in] hubPort - TCP/IP Port of the ST Hub + /// @param[in] callout - Set the Callout Function that is called on Msg Reception + /// @param[in] shieldType (optional) - Set the Reported SheildType to the Server + /// @param[in] enableDebug (optional) - Enable internal Library debug + //******************************************************************************* + SmartThingsESP8266WiFi(String ssid, String password, IPAddress localIP, IPAddress localGateway, IPAddress localSubnetMask, IPAddress localDNSServer, uint16_t serverPort, IPAddress hubIP, uint16_t hubPort, SmartThingsCallout_t *callout, String shieldType = "ESP8266Wifi", bool enableDebug = false); + + //******************************************************************************* + /// Destructor + //******************************************************************************* + ~SmartThingsESP8266WiFi(); + + //******************************************************************************* + /// Initialize SmartThingsESP8266WiFI Library + //******************************************************************************* + virtual void init(void); + + //******************************************************************************* + /// Run SmartThingsESP8266WiFI Library + //******************************************************************************* + virtual void run(void); + + //******************************************************************************* + /// Send Message to the Hub + //******************************************************************************* + virtual void send(String message); + + }; +} +#endif +#endif diff --git a/Arduino/libraries/SmartThings/SmartThingsEthernet.cpp b/Arduino/libraries/SmartThings/SmartThingsEthernet.cpp new file mode 100644 index 00000000..dc1f4aad --- /dev/null +++ b/Arduino/libraries/SmartThings/SmartThingsEthernet.cpp @@ -0,0 +1,39 @@ +//******************************************************************************* +// SmartThings Arduino Ethernet Library +// +// License +// (C) Copyright 2017 Dan Ogorchock +// +// History +// 2017-02-04 Dan Ogorchock Created +//******************************************************************************* + +#include "SmartThingsEthernet.h" + +namespace st +{ + //******************************************************************************* + // SmartThingsEthernet Constructor + //******************************************************************************* + SmartThingsEthernet::SmartThingsEthernet(IPAddress localIP, IPAddress localGateway, IPAddress localSubnetMask, IPAddress localDNSServer, uint16_t serverPort, IPAddress hubIP, uint16_t hubPort, SmartThingsCallout_t *callout, String shieldType, bool enableDebug) : + SmartThings(callout, shieldType, enableDebug), + st_localIP(localIP), + st_localGateway(localGateway), + st_localSubnetMask(localSubnetMask), + st_localDNSServer(localDNSServer), + st_hubIP(hubIP), + st_serverPort(serverPort), + st_hubPort(hubPort) + { + + } + + //***************************************************************************** + //SmartThingsEthernet::~SmartThingsEthernet() + //***************************************************************************** + SmartThingsEthernet::~SmartThingsEthernet() + { + + } + +} diff --git a/Arduino/libraries/SmartThings/SmartThingsEthernet.h b/Arduino/libraries/SmartThings/SmartThingsEthernet.h new file mode 100644 index 00000000..dcb414f4 --- /dev/null +++ b/Arduino/libraries/SmartThings/SmartThingsEthernet.h @@ -0,0 +1,81 @@ +//******************************************************************************* +// SmartThings Arduino Ethernet Library +// +// License +// (C) Copyright 2017 Dan Ogorchock +// +// History +// 2017-02-04 Dan Ogorchock Created +//******************************************************************************* + +#ifndef __SMARTTHINGSETHERNET_H__ +#define __SMARTTHINGSETHERNET_H__ + +#include "SmartThings.h" + +//******************************************************************************* +// Using Ethernet Shield +//******************************************************************************* +#if defined ARDUINO_ARCH_AVR +#include +#include +#elif defined ARDUINO_ARCH_ESP8266 +#include +#endif + +namespace st +{ + class SmartThingsEthernet: public SmartThings + { + private: + + protected: + IPAddress st_localIP; + IPAddress st_localGateway; + IPAddress st_localSubnetMask; + IPAddress st_localDNSServer; + IPAddress st_hubIP; + uint16_t st_serverPort; + uint16_t st_hubPort; + + public: + + //******************************************************************************* + /// @brief SmartThings Ethernet Constructor + /// @param[in] localIP - TCP/IP Address of the Arduino + /// @param[in] localGateway - TCP/IP Gateway Address of local LAN (your Router's LAN Address) + /// @param[in] localSubnetMask - Subnet Mask of the Arduino + /// @param[in] localDNSServer - DNS Server + /// @param[in] serverPort - TCP/IP Port of the Arduino + /// @param[in] hubIP - TCP/IP Address of the ST Hub + /// @param[in] hubPort - TCP/IP Port of the ST Hub + /// @param[in] callout - Set the Callout Function that is called on Msg Reception + /// @param[in] shieldType (optional) - Set the Reported SheildType to the Server + /// @param[in] enableDebug (optional) - Enable internal Library debug + //******************************************************************************* + SmartThingsEthernet(IPAddress localIP, IPAddress localGateway, IPAddress localSubnetMask, IPAddress localDNSServer, uint16_t serverPort, IPAddress hubIP, uint16_t hubPort, SmartThingsCallout_t *callout, String shieldType = "EthernetShield", bool enableDebug = false); + + //******************************************************************************* + /// Destructor + //******************************************************************************* + ~SmartThingsEthernet(); + + //******************************************************************************* + /// Initialize SmartThings Library + //******************************************************************************* + virtual void init(void) = 0; //all derived classes must implement this pure virtual function + + //******************************************************************************* + /// Run SmartThings Library + //******************************************************************************* + virtual void run(void) = 0; //all derived classes must implement this pure virtual function + + //******************************************************************************* + /// Send Message to the Hub + //******************************************************************************* + virtual void send(String message) = 0; //all derived classes must implement this pure virtual function + + + }; +} +#endif diff --git a/Arduino/libraries/SmartThings/SmartThingsEthernet5100.cpp b/Arduino/libraries/SmartThings/SmartThingsEthernet5100.cpp new file mode 100644 index 00000000..826860ec --- /dev/null +++ b/Arduino/libraries/SmartThings/SmartThingsEthernet5100.cpp @@ -0,0 +1,181 @@ +//******************************************************************************* +// SmartThings Arduino Ethernet Library +// +// License +// (C) Copyright 2017 Dan Ogorchock +// +// History +// 2017-02-04 Dan Ogorchock Created +//******************************************************************************* +#if defined ARDUINO_ARCH_AVR + +#include "SmartThingsEthernetW5100.h" + +namespace st +{ + //******************************************************************************* + // SmartThingsEthernet Constructor + //******************************************************************************* + SmartThingsEthernetW5100::SmartThingsEthernetW5100(byte mac[], IPAddress localIP, IPAddress localGateway, IPAddress localSubnetMask, IPAddress localDNSServer, uint16_t serverPort, IPAddress hubIP, uint16_t hubPort, SmartThingsCallout_t *callout, String shieldType, bool enableDebug) : + SmartThingsEthernet(localIP, localGateway, localSubnetMask, localDNSServer, serverPort, hubIP, hubPort, callout, shieldType, enableDebug), + st_server(serverPort) + { + //make a local copy of the MAC address + for (byte x = 0; x <= 5; x++) + { + st_mac[x] = mac[x]; + } + } + + + //***************************************************************************** + //SmartThingsEthernet::~SmartThingsEthernet() + //***************************************************************************** + SmartThingsEthernetW5100::~SmartThingsEthernetW5100() + { + + } + + //******************************************************************************* + /// Initialize SmartThingsEthernet Library + //******************************************************************************* + void SmartThingsEthernetW5100::init(void) + { + // give the ethernet module time to boot up: + delay(1000); + Ethernet.begin(st_mac, st_localIP, st_localDNSServer, st_localGateway, st_localSubnetMask); + st_server.begin(); + + if (_isDebugEnabled) + { + Serial.print(F("MAC Address = ")); + Serial.print(st_mac[0], HEX); + Serial.print(F(":")); + Serial.print(st_mac[1], HEX); + Serial.print(F(":")); + Serial.print(st_mac[2], HEX); + Serial.print(F(":")); + Serial.print(st_mac[3], HEX); + Serial.print(F(":")); + Serial.print(st_mac[4], HEX); + Serial.print(F(":")); + Serial.println(st_mac[5], HEX); + Serial.print(F("hubIP = ")); + Serial.println(st_hubIP); + Serial.print(F("hubPort = ")); + Serial.println(st_hubPort); + + Serial.println(F("SmartThingsEthernet: Intialized")); + } + } + + //***************************************************************************** + // Run SmartThingsEthernet Library + //***************************************************************************** + void SmartThingsEthernetW5100::run(void) + { + String readString; + String tempString; + EthernetClient client = st_server.available(); + if (client) { + boolean currentLineIsBlank = true; + while (client.connected()) { + if (client.available()) { + char c = client.read(); + //read char by char HTTP request + if (readString.length() < 100) { + //store characters to string + readString += c; + } + if (c == '\n' && currentLineIsBlank) { + //now output HTML data header + tempString = readString.substring(readString.indexOf('/') + 1, readString.indexOf('?')); + + if (tempString.length() > 0) { + client.println(F("HTTP/1.1 200 OK")); //send new page + if (_isDebugEnabled) + { + Serial.print(F("Handling request from ST. tempString = ")); + Serial.println(tempString); + } + _calloutFunction(tempString); + } + else { + client.println(F("HTTP/1.1 204 No Content")); + client.println(); + client.println(); + if (_isDebugEnabled) + { + Serial.println(F("No Valid Data Received")); + } + + } + break; + } + if (c == '\n') { + // you're starting a new line + currentLineIsBlank = true; + } + else if (c != '\r') { + // you've gotten a character on the current line + currentLineIsBlank = false; + } + } + } + readString = ""; + tempString = ""; + + delay(1); + //stopping client + client.stop(); + } + } + + //******************************************************************************* + /// Send Message out over Ethernet to the Hub + //******************************************************************************* + void SmartThingsEthernetW5100::send(String message) + { + if (st_client.connect(st_hubIP, st_hubPort)) + { + st_client.println(F("POST / HTTP/1.1")); + st_client.print(F("HOST: ")); + st_client.print(st_hubIP); + st_client.print(F(":")); + st_client.println(st_hubPort); + //st_client.println(message); + + st_client.println(F("CONTENT-TYPE: text")); + st_client.print(F("CONTENT-LENGTH: ")); + st_client.println(message.length()); + st_client.println(); + st_client.println(message); + } + else + { + //connection failed; + if (_isDebugEnabled) + { + Serial.print(F("")); + Serial.println(F("SmartThingsEthernet::send() - Ethernet Connection Failed")); + Serial.print(F("hubIP = ")); + Serial.print(st_hubIP); + Serial.print(F(" ")); + Serial.print(F("hubPort = ")); + Serial.println(st_hubPort); + } + } + + // read any data returned from the POST + while (st_client.connected() && !st_client.available()) delay(1); //waits for data + while (st_client.connected() || st_client.available()) //connected or data available + { + char c = st_client.read(); + } + + delay(1); + st_client.stop(); + } + +} +#endif \ No newline at end of file diff --git a/Arduino/libraries/SmartThings/SmartThingsEthernetW5100.h b/Arduino/libraries/SmartThings/SmartThingsEthernetW5100.h new file mode 100644 index 00000000..24a14013 --- /dev/null +++ b/Arduino/libraries/SmartThings/SmartThingsEthernetW5100.h @@ -0,0 +1,72 @@ +//******************************************************************************* +// SmartThings Arduino Ethernet Library +// +// License +// (C) Copyright 2017 Dan Ogorchock +// +// History +// 2017-02-04 Dan Ogorchock Created +//******************************************************************************* +#if defined ARDUINO_ARCH_AVR + +#ifndef __SMARTTHINGSETHERNETW5100_H__ +#define __SMARTTHINGSETHERNETW5100_H__ + +#include "SmartThingsEthernet.h" + +//******************************************************************************* +// Using Ethernet Shield +//******************************************************************************* + +namespace st +{ + class SmartThingsEthernetW5100: public SmartThingsEthernet + { + private: + //Ethernet W5100 Specific + byte st_mac[6]; + EthernetServer st_server; //server + EthernetClient st_client; //client + + public: + + //******************************************************************************* + /// @brief SmartThings Ethernet Constructor + /// @param[in] mac[] - MAC Address of the Ethernet Shield, 6 bytes + /// @param[in] localIP - TCP/IP Address of the Arduino + /// @param[in] localGateway - TCP/IP Gateway Address of local LAN (your Router's LAN Address) + /// @param[in] localSubnetMask - Subnet Mask of the Arduino + /// @param[in] localDNSServer - DNS Server + /// @param[in] serverPort - TCP/IP Port of the Arduino + /// @param[in] hubIP - TCP/IP Address of the ST Hub + /// @param[in] hubPort - TCP/IP Port of the ST Hub + /// @param[in] callout - Set the Callout Function that is called on Msg Reception + /// @param[in] shieldType (optional) - Set the Reported SheildType to the Server + /// @param[in] enableDebug (optional) - Enable internal Library debug + //******************************************************************************* + SmartThingsEthernetW5100(byte mac[], IPAddress localIP, IPAddress localGateway, IPAddress localSubnetMask, IPAddress localDNSServer, uint16_t serverPort, IPAddress hubIP, uint16_t hubPort, SmartThingsCallout_t *callout, String shieldType = "EthernetShield", bool enableDebug = false); + + //******************************************************************************* + /// Destructor + //******************************************************************************* + ~SmartThingsEthernetW5100(); + + //******************************************************************************* + /// Initialize SmartThingsEthernet Library + //******************************************************************************* + virtual void init(void); + + //******************************************************************************* + /// Run SmartThingsEthernet Library + //******************************************************************************* + virtual void run(void); + + //******************************************************************************* + /// Send Message to the Hub + //******************************************************************************* + virtual void send(String message); + + }; +} +#endif +#endif diff --git a/Arduino/libraries/SmartThings/SmartThingsThingShield.cpp b/Arduino/libraries/SmartThings/SmartThingsThingShield.cpp new file mode 100644 index 00000000..d2208d3f --- /dev/null +++ b/Arduino/libraries/SmartThings/SmartThingsThingShield.cpp @@ -0,0 +1,538 @@ +//******************************************************************************* +/// @file +/// @brief +/// SmartThingsThingShield Arduino Library +/// @section License +/// (C) Copyright 2013 Physical Graph +/// +/// Updates by Daniel Ogorchock 12/30/2014 - Arduino Mega 2560 HW Serial support +/// -Numerous performance and size optimizations (helpful on UNO with only 2K SRAM) +/// -Arduino UNO should use the SoftwareSerial library Constructor since the UNO has +/// only one Hardware UART port ("Serial") which is used by the USB port for +/// programming and debugging typically. UNO can use the Hardware "Serial" +/// if desired, but USB programming and debug will be troublesome. +/// Leonardo and Mega can use SoftwareSerial BUT cannot use Pin3 for Rx - use +/// Pin10 for Rx and add jumper from Pin10 to Pin3. +/// -Arduino LEONARDO should use the Hardware Serial Constructor since it has 1 UART +/// separate from the USB port. "Serial1" port uses pins 0(Rx) and 1(Tx). +/// -Arduino MEGA should use the Hardware Serial Constructor since it has 4 UARTs. +/// "Serial3" port uses pins 14(Tx) and 15(Rx). Wire Pin14 to Pin2 and Pin15 to Pin3. +/// -Be certain to not use Pins 2 & 3 in your Arduino sketch for I/O since they are +/// electrically connected to the ThingShield if set to D2/D3. +/// -Note - Pin6 is reserved by the ThingShield as well. Best to avoid using it. +/// -The SoftwareSerial library has the following known limitations: +/// - If using multiple software serial ports, only one can receive data at a time. +/// - Not all pins on the Mega and Mega 2560 support change interrupts, so only +/// the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, +/// A8(62), A9(63), A10(64), A11(65), A12(66), A13(67), A14(68), A15(69). +/// - Not all pins on the Leonardo and Micro support change interrupts, so only +/// the following can be used for RX : 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI). +/// -2016-06-04 Dan Ogorchock Added improved support for Arduino Leonardo +/// -2017-02-04 Dan Ogorchock Modified to be a subclass of new SmartThings base class +/// -2017-02-08 Dan Ogorchock Cleaned up. Now uses HardwareSerial* objects directly. +//******************************************************************************* +#include "SmartThingsThingShield.h" + +namespace st +{ + //***************************************************************************** + void SmartThingsThingShield::debugPrintBuffer(String prefix, uint8_t * pBuf, uint_fast8_t nBuf) + { + if (_isDebugEnabled) + { + Serial.print(prefix); + for (uint_fast8_t i = 0; i < nBuf; i++) + { + Serial.print(char(pBuf[i])); + } + Serial.println(); + } + } + + //***************************************************************************** + bool SmartThingsThingShield::isRxLine(uint8_t * pLine) + { + // line starts with "T00000000:RX" + return ((pLine[0] == 'T') && (pLine[9] == ':') && (pLine[10] == 'R') && (pLine[11] == 'X')); + } + + //******************************************************************************* + bool SmartThingsThingShield::isAsciiHex(uint8_t ascii) + { + bool retVal = false; + if ( + ((ascii >= 'A') && (ascii <= 'F')) || + ((ascii >= 'a') && (ascii <= 'f')) || + ((ascii >= '0') && (ascii <= '9')) + ) + { + retVal = true; + } + return retVal; + } + + //******************************************************************************* + /// @note this function doesn't check for hex validity before converting + //******************************************************************************* + uint8_t SmartThingsThingShield::asciiToHexU8(uint8_t pAscii[2]) + { + uint8_t hex; + hex = ((pAscii[0] - (((pAscii[0] >> 6) & 0x1) * 0x37)) & 0xF); + hex <<= 4; + hex |= ((pAscii[1] - (((pAscii[1] >> 6) & 0x1) * 0x37)) & 0xF); + return hex; + } + + //***************************************************************************** + uint_fast8_t SmartThingsThingShield::translatePayload(uint8_t *pBuf, uint_fast8_t nBuf) + { + uint_fast8_t payloadLength = 0; // return value + uint_fast8_t payloadStart = 0; + uint_fast8_t payloadEnd = 0; + + uint_fast8_t i; + + // find [ ] message from the back of the message + for (i = nBuf - 1; i > 0; i--) + { + if (pBuf[i] == ']') + { + payloadEnd = i; + } + else if (pBuf[i] == '[') + { + payloadStart = i; + break; + } + } + + if (_isDebugEnabled) + { + Serial.print(F("payload start: ")); + Serial.print(payloadStart); + Serial.print(F(" end: ")); + Serial.print(payloadEnd); + Serial.print(F(" : ")); + for (i = payloadStart + 1; i < payloadEnd; i++) + { + Serial.print(pBuf[i]); + Serial.print(' '); + } + Serial.println(); + } + + if ((payloadStart != 0) && (payloadEnd != 0) && (payloadEnd - payloadStart > 4) && (pBuf[payloadStart + 1] == '0') && (pBuf[payloadStart + 2] == 'A')) + { // if valid message then parse + i = payloadStart + 4; // start+3 should be ' ' + while (i < payloadEnd) + { + if (pBuf[i] != ' ') + { + if (isAsciiHex(pBuf[i]) && isAsciiHex(pBuf[i + 1])) + { + pBuf[payloadLength++] = asciiToHexU8(&(pBuf[i++])); + } + } + i++; + } + } + + pBuf[payloadLength] = 0x0; // null-terminate the string + return payloadLength; + } + + //***************************************************************************** + void SmartThingsThingShield::_process(void) + { + uint32_t nowMilliseconds = millis(); + + if ((nowMilliseconds < _lastShieldMS) || ((nowMilliseconds - _lastShieldMS) > 5000)) + { + _shieldGetNetworkInfo(); + _lastShieldMS = nowMilliseconds; + } + else if ((_networkState == STATE_JOINED) && + ((nowMilliseconds < _lastPingMS) || ((nowMilliseconds - _lastPingMS) > 60000))) + { // ping every minutes or on rollover + send("ping"); + _lastPingMS = nowMilliseconds; + } + } + + //***************************************************************************** + void SmartThingsThingShield::handleLine(void) + { + if (_nBufRX > 0) + { + if (isRxLine(_pBufRX)) + { + debugPrintBuffer("->| ", _pBufRX, _nBufRX); + { + uint_fast8_t messageBufLength = translatePayload(_pBufRX, _nBufRX); + + if (messageBufLength > 0) + { + debugPrintBuffer("->| payload :: ", (uint8_t *)_pBufRX, messageBufLength); + + _calloutFunction(String((char *)_pBufRX)); // call out to main application + } + else + { + debugPrintBuffer("->| no payload from :: ", _pBufRX, _nBufRX); + } + } + } + else + { //XXX Totally slapped together since this is temp-- will go away with command set change + uint_fast8_t i = 0; + bool found = false; + if (_nBufRX >= 32) //netinfo:0022A3000000B675,E30E,02 + { + while (i < _nBufRX) + { + if ( + (_pBufRX[i] == 'n') && + (_pBufRX[i + 1] == 'e') && + (_pBufRX[i + 2] == 't') && + (_pBufRX[i + 3] == 'i') && + (_pBufRX[i + 4] == 'n') && + (_pBufRX[i + 5] == 'f') && + (_pBufRX[i + 6] == 'o') && + (_pBufRX[i + 7] == ':') && + (_pBufRX[i + 24] == ',') && + (_pBufRX[i + 29] == ',') + ) + { + // parse off EUI + if ( + isAsciiHex(_pBufRX[i + 8]) && + isAsciiHex(_pBufRX[i + 9]) && + isAsciiHex(_pBufRX[i + 10]) && + isAsciiHex(_pBufRX[i + 11]) && + isAsciiHex(_pBufRX[i + 12]) && + isAsciiHex(_pBufRX[i + 13]) && + isAsciiHex(_pBufRX[i + 14]) && + isAsciiHex(_pBufRX[i + 15]) && + isAsciiHex(_pBufRX[i + 16]) && + isAsciiHex(_pBufRX[i + 17]) && + isAsciiHex(_pBufRX[i + 18]) && + isAsciiHex(_pBufRX[i + 19]) && + isAsciiHex(_pBufRX[i + 20]) && + isAsciiHex(_pBufRX[i + 21]) && + isAsciiHex(_pBufRX[i + 22]) && + isAsciiHex(_pBufRX[i + 23]) && + + isAsciiHex(_pBufRX[i + 25]) && + isAsciiHex(_pBufRX[i + 26]) && + isAsciiHex(_pBufRX[i + 27]) && + isAsciiHex(_pBufRX[i + 28]) && + + isAsciiHex(_pBufRX[i + 30]) && + isAsciiHex(_pBufRX[i + 31]) + ) + { + uint8_t tempNetStat = asciiToHexU8(&(_pBufRX[i + 30])); + if (tempNetStat <= STATE_LEAVING) // make sure it maps to the enum + { + _networkState = (SmartThingsNetworkState_t)tempNetStat; + + _nodeID = asciiToHexU8(&(_pBufRX[i + 25])); + _nodeID <<= 8; + _nodeID |= asciiToHexU8(&(_pBufRX[i + 27])); + + _eui64[7] = asciiToHexU8(&(_pBufRX[i + 8])); + _eui64[6] = asciiToHexU8(&(_pBufRX[i + 10])); + _eui64[5] = asciiToHexU8(&(_pBufRX[i + 12])); + _eui64[4] = asciiToHexU8(&(_pBufRX[i + 14])); + _eui64[3] = asciiToHexU8(&(_pBufRX[i + 16])); + _eui64[2] = asciiToHexU8(&(_pBufRX[i + 18])); + _eui64[1] = asciiToHexU8(&(_pBufRX[i + 20])); + _eui64[0] = asciiToHexU8(&(_pBufRX[i + 22])); + + debugPrintBuffer(" |~> ", &(_pBufRX[i]), 32); + found = true; + } + } + } + i++; + } + } + if (found == false) + debugPrintBuffer("->| IGNORING :: ", _pBufRX, _nBufRX); + } + _nBufRX = 0; + } + } + //***************************************************************************** + void SmartThingsThingShield::_shieldGetNetworkInfo(void) + { + _mySerial->print(F("custom netinfo\n")); + + if (_isDebugEnabled) + { + Serial.print(F(" |<~ custom netinfo\n")); + } + } + + //***************************************************************************** + // Thing API | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | + // 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 V V V + //***************************************************************************** + + // SoftwareSerial Constructor +#ifndef DISABLE_SOFTWARESERIAL + SmartThingsThingShield::SmartThingsThingShield(uint8_t pinRX, uint8_t pinTX, SmartThingsCallout_t *callout, String shieldType, bool enableDebug) : + SmartThings(callout, shieldType, enableDebug), + //_SerialPort(SW_SERIAL), + _lastPingMS(0xFFFFFF00), + _lastShieldMS(0xFFFFFF00), + _networkState(STATE_UNKNOWN), + _nBufRX(0) + { + _mySerial = new SoftwareSerial(pinRX, pinTX); + _mySerial->begin(2400); + } +#else + //Hardware Serial Constructor + SmartThingsThingShield::SmartThingsThingShield(HardwareSerial* hwSerialPort, SmartThingsCallout_t *callout, String shieldType, bool enableDebug) : + SmartThings(callout, shieldType, enableDebug), + _mySerial(hwSerialPort), + _lastPingMS(0xFFFFFF00), + _lastShieldMS(0xFFFFFF00), + _networkState(STATE_UNKNOWN), + _nBufRX(0) + { +// _isDebugEnabled = hwSerialPort != Serial ? enableDebug : false; //Do not allow debug print statements if using Hardware Serial (pins 0,1) for ST Communications + _mySerial->begin(2400); + } +#endif + //***************************************************************************** + //SmartThings::~SmartThings() + SmartThingsThingShield::~SmartThingsThingShield() + { + } + + //******************************************************************************* + /// Initialize SmartThings Thingshield Library + //******************************************************************************* + void SmartThingsThingShield::init(void) + { + unsigned long tmpTime = millis(); + do + { + //updateNetworkState(); + run(); + delay(10); + updateNetworkState(); + } while ((_networkState != STATE_JOINED) && ((millis() - tmpTime) < 5000)); + + if (_isDebugEnabled) + { + if (_networkState != STATE_JOINED) + { + Serial.println(F("SmartThingsThingShield: Intialization timed out waiting for shield to connect.")); + } + else + { + Serial.println(F("SmartThingsThingShield: Intialization Successful. Shield connected.")); + } + } + } + + + //***************************************************************************** + void SmartThingsThingShield::run(void) + { + uint8_t readByte; + + while ((_nBufRX < SMARTTHINGS_RX_BUFFER_SIZE) && _mySerial->available()) + { + + readByte = _mySerial->read(); + + if ((readByte == 0x0D) || (readByte == 0x0A)) + { // handle data from SmartThing Hub line-by-line, execute user's callback function for each line + handleLine(); + } + else + { + // keep track of everything that comes in until we reach a newline + // TODO(cwvh): validate bufferlength 1988-10-19 + //if (_nBufRX > 200) + // panic("too many characters!"); + _pBufRX[_nBufRX++] = readByte; + } + + } + _process(); + } + + //***************************************************************************** + void SmartThingsThingShield::send(String message) + { + // e.g. thing.print("raw 0x0 {00 00 0A 0A 62 75 74 74 6f 6e 20 64 6f 77 6e }"); + _mySerial->print(F("raw 0x0 { 00 00 0A 0A ")); + + if (_isDebugEnabled) + { + Serial.print(F("<-| raw 0x0 { 00 00 0A 0A ")); + } + + for (int i = 0; i < message.length(); i++) + { + _mySerial->print(message[i], HEX); + _mySerial->print(' '); + + if (_isDebugEnabled) + { + Serial.print(message[i], HEX); + Serial.print(' '); + } + } + + _mySerial->print(F("}\nsend 0x0 1 1\n")); + + if (_isDebugEnabled) + { + Serial.print(F("}\nsend 0x0 1 1\n")); + } + } + + //***************************************************************************** + void SmartThingsThingShield::shieldSetLED(uint8_t red, uint8_t green, uint8_t blue) + { + if (red > 9) red = 9; + if (green > 9) green = 9; + if (blue > 9) blue = 9; + + _mySerial->print(F("custom rgb ")); + _mySerial->write((red + '0')); + _mySerial->print(' '); + _mySerial->write((green + '0')); + _mySerial->print(' '); + _mySerial->write((blue + '0')); + _mySerial->print(F(" \n")); + + if (_isDebugEnabled) + { + Serial.print(F(" |<~ custom rgb ")); + Serial.write(red + '0'); + Serial.print(' '); + Serial.write(green + '0'); + Serial.print(' '); + Serial.write(blue + '0'); + Serial.print(F(" \n")); + } + } + + + //***************************************************************************** + SmartThingsNetworkState_t SmartThingsThingShield::shieldGetLastNetworkState(void) + { + return _networkState; + } + + //***************************************************************************** + SmartThingsNetworkState_t SmartThingsThingShield::shieldGetNetworkState(void) + { + _shieldGetNetworkInfo(); + return _networkState; + } + + //***************************************************************************** + uint16_t SmartThingsThingShield::shieldGetNodeID(void) + { + _shieldGetNetworkInfo(); + return _nodeID; + } + + //***************************************************************************** + void SmartThingsThingShield::shieldGetEUI64(uint8_t eui[8]) + { + _shieldGetNetworkInfo(); + { + uint_fast8_t i = 7; + do + { + eui[i] = _eui64[i]; + } while (i--); + } + } + + //***************************************************************************** + void SmartThingsThingShield::shieldFindNetwork(void) + { + _mySerial->print(F("custom find\n")); + + if (_isDebugEnabled) + { + Serial.print(F(" |<~ custom find\n")); + + } + } + + //***************************************************************************** + void SmartThingsThingShield::shieldLeaveNetwork(void) + { + _mySerial->print(F("custom leave\n")); + + + if (_isDebugEnabled) + { + Serial.print(F(" |<~ custom leave\n")); + } + } + + //******************************************************************************* + // Update the network State/LED + //******************************************************************************* + void SmartThingsThingShield::updateNetworkState() //get the current zigbee network status of the ST Shield + { + static SmartThingsNetworkState_t tempState = shieldGetLastNetworkState(); + + if (_isDebugEnabled) + { + Serial.println(F("Called updateNetworkState()")); + } + + if (tempState != _networkState) + { + if (_isDebugEnabled) + { + Serial.print(F("Called updateNetworkState() tmpState =")); + Serial.println(tempState); + } + + switch (_networkState) + { + case STATE_NO_NETWORK: + if (_isDebugEnabled) Serial.println(F("Everything: NO_NETWORK")); + shieldSetLED(2, 0, 0); // red + break; + case STATE_JOINING: + if (_isDebugEnabled) Serial.println(F("Everything: JOINING")); + shieldSetLED(2, 0, 0); // red + break; + case STATE_JOINED: + if (_isDebugEnabled) Serial.println(F("Everything: JOINED")); + shieldSetLED(0, 0, 0); // off + break; + case STATE_JOINED_NOPARENT: + if (_isDebugEnabled) Serial.println(F("Everything: JOINED_NOPARENT")); + shieldSetLED(2, 0, 2); // purple + break; + case STATE_LEAVING: + if (_isDebugEnabled) Serial.println(F("Everything: LEAVING")); + shieldSetLED(2, 0, 0); // red + break; + default: + case STATE_UNKNOWN: + if (_isDebugEnabled) Serial.println(F("Everything: UNKNOWN")); + shieldSetLED(0, 2, 0); // green + break; + } + _networkState = tempState; + } + } + +} \ No newline at end of file diff --git a/Arduino/libraries/SmartThings/SmartThingsThingShield.h b/Arduino/libraries/SmartThings/SmartThingsThingShield.h new file mode 100644 index 00000000..e49c0aa4 --- /dev/null +++ b/Arduino/libraries/SmartThings/SmartThingsThingShield.h @@ -0,0 +1,209 @@ +//******************************************************************************* +/// @file +/// @brief +/// SmartThingsThingShield Arduino Library +/// @section License +/// (C) Copyright 2013 Physical Graph +/// +/// Updates by Daniel Ogorchock 12/30/2014 - Arduino Mega 2560 HW Serial support +/// -Numerous performance and size optimizations (helpful on UNO with only 2K SRAM) +/// -Arduino UNO should use the SoftwareSerial library Constructor since the UNO has +/// only one Hardware UART port ("Serial") which is used by the USB port for +/// programming and debugging typically. UNO can use the Hardware "Serial" +/// if desired, but USB programming and debug will be troublesome. +/// Leonardo and Mega can use SoftwareSerial BUT cannot use Pin3 for Rx - use +/// Pin10 for Rx and add jumper from Pin10 to Pin3. +/// -Arduino LEONARDO should use the Hardware Serial Constructor since it has 1 UART +/// separate from the USB port. "Serial1" port uses pins 0(Rx) and 1(Tx). +/// -Arduino MEGA should use the Hardware Serial Constructor since it has 4 UARTs. +/// "Serial3" port uses pins 14(Tx) and 15(Rx). Wire Pin14 to Pin2 and Pin15 to Pin3. +/// -Be certain to not use Pins 2 & 3 in your Arduino sketch for I/O since they are +/// electrically connected to the ThingShield if set to D2/D3. +/// -Note - Pin6 is reserved by the ThingShield as well. Best to avoid using it. +/// -The SoftwareSerial library has the following known limitations: +/// - If using multiple software serial ports, only one can receive data at a time. +/// - Not all pins on the Mega and Mega 2560 support change interrupts, so only +/// the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, +/// A8(62), A9(63), A10(64), A11(65), A12(66), A13(67), A14(68), A15(69). +/// - Not all pins on the Leonardo and Micro support change interrupts, so only +/// the following can be used for RX : 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI). +/// -2016-06-04 Dan Ogorchock Added improved support for Arduino Leonardo +/// -2017-02-04 Dan Ogorchock Modified to be a subclass of new SmartThings base class +/// -2017-02-08 Dan Ogorchock Cleaned up. Now uses HardwareSerial* objects directly. +//******************************************************************************* +#ifndef __SMARTTHINGS_THINGSHIELD_H__ +#define __SMARTTHINGS_THINGSHIELD_H__ + +#include "SmartThings.h" + +//******************************************************************************* +#define BOARD_TYPE_UNO 0 +#define BOARD_TYPE_LEONARDO 1 +#define BOARD_TYPE_MEGA 2 +//******************************************************************************* + +#include + +//******************************************************************************* +// Set the correct board type automatically +//******************************************************************************* +#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega328P__) +#define BOARD_TYPE BOARD_TYPE_UNO +//#define DISABLE_SOFTWARESERIAL // uncomment to disable SoftwareSerial to save some program space if neccessary while using HW Serial +#elif defined(__AVR_ATmega32U4__) +#define BOARD_TYPE BOARD_TYPE_LEONARDO +#define DISABLE_SOFTWARESERIAL //Assume HW Serial is being used. Saves some program space while using HW Serial +#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) +#define BOARD_TYPE BOARD_TYPE_MEGA +#define DISABLE_SOFTWARESERIAL //Assume HW Serial is being used. Saves some program space while using HW Serial +#else //assume user is using an UNO for the unknown case +#define BOARD_TYPE BOARD_TYPE_UNO +//#define DISABLE_SOFTWARESERIAL // uncomment to disable SoftwareSerial to save some program space if neccessary while using HW Serial +#endif + +#ifndef DISABLE_SOFTWARESERIAL +#include +#endif + +//******************************************************************************* +#define SMARTTHINGS_RX_BUFFER_SIZE 256 // if > 255: change _nBufRX to u16 +#define SMARTTHINGS_SHIELDTYPE_SIZE 32 // if > 255: change _shieldTypeLen to u16 + +namespace st +{ + //******************************************************************************* + /// @brief ZigBee Network State Definition + //******************************************************************************* + typedef enum + { + STATE_NO_NETWORK, + STATE_JOINING, + STATE_JOINED, + STATE_JOINED_NOPARENT, + STATE_LEAVING, + STATE_UNKNOWN + } SmartThingsNetworkState_t; + + //******************************************************************************* + + class SmartThingsThingShield: public SmartThings + { + private: +#ifndef DISABLE_SOFTWARESERIAL + SoftwareSerial* _mySerial; +#else + HardwareSerial* _mySerial; +#endif + //SmartThingsSerialType_t _SerialPort; + + uint32_t _lastPingMS; + uint32_t _lastShieldMS; + SmartThingsNetworkState_t _networkState; + uint8_t _eui64[8]; + uint16_t _nodeID; + + uint8_t _pBufRX[SMARTTHINGS_RX_BUFFER_SIZE]; + uint_fast8_t _nBufRX; + + void _shieldGetNetworkInfo(void); + void _process(void); + + void debugPrintBuffer(String prefix, uint8_t * pBuf, uint_fast8_t nBuf); + bool isRxLine(uint8_t * pLine); + bool isAsciiHex(uint8_t ascii); + uint8_t asciiToHexU8(uint8_t pAscii[2]); + uint_fast8_t translatePayload(uint8_t *pBuf, uint_fast8_t nBuf); + void handleLine(void); + + public: + //******************************************************************************* + /// @brief SmartThings SoftwareSerial Constructor + /// @param[in] pinRX - Receive Pin for the SoftwareSerial Port to the Arduino + /// @param[in] pinTX - Transmit Pin for the SoftwareSerial Port to the Arduino + /// @param[in] callout - Set the Callout Function that is called on Msg Reception + /// @param[in] shieldType (optional) - Set the Reported SheildType to the Server + /// @param[in] enableDebug (optional) - Enable internal Library debug + //******************************************************************************* +#ifndef DISABLE_SOFTWARESERIAL + SmartThingsThingShield(uint8_t pinRX, uint8_t pinTX, SmartThingsCallout_t *callout, String shieldType = "ThingShield", bool enableDebug = false); +#else + //******************************************************************************* + /// @brief SmartThings HardwareSerial Constructor + /// @param[in] hwSerialPort - HardwareSerial Port of the Arduino (i.e. &Serial, &Serial1, &Serial2, &Serial3) + /// @param[in] callout - Set the Callout Function that is called on Msg Reception + /// @param[in] shieldType (optional) - Set the Reported SheildType to the Server + /// @param[in] enableDebug (optional) - Enable internal Library debug + //******************************************************************************* + SmartThingsThingShield(HardwareSerial* hwSerialPort, SmartThingsCallout_t *callout, String shieldType = "ThingShield", bool enableDebug = false); +#endif + //******************************************************************************* + /// @brief Destructor + //******************************************************************************* + virtual ~SmartThingsThingShield(); + + //******************************************************************************* + /// @brief Initialize SmartThings Library + //******************************************************************************* + virtual void init(void); + + //******************************************************************************* + /// @brief Run SmartThings Library + //******************************************************************************* + virtual void run(void); + + //******************************************************************************* + /// @brief Send Message out over ZigBee to the Hub + /// @param[in] message to send + //******************************************************************************* + virtual void send(String message); + + //******************************************************************************* + /// @brief Set SmartThings Shield MultiColor LED + /// @param[in] red: intensity {0=off to 9=max} + /// @param[in] green: intensity {0=off to 9=max} + /// @param[in] blue: intensity {0=off to 9=max} + //******************************************************************************* + void shieldSetLED(uint8_t red, uint8_t green, uint8_t blue); + + //******************************************************************************* + /// @brief Get Last Read Shield State + /// @return Last Read Network State + //******************************************************************************* + SmartThingsNetworkState_t shieldGetLastNetworkState(void); + + //******************************************************************************* + /// @brief Get Last Read Shield State and Trigger Refresh of Network Info + /// @return Last Read Network State + //******************************************************************************* + SmartThingsNetworkState_t shieldGetNetworkState(void); + + //******************************************************************************* + /// @brief Get Last Read NodeID and Trigger Refresh of Network Info + /// @return Last Read NodeID + //******************************************************************************* + uint16_t shieldGetNodeID(void); + + //******************************************************************************* + /// @brief Get Last Read EUI64 and Trigger Refresh of Network Info + /// @return Last Read EUI64 + //******************************************************************************* + void shieldGetEUI64(uint8_t eui[8]); + + //******************************************************************************* + /// @brief Find and Join a Network + //******************************************************************************* + void shieldFindNetwork(void); + + //******************************************************************************* + /// @brief Leave the Current ZigBee Network + //******************************************************************************* + void shieldLeaveNetwork(void); + + //******************************************************************************* + // Update the network State/LED + //******************************************************************************* + void updateNetworkState(void); //get the current zigbee network status of the ST Shield + + }; +} +#endif diff --git a/Arduino/libraries/SmartThings/docs/Doxyfile b/Arduino/libraries/SmartThings/docs/Doxyfile deleted file mode 100644 index 9fa55a06..00000000 --- a/Arduino/libraries/SmartThings/docs/Doxyfile +++ /dev/null @@ -1,1809 +0,0 @@ -tt# Doxyfile 1.8.2 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project. -# -# All text after a hash (#) is considered a comment and will be ignored. -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" "). - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all -# text before the first occurrence of this tag. Doxygen uses libiconv (or the -# iconv built into libc) for the transcoding. See -# http://www.gnu.org/software/libiconv for the list of possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or sequence of words) that should -# identify the project. Note that if you do not use Doxywizard you need -# to put quotes around the project name if it contains spaces. - -PROJECT_NAME = "SmartThings Arduino Shield" - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = "\r\n" - -# Using the PROJECT_BRIEF tag one can provide an optional one line description -# for a project that appears at the top of each page and should give viewer -# a quick idea about the purpose of the project. Keep the description short. - -PROJECT_BRIEF = "SmartThings Arduino Shield Library Interface" - -# With the PROJECT_LOGO tag one can specify an logo or icon that is -# included in the documentation. The maximum height of the logo should not -# exceed 55 pixels and the maximum width should not exceed 200 pixels. -# Doxygen will copy the logo to the output directory. - -PROJECT_LOGO = "logo.gif" - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, -# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English -# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, -# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, -# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = "SmartThings Arduino Shield Interface" - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = YES - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = NO - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. Note that you specify absolute paths here, but also -# relative paths, which will be relative from the directory where doxygen is -# started. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful if your file system -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments -# (thus requiring an explicit @brief command for a brief description.) - -JAVADOC_AUTOBRIEF = NO - -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring -# an explicit \brief command for a brief description.) - -QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = YES - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 4 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding -# "class=itcl::class" will allow you to use the command class in the -# itcl::class meaning. - -TCL_SUBST = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = YES - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for -# Java. For instance, namespaces will be presented as packages, qualified -# scopes will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources only. Doxygen will then generate output that is more tailored for -# Fortran. - -OPTIMIZE_FOR_FORTRAN = NO - -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for -# VHDL. - -OPTIMIZE_OUTPUT_VHDL = NO - -# Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given -# extension. Doxygen has a built-in mapping, but you can override or extend it -# using this tag. The format is ext=language, where ext is a file extension, -# and language is one of the parsers supported by doxygen: IDL, Java, -# Javascript, CSharp, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, -# C++. For instance to make doxygen treat .inc files as Fortran files (default -# is PHP), and .f files as C (default is Fortran), use: inc=Fortran f=C. Note -# that for custom extensions you also need to set FILE_PATTERNS otherwise the -# files are not read by doxygen. - -EXTENSION_MAPPING = - -# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all -# comments according to the Markdown format, which allows for more readable -# documentation. See http://daringfireball.net/projects/markdown/ for details. -# The output of markdown processing is further processed by doxygen, so you -# can mix doxygen, HTML, and XML commands with Markdown formatting. -# Disable only in case of backward compatibilities issues. - -MARKDOWN_SUPPORT = YES - -# When enabled doxygen tries to link words that correspond to documented classes, -# or namespaces to their corresponding documentation. Such a link can be -# prevented in individual cases by by putting a % sign in front of the word or -# globally by setting AUTOLINK_SUPPORT to NO. - -AUTOLINK_SUPPORT = YES - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also makes the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - -CPP_CLI_SUPPORT = NO - -# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. -# Doxygen will parse them like normal C++ but will assume all classes use public -# instead of private inheritance when no explicit protection keyword is present. - -SIP_SUPPORT = NO - -# For Microsoft's IDL there are propget and propput attributes to indicate getter and setter methods for a property. Setting this option to YES (the default) will make doxygen replace the get and set methods by a property in the documentation. This will only work if the methods are indeed getting or setting a simple type. If this is not the case, or you want to show the methods anyway, you should set this option to NO. - -IDL_PROPERTY_SUPPORT = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and -# unions are shown inside the group in which they are included (e.g. using -# @ingroup) instead of on a separate page (for HTML and Man pages) or -# section (for LaTeX and RTF). - -INLINE_GROUPED_CLASSES = NO - -# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and -# unions with only public data fields will be shown inline in the documentation -# of the scope in which they are defined (i.e. file, namespace, or group -# documentation), provided this scope is documented. If set to NO (the default), -# structs, classes, and unions are shown on a separate page (for HTML and Man -# pages) or section (for LaTeX and RTF). - -INLINE_SIMPLE_STRUCTS = NO - -# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum -# is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically -# be useful for C code in case the coding convention dictates that all compound -# types are typedef'ed and only the typedef is referenced, never the tag name. - -TYPEDEF_HIDES_STRUCT = NO - -# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to -# determine which symbols to keep in memory and which to flush to disk. -# When the cache is full, less often used symbols will be written to disk. -# For small to medium size projects (<1000 input files) the default value is -# probably good enough. For larger projects a too small cache size can cause -# doxygen to be busy swapping symbols to and from disk most of the time -# causing a significant performance penalty. -# If the system has enough physical memory increasing the cache will improve the -# performance by keeping more symbols in memory. Note that the value works on -# a logarithmic scale so increasing the size by one will roughly double the -# memory usage. The cache size is given by this formula: -# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols. - -SYMBOL_CACHE_SIZE = 0 - -# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be -# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given -# their name and scope. Since this can be an expensive process and often the -# same symbol appear multiple times in the code, doxygen keeps a cache of -# pre-resolved symbols. If the cache is too small doxygen will become slower. -# If the cache is too large, memory is wasted. The cache size is given by this -# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols. - -LOOKUP_CACHE_SIZE = 0 - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal -# scope will be included in the documentation. - -EXTRACT_PACKAGE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespaces are hidden. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = NO - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = NO - -# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen -# will list include files with double quotes in the documentation -# rather than with sharp brackets. - -FORCE_LOCAL_INCLUDES = NO - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen -# will sort the (brief and detailed) documentation of class members so that -# constructors and destructors are listed first. If set to NO (the default) -# the constructors will appear in the respective orders defined by -# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. -# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO -# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. - -SORT_MEMBERS_CTORS_1ST = NO - -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the -# hierarchy of group names into alphabetical order. If set to NO (the default) -# the group names will appear in their defined order. - -SORT_GROUP_NAMES = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to -# do proper type resolution of all parameters of a function it will reject a -# match between the prototype and the implementation of a member function even -# if there is only one candidate or it is obvious which candidate to choose -# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen -# will still accept a match between prototype and implementation in such cases. - -STRICT_PROTO_MATCHING = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or macro consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and macros in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. -# This will remove the Files entry from the Quick Index and from the -# Folder Tree View (if specified). The default is YES. - -SHOW_FILES = YES - -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the -# Namespaces page. -# This will remove the Namespaces entry from the Quick Index -# and from the Folder Tree View (if specified). The default is YES. - -SHOW_NAMESPACES = YES - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed -# by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. To create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. -# You can optionally specify a file name after the option, if omitted -# DoxygenLayout.xml will be used as the name of the layout file. - -LAYOUT_FILE = - -# The CITE_BIB_FILES tag can be used to specify one or more bib files -# containing the references data. This must be a list of .bib files. The -# .bib extension is automatically appended if omitted. Using this command -# requires the bibtex tool to be installed. See also -# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style -# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this -# feature you need bibtex and perl available in the search path. - -CITE_BIB_FILES = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# The WARN_NO_PARAMDOC option can be enabled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = ../ # \ - # indexDoc.txt - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is -# also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for -# the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh -# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py -# *.f90 *.f *.for *.vhd *.vhdl - -FILE_PATTERNS = *.h - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = NO - -# The EXCLUDE tag can be used to specify files and/or directories that should be -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. -# Note that relative paths are relative to the directory from which doxygen is -# run. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or -# directories that are symbolic links (a Unix file system feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. -# If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. -# Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. -# The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty or if -# non of the patterns match the file name, INPUT_FILTER is applied. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file -# pattern. A pattern will override the setting for FILTER_PATTERN (if any) -# and it is also possible to disable source filtering for a specific pattern -# using *.ext= (so without naming a filter). This option only has effect when -# FILTER_SOURCE_FILES is enabled. - -FILTER_SOURCE_PATTERNS = - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C, C++ and Fortran comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = YES - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. -# Otherwise they will link to the documentation. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = NO - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 4 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. Note that when using a custom header you are responsible -# for the proper inclusion of any scripts and style sheets that doxygen -# needs, which is dependent on the configuration options used. -# It is advised to generate a default header using "doxygen -w html -# header.html footer.html stylesheet.css YourConfigFile" and then modify -# that header. Note that the header is subject to change so you typically -# have to redo this when upgrading to a newer version of doxygen or when -# changing the value of configuration settings such as GENERATE_TREEVIEW! - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If left blank doxygen will -# generate a default style sheet. Note that it is recommended to use -# HTML_EXTRA_STYLESHEET instead of this one, as it is more robust and this -# tag will in the future become obsolete. - -HTML_STYLESHEET = - -# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional -# user-defined cascading style sheet that is included after the standard -# style sheets created by doxygen. Using this option one can overrule -# certain style aspects. This is preferred over using HTML_STYLESHEET -# since it does not replace the standard style sheet and is therefor more -# robust against future updates. Doxygen will copy the style sheet file to -# the output directory. - -HTML_EXTRA_STYLESHEET = - -# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or -# other source files which should be copied to the HTML output directory. Note -# that these files will be copied to the base HTML output directory. Use the -# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these -# files. In the HTML_STYLESHEET file, use the file name only. Also note that -# the files will be copied as-is; there are no commands or markers available. - -HTML_EXTRA_FILES = - -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. -# Doxygen will adjust the colors in the style sheet and background images -# according to this color. Hue is specified as an angle on a colorwheel, -# see http://en.wikipedia.org/wiki/Hue for more information. -# For instance the value 0 represents red, 60 is yellow, 120 is green, -# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. -# The allowed range is 0 to 359. - -HTML_COLORSTYLE_HUE = 220 - -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of -# the colors in the HTML output. For a value of 0 the output will use -# grayscales only. A value of 255 will produce the most vivid colors. - -HTML_COLORSTYLE_SAT = 100 - -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to -# the luminance component of the colors in the HTML output. Values below -# 100 gradually make the output lighter, whereas values above 100 make -# the output darker. The value divided by 100 is the actual gamma applied, -# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, -# and 100 does not change the gamma. - -HTML_COLORSTYLE_GAMMA = 80 - -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting -# this to NO can help when comparing the output of multiple runs. - -HTML_TIMESTAMP = YES - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. - -HTML_DYNAMIC_SECTIONS = YES - -# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of -# entries shown in the various tree structured indices initially; the user -# can expand and collapse entries dynamically later on. Doxygen will expand -# the tree to such a level that at most the specified number of entries are -# visible (unless a fully collapsed tree already exceeds this amount). -# So setting the number of entries 1 will produce a full collapsed tree by -# default. 0 is a special value representing an infinite number of entries -# and will result in a full expanded tree by default. - -HTML_INDEX_NUM_ENTRIES = 100 - -# If the GENERATE_DOCSET tag is set to YES, additional index files -# will be generated that can be used as input for Apple's Xcode 3 -# integrated development environment, introduced with OSX 10.5 (Leopard). -# To create a documentation set, doxygen will generate a Makefile in the -# HTML output directory. Running make will produce the docset in that -# directory and running "make install" will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find -# it at startup. -# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. - -GENERATE_DOCSET = NO - -# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the -# feed. A documentation feed provides an umbrella under which multiple -# documentation sets from a single provider (such as a company or product suite) -# can be grouped. - -DOCSET_FEEDNAME = "Doxygen generated docs" - -# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that -# should uniquely identify the documentation set bundle. This should be a -# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen -# will append .docset to the name. - -DOCSET_BUNDLE_ID = org.doxygen.Project - -# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely -# identify the documentation publisher. This should be a reverse domain-name -# style string, e.g. com.mycompany.MyDocSet.documentation. - -DOCSET_PUBLISHER_ID = org.doxygen.Publisher - -# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. - -DOCSET_PUBLISHER_NAME = Publisher - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING -# is used to encode HtmlHelp index (hhk), content (hhc) and project file -# content. - -CHM_INDEX_ENCODING = - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated -# that can be used as input for Qt's qhelpgenerator to generate a -# Qt Compressed Help (.qch) of the generated HTML documentation. - -GENERATE_QHP = NO - -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can -# be used to specify the file name of the resulting .qch file. -# The path specified is relative to the HTML output folder. - -QCH_FILE = - -# The QHP_NAMESPACE tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#namespace - -QHP_NAMESPACE = org.doxygen.Project - -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#virtual-folders - -QHP_VIRTUAL_FOLDER = doc - -# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to -# add. For more information please see -# http://doc.trolltech.com/qthelpproject.html#custom-filters - -QHP_CUST_FILTER_NAME = - -# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see -# -# Qt Help Project / Custom Filters. - -QHP_CUST_FILTER_ATTRS = - -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's -# filter section matches. -# -# Qt Help Project / Filter Attributes. - -QHP_SECT_FILTER_ATTRS = - -# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can -# be used to specify the location of Qt's qhelpgenerator. -# If non-empty doxygen will try to run qhelpgenerator on the generated -# .qhp file. - -QHG_LOCATION = - -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files -# will be generated, which together with the HTML files, form an Eclipse help -# plugin. To install this plugin and make it available under the help contents -# menu in Eclipse, the contents of the directory containing the HTML and XML -# files needs to be copied into the plugins directory of eclipse. The name of -# the directory within the plugins directory should be the same as -# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before -# the help appears. - -GENERATE_ECLIPSEHELP = NO - -# A unique identifier for the eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have -# this name. - -ECLIPSE_DOC_ID = org.doxygen.Project - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) -# at top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. Since the tabs have the same information as the -# navigation tree you can set this option to NO if you already set -# GENERATE_TREEVIEW to YES. - -DISABLE_INDEX = NO - -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. -# If the tag value is set to YES, a side panel will be generated -# containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). -# Windows users are probably better off using the HTML help feature. -# Since the tree basically has the same information as the tab index you -# could consider to set DISABLE_INDEX to NO when enabling this option. - -GENERATE_TREEVIEW = YES - -# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values -# (range [0,1..20]) that doxygen will group on one line in the generated HTML -# documentation. Note that a value of 0 will completely suppress the enum -# values from appearing in the overview section. - -ENUM_VALUES_PER_LINE = 4 - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open -# links to external symbols imported via tag files in a separate window. - -EXT_LINKS_IN_WINDOW = NO - -# Use this tag to change the font size of Latex formulas included -# as images in the HTML documentation. The default is 10. Note that -# when you change the font size after a successful doxygen run you need -# to manually remove any form_*.png images from the HTML output directory -# to force them to be regenerated. - -FORMULA_FONTSIZE = 10 - -# Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are -# not supported properly for IE 6.0, but are supported on all modern browsers. -# Note that when changing this option you need to delete any form_*.png files -# in the HTML output before the changes have effect. - -FORMULA_TRANSPARENT = YES - -# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax -# (see http://www.mathjax.org) which uses client side Javascript for the -# rendering instead of using prerendered bitmaps. Use this if you do not -# have LaTeX installed or if you want to formulas look prettier in the HTML -# output. When enabled you may also need to install MathJax separately and -# configure the path to it using the MATHJAX_RELPATH option. - -USE_MATHJAX = NO - -# When MathJax is enabled you need to specify the location relative to the -# HTML output directory using the MATHJAX_RELPATH option. The destination -# directory should contain the MathJax.js script. For instance, if the mathjax -# directory is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to -# the MathJax Content Delivery Network so you can quickly see the result without -# installing MathJax. -# However, it is strongly recommended to install a local -# copy of MathJax from http://www.mathjax.org before deployment. - -MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest - -# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension -# names that should be enabled during MathJax rendering. - -MATHJAX_EXTENSIONS = - -# When the SEARCHENGINE tag is enabled doxygen will generate a search box -# for the HTML output. The underlying search engine uses javascript -# and DHTML and should work on any modern browser. Note that when using -# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets -# (GENERATE_DOCSET) there is already a search function so this one should -# typically be disabled. For large projects the javascript based search engine -# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. - -SEARCHENGINE = YES - -# When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a PHP enabled web server instead of at the web client -# using Javascript. Doxygen will generate the search PHP script and index -# file to put on the web server. The advantage of the server -# based approach is that it scales better to large projects and allows -# full text search. The disadvantages are that it is more difficult to setup -# and does not have live searching capabilities. - -SERVER_BASED_SEARCH = NO - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = YES - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. -# Note that when enabling USE_PDFLATEX this option is only used for -# generating bitmaps for formulas in the HTML output, but not in the -# Makefile that is written to the output directory. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = letter - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for -# the generated latex document. The footer should contain everything after -# the last chapter. If it is left blank doxygen will generate a -# standard footer. Notice: only use this tag if you know what you are doing! - -LATEX_FOOTER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = YES - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = YES - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -# If LATEX_SOURCE_CODE is set to YES then doxygen will include -# source code with syntax highlighting in the LaTeX output. -# Note that which sources are shown also depends on other settings -# such as SOURCE_BROWSER. - -LATEX_SOURCE_CODE = NO - -# The LATEX_BIB_STYLE tag can be used to specify the style to use for the -# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See -# http://en.wikipedia.org/wiki/BibTeX for more info. - -LATEX_BIB_STYLE = plain - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load style sheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. -# This is useful -# if you want to understand what is going on. -# On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# pointed to by INCLUDE_PATH will be searched when a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition that -# overrules the definition found in the source code. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all references to function-like macros -# that are alone on a line, have an all uppercase name, and do not end with a -# semicolon, because these will confuse the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. For each -# tag file the location of the external documentation should be added. The -# format of a tag file without this location is as follows: -# -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths -# or URLs. Note that each tag file must have a unique name (where the name does -# NOT include the path). If a tag file is not located in the directory in which -# doxygen is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option also works with HAVE_DOT disabled, but it is recommended to -# install and use dot, since it yields more powerful graphs. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see -# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is -# allowed to run in parallel. When set to 0 (the default) doxygen will -# base this on the number of processors available in the system. You can set it -# explicitly to a value larger than 0 to get control over the balance -# between CPU load and processing speed. - -DOT_NUM_THREADS = 0 - -# By default doxygen will use the Helvetica font for all dot files that -# doxygen generates. When you want a differently looking font you can specify -# the font name using DOT_FONTNAME. You need to make sure dot is able to find -# the font, which can be done by putting it in a standard location or by setting -# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the -# directory containing the font. - -DOT_FONTNAME = Helvetica - -# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. -# The default size is 10pt. - -DOT_FONTSIZE = 10 - -# By default doxygen will tell dot to use the Helvetica font. -# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to -# set the path where dot can find it. - -DOT_FONTPATH = - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If the UML_LOOK tag is enabled, the fields and methods are shown inside -# the class node. If there are many fields or methods and many nodes the -# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS -# threshold limits the number of items for each type to make the size more -# managable. Set this to 0 for no limit. Note that the threshold may be -# exceeded by 50% before the limit is enforced. - -UML_LIMIT_NUM_FIELDS = 10 - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT options are set to YES then -# doxygen will generate a call dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable call graphs -# for selected functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then -# doxygen will generate a caller dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable caller -# graphs for selected functions only using the \callergraph command. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will generate a graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are svg, png, jpg, or gif. -# If left blank png will be used. If you choose svg you need to set -# HTML_FILE_EXTENSION to xhtml in order to make the SVG files -# visible in IE 9+ (other browsers do not have this requirement). - -DOT_IMAGE_FORMAT = png - -# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to -# enable generation of interactive SVG images that allow zooming and panning. -# Note that this requires a modern browser other than Internet Explorer. -# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you -# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files -# visible. Older versions of IE do not have SVG support. - -INTERACTIVE_SVG = NO - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MSCFILE_DIRS tag can be used to specify one or more directories that -# contain msc files that are included in the documentation (see the -# \mscfile command). - -MSCFILE_DIRS = - -# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the -# number of direct children of the root node in a graph is already larger than -# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note -# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. - -DOT_GRAPH_MAX_NODES = 50 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by -# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. - -MAX_DOT_GRAPH_DEPTH = 0 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, because dot on Windows does not -# seem to support this out of the box. Warning: Depending on the platform used, -# enabling this option may lead to badly anti-aliased labels on the edges of -# a graph (i.e. they become hard to read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES diff --git a/Arduino/libraries/SmartThings/examples/stLEDwithNetworkStatus/stLEDwithNetworkStatus.ino b/Arduino/libraries/SmartThings/examples/SmartThings_On_Off_LED_ESP8266WiFi/SmartThings_On_Off_LED_ESP8266WiFi.ino similarity index 56% rename from Arduino/libraries/SmartThings/examples/stLEDwithNetworkStatus/stLEDwithNetworkStatus.ino rename to Arduino/libraries/SmartThings/examples/SmartThings_On_Off_LED_ESP8266WiFi/SmartThings_On_Off_LED_ESP8266WiFi.ino index d516dce4..22a3d3dd 100644 --- a/Arduino/libraries/SmartThings/examples/stLEDwithNetworkStatus/stLEDwithNetworkStatus.ino +++ b/Arduino/libraries/SmartThings/examples/SmartThings_On_Off_LED_ESP8266WiFi/SmartThings_On_Off_LED_ESP8266WiFi.ino @@ -1,54 +1,70 @@ //***************************************************************************** /// @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 |-- -/// |____| |____| -/// |____| +/// Arduino SmartThings Ethernet ESP8266 WiFi On/Off with LED Example +/// +/// Revised by Dan Ogorchock on 2017-02-11 to work with new "SmartThings v2.0" Library +/// +/// Notes: The NodeMCU ESP communicates via WiFi to your home network router, +/// then to the ST Hub, and eventually to the ST cloud servers. +/// /// //***************************************************************************** -#include //TODO need to set due to some weird wire language linker, should we absorb this whole library into smartthings -#include + +#include //***************************************************************************** // 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 +//****************************************************************************************** +//NodeMCU ESP8266 Pin Definitions (makes it much easier as these match the board markings) +//****************************************************************************************** +#define LED_BUILTIN 16 +#define BUILTIN_LED 16 + +#define D0 16 +#define D1 5 +#define D2 4 +#define D3 0 +#define D4 2 +#define D5 14 +#define D6 12 +#define D7 13 +#define D8 15 +#define D9 3 +#define D10 1 + + +#define PIN_LED LED_BUILTIN //Onboard LED //***************************************************************************** // 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 + +//****************************************************************************************** +//ESP8266 WiFi Information CHANGE THIS INFORMATION ACCORDINGLY FOR YOUR NETWORK! +//****************************************************************************************** +String str_ssid = "yourSSIDhere"; // <---You must edit this line! +String str_password = "yourWiFiPasswordhere"; // <---You must edit this line! +IPAddress ip(192, 168, 1, 202); // Device IP Address // <---You must edit this line! +IPAddress gateway(192, 168, 1, 1); //router gateway // <---You must edit this line! +IPAddress subnet(255, 255, 255, 0); //LAN subnet mask // <---You must edit this line! +IPAddress dnsserver(192, 168, 1, 1); //DNS server // <---You must edit this line! +const unsigned int serverPort = 8090; // port to run the http server on + +// Smartthings Hub Information +IPAddress hubIp(192, 168, 1, 149); // smartthings hub ip // <---You must edit this line! +const unsigned int hubPort = 39500; // smartthings hub port + + +//Create a SmartThings Ethernet ESP8266WiFi object +st::SmartThingsESP8266WiFi smartthing(str_ssid, str_password, ip, gateway, subnet, dnsserver, serverPort, hubIp, hubPort, messageCallout); 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 | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | @@ -58,7 +74,6 @@ 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 } @@ -67,48 +82,9 @@ 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 @@ -118,17 +94,22 @@ 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(""); Serial.println("setup.."); // print out 'setup..' on start } + + // 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 + + //Run the SmartThings init() routine to make sure the ThingShield is connected to the ST Hub + smartthing.init(); + + } //***************************************************************************** @@ -136,7 +117,6 @@ void loop() { // run smartthing logic smartthing.run(); - setNetworkStateLED(); } //***************************************************************************** diff --git a/Arduino/libraries/SmartThings/examples/SmartThings_On_Off_LED_EthernetW5100/SmartThings_On_Off_LED_EthernetW5100.ino b/Arduino/libraries/SmartThings/examples/SmartThings_On_Off_LED_EthernetW5100/SmartThings_On_Off_LED_EthernetW5100.ino new file mode 100644 index 00000000..109d3af0 --- /dev/null +++ b/Arduino/libraries/SmartThings/examples/SmartThings_On_Off_LED_EthernetW5100/SmartThings_On_Off_LED_EthernetW5100.ino @@ -0,0 +1,135 @@ +//***************************************************************************** +/// @file +/// @brief +/// Arduino SmartThings Ethernet W5100 On/Off with LED Example +/// +/// Revised by Dan Ogorchock on 2017-02-10 to work with new "SmartThings v2.0" Library +/// +/// Notes: Arduino communicates with both the W5100 and SD card using the SPI bus (through the ICSP header). +/// This is on digital pins 10, 11, 12, and 13 on the Uno and pins 50, 51, and 52 on the Mega. +/// On both boards, pin 10 is used to select the W5100 and pin 4 for the SD card. +/// These pins cannot be used for general I/O. On the Mega, the hardware SS pin, 53, +/// is not used to select either the W5100 or the SD card, but it must be kept as an output +/// or the SPI interface won't work. +/// See https://www.arduino.cc/en/Main/ArduinoEthernetShieldV1 for details on the W5100 Sield +/// +/// +//***************************************************************************** + +#include + +//***************************************************************************** +// 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 +//***************************************************************************** +// "RESERVED" pins for W5100 Ethernet Shield - best to avoid +#define PIN_1O_RESERVED 10 //reserved by W5100 Shield on both UNO and MEGA +#define PIN_11_RESERVED 11 //reserved by W5100 Shield on UNO +#define PIN_12_RESERVED 12 //reserved by W5100 Shield on UNO +#define PIN_13_RESERVED 13 //reserved by W5100 Shield on UNO +#define PIN_50_RESERVED 50 //reserved by W5100 Shield on MEGA +#define PIN_51_RESERVED 51 //reserved by W5100 Shield on MEGA +#define PIN_52_RESERVED 52 //reserved by W5100 Shield on MEGA +#define PIN_53_RESERVED 53 //reserved by W5100 Shield on MEGA + +#define PIN_LED 13 //Onboard LED + +//***************************************************************************** +// 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 + +//****************************************************************************************** +//W5100 Ethernet Shield Information CHANGE THIS INFORMATION ACCORDINGLY FOR YOUR NETWORK! +//****************************************************************************************** +byte mac[] = {0x01,0x02,0x03,0x04,0x05,0x06}; //physical MAC address, MAKE SURE IT's UNIQUE // <---You must edit this line! +IPAddress ip(192, 168, 1, 204); // Device IP Address // <---You must edit this line! +IPAddress gateway(192, 168, 1, 1); //router gateway // <---You must edit this line! +IPAddress subnet(255, 255, 255, 0); //LAN subnet mask // <---You must edit this line! +IPAddress dnsserver(192, 168, 1, 1); //DNS server // <---You must edit this line! +const unsigned int serverPort = 8090; // port to run the http server on + +// Smartthings hub information +IPAddress hubIp(192,168,1,149); // smartthings hub ip // <---You must edit this line! +const unsigned int hubPort = 39500; // smartthings hub port + +//Create a SmartThings Ethernet W5100 object +st::SmartThingsEthernetW5100 smartthing(mac, ip, gateway, subnet, dnsserver, serverPort, hubIp, hubPort, messageCallout); + +bool isDebugEnabled; // enable or disable debug in this example +int stateLED; // state to track last set value of LED + +//***************************************************************************** +// 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.send("on"); // send message to cloud +} + +//***************************************************************************** +void off() +{ + stateLED = 0; // set state to 0 (off) + digitalWrite(PIN_LED, LOW); // turn LED off + smartthing.send("off"); // send message to cloud +} + +//***************************************************************************** +// 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 + + // 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 + + //Run the SmartThings init() routine to make sure the ThingShield is connected to the ST Hub + smartthing.init(); + + 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(); +} + +//***************************************************************************** +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(); + } +} + diff --git a/Arduino/libraries/SmartThings/examples/stLED/stLED.ino b/Arduino/libraries/SmartThings/examples/SmartThings_On_Off_LED_ThingShield/SmartThings_On_Off_LED_ThingShield.ino similarity index 65% rename from Arduino/libraries/SmartThings/examples/stLED/stLED.ino rename to Arduino/libraries/SmartThings/examples/SmartThings_On_Off_LED_ThingShield/SmartThings_On_Off_LED_ThingShield.ino index 3eef3df9..d41a8b17 100644 --- a/Arduino/libraries/SmartThings/examples/stLED/stLED.ino +++ b/Arduino/libraries/SmartThings/examples/SmartThings_On_Off_LED_ThingShield/SmartThings_On_Off_LED_ThingShield.ino @@ -1,15 +1,27 @@ //***************************************************************************** /// @file /// @brief -/// Arduino SmartThings Shield LED Example -/// @note +/// Arduino SmartThings ThingShield On/Off with LED Example +/// +/// Revised by Dan Ogorchock on 2017-02-10 to work with new "SmartThings v2.0" Library +/// -Now supports automatic selectic of SoftwareSerial or HardwareSerial constructor +/// depending on the Arduino Model. +/// -If using an Arduino UNO R3, be sure to set the ThingShield switch to the D2/D3 position +/// -If using an Arduino Leonardo, be sure to set the ThingShield switch to the D0/D1 position +/// -If using an Arduino MEGA 2560, bbe sure to set the ThingShield switch to the D2/D3 position AND +/// connect jumper wires between pins 2 & 14 as well as between pins 3 & 15. +/// +/// DO NOT USE PINS 0,1,2,3,6 for I/O in your sketch as pins 0,1,2,3 are used by the ThingShield +/// and USB communications to your computer. Pin 6 is reserved by the ThingShield. +/// +/// @note UNO R3 Pins /// ______________ /// | | /// | SW[] | /// |[]RST | /// | AREF |-- /// | GND |-- -/// | 13 |--X LED +/// | 13 |--X Onboard LED /// | 12 |-- /// | 11 |-- /// --| 3.3V 10 |-- @@ -17,19 +29,18 @@ /// --| GND 8 |-- /// --| GND | /// --| Vin 7 |-- -/// | 6 |-- +/// | 6 |--Reserved /// --| A0 5 |-- /// --| A1 ( ) 4 |-- /// --| A2 3 |--X THING_RX /// --| A3 ____ 2 |--X THING_TX -/// --| A4 | | 1 |-- -/// --| A5 | | 0 |-- +/// --| A4 | | 1 |--X THING_RX +/// --| A5 | | 0 |--X THING_RX /// |____| |____| /// |____| /// //***************************************************************************** -#include //TODO need to set due to some weird wire language linker, should we absorb this whole library into smartthings -#include +#include //***************************************************************************** // Pin Definitions | | | | | | | | | | | | | | | | | | | | | | | | | | | | | @@ -44,7 +55,17 @@ // 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 + + #if defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_MINI) //Arduino UNO, NANO, MINI + st::SmartThingsThingShield smartthing(PIN_THING_RX, PIN_THING_TX, messageCallout); //Use Software Serial constructor + #elif defined(ARDUINO_AVR_LEONARDO) //Arduino Leonardo + st::SmartThingsThingShield smartthing(&Serial1, messageCallout); //Use Hardware Serial constructor w/Serial1 + #elif defined(ARDUINO_AVR_MEGA) || defined(ARDUINO_AVR_MEGA2560) //Arduino MEGA 1280 or 2560 + st::SmartThingsThingShield smartthing(&Serial3, messageCallout); //Use Hardware Serial constructor w/Serial3 + #else + //assume user is using an UNO for the unknown case + st::SmartThingsThingShield smartthing(PIN_THING_RX, PIN_THING_TX, messageCallout); //Use Software Serial constructor + #endif bool isDebugEnabled; // enable or disable debug in this example int stateLED; // state to track last set value of LED @@ -84,6 +105,9 @@ void setup() pinMode(PIN_LED, OUTPUT); // define PIN_LED as an output digitalWrite(PIN_LED, LOW); // set value to LOW (off) to match stateLED=0 + //Run the SmartThings init() routine to make sure the ThingShield is connected to the ST Hub + smartthing.init(); + if (isDebugEnabled) { // setup debug serial port Serial.begin(9600); // setup serial with a baud rate of 9600 diff --git a/Arduino/libraries/SmartThings/extras/On_Off_LED_Ethernet.device.groovy b/Arduino/libraries/SmartThings/extras/On_Off_LED_Ethernet.device.groovy new file mode 100644 index 00000000..f1a6b69d --- /dev/null +++ b/Arduino/libraries/SmartThings/extras/On_Off_LED_Ethernet.device.groovy @@ -0,0 +1,111 @@ +/** + * Copyright 2015 SmartThings (original) + * + * 2017-02-11 Dan Ogorchock - Since SmartThings has abandoned the ThingShield, I have created a new + * Arduino "SmartThings" library with support for the ThingShield, + * W5100 Ethernet Shield, and the NodeMCU ESP8266 Board for connectivity to + * the SmartThings cloud. This file is to be used with the On/Off Ethernet W5100 + * and ESP8266 examples found in this new library which can be found at + * + * https://github.com/DanielOgorchock/ST_Anything/tree/master/Arduino/libraries/SmartThings + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License + * for the specific language governing permissions and limitations under the License. + * + */ +metadata { + definition (name: "On/Off Ethernet", namespace: "ogiewon", author: "Dan Ogorchock") { + capability "Actuator" + capability "Switch" + capability "Sensor" + } + + // Simulator metadata + simulator { + + } + + // Preferences + preferences { + input "ip", "text", title: "Arduino IP Address", description: "ip", required: true, displayDuringSetup: true + input "port", "text", title: "Arduino Port", description: "port", required: true, displayDuringSetup: true + input "mac", "text", title: "Arduino MAC Addr", description: "mac", required: true, displayDuringSetup: true + } + // UI tile definitions + tiles { + standardTile("switch", "device.switch", width: 2, height: 2, canChangeIcon: true, canChangeBackground: true) { + state "on", label: '${name}', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#79b821" + state "off", label: '${name}', action: "switch.on", icon: "st.switches.switch.off", backgroundColor: "#ffffff" + } + standardTile("configure", "device.configure", inactiveLabel: false, decoration: "flat") { + state "configure", label:'', action:"configuration.configure", icon:"st.secondary.configure" + } + + main (["switch"]) + details (["switch","configure"]) + } +} + +// parse events into attributes +def parse(String description) { + //log.debug "Parsing '${description}'" + def msg = parseLanMessage(description) + def headerString = msg.header + + if (!headerString) { + //log.debug "headerstring was null for some reason :(" + } + + def bodyString = msg.body + + if (bodyString) { + //log.debug "BodyString: $bodyString" + def value = bodyString + def name = value in ["on","off"] ? "switch" : null + def result = createEvent(name: name, value: value) + log.debug "Parse returned ${result?.descriptionText}" + return result + } +} + +private getHostAddress() { + def ip = settings.ip + def port = settings.port + + log.debug "Using ip: ${ip} and port: ${port} for device: ${device.id}" + return ip + ":" + port +} + +def sendEthernet(message) { + log.debug "Executing 'sendEthernet' ${message}" + new physicalgraph.device.HubAction( + method: "POST", + path: "/${message}?", + headers: [ HOST: "${getHostAddress()}" ] + ) +} + +// Commands sent to the device +def on() { + log.debug "Sending 'on'" + sendEthernet("on") +} + +def off() { + log.debug "Sending 'off'" + sendEthernet("off") +} + +def configure() { + log.debug "Executing 'configure'" + if(device.deviceNetworkId!=settings.mac) { + log.debug "setting device network id" + device.deviceNetworkId = settings.mac + } +} \ No newline at end of file diff --git a/Arduino/libraries/SmartThings/extras/On_Off_LED_ThingShield.device.groovy b/Arduino/libraries/SmartThings/extras/On_Off_LED_ThingShield.device.groovy new file mode 100644 index 00000000..51f707ae --- /dev/null +++ b/Arduino/libraries/SmartThings/extras/On_Off_LED_ThingShield.device.groovy @@ -0,0 +1,67 @@ +/** + * Copyright 2015 SmartThings (original) + * + * 2017-02-11 Dan Ogorchock - Since SmartThings has abandoned the ThingShield, I have created a new + * Arduino "SmartThings" library with support for the ThingShield, + * W5100 Ethernet Shield, and the NodeMCU ESP8266 Board for connectivity to + * the SmartThings cloud. This file is to be used with the On/Off ThingShield + * example found in this new library which can be found at + * + * https://github.com/DanielOgorchock/ST_Anything/tree/master/Arduino/libraries/SmartThings + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License + * for the specific language governing permissions and limitations under the License. + * + */ +metadata { + definition (name: "On/Off ThingShield", namespace: "ogiewon", author: "Dan Ogorchock") { + capability "Actuator" + capability "Switch" + capability "Sensor" + } + + // Simulator metadata + simulator { + status "on": "catchall: 0104 0000 01 01 0040 00 0A21 00 00 0000 0A 00 0A6F6E" + status "off": "catchall: 0104 0000 01 01 0040 00 0A21 00 00 0000 0A 00 0A6F6666" + + // reply messages + reply "raw 0x0 { 00 00 0a 0a 6f 6e }": "catchall: 0104 0000 01 01 0040 00 0A21 00 00 0000 0A 00 0A6F6E" + reply "raw 0x0 { 00 00 0a 0a 6f 66 66 }": "catchall: 0104 0000 01 01 0040 00 0A21 00 00 0000 0A 00 0A6F6666" + } + + // UI tile definitions + tiles { + standardTile("switch", "device.switch", width: 2, height: 2, canChangeIcon: true, canChangeBackground: true) { + state "on", label: '${name}', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#79b821" + state "off", label: '${name}', action: "switch.on", icon: "st.switches.switch.off", backgroundColor: "#ffffff" + } + + main "switch" + details "switch" + } +} + +// Parse incoming device messages to generate events +def parse(String description) { + def value = zigbee.parse(description)?.text + def name = value in ["on","off"] ? "switch" : null + def result = createEvent(name: name, value: value) + log.debug "Parse returned ${result?.descriptionText}" + return result +} + +// Commands sent to the device +def on() { + zigbee.smartShield(text: "on").format() +} + +def off() { + zigbee.smartShield(text: "off").format() +} \ No newline at end of file diff --git a/Arduino/libraries/SmartThings/info.txt b/Arduino/libraries/SmartThings/info.txt index b9f2faf8..f1c38789 100644 --- a/Arduino/libraries/SmartThings/info.txt +++ b/Arduino/libraries/SmartThings/info.txt @@ -13,10 +13,15 @@ -------------------------------------------------------------------------------------------------- | 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/10/2017 (v2.0.0) do ~ Totally rearchitected C++ Class structure to support ThingShield, W5100 Ethernet, and ESP8266 WiFi + + Added new init() function to allow object to connect to network at runtime in sketch setup() routine + + Revised On/Off Thingshield example to use the new library class, SmartThingsThingShield + + Added On/Off W5100 example to use the new SmartThingsEthernetW5100 class + + Added On/Off ESP8266WiFi example to use the new SmartThingsESP8266WiFi class +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 diff --git a/Arduino/libraries/SmartThings/keywords.txt b/Arduino/libraries/SmartThings/keywords.txt index 0d9d186e..7661b6d5 100644 --- a/Arduino/libraries/SmartThings/keywords.txt +++ b/Arduino/libraries/SmartThings/keywords.txt @@ -2,15 +2,19 @@ # Data Types ####################################### SmartThings KEYWORD1 +SmartThingsThingShield KEYWORD1 +SmartThingsEthernet KEYWORD1 +SmartThingsEthernetW5100 KEYWORD1 +SmartThingsESP8266WiFi KEYWORD1 SmartThingsCallout_t KEYWORD1 SmartThingsNetworkState_t KEYWORD1 -SmartThingsSerialType_t KEYWORD1 ####################################### # Public Methods / Functions ####################################### run KEYWORD2 send KEYWORD2 +init KEYWORD2 shieldSetLED KEYWORD2 shieldFindNetwork KEYWORD2 shieldLeaveNetwork KEYWORD2 diff --git a/Arduino/libraries/SmartThings/library.properties b/Arduino/libraries/SmartThings/library.properties new file mode 100644 index 00000000..ddc911c2 --- /dev/null +++ b/Arduino/libraries/SmartThings/library.properties @@ -0,0 +1,10 @@ +name=SmartThings +version=2.0 +author=Dan G Ogorchock , Daniel J Ogorchock +maintainer=Dan G Ogorchock +sentence=A library that provides multiple methods to connect to SmartThings. +paragraph=This is a new and improved version of the SmartThings libray which now supports the original ThingShield, the W5100 Ethernet shield, as well as the NodeMCU ESP8266 WiFi board. +category=Communication +url=https://github.com/DanielOgorchock/ST_Anything/tree/master/Arduino/libraries/SmartThings +architectures=avr,esp8266 +includes= \ No newline at end of file diff --git a/Groovy/ST_Anything_Alarm_Panel/ST_Anything_Alarm_Panel.device.groovy b/Groovy/ST_Anything_Alarm_Panel/ST_Anything_Alarm_Panel.device.groovy deleted file mode 100644 index be4073fe..00000000 --- a/Groovy/ST_Anything_Alarm_Panel/ST_Anything_Alarm_Panel.device.groovy +++ /dev/null @@ -1,193 +0,0 @@ -/** - * ST_Anything_Alarm_Panel Device Type - ST_Anything_Alarm_Panel.device.groovy - * - * Copyright 2015 Daniel Ogorchock - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License - * for the specific language governing permissions and limitations under the License. - * - * Change History: - * - * Date Who What - * ---- --- ---- - * 2015-12-06 Dan Ogorchock Original Creation - * - * - */ - -metadata { - definition (name: "ST_Anything_Alarm_Panel", namespace: "ogiewon", author: "Daniel Ogorchock") { - capability "Actuator" - capability "Alarm" - capability "Contact Sensor" - capability "Motion Sensor" - capability "Sensor" - capability "Smoke Detector" - - - attribute "motion1", "string" - attribute "motion2", "string" - attribute "contact1", "string" - attribute "contact2", "string" - attribute "contact3", "string" - attribute "contact4", "string" - attribute "contact5", "string" - attribute "contact6", "string" - attribute "contact7", "string" - attribute "contact8", "string" - attribute "contact9", "string" - attribute "contact10", "string" - attribute "smoke1", "string" - attribute "smoke2", "string" - attribute "smoke3", "string" - - command "test" - } - - simulator { - - } - - // Preferences - - // tile definitions - tiles { - standardTile("motion1", "device.motion1", width: 1, height: 1) { - state("active", label:'motion', icon:"st.motion.motion.active", backgroundColor:"#53a7c0") - state("inactive", label:'no motion', icon:"st.motion.motion.inactive", backgroundColor:"#ffffff") - } - standardTile("motion2", "device.motion2", width: 1, height: 1) { - state("active", label:'motion', icon:"st.motion.motion.active", backgroundColor:"#53a7c0") - state("inactive", label:'no motion', icon:"st.motion.motion.inactive", backgroundColor:"#ffffff") - } - - - standardTile("contact1", "device.contact1", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) { - state("open", label:'CS1 ${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e") - state("closed", label:'CS1 ${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821") - } - standardTile("contact2", "device.contact2", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) { - state("open", label:'CS2 ${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e") - state("closed", label:'CS2 ${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821") - } - standardTile("contact3", "device.contact3", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) { - state("open", label:'CS3 ${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e") - state("closed", label:'CS3 ${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821") - } - standardTile("contact4", "device.contact4", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) { - state("open", label:'CS4 ${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e") - state("closed", label:'CS4 ${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821") - } - standardTile("contact5", "device.contact5", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) { - state("open", label:'CS5 ${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e") - state("closed", label:'CS5 ${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821") - } - standardTile("contact6", "device.contact6", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) { - state("open", label:'CS6 ${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e") - state("closed", label:'CS6 ${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821") - } - standardTile("contact7", "device.contact7", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) { - state("open", label:'CS7 ${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e") - state("closed", label:'CS7 ${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821") - } - standardTile("contact8", "device.contact8", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) { - state("open", label:'CS8 ${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e") - state("closed", label:'CS8 ${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821") - } - standardTile("contact9", "device.contact9", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) { - state("open", label:'CS9 ${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e") - state("closed", label:'CS9 ${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821") - } - standardTile("contact10", "device.contact10", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) { - state("open", label:'CS10 ${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e") - state("closed", label:'CS10 ${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821") - } - - standardTile("smoke1", "device.smoke1", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) { - state("clear", label:"SM1 Clear", icon:"st.alarm.smoke.clear", backgroundColor:"#ffffff", action:"smoke") - state("detected", label:"SM2 Smoke!", icon:"st.alarm.smoke.smoke", backgroundColor:"#e86d13", action:"clear") - } - standardTile("smoke2", "device.smoke2", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) { - state("clear", label:"SM2 Clear", icon:"st.alarm.smoke.clear", backgroundColor:"#ffffff", action:"smoke") - state("detected", label:"SM2 Smoke!", icon:"st.alarm.smoke.smoke", backgroundColor:"#e86d13", action:"clear") - } - standardTile("smoke3", "device.smoke3", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) { - state("clear", label:"SM3 Clear", icon:"st.alarm.smoke.clear", backgroundColor:"#ffffff", action:"smoke") - state("detected", label:"SM3 Smoke!", icon:"st.alarm.smoke.smoke", backgroundColor:"#e86d13", action:"clear") - } - - standardTile("alarm", "device.alarm", width: 1, height: 1) { - state "off", label:'off', action:'alarm.siren', icon:"st.alarm.alarm.alarm", backgroundColor:"#ffffff" - state "strobe", label:'', action:'alarm.off', icon:"st.secondary.strobe", backgroundColor:"#cccccc" - state "siren", label:'siren!', action:'alarm.off', icon:"st.alarm.beep.beep", backgroundColor:"#e86d13" - state "both", label:'alarm!', action:'alarm.off', icon:"st.alarm.alarm.alarm", backgroundColor:"#e86d13" - } - standardTile("test", "device.alarm", inactiveLabel: false, decoration: "flat") { - state "default", label:'', action:"test", icon:"st.secondary.test" - } - standardTile("off", "device.alarm", , width: 1, height: 1) { - state "default", label:'Alarm', action:"alarm.off", icon:"st.secondary.off" - } - - main (["alarm"]) - details(["alarm","test","off",,"smoke1","smoke2","smoke3","motion1","motion2","contact1","contact2","contact3","contact4","contact5","contact6","contact7","contact8","contact9","contact10"]) - } -} - -//Map parse(String description) { -def parse(String description) { - def msg = zigbee.parse(description)?.text - log.debug "Parse got '${msg}'" - - def parts = msg.split(" ") - def name = parts.length>0?parts[0].trim():null - def value = parts.length>1?parts[1].trim():null - - name = value != "ping" ? name : null - - //if (name == "temperature") - //{ - // value = fahrenheitToCelsius(value.toDouble()) - //} - - def result = createEvent(name: name, value: value, isStateChange: true) - - log.debug result - - return result -} - -def off() { - log.debug "Executing 'alarm off'" - zigbee.smartShield(text: "alarm off").format() -} - -def strobe() { - log.debug "Executing 'alarm strobe'" - zigbee.smartShield(text: "alarm strobe").format() -} - -def siren() { - log.debug "Executing 'alarm siren'" - zigbee.smartShield(text: "alarm siren").format() -} - -def both() { - log.debug "Executing 'alarm both'" - zigbee.smartShield(text: "alarm both").format() -} - -def test() { - log.debug "Executing 'alarm test'" - [ - zigbee.smartShield(text: "alarm siren").format(), - "delay 3000", - zigbee.smartShield(text: "alarm off").format() - ] -} \ No newline at end of file diff --git a/Groovy/ST_Anything_Alarm_Panel/ST_Anything_Example_Multiplexer.smartapp.groovy b/Groovy/ST_Anything_Alarm_Panel/ST_Anything_Example_Multiplexer.smartapp.groovy deleted file mode 100644 index 52e970b1..00000000 --- a/Groovy/ST_Anything_Alarm_Panel/ST_Anything_Example_Multiplexer.smartapp.groovy +++ /dev/null @@ -1,149 +0,0 @@ -/** - * ST_Anything Example Multiplexer - ST_Anything_Example_Multiplexer.smartapp.groovy - * - * Copyright 2016 Daniel Ogorchock - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License - * for the specific language governing permissions and limitations under the License. - * - * Change History: - * - * Date Who What - * ---- --- ---- - * 2016-10-25 Dan Ogorchock Original Creation - * - */ - -definition( - name: "ST_Anything Example Multiplexer", - namespace: "ogiewon", - author: "Daniel Ogorchock", - description: "Connects single Arduino with multiple similar devices to their virtual device counterparts.", - category: "My Apps", - iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", - iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png", - iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png") - -preferences { - - section("Select the Virtual Contact Sensor devices") { - input "contact1", title: "Virtual Contact Sensor 1", "capability.contactSensor" - input "contact2", title: "Virtual Contact Sensor 2", "capability.contactSensor" - } - - section("Select the Virtual Motion Sensor devices") { - input "motion1", title: "Virtual Motion Sensor 1", "capability.motionSensor" - input "motion2", title: "Virtual Motion Sensor 2", "capability.motionSensor" - } - - section("Select the Arduino device") { - input "arduino", "capability.contactSensor" - } -} - -def installed() { - log.debug "Installed with settings: ${settings}" - subscribe() -} - -def updated() { - log.debug "Updated with settings: ${settings}" - unsubscribe() - subscribe() -} - -def subscribe() { - - subscribe(arduino, "contact1.open", contact1Open) - subscribe(arduino, "contact1.closed", frontDoorClosed) - - subscribe(arduino, "contact2.open", contact2Open) - subscribe(arduino, "contact2.closed", contact3Closed) - - subscribe(arduino, "motion1.active", motion1Active) - subscribe(arduino, "motion1.inactive", motion1Inactive) - - subscribe(arduino, "motion2.active", motion2Active) - subscribe(arduino, "motion2.inactive", motion2Inactive) - -} - - -// --- contact1 ------------------------------------------------------ -def contact1Open(evt) -{ - if (contact1.currentValue("contact") != "open") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - contact1.openme() - } -} - -def contact1Closed(evt) -{ - if (contact1.currentValue("contact") != "closed") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - contact1.closeme() - } -} - -// --- contact2 ------------------------------------------------------ -def contact2Open(evt) -{ - if (contact2.currentValue("contact") != "open") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - contact2.openme() - } -} - -def contact2Closed(evt) -{ - if (contact2.currentValue("contact") != "closed") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - contact2.closeme() - } -} - -// --- motion1 ------------------------------------------------------ -def motion1Active(evt) -{ - if (motion1.currentValue("motion") != "active") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - motion1.active() - } -} - -def motion1Inactive(evt) -{ - if (motion1.currentValue("motion") != "inactive") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - motion1.inactive() - } -} - -// --- motion2 ------------------------------------------------------ -def motion2Active(evt) -{ - if (motion2.currentValue("motion") != "active") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - motion2.active() - } -} - -def motion2Inactive(evt) -{ - if (motion2.currentValue("motion") != "inactive") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - motion2.inactive() - } -} - - -def initialize() { - // TODO: subscribe to attributes, devices, locations, etc. -} \ No newline at end of file diff --git a/Groovy/ST_Anything_Doors/DeviceTypes/ST_Anything_Doors.device.groovy b/Groovy/ST_Anything_Doors_ThingShield/DeviceHandlers/ST_Anything_Doors_ThingShield.device.groovy similarity index 100% rename from Groovy/ST_Anything_Doors/DeviceTypes/ST_Anything_Doors.device.groovy rename to Groovy/ST_Anything_Doors_ThingShield/DeviceHandlers/ST_Anything_Doors_ThingShield.device.groovy diff --git a/Groovy/ST_Anything_Doors/SmartApps/ST_Anything_Doors_Multiplexer.smartapp.groovy b/Groovy/ST_Anything_Doors_ThingShield/SmartApps/ST_Anything_Doors_Multiplexer.smartapp.groovy similarity index 100% rename from Groovy/ST_Anything_Doors/SmartApps/ST_Anything_Doors_Multiplexer.smartapp.groovy rename to Groovy/ST_Anything_Doors_ThingShield/SmartApps/ST_Anything_Doors_Multiplexer.smartapp.groovy diff --git a/Groovy/ST_Anything_Doors_Windows/DeviceTypes/ST_Anything_Doors_Windows.device.groovy b/Groovy/ST_Anything_Doors_Windows/DeviceTypes/ST_Anything_Doors_Windows.device.groovy deleted file mode 100644 index 980054a2..00000000 --- a/Groovy/ST_Anything_Doors_Windows/DeviceTypes/ST_Anything_Doors_Windows.device.groovy +++ /dev/null @@ -1,142 +0,0 @@ -/** - * ST_Anything_Doors_Windows Device Type - ST_Anything_Doors_Windows.device.groovy - * - * Copyright 2015 Daniel Ogorchock - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License - * for the specific language governing permissions and limitations under the License. - * - * Change History: - * - * Date Who What - * ---- --- ---- - * 2015-10-31 Dan Ogorchock Original Creation - * - * - */ - -metadata { - definition (name: "ST_Anything_Doors_Windows", namespace: "ogiewon", author: "Daniel Ogorchock") { - capability "Contact Sensor" - capability "Motion Sensor" - capability "Sensor" - - attribute "frontDoor", "string" - attribute "bedroomDoor", "string" - attribute "kitchenDoor", "string" - attribute "garageDoor", "string" - attribute "kitchenWindow1", "string" - attribute "kitchenWindow2", "string" - attribute "kitchenWindow3", "string" - attribute "masterWindow1", "string" - attribute "masterWindow2", "string" - attribute "officeWindow1", "string" - attribute "officeWindow2", "string" - attribute "guestWindow1", "string" - attribute "guestWindow2", "string" - } - - simulator { - status "on": "catchall: 0104 0000 01 01 0040 00 0A21 00 00 0000 0A 00 0A6F6E" - status "off": "catchall: 0104 0000 01 01 0040 00 0A21 00 00 0000 0A 00 0A6F6666" - - // reply messages - reply "raw 0x0 { 00 00 0a 0a 6f 6e }": "catchall: 0104 0000 01 01 0040 00 0A21 00 00 0000 0A 00 0A6F6E" - reply "raw 0x0 { 00 00 0a 0a 6f 66 66 }": "catchall: 0104 0000 01 01 0040 00 0A21 00 00 0000 0A 00 0A6F6666" - } - - // Preferences - - // tile definitions - tiles { - standardTile("frontDoor", "device.frontDoor", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) { - state("open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e") - state("closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821") - } - standardTile("kitchenDoor", "device.kitchenDoor", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) { - state("open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e") - state("closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821") - } - standardTile("garageDoor", "device.garageDoor", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) { - state("open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e") - state("closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821") - } - standardTile("bedroomDoor", "device.bedroomDoor", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) { - state("open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e") - state("closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821") - } - standardTile("kitchenWindow1", "device.kitchenWindow1", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) { - state("open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e") - state("closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821") - } - standardTile("kitchenWindow2", "device.kitchenWindow2", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) { - state("open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e") - state("closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821") - } - standardTile("kitchenWindow3", "device.kitchenWindow3", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) { - state("open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e") - state("closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821") - } - standardTile("masterWindow1", "device.masterWindow1", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) { - state("open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e") - state("closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821") - } - standardTile("masterWindow2", "device.masterWindow2", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) { - state("open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e") - state("closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821") - } - standardTile("officeWindow1", "device.officeWindow1", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) { - state("open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e") - state("closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821") - } - standardTile("officeWindow2", "device.officeWindow2", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) { - state("open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e") - state("closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821") - } - standardTile("guestWindow1", "device.guestWindow1", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) { - state("open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e") - state("closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821") - } - standardTile("guestWindow2", "device.guestWindow2", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) { - state("open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e") - state("closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821") - } - - standardTile("motion", "device.motion", width: 1, height: 1) { - state("active", label:'motion', icon:"st.motion.motion.active", backgroundColor:"#53a7c0") - state("inactive", label:'no motion', icon:"st.motion.motion.inactive", backgroundColor:"#ffffff") - } - - main (["motion"]) - details(["motion","frontDoor","kitchenDoor","garageDoor","bedroomDoor","kitchenWindow1","kitchenWindow2","kitchenWindow3","masterWindow1","masterWindow2","officeWindow1","officeWindow2","guestWindow1","guestWindow2"]) - } -} - -//Map parse(String description) { -def parse(String description) { - def msg = zigbee.parse(description)?.text - log.debug "Parse got '${msg}'" - - def parts = msg.split(" ") - def name = parts.length>0?parts[0].trim():null - def value = parts.length>1?parts[1].trim():null - - name = value != "ping" ? name : null - - //if (name == "temperature") - //{ - // value = fahrenheitToCelsius(value.toDouble()) - //} - - def result = createEvent(name: name, value: value, isStateChange: true) - - log.debug result - - return result -} diff --git a/Groovy/ST_Anything_Doors_Windows/SmartApps/ST_Anything_Doors_Windows_Multiplexer.smartapp.groovy b/Groovy/ST_Anything_Doors_Windows/SmartApps/ST_Anything_Doors_Windows_Multiplexer.smartapp.groovy deleted file mode 100644 index 0bc931d4..00000000 --- a/Groovy/ST_Anything_Doors_Windows/SmartApps/ST_Anything_Doors_Windows_Multiplexer.smartapp.groovy +++ /dev/null @@ -1,339 +0,0 @@ -/** - * ST_Anything Doors & Windows Multiplexer - ST_Anything_Doors_Windows_Multiplexer.smartapp.groovy - * - * Copyright 2015 Daniel Ogorchock - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License - * for the specific language governing permissions and limitations under the License. - * - * Change History: - * - * Date Who What - * ---- --- ---- - * 2015-10-31 Dan Ogorchock Original Creation - * - */ - -definition( - name: "ST_Anything Doors & Windows Multiplexer", - namespace: "ogiewon", - author: "Daniel Ogorchock", - description: "Connects single Arduino with multiple ContactSensor devices to their virtual device counterparts.", - category: "My Apps", - iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", - iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png", - iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png") - -preferences { - - section("Select the House Doors (Virtual Contact Sensor devices)") { - input "frontdoor", title: "Virtual Contact Sensor for Front Door", "capability.contactSensor" - input "bedroomdoor", title: "Virtual Contact Sensor for Bedroom Door", "capability.contactSensor" - input "kitchendoor", title: "Virtual Contact Sensor for Kitchen Door", "capability.contactSensor" - input "garagedoor", title: "Virtual Contact Sensor for Garage Door", "capability.contactSensor" - } - - section("Select the Windows (Virtual Contact Sensor devices)") { - input "kitchenwindow1", title: "Virtual Contact Sensor for Kitchen Window 1", "capability.contactSensor" - input "kitchenwindow2", title: "Virtual Contact Sensor for Kitchen Window 2", "capability.contactSensor" - input "kitchenwindow3", title: "Virtual Contact Sensor for Kitchen Window 3", "capability.contactSensor" - input "masterwindow1", title: "Virtual Contact Sensor for Master Window 1", "capability.contactSensor" - input "masterwindow2", title: "Virtual Contact Sensor for Master Window 2", "capability.contactSensor" - input "officewindow1", title: "Virtual Contact Sensor for Office Window 1", "capability.contactSensor" - input "officewindow2", title: "Virtual Contact Sensor for Office Window 2", "capability.contactSensor" - input "guestwindow1", title: "Virtual Contact Sensor for Guest Window 1", "capability.contactSensor" - input "guestwindow2", title: "Virtual Contact Sensor for Guest Window 2", "capability.contactSensor" - } - - section("Select the Arduino ST_Anything_Doors_Windows device") { - input "arduino", "capability.contactSensor" - } -} - -def installed() { - log.debug "Installed with settings: ${settings}" - subscribe() -} - -def updated() { - log.debug "Updated with settings: ${settings}" - unsubscribe() - subscribe() -} - -def subscribe() { - - - subscribe(arduino, "frontDoor.open", frontDoorOpen) - subscribe(arduino, "frontDoor.closed", frontDoorClosed) - - subscribe(arduino, "bedroomDoor.open", bedroomDoorOpen) - subscribe(arduino, "bedroomDoor.closed", bedroomDoorClosed) - - subscribe(arduino, "kitchenDoor.open", kitchenDoorOpen) - subscribe(arduino, "kitchenDoor.closed", kitchenDoorClosed) - - subscribe(arduino, "garageDoor.open", garageDoorOpen) - subscribe(arduino, "garageDoor.closed", garageDoorClosed) - - subscribe(arduino, "kitchenWindow1.open", kitchenWindow1Open) - subscribe(arduino, "kitchenWindow1.closed", kitchenWindow1Closed) - - subscribe(arduino, "kitchenWindow2.open", kitchenWindow2Open) - subscribe(arduino, "kitchenWindow2.closed", kitchenWindow2Closed) - - subscribe(arduino, "kitchenWindow3.open", kitchenWindow3Open) - subscribe(arduino, "kitchenWindow3.closed", kitchenWindow3Closed) - - subscribe(arduino, "masterWindow1.open", masterWindow1Open) - subscribe(arduino, "masterWindow1.closed", masterWindow1Closed) - - subscribe(arduino, "masterWindow2.open", masterWindow2Open) - subscribe(arduino, "masterWindow2.closed", masterWindow2Closed) - - subscribe(arduino, "officeWindow1.open", officeWindow1Open) - subscribe(arduino, "officeWindow1.closed", officeWindow1Closed) - - subscribe(arduino, "officeWindow2.open", officeWindow2Open) - subscribe(arduino, "officeWindow2.closed", officeWindow2Closed) - - subscribe(arduino, "guestWindow1.open", guestWindow1Open) - subscribe(arduino, "guestWindow1.closed", guestWindow1Closed) - - subscribe(arduino, "guestWindow2.open", guestWindow2Open) - subscribe(arduino, "guestWindow2.closed", guestWindow2Closed) - -} - -// --- Front Door --- -def frontDoorOpen(evt) -{ - if (frontdoor.currentValue("contact") != "open") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - frontdoor.openme() - } -} - -def frontDoorClosed(evt) -{ - if (frontdoor.currentValue("contact") != "closed") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - frontdoor.closeme() - } -} - -// --- bedroom Door --- -def bedroomDoorOpen(evt) -{ - if (bedroomdoor.currentValue("contact") != "open") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - bedroomdoor.openme() - } -} - -def bedroomDoorClosed(evt) -{ - if (bedroomdoor.currentValue("contact") != "closed") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - bedroomdoor.closeme() - } -} - -// --- Kitchen Door --- -def kitchenDoorOpen(evt) -{ - if (kitchendoor.currentValue("contact") != "open") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - kitchendoor.openme() - } -} - -def kitchenDoorClosed(evt) -{ - if (kitchendoor.currentValue("contact") != "closed") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - kitchendoor.closeme() - } -} - - -// --- Garage Door --- -def garageDoorOpen(evt) -{ - if (garagedoor.currentValue("contact") != "open") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - garagedoor.openme() - } -} - -def garageDoorClosed(evt) -{ - if (garagedoor.currentValue("contact") != "closed") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - garagedoor.closeme() - } -} - -// --- Kitchen Window 1 --- -def kitchenWindow1Open(evt) -{ - if (kitchenwindow1.currentValue("contact") != "open") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - kitchenwindow1.openme() - } -} - -def kitchenWindow1Closed(evt) -{ - if (kitchenwindow1.currentValue("contact") != "closed") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - kitchenwindow1.closeme() - } -} - -// --- Kitchen Window 2 --- -def kitchenWindow2Open(evt) -{ - if (kitchenwindow2.currentValue("contact") != "open") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - kitchenwindow2.openme() - } -} - -def kitchenWindow2Closed(evt) -{ - if (kitchenwindow2.currentValue("contact") != "closed") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - kitchenwindow2.closeme() - } -} - -// --- Kitchen Window 3 --- -def kitchenWindow3Open(evt) -{ - if (kitchenwindow3.currentValue("contact") != "open") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - kitchenwindow3.openme() - } -} - -def kitchenWindow3Closed(evt) -{ - if (kitchenwindow3.currentValue("contact") != "closed") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - kitchenwindow3.closeme() - } -} - -// --- Master Window 1 --- -def masterWindow1Open(evt) -{ - if (masterwindow1.currentValue("contact") != "open") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - masterwindow1.openme() - } -} - -def masterWindow1Closed(evt) -{ - if (masterwindow1.currentValue("contact") != "closed") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - masterwindow1.openme() - } -} - -// --- Master Window 2 --- -def masterWindow2Open(evt) -{ - if (masterwindow2.currentValue("contact") != "open") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - masterwindow2.openme() - } -} - -def masterWindow2Closed(evt) -{ - if (masterwindow2.currentValue("contact") != "closed") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - masterwindow2.closeme() - } -} - -// --- Office Window 1 --- -def officewindow1Open(evt) -{ - if (officewindow1.currentValue("contact") != "open") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - officewindow1.openme() - } -} - -def officewindow1Closed(evt) -{ - if (officewindow1.currentValue("contact") != "closed") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - officewindow1.openme() - } -} - -// --- Office Window 2 --- -def officewindow2Open(evt) -{ - if (officewindow2.currentValue("contact") != "open") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - officewindow2.openme() - } -} - -def officewindow2Closed(evt) -{ - if (officewindow2.currentValue("contact") != "closed") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - officewindow2.closeme() - } -} - -// --- Guest Window 1 --- -def guestwindow1Open(evt) -{ - if (guestwindow1.currentValue("contact") != "open") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - guestwindow1.openme() - } -} - -def guestwindow1Closed(evt) -{ - if (guestwindow1.currentValue("contact") != "closed") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - guestwindow1.openme() - } -} - -// --- Guest Window 2 --- -def guestwindow2Open(evt) -{ - if (guestwindow2.currentValue("contact") != "open") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - guestwindow2.openme() - } -} - -def guestwindow2Closed(evt) -{ - if (guestwindow2.currentValue("contact") != "closed") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - guestwindow2.closeme() - } -} - - -def initialize() { - // TODO: subscribe to attributes, devices, locations, etc. -} \ No newline at end of file diff --git a/Groovy/ST_Anything_Ethernet/DeviceHandlers/ST_Anything_Ethernet.device.groovy b/Groovy/ST_Anything_Ethernet/DeviceHandlers/ST_Anything_Ethernet.device.groovy new file mode 100644 index 00000000..30a77c3f --- /dev/null +++ b/Groovy/ST_Anything_Ethernet/DeviceHandlers/ST_Anything_Ethernet.device.groovy @@ -0,0 +1,241 @@ +/** + * ST_AnyThing_Ethernet.device.groovy + * + * Copyright 2017 Dan G Ogorchock + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License + * for the specific language governing permissions and limitations under the License. + * + * Change History: + * + * Date Who What + * ---- --- ---- + * 2017-02-08 Dan Ogorchock Original Creation + * 2017-02-12 Dan Ogorchock Modified to work with Ethernet based devices instead of ThingShield + * + */ + +metadata { + definition (name: "ST_AnyThing_Ethernet", namespace: "ogiewon", author: "Dan Ogorchock") { + capability "Configuration" + capability "Illuminance Measurement" + capability "Temperature Measurement" + capability "Relative Humidity Measurement" + capability "Water Sensor" + capability "Motion Sensor" + capability "Switch" + capability "Sensor" + capability "Alarm" + capability "Contact Sensor" + capability "Polling" + + command "test" + command "alarmoff" + } + + simulator { + + } + + // Preferences + preferences { + input "ip", "text", title: "Arduino IP Address", description: "ip", required: true, displayDuringSetup: true + input "port", "text", title: "Arduino Port", description: "port", required: true, displayDuringSetup: true + input "mac", "text", title: "Arduino MAC Addr", description: "mac", required: true, displayDuringSetup: true + input "illuminanceSampleRate", "number", title: "Light Sensor Inputs", description: "Sampling Interval (seconds)", defaultValue: 30, required: true, displayDuringSetup: true + input "temphumidSampleRate", "number", title: "Temperature/Humidity Sensor Inputs", description: "Sampling Interval (seconds)", defaultValue: 30, required: true, displayDuringSetup: true + input "waterSampleRate", "number", title: "Water Sensor Inputs", description: "Sampling Interval (seconds)", defaultValue: 30, required: true, displayDuringSetup: true + } + + // Tile Definitions + tiles { + valueTile("illuminance", "device.illuminance", width: 1, height: 1) { + state("illuminance", label:'${currentValue} ${unit}', unit:"lux", + backgroundColors:[ + [value: 9, color: "#767676"], + [value: 315, color: "#ffa81e"], + [value: 1000, color: "#fbd41b"] + ] + ) + } + valueTile("temperature", "device.temperature", width: 1, height: 1) { + state("temperature", label:'${currentValue}°', + backgroundColors:[ + [value: 31, color: "#153591"], + [value: 44, color: "#1e9cbb"], + [value: 59, color: "#90d2a7"], + [value: 74, color: "#44b621"], + [value: 84, color: "#f1d801"], + [value: 95, color: "#d04e00"], + [value: 96, color: "#bc2323"] + ] + ) + } + + valueTile("humidity", "device.humidity", inactiveLabel: false) { + state "humidity", label:'${currentValue}% humidity', unit:"" + } + + + standardTile("water", "device.water", width: 1, height: 1) { + state "dry", icon:"st.alarm.water.dry", backgroundColor:"#ffffff" + state "wet", icon:"st.alarm.water.wet", backgroundColor:"#53a7c0" + } + + standardTile("motion", "device.motion", width: 1, height: 1) { + state("active", label:'motion', icon:"st.motion.motion.active", backgroundColor:"#53a7c0") + state("inactive", label:'no motion', icon:"st.motion.motion.inactive", backgroundColor:"#ffffff") + } + + standardTile("switch", "device.switch", width: 1, height: 1, canChangeIcon: true) { + state "off", label: '${name}', action: "switch.on", icon: "st.switches.switch.off", backgroundColor: "#ffffff" + state "on", label: '${name}', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#79b821" + } + + standardTile("configure", "device.configure", inactiveLabel: false, decoration: "flat") { + state "configure", label:'', action:"configuration.configure", icon:"st.secondary.configure" + } + + standardTile("contact", "device.contact", width: 1, height: 1) { + state("open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e") + state("closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821") + } + + standardTile("alarm", "device.alarm", width: 1, height: 1) { + state "off", label:'off', action:'alarm.siren', icon:"st.alarm.alarm.alarm", backgroundColor:"#ffffff" + state "strobe", label:'', action:'alarmoff', icon:"st.secondary.strobe", backgroundColor:"#cccccc" + state "siren", label:'siren!', action:'alarmoff', icon:"st.alarm.beep.beep", backgroundColor:"#e86d13" + state "both", label:'alarm!', action:'alarmoff', icon:"st.alarm.alarm.alarm", backgroundColor:"#e86d13" + } + + standardTile("test", "device.alarm", inactiveLabel: false, decoration: "flat") { + state "default", label:'', action:"test", icon:"st.secondary.test" + } + + standardTile("off", "device.alarm", , width: 1, height: 1) { + state "default", label:'Alarm', action:"alarmoff", icon:"st.secondary.off" + } + //standardTile("off", "device.alarm", inactiveLabel: false, decoration: "flat") { + // state "default", label:'', action:"alarmoff", icon:"st.secondary.off" + //} + + main(["motion","temperature","humidity","illuminance","switch","contact","alarm","water"]) + details(["motion","temperature","humidity","illuminance","switch","contact","alarm","test","off","water","configure"]) + } +} + +// parse events into attributes +def parse(String description) { + //log.debug "Parsing '${description}'" + def msg = parseLanMessage(description) + def headerString = msg.header + + if (!headerString) { + //log.debug "headerstring was null for some reason :(" + } + + def bodyString = msg.body + + if (bodyString) { + log.debug "BodyString: $bodyString" + def parts = bodyString.split(" ") + def name = parts.length>0?parts[0].trim():null + def value = parts.length>1?parts[1].trim():null + + def result = createEvent(name: name, value: value) + + log.debug result + + return result + } +} + +private getHostAddress() { + def ip = settings.ip + def port = settings.port + + log.debug "Using ip: ${ip} and port: ${port} for device: ${device.id}" + return ip + ":" + port +} + + +def sendEthernet(message) { + log.debug "Executing 'sendEthernet' ${message}" + new physicalgraph.device.HubAction( + method: "POST", + path: "/${message}?", + headers: [ HOST: "${getHostAddress()}" ] + ) +} + +// handle commands + +def on() { + log.debug "Executing 'switch on'" + sendEthernet("switch on") +} + +def off() { + log.debug "Executing 'switch off'" + sendEthernet("switch off") +} + +def alarmoff() { + log.debug "Executing 'alarm off'" + sendEthernet("alarm off") +} + +def strobe() { + log.debug "Executing 'alarm strobe'" + sendEthernet("alarm strobe") +} + +def siren() { + log.debug "Executing 'alarm siren'" + sendEthernet("alarm siren") +} + +def both() { + log.debug "Executing 'alarm both'" + sendEthernet("alarm both") +} + +def test() { + log.debug "Executing 'alarm test'" + [ + sendEthernet("alarm both"), + "delay 3000", + sendEthernet("alarm off") + ] +} + +def poll() { + //temporarily implement poll() to issue a configure() command to send the polling interval settings to the arduino + configure() +} + + +def configure() { + log.debug "Executing 'configure'" + if(device.deviceNetworkId!=settings.mac) { + log.debug "setting device network id" + device.deviceNetworkId = settings.mac + } + //log.debug "illuminance " + illuminanceSampleRate + "|temphumid " + temphumidSampleRate + "|water " + waterSampleRate + log.debug "water " + waterSampleRate + log.debug "illuminance " + illuminanceSampleRate + log.debug "temphumid " + temphumidSampleRate + [ + sendEthernet("water " + waterSampleRate), + "delay 1000", + sendEthernet("illuminance " + illuminanceSampleRate), + "delay 1000", + sendEthernet("temphumid " + temphumidSampleRate) + ] +} diff --git a/Groovy/ST_Anything_FurnaceAlarm/ST_Anything_FurnaceAlarm.device.groovy b/Groovy/ST_Anything_FurnaceAlarm/ST_Anything_FurnaceAlarm.device.groovy deleted file mode 100644 index ba348a88..00000000 --- a/Groovy/ST_Anything_FurnaceAlarm/ST_Anything_FurnaceAlarm.device.groovy +++ /dev/null @@ -1,65 +0,0 @@ -/** - * ST_Anything_FurnaceAlarm.groovy - * - * Copyright 2015 Dan G Ogorchock - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License - * for the specific language governing permissions and limitations under the License. - * - * Change History: - * - * Date Who What - * ---- --- ---- - * 2015-03-10 Dan Original Creation - * - */ - -metadata { - definition (name: "ST_AnyThing_FurnaceAlarm", namespace: "ogiewon", author: "Daniel Ogorchock") { - capability "Contact Sensor" - } - - simulator { - } - - // Preferences - preferences { - } - - // Tile Definitions - tiles { - - standardTile("contact", "device.contact", width: 1, height: 1) { - state("open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e") - state("closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821") - } - - main(["contact"]) - details(["contact"]) - } -} - -// parse events into attributes -def parse(String description) { - log.debug "Parsing '${description}'" - def msg = zigbee.parse(description)?.text - log.debug "Parse got '${msg}'" - - def parts = msg.split(" ") - def name = parts.length>0?parts[0].trim():null - def value = parts.length>1?parts[1].trim():null - - name = value != "ping" ? name : null - - def result = createEvent(name: name, value: value) - - log.debug result - - return result -} diff --git a/Groovy/ST_Anything_Power/ST_AnyThing_Power.device.groovy b/Groovy/ST_Anything_Power/ST_AnyThing_Power.device.groovy deleted file mode 100644 index 9da96416..00000000 --- a/Groovy/ST_Anything_Power/ST_AnyThing_Power.device.groovy +++ /dev/null @@ -1,88 +0,0 @@ -/** - * ST_AnyThing_Power.device.groovy - * - * Copyright 2015 Daniel Ogorchock - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License - * for the specific language governing permissions and limitations under the License. - * - * Change History: - * - * Date Who What - * ---- --- ---- - * 2015-04-01 Dan Ogorchock Original Creation - * - */ - -metadata { - definition (name: "ST_Anything_Power", namespace: "ogiewon", author: "Daniel Ogorchock") { - capability "Configuration" - capability "Power Meter" - capability "Sensor" - capability "Polling" - } - - simulator { - } - - // Preferences - preferences { - input "powerSampleRate", "number", title: "Power Meter Sampling Interval (seconds)", description: "Sampling Interval (seconds)", defaultValue: 30, required: true, displayDuringSetup: true - } - - // Tile Definitions - tiles { - valueTile("power", "device.power", width: 2, height: 2, decoration: "flat") { - state "default", label:'${currentValue} W', unit:"" - } - - standardTile("configure", "device.configure", inactiveLabel: false, decoration: "flat") { - state "configure", label:'', action:"configuration.configure", icon:"st.secondary.configure" - } - - main(["power"]) - details(["power","configure"]) - } -} - -// parse events into attributes -def parse(String description) { - log.debug "Parsing '${description}'" - def msg = zigbee.parse(description)?.text - log.debug "Parse got '${msg}'" - - def parts = msg.split(" ") - def name = parts.length>0?parts[0].trim():null - def value = parts.length>1?parts[1].trim():null - - name = value != "ping" ? name : null - - def result = createEvent(name: name, value: value) - - log.debug result - - return result -} - -// handle commands - - -def poll() { - //temporarily implement poll() to issue a configure() command to send the polling interval settings to the arduino - configure() -} - - -def configure() { - log.debug "Executing 'configure'" - log.debug "power" + powerSampleRate - [ - zigbee.smartShield(text: "power " + powerSampleRate).format() - ] -} \ No newline at end of file diff --git a/Groovy/ST_Anything_RCSwitch/DeviceTypes/ST_Anything_RCSwitch.device.groovy b/Groovy/ST_Anything_RCSwitch/DeviceTypes/ST_Anything_RCSwitch.device.groovy deleted file mode 100644 index fc0d0faf..00000000 --- a/Groovy/ST_Anything_RCSwitch/DeviceTypes/ST_Anything_RCSwitch.device.groovy +++ /dev/null @@ -1,113 +0,0 @@ -/** - * ST_Anything_RCSwitch - ST_Anything_RCSwitch.device.groovy - * - * Copyright 2015 Daniel Ogorchock - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License - * for the specific language governing permissions and limitations under the License. - * - * Change History: - * - * Date Who What - * ---- --- ---- - * 2015-01-31 Dan Ogorchock Original Creation - * - * - */ - -metadata { - definition (name: "ST_Anything_RCSwitch", namespace: "ogiewon", author: "Daniel Ogorchock") { - capability "Switch" - - attribute "rcswitch1", "string" - attribute "rcswitch2", "string" - attribute "rcswitch3", "string" - - command "rcswitch1on" - command "rcswitch1off" - command "rcswitch2on" - command "rcswitch2off" - command "rcswitch3on" - command "rcswitch3off" - } - - simulator { - } - - - // tile definitions - tiles { - - standardTile("rcswitch1", "device.rcswitch1", width: 1, height: 1, canChangeIcon: true) { - state "off", label: '${name}', action: "rcswitch1on", icon: "st.switches.switch.off", backgroundColor: "#ffffff" - state "on", label: '${name}', action: "rcswitch1off", icon: "st.switches.switch.on", backgroundColor: "#79b821" - } - - standardTile("rcswitch2", "device.rcswitch2", width: 1, height: 1, canChangeIcon: true) { - state "off", label: '${name}', action: "rcswitch2on", icon: "st.switches.switch.off", backgroundColor: "#ffffff" - state "on", label: '${name}', action: "rcswitch2off", icon: "st.switches.switch.on", backgroundColor: "#79b821" - } - - standardTile("rcswitch3", "device.rcswitch3", width: 1, height: 1, canChangeIcon: true) { - state "off", label: '${name}', action: "rcswitch3on", icon: "st.switches.switch.off", backgroundColor: "#ffffff" - state "on", label: '${name}', action: "rcswitch3off", icon: "st.switches.switch.on", backgroundColor: "#79b821" - } - - main (["rcswitch1","rcswitch2","rcswitch3"]) - details(["rcswitch1","rcswitch2","rcswitch3"]) - } -} - -//Map parse(String description) { -def parse(String description) { - def msg = zigbee.parse(description)?.text - log.debug "Parse got '${msg}'" - - def parts = msg.split(" ") - def name = parts.length>0?parts[0].trim():null - def value = parts.length>1?parts[1].trim():null - - name = value != "ping" ? name : null - - def result = createEvent(name: name, value: value, isStateChange: true) - - log.debug result - - return result -} - -def rcswitch1on() { - log.debug "Executing 'rcswitch1on' = 'rcswitch1 on'" - zigbee.smartShield(text: "rcswitch1 on").format() -} - -def rcswitch1off() { - log.debug "Executing 'rcswitch1off' = 'rcswitch1 off'" - zigbee.smartShield(text: "rcswitch1 off").format() -} - -def rcswitch2on() { - log.debug "Executing 'rcswitch2on' = 'rcswitch2 on'" - zigbee.smartShield(text: "rcswitch2 on").format() -} - -def rcswitch2off() { - log.debug "Executing 'rcswitch2off' = 'rcswitch2 off'" - zigbee.smartShield(text: "rcswitch2 off").format() -} - -def rcswitch3on() { - log.debug "Executing 'rcswitch3on' = 'rcswitch3 on'" - zigbee.smartShield(text: "rcswitch3 on").format() -} - -def rcswitch3off() { - log.debug "Executing 'rcswitch3off' = 'rcswitch3 off'" - zigbee.smartShield(text: "rcswitch3 off").format() -} diff --git a/Groovy/ST_Anything_RCSwitch/DeviceTypes/readme.txt b/Groovy/ST_Anything_RCSwitch/DeviceTypes/readme.txt deleted file mode 100644 index 0c7a0fcf..00000000 --- a/Groovy/ST_Anything_RCSwitch/DeviceTypes/readme.txt +++ /dev/null @@ -1,2 +0,0 @@ -Make sure you also get the Virtual Switch Device - VirtualSwitch.device.groovy - -from the \Groovy\VirtualDevices\ folder. \ No newline at end of file diff --git a/Groovy/ST_Anything_RCSwitch/SmartApps/ST_Anything_RCSwitch_Multiplexer.smartapp.groovy b/Groovy/ST_Anything_RCSwitch/SmartApps/ST_Anything_RCSwitch_Multiplexer.smartapp.groovy deleted file mode 100644 index a979b2b7..00000000 --- a/Groovy/ST_Anything_RCSwitch/SmartApps/ST_Anything_RCSwitch_Multiplexer.smartapp.groovy +++ /dev/null @@ -1,179 +0,0 @@ -/** - * ST_Anything_RCSwitch Multiplexer - ST_Anything_RCSwitch _Multiplexer.smartapp.groovy - * - * Copyright 2015 Daniel Ogorchock - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License - * for the specific language governing permissions and limitations under the License. - * - * Change History: - * - * Date Who What - * ---- --- ---- - * 2015-06-18 Dan Ogorchock Original Creation - * - */ -definition( - name: "ST_Anything_RCSwitch Multiplexer", - namespace: "ogiewon", - author: "Daniel Ogorchock", - description: "Virtual Switches to Arduino RCSwitches Multiplexer/Demultiplexer", - category: "My Apps", - iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", - iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png", - iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png") - - -preferences { - section("Select the Switches (Virtual Switch devices)") { - input "virtual_switch_1", title: "Virtual Switch for RCSwitch 1", "capability.switch", required: true - input "virtual_switch_2", title: "Virtual Switch for RCSwitch 2", "capability.switch", required: false - input "virtual_switch_3", title: "Virtual Switch for RCSwitch 3", "capability.switch", required: false - } - - section("Select the Arduino ST_Anything_RCSwitch device") { - input "arduino", "capability.switch", required: true - } -} - -def installed() { - log.debug "Installed with settings: ${settings}" - subscribe() -} - -def updated() { - log.debug "Updated with settings: ${settings}" - unsubscribe() - subscribe() -} - -def subscribe() { - - subscribe(arduino, "rcswitch1.on", switch1on) - subscribe(arduino, "rcswitch1.off", switch1off) - subscribe(virtual_switch_1, "switch.on", rcswitch1on) - subscribe(virtual_switch_1, "switch.off", rcswitch1off) - - if (virtual_switch_2) { - subscribe(arduino, "rcswitch2.on", switch2on) - subscribe(arduino, "rcswitch2.off", switch2off) - subscribe(virtual_switch_2, "switch.on", rcswitch2on) - subscribe(virtual_switch_2, "switch.off", rcswitch2off) - } - - if (virtual_switch_3) { - subscribe(arduino, "rcswitch3.on", switch3on) - subscribe(arduino, "rcswitch3.off", switch3off) - subscribe(virtual_switch_3, "switch.on", rcswitch3on) - subscribe(virtual_switch_3, "switch.off", rcswitch3off) - } - -} - -//--------------- RCSwitch 1 handlers --------------- -def switch1on(evt) -{ - if (virtual_switch_1.currentValue("switch") != "on") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping On Virtual Switch to match Arduino" - virtual_switch_1.on() - } -} -def switch1off(evt) -{ - if (virtual_switch_1.currentValue("switch") != "off") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping Off Virtual Switch to match Arduino" - virtual_switch_1.off() - } -} -def rcswitch1on(evt) -{ - if (arduino.currentValue("switch1") != "on") { - log.debug "rcswitch1event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning On Arduino RCSwitch to match Virtual Switch" - arduino.rcswitch1on() - } -} -def rcswitch1off(evt) -{ - if (arduino.currentValue("switch1") != "off") { - log.debug "rcswitch1event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning Off Arduino RCSwitch to match Virtual Switch" - arduino.rcswitch1off() - } -} - -//--------------- RCSwitch 2 handlers --------------- -def switch2on(evt) -{ - if (virtual_switch_2.currentValue("switch") != "on") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping On Virtual Switch to match Arduino" - virtual_switch_2.on() - } -} -def switch2off(evt) -{ - if (virtual_switch_2.currentValue("switch") != "off") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping Off Virtual Switch to match Arduino" - virtual_switch_2.off() - } -} -def rcswitch2on(evt) -{ - if (arduino.currentValue("switch2") != "on") { - log.debug "rcswitch2event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning On Arduino RCSwitch to match Virtual Switch" - arduino.rcswitch2on() - } -} -def rcswitch2off(evt) -{ - if (arduino.currentValue("switch2") != "off") { - log.debug "rcswitch2event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning Off Arduino RCSwitch to match Virtual Switch" - arduino.rcswitch2off() - } -} - -//--------------- RCSwitch 3 handlers --------------- -def switch3on(evt) -{ - if (virtual_switch_3.currentValue("switch") != "on") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping On Virtual Switch to match Arduino" - virtual_switch_3.on() - } -} -def switch3off(evt) -{ - if (virtual_switch_3.currentValue("switch") != "off") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping Off Virtual Switch to match Arduino" - virtual_switch_3.off() - } -} -def rcswitch3on(evt) -{ - if (arduino.currentValue("switch3") != "on") { - log.debug "rcswitch3event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning On Arduino RCSwitch to match Virtual Switch" - arduino.rcswitch3on() - } -} -def rcswitch3off(evt) -{ - if (arduino.currentValue("switch3") != "off") { - log.debug "rcswitch3event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning Off Arduino RCSwitch to match Virtual Switch" - arduino.rcswitch3off() - } -} diff --git a/Groovy/ST_Anything_RCSwitch/SmartApps/readme.txt b/Groovy/ST_Anything_RCSwitch/SmartApps/readme.txt deleted file mode 100644 index 0c7a0fcf..00000000 --- a/Groovy/ST_Anything_RCSwitch/SmartApps/readme.txt +++ /dev/null @@ -1,2 +0,0 @@ -Make sure you also get the Virtual Switch Device - VirtualSwitch.device.groovy - -from the \Groovy\VirtualDevices\ folder. \ No newline at end of file diff --git a/Groovy/ST_Anything_Relays/DeviceTypes/ST_anything_Relays.device.groovy b/Groovy/ST_Anything_Relays/DeviceTypes/ST_anything_Relays.device.groovy deleted file mode 100644 index 6f11604e..00000000 --- a/Groovy/ST_Anything_Relays/DeviceTypes/ST_anything_Relays.device.groovy +++ /dev/null @@ -1,349 +0,0 @@ -/** - * ST_Anything_Relays - ST_Anything_Relays.device.groovy - * - * Copyright 2015 Daniel Ogorchock - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License - * for the specific language governing permissions and limitations under the License. - * - * Change History: - * - * Date Who What - * ---- --- ---- - * 2015-03-27 Dan Ogorchock Original Creation - * - * - */ - -metadata { - definition (name: "ST_Anything_Relays", namespace: "ogiewon", author: "Daniel Ogorchock") { - capability "Actuator" - capability "Switch" - - attribute "switch1", "string" - attribute "switch2", "string" - attribute "switch3", "string" - attribute "switch4", "string" - attribute "switch5", "string" - attribute "switch6", "string" - attribute "switch7", "string" - attribute "switch8", "string" - attribute "switch9", "string" - attribute "switch10", "string" - attribute "switch11", "string" - attribute "switch12", "string" - attribute "switch13", "string" - attribute "switch14", "string" - attribute "switch15", "string" - attribute "switch16", "string" - - command "switch1on" - command "switch1off" - command "switch2on" - command "switch2off" - command "switch3on" - command "switch3off" - command "switch4on" - command "switch4off" - command "switch5on" - command "switch5off" - command "switch6on" - command "switch6off" - command "switch7on" - command "switch7off" - command "switch8on" - command "switch8off" - command "switch9on" - command "switch9off" - command "switch10on" - command "switch10off" - command "switch11on" - command "switch11off" - command "switch12on" - command "switch12off" - command "switch13on" - command "switch13off" - command "switch14on" - command "switch14off" - command "switch15on" - command "switch15off" - command "switch16on" - command "switch16off" - -} - - simulator { - } - - - // tile definitions - tiles { - - standardTile("switch1", "device.switch1", width: 1, height: 1, canChangeIcon: true) { - state "off", label: '${name}', action: "switch1on", icon: "st.switches.switch.off", backgroundColor: "#ffffff" - state "on", label: '${name}', action: "switch1off", icon: "st.switches.switch.on", backgroundColor: "#79b821" - } - - standardTile("switch2", "device.switch2", width: 1, height: 1, canChangeIcon: true) { - state "off", label: '${name}', action: "switch2on", icon: "st.switches.switch.off", backgroundColor: "#ffffff" - state "on", label: '${name}', action: "switch2off", icon: "st.switches.switch.on", backgroundColor: "#79b821" - } - - standardTile("switch3", "device.switch3", width: 1, height: 1, canChangeIcon: true) { - state "off", label: '${name}', action: "switch3on", icon: "st.switches.switch.off", backgroundColor: "#ffffff" - state "on", label: '${name}', action: "switch3off", icon: "st.switches.switch.on", backgroundColor: "#79b821" - } - - standardTile("switch4", "device.switch4", width: 1, height: 1, canChangeIcon: true) { - state "off", label: '${name}', action: "switch4on", icon: "st.switches.switch.off", backgroundColor: "#ffffff" - state "on", label: '${name}', action: "switch4off", icon: "st.switches.switch.on", backgroundColor: "#79b821" - } - - standardTile("switch5", "device.switch5", width: 1, height: 1, canChangeIcon: true) { - state "off", label: '${name}', action: "switch5on", icon: "st.switches.switch.off", backgroundColor: "#ffffff" - state "on", label: '${name}', action: "switch5off", icon: "st.switches.switch.on", backgroundColor: "#79b821" - } - - standardTile("switch6", "device.switch6", width: 1, height: 1, canChangeIcon: true) { - state "off", label: '${name}', action: "switch6on", icon: "st.switches.switch.off", backgroundColor: "#ffffff" - state "on", label: '${name}', action: "switch6off", icon: "st.switches.switch.on", backgroundColor: "#79b821" - } - - standardTile("switch7", "device.switch7", width: 1, height: 1, canChangeIcon: true) { - state "off", label: '${name}', action: "switch7on", icon: "st.switches.switch.off", backgroundColor: "#ffffff" - state "on", label: '${name}', action: "switch7off", icon: "st.switches.switch.on", backgroundColor: "#79b821" - } - - standardTile("switch8", "device.switch8", width: 1, height: 1, canChangeIcon: true) { - state "off", label: '${name}', action: "switch8on", icon: "st.switches.switch.off", backgroundColor: "#ffffff" - state "on", label: '${name}', action: "switch8off", icon: "st.switches.switch.on", backgroundColor: "#79b821" - } - - standardTile("switch9", "device.switch9", width: 1, height: 1, canChangeIcon: true) { - state "off", label: '${name}', action: "switch9on", icon: "st.switches.switch.off", backgroundColor: "#ffffff" - state "on", label: '${name}', action: "switch9off", icon: "st.switches.switch.on", backgroundColor: "#79b821" - } - - standardTile("switch10", "device.switch10", width: 1, height: 1, canChangeIcon: true) { - state "off", label: '${name}', action: "switch10on", icon: "st.switches.switch.off", backgroundColor: "#ffffff" - state "on", label: '${name}', action: "switch10off", icon: "st.switches.switch.on", backgroundColor: "#79b821" - } - - standardTile("switch11", "device.switch11", width: 1, height: 1, canChangeIcon: true) { - state "off", label: '${name}', action: "switch11on", icon: "st.switches.switch.off", backgroundColor: "#ffffff" - state "on", label: '${name}', action: "switch11off", icon: "st.switches.switch.on", backgroundColor: "#79b821" - } - - standardTile("switch12", "device.switch12", width: 1, height: 1, canChangeIcon: true) { - state "off", label: '${name}', action: "switch12on", icon: "st.switches.switch.off", backgroundColor: "#ffffff" - state "on", label: '${name}', action: "switch12off", icon: "st.switches.switch.on", backgroundColor: "#79b821" - } - - standardTile("switch13", "device.switch13", width: 1, height: 1, canChangeIcon: true) { - state "off", label: '${name}', action: "switch13on", icon: "st.switches.switch.off", backgroundColor: "#ffffff" - state "on", label: '${name}', action: "switch13off", icon: "st.switches.switch.on", backgroundColor: "#79b821" - } - - standardTile("switch14", "device.switch14", width: 1, height: 1, canChangeIcon: true) { - state "off", label: '${name}', action: "switch14on", icon: "st.switches.switch.off", backgroundColor: "#ffffff" - state "on", label: '${name}', action: "switch14off", icon: "st.switches.switch.on", backgroundColor: "#79b821" - } - - standardTile("switch15", "device.switch15", width: 1, height: 1, canChangeIcon: true) { - state "off", label: '${name}', action: "switch15on", icon: "st.switches.switch.off", backgroundColor: "#ffffff" - state "on", label: '${name}', action: "switch15off", icon: "st.switches.switch.on", backgroundColor: "#79b821" - } - - standardTile("switch16", "device.switch16", width: 1, height: 1, canChangeIcon: true) { - state "off", label: '${name}', action: "switch16on", icon: "st.switches.switch.off", backgroundColor: "#ffffff" - state "on", label: '${name}', action: "switch16off", icon: "st.switches.switch.on", backgroundColor: "#79b821" - } - - main (["switch1"]) - details (["switch1","switch2","switch3","switch4","switch5","switch6","switch7","switch8","switch9","switch10","switch11","switch12","switch13","switch14","switch15","switch16"]) - } -} - -//Map parse(String description) { -def parse(String description) { - def msg = zigbee.parse(description)?.text - log.debug "Parse got '${msg}'" - - def parts = msg.split(" ") - def name = parts.length>0?parts[0].trim():null - def value = parts.length>1?parts[1].trim():null - - name = value != "ping" ? name : null - - def result = createEvent(name: name, value: value, isStateChange: true) - - log.debug result - - return result -} - -def switch1on() { - log.debug "Executing 'switch1on' = 'switch1 on'" - zigbee.smartShield(text: "switch1 on").format() -} - -def switch1off() { - log.debug "Executing 'switch1off' = 'switch1 off'" - zigbee.smartShield(text: "switch1 off").format() -} - -def switch2on() { - log.debug "Executing 'switch2on' = 'switch2 on'" - zigbee.smartShield(text: "switch2 on").format() -} - -def switch2off() { - log.debug "Executing 'switch2off' = 'switch2 off'" - zigbee.smartShield(text: "switch2 off").format() -} - -def switch3on() { - log.debug "Executing 'switch3on' = 'switch3 on'" - zigbee.smartShield(text: "switch3 on").format() -} - -def switch3off() { - log.debug "Executing 'switch3off' = 'switch3 off'" - zigbee.smartShield(text: "switch3 off").format() -} - -def switch4on() { - log.debug "Executing 'switch4on' = 'switch4 on'" - zigbee.smartShield(text: "switch4 on").format() -} - -def switch4off() { - log.debug "Executing 'switch4off' = 'switch4 off'" - zigbee.smartShield(text: "switch4 off").format() -} - -def switch5on() { - log.debug "Executing 'switch5on' = 'switch5 on'" - zigbee.smartShield(text: "switch5 on").format() -} - -def switch5off() { - log.debug "Executing 'switch5off' = 'switch5 off'" - zigbee.smartShield(text: "switch5 off").format() -} - -def switch6on() { - log.debug "Executing 'switch6on' = 'switch6 on'" - zigbee.smartShield(text: "switch6 on").format() -} - -def switch6off() { - log.debug "Executing 'switch6off' = 'switch6 off'" - zigbee.smartShield(text: "switch6 off").format() -} - -def switch7on() { - log.debug "Executing 'switch7on' = 'switch7 on'" - zigbee.smartShield(text: "switch7 on").format() -} - -def switch7off() { - log.debug "Executing 'switch7off' = 'switch7 off'" - zigbee.smartShield(text: "switch7 off").format() -} - -def switch8on() { - log.debug "Executing 'switch8on' = 'switch8 on'" - zigbee.smartShield(text: "switch8 on").format() -} - -def switch8off() { - log.debug "Executing 'switch8off' = 'switch8 off'" - zigbee.smartShield(text: "switch8 off").format() -} - -def switch9on() { - log.debug "Executing 'switch9on' = 'switch9 on'" - zigbee.smartShield(text: "switch9 on").format() -} - -def switch9off() { - log.debug "Executing 'switch9off' = 'switch9 off'" - zigbee.smartShield(text: "switch9 off").format() -} - -def switch10on() { - log.debug "Executing 'switch10on' = 'switch10 on'" - zigbee.smartShield(text: "switch10 on").format() -} - -def switch10off() { - log.debug "Executing 'switch10off' = 'switch10 off'" - zigbee.smartShield(text: "switch10 off").format() -} - -def switch11on() { - log.debug "Executing 'switch11on' = 'switch11 on'" - zigbee.smartShield(text: "switch11 on").format() -} - -def switch11off() { - log.debug "Executing 'switch11off' = 'switch11 off'" - zigbee.smartShield(text: "switch11 off").format() -} - -def switch12on() { - log.debug "Executing 'switch12on' = 'switch12 on'" - zigbee.smartShield(text: "switch12 on").format() -} - -def switch12off() { - log.debug "Executing 'switch12off' = 'switch12 off'" - zigbee.smartShield(text: "switch12 off").format() -} - -def switch13on() { - log.debug "Executing 'switch13on' = 'switch13 on'" - zigbee.smartShield(text: "switch13 on").format() -} - -def switch13off() { - log.debug "Executing 'switch13off' = 'switch13 off'" - zigbee.smartShield(text: "switch13 off").format() -} - -def switch14on() { - log.debug "Executing 'switch14on' = 'switch14 on'" - zigbee.smartShield(text: "switch14 on").format() -} - -def switch14off() { - log.debug "Executing 'switch14off' = 'switch14 off'" - zigbee.smartShield(text: "switch14 off").format() -} - -def switch15on() { - log.debug "Executing 'switch15on' = 'switch15 on'" - zigbee.smartShield(text: "switch15 on").format() -} - -def switch15off() { - log.debug "Executing 'switch15off' = 'switch15 off'" - zigbee.smartShield(text: "switch15 off").format() -} - -def switch16on() { - log.debug "Executing 'switch16on' = 'switch16 on'" - zigbee.smartShield(text: "switch16 on").format() -} - -def switch16off() { - log.debug "Executing 'switch16off' = 'switch16 off'" - zigbee.smartShield(text: "switch16 off").format() -} diff --git a/Groovy/ST_Anything_Relays/DeviceTypes/readme.txt b/Groovy/ST_Anything_Relays/DeviceTypes/readme.txt deleted file mode 100644 index 0c7a0fcf..00000000 --- a/Groovy/ST_Anything_Relays/DeviceTypes/readme.txt +++ /dev/null @@ -1,2 +0,0 @@ -Make sure you also get the Virtual Switch Device - VirtualSwitch.device.groovy - -from the \Groovy\VirtualDevices\ folder. \ No newline at end of file diff --git a/Groovy/ST_Anything_Relays/SmartApps/ST_Anything_Relays_Multiplexer.smartapp.groovy b/Groovy/ST_Anything_Relays/SmartApps/ST_Anything_Relays_Multiplexer.smartapp.groovy deleted file mode 100644 index c439311e..00000000 --- a/Groovy/ST_Anything_Relays/SmartApps/ST_Anything_Relays_Multiplexer.smartapp.groovy +++ /dev/null @@ -1,725 +0,0 @@ -/** - * ST_Anything_Relays Multiplexer - ST_Anything_Relays_Multiplexer.smartapp.groovy - * - * Copyright 2015 Daniel Ogorchock - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License - * for the specific language governing permissions and limitations under the License. - * - * Change History: - * - * Date Who What - * ---- --- ---- - * 2015-03-27 Dan Ogorchock Original Creation - * - */ -definition( - name: "ST_Anything_Relays Multiplexer", - namespace: "ogiewon", - author: "Daniel Ogorchock", - description: "Virtual Switches to Arduino Relays Multiplexer/Demultiplexer", - category: "My Apps", - iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", - iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png", - iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png") - - -preferences { - section("Select the Relays (Virtual Switch devices)") { - input "virtual_switch_1", title: "Virtual Switch for Relay 1", "capability.switch", required: true - input "virtual_switch_2", title: "Virtual Switch for Relay 2", "capability.switch", required: false - input "virtual_switch_3", title: "Virtual Switch for Relay 3", "capability.switch", required: false - input "virtual_switch_4", title: "Virtual Switch for Relay 4", "capability.switch", required: false - input "virtual_switch_5", title: "Virtual Switch for Relay 5", "capability.switch", required: false - input "virtual_switch_6", title: "Virtual Switch for Relay 6", "capability.switch", required: false - input "virtual_switch_7", title: "Virtual Switch for Relay 7", "capability.switch", required: false - input "virtual_switch_8", title: "Virtual Switch for Relay 8", "capability.switch", required: false - input "virtual_switch_9", title: "Virtual Switch for Relay 9", "capability.switch", required: false - input "virtual_switch_10", title: "Virtual Switch for Relay 10", "capability.switch", required: false - input "virtual_switch_11", title: "Virtual Switch for Relay 11", "capability.switch", required: false - input "virtual_switch_12", title: "Virtual Switch for Relay 12", "capability.switch", required: false - input "virtual_switch_13", title: "Virtual Switch for Relay 13", "capability.switch", required: false - input "virtual_switch_14", title: "Virtual Switch for Relay 14", "capability.switch", required: false - input "virtual_switch_15", title: "Virtual Switch for Relay 15", "capability.switch", required: false - input "virtual_switch_16", title: "Virtual Switch for Relay 16", "capability.switch", required: false - } - - section("Select the Arduino ST_Anything_Relays device") { - input "arduino", "capability.switch", required: true - } -} - -def installed() { - log.debug "Installed with settings: ${settings}" - subscribe() -} - -def updated() { - log.debug "Updated with settings: ${settings}" - unsubscribe() - subscribe() -} - -def subscribe() { - - subscribe(arduino, "switch1.on", switch1on) - subscribe(arduino, "switch1.off", switch1off) - subscribe(virtual_switch_1, "switch.on", relay1on) - subscribe(virtual_switch_1, "switch.off", relay1off) - - if (virtual_switch_2) { - subscribe(arduino, "switch2.on", switch2on) - subscribe(arduino, "switch2.off", switch2off) - subscribe(virtual_switch_2, "switch.on", relay2on) - subscribe(virtual_switch_2, "switch.off", relay2off) - } - - if (virtual_switch_3) { - subscribe(arduino, "switch3.on", switch3on) - subscribe(arduino, "switch3.off", switch3off) - subscribe(virtual_switch_3, "switch.on", relay3on) - subscribe(virtual_switch_3, "switch.off", relay3off) - } - - if (virtual_switch_4) { - subscribe(arduino, "switch4.on", switch4on) - subscribe(arduino, "switch4.off", switch4off) - subscribe(virtual_switch_4, "switch.on", relay4on) - subscribe(virtual_switch_4, "switch.off", relay4off) - } - - if (virtual_switch_5) { - subscribe(arduino, "switch5.on", switch5on) - subscribe(arduino, "switch5.off", switch5off) - subscribe(virtual_switch_5, "switch.on", relay5on) - subscribe(virtual_switch_5, "switch.off", relay5off) - } - - if (virtual_switch_6) { - subscribe(arduino, "switch6.on", switch6on) - subscribe(arduino, "switch6.off", switch6off) - subscribe(virtual_switch_6, "switch.on", relay6on) - subscribe(virtual_switch_6, "switch.off", relay6off) - } - - if (virtual_switch_7) { - subscribe(arduino, "switch7.on", switch7on) - subscribe(arduino, "switch7.off", switch7off) - subscribe(virtual_switch_7, "switch.on", relay7on) - subscribe(virtual_switch_7, "switch.off", relay7off) - } - - if (virtual_switch_8) { - subscribe(arduino, "switch8.on", switch8on) - subscribe(arduino, "switch8.off", switch8off) - subscribe(virtual_switch_8, "switch.on", relay8on) - subscribe(virtual_switch_8, "switch.off", relay8off) - } - - if (virtual_switch_9) { - subscribe(arduino, "switch9.on", switch9on) - subscribe(arduino, "switch9.off", switch9off) - subscribe(virtual_switch_9, "switch.on", relay9on) - subscribe(virtual_switch_9, "switch.off", relay9off) - } - - if (virtual_switch_10) { - subscribe(arduino, "switch10.on", switch10on) - subscribe(arduino, "switch10.off", switch10off) - subscribe(virtual_switch_10, "switch.on", relay10on) - subscribe(virtual_switch_10, "switch.off", relay10off) - } - - if (virtual_switch_11) { - subscribe(arduino, "switch11.on", switch11on) - subscribe(arduino, "switch11.off", switch11off) - subscribe(virtual_switch_11, "switch.on", relay11on) - subscribe(virtual_switch_11, "switch.off", relay11off) - } - - if (virtual_switch_12) { - subscribe(arduino, "switch12.on", switch12on) - subscribe(arduino, "switch12.off", switch2off) - subscribe(virtual_switch_12, "switch.on", relay12on) - subscribe(virtual_switch_12, "switch.off", relay12off) - } - - if (virtual_switch_13) { - subscribe(arduino, "switch13.on", switch13on) - subscribe(arduino, "switch13.off", switch13off) - subscribe(virtual_switch_13, "switch.on", relay13on) - subscribe(virtual_switch_13, "switch.off", relay13off) - } - - if (virtual_switch_14) { - subscribe(arduino, "switch14.on", switch14on) - subscribe(arduino, "switch14.off", switch14off) - subscribe(virtual_switch_14, "switch.on", relay14on) - subscribe(virtual_switch_14, "switch.off", relay14off) - } - - if (virtual_switch_15) { - subscribe(arduino, "switch15.on", switch15on) - subscribe(arduino, "switch15.off", switch15off) - subscribe(virtual_switch_15, "switch.on", relay15on) - subscribe(virtual_switch_15, "switch.off", relay15off) - } - - if (virtual_switch_16) { - subscribe(arduino, "switch16.on", switch16on) - subscribe(arduino, "switch16.off", switch16off) - subscribe(virtual_switch_16, "switch.on", relay16on) - subscribe(virtual_switch_16, "switch.off", relay16off) - } - -} - -//--------------- Relay 1 handlers --------------- -def switch1on(evt) -{ - if (virtual_switch_1.currentValue("switch") != "on") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping On Virtual Switch to match Arduino" - virtual_switch_1.on() - } -} -def switch1off(evt) -{ - if (virtual_switch_1.currentValue("switch") != "off") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping Off Virtual Switch to match Arduino" - virtual_switch_1.off() - } -} -def relay1on(evt) -{ - if (arduino.currentValue("switch1") != "on") { - log.debug "relay1event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning On Arduino Relay to match Virtual Switch" - arduino.switch1on() - } -} -def relay1off(evt) -{ - if (arduino.currentValue("switch1") != "off") { - log.debug "relay1event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning Off Arduino Relay to match Virtual Switch" - arduino.switch1off() - } -} - -//--------------- Relay 2 handlers --------------- -def switch2on(evt) -{ - if (virtual_switch_2.currentValue("switch") != "on") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping On Virtual Switch to match Arduino" - virtual_switch_2.on() - } -} -def switch2off(evt) -{ - if (virtual_switch_2.currentValue("switch") != "off") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping Off Virtual Switch to match Arduino" - virtual_switch_2.off() - } -} -def relay2on(evt) -{ - if (arduino.currentValue("switch2") != "on") { - log.debug "relay2event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning On Arduino Relay to match Virtual Switch" - arduino.switch2on() - } -} -def relay2off(evt) -{ - if (arduino.currentValue("switch2") != "off") { - log.debug "relay2event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning Off Arduino Relay to match Virtual Switch" - arduino.switch2off() - } -} - -//--------------- Relay 3 handlers --------------- -def switch3on(evt) -{ - if (virtual_switch_3.currentValue("switch") != "on") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping On Virtual Switch to match Arduino" - virtual_switch_3.on() - } -} -def switch3off(evt) -{ - if (virtual_switch_3.currentValue("switch") != "off") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping Off Virtual Switch to match Arduino" - virtual_switch_3.off() - } -} -def relay3on(evt) -{ - if (arduino.currentValue("switch3") != "on") { - log.debug "relay3event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning On Arduino Relay to match Virtual Switch" - arduino.switch3on() - } -} -def relay3off(evt) -{ - if (arduino.currentValue("switch3") != "off") { - log.debug "relay3event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning Off Arduino Relay to match Virtual Switch" - arduino.switch3off() - } -} - -//--------------- Relay 4 handlers --------------- -def switch4on(evt) -{ - if (virtual_switch_4.currentValue("switch") != "on") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping On Virtual Switch to match Arduino" - virtual_switch_4.on() - } -} -def switch4off(evt) -{ - if (virtual_switch_4.currentValue("switch") != "off") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping Off Virtual Switch to match Arduino" - virtual_switch_4.off() - } -} -def relay4on(evt) -{ - if (arduino.currentValue("switch4") != "on") { - log.debug "relay4event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning On Arduino Relay to match Virtual Switch" - arduino.switch4on() - } -} -def relay4off(evt) -{ - if (arduino.currentValue("switch4") != "off") { - log.debug "relay4event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning Off Arduino Relay to match Virtual Switch" - arduino.switch4off() - } -} - -//--------------- Relay 5 handlers --------------- -def switch5on(evt) -{ - if (virtual_switch_5.currentValue("switch") != "on") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping On Virtual Switch to match Arduino" - virtual_switch_5.on() - } -} -def switch5off(evt) -{ - if (virtual_switch_5.currentValue("switch") != "off") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping Off Virtual Switch to match Arduino" - virtual_switch_5.off() - } -} -def relay5on(evt) -{ - if (arduino.currentValue("switch5") != "on") { - log.debug "relay5event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning On Arduino Relay to match Virtual Switch" - arduino.switch5on() - } -} -def relay5off(evt) -{ - if (arduino.currentValue("switch5") != "off") { - log.debug "relay5event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning Off Arduino Relay to match Virtual Switch" - arduino.switch5off() - } -} - -//--------------- Relay 6 handlers --------------- -def switch6on(evt) -{ - if (virtual_switch_6.currentValue("switch") != "on") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping On Virtual Switch to match Arduino" - virtual_switch_6.on() - } -} -def switch6off(evt) -{ - if (virtual_switch_6.currentValue("switch") != "off") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping Off Virtual Switch to match Arduino" - virtual_switch_6.off() - } -} -def relay6on(evt) -{ - if (arduino.currentValue("switch6") != "on") { - log.debug "relay6event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning On Arduino Relay to match Virtual Switch" - arduino.switch6on() - } -} -def relay6off(evt) -{ - if (arduino.currentValue("switch6") != "off") { - log.debug "relay6event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning Off Arduino Relay to match Virtual Switch" - arduino.switch6off() - } -} - -//--------------- Relay 7 handlers --------------- -def switch7on(evt) -{ - if (virtual_switch_7.currentValue("switch") != "on") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping On Virtual Switch to match Arduino" - virtual_switch_7.on() - } -} -def switch7off(evt) -{ - if (virtual_switch_7.currentValue("switch") != "off") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping Off Virtual Switch to match Arduino" - virtual_switch_7.off() - } -} -def relay7on(evt) -{ - if (arduino.currentValue("switch7") != "on") { - log.debug "relay7event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning On Arduino Relay to match Virtual Switch" - arduino.switch7on() - } -} -def relay7off(evt) -{ - if (arduino.currentValue("switch7") != "off") { - log.debug "relay7event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning Off Arduino Relay to match Virtual Switch" - arduino.switch7off() - } -} - -//--------------- Relay 8 handlers --------------- -def switch8on(evt) -{ - if (virtual_switch_8.currentValue("switch") != "on") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping On Virtual Switch to match Arduino" - virtual_switch_8.on() - } -} -def switch8off(evt) -{ - if (virtual_switch_8.currentValue("switch") != "off") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping Off Virtual Switch to match Arduino" - virtual_switch_8.off() - } -} -def relay8on(evt) -{ - if (arduino.currentValue("switch8") != "on") { - log.debug "relay8event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning On Arduino Relay to match Virtual Switch" - arduino.switch8on() - } -} -def relay8off(evt) -{ - if (arduino.currentValue("switch8") != "off") { - log.debug "relay8event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning Off Arduino Relay to match Virtual Switch" - arduino.switch8off() - } -} - -//--------------- Relay 9 handlers --------------- -def switch9on(evt) -{ - if (virtual_switch_9.currentValue("switch") != "on") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping On Virtual Switch to match Arduino" - virtual_switch_9.on() - } -} -def switch9off(evt) -{ - if (virtual_switch_9.currentValue("switch") != "off") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping Off Virtual Switch to match Arduino" - virtual_switch_9.off() - } -} -def relay9on(evt) -{ - if (arduino.currentValue("switch9") != "on") { - log.debug "relay9event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning On Arduino Relay to match Virtual Switch" - arduino.switch9on() - } -} -def relay9off(evt) -{ - if (arduino.currentValue("switch9") != "off") { - log.debug "relay9event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning Off Arduino Relay to match Virtual Switch" - arduino.switch9off() - } -} - -//--------------- Relay 10 handlers --------------- -def switch10on(evt) -{ - if (virtual_switch_10.currentValue("switch") != "on") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping On Virtual Switch to match Arduino" - virtual_switch_10.on() - } -} -def switch10off(evt) -{ - if (virtual_switch_10.currentValue("switch") != "off") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping Off Virtual Switch to match Arduino" - virtual_switch_10.off() - } -} -def relay10on(evt) -{ - if (arduino.currentValue("switch10") != "on") { - log.debug "relay10event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning On Arduino Relay to match Virtual Switch" - arduino.switch10on() - } -} -def relay10off(evt) -{ - if (arduino.currentValue("switch10") != "off") { - log.debug "relay10event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning Off Arduino Relay to match Virtual Switch" - arduino.switch10off() - } -} - -//--------------- Relay 11 handlers --------------- -def switch11on(evt) -{ - if (virtual_switch_11.currentValue("switch") != "on") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping On Virtual Switch to match Arduino" - virtual_switch_11.on() - } -} -def switch11off(evt) -{ - if (virtual_switch_11.currentValue("switch") != "off") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping Off Virtual Switch to match Arduino" - virtual_switch_11.off() - } -} -def relay11on(evt) -{ - if (arduino.currentValue("switch11") != "on") { - log.debug "relay11event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning On Arduino Relay to match Virtual Switch" - arduino.switch11on() - } -} -def relay11off(evt) -{ - if (arduino.currentValue("switch11") != "off") { - log.debug "relay11event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning Off Arduino Relay to match Virtual Switch" - arduino.switch11off() - } -} - -//--------------- Relay 12 handlers --------------- -def switch12on(evt) -{ - if (virtual_switch_12.currentValue("switch") != "on") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping On Virtual Switch to match Arduino" - virtual_switch_12.on() - } -} -def switch12off(evt) -{ - if (virtual_switch_12.currentValue("switch") != "off") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping Off Virtual Switch to match Arduino" - virtual_switch_12.off() - } -} -def relay12on(evt) -{ - if (arduino.currentValue("switch12") != "on") { - log.debug "relay12event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning On Arduino Relay to match Virtual Switch" - arduino.switch12on() - } -} -def relay12off(evt) -{ - if (arduino.currentValue("switch12") != "off") { - log.debug "relay12event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning Off Arduino Relay to match Virtual Switch" - arduino.switch12off() - } -} - -//--------------- Relay 13 handlers --------------- -def switch13on(evt) -{ - if (virtual_switch_13.currentValue("switch") != "on") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping On Virtual Switch to match Arduino" - virtual_switch_13.on() - } -} -def switch13off(evt) -{ - if (virtual_switch_13.currentValue("switch") != "off") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping Off Virtual Switch to match Arduino" - virtual_switch_13.off() - } -} -def relay13on(evt) -{ - if (arduino.currentValue("switch13") != "on") { - log.debug "relay13event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning On Arduino Relay to match Virtual Switch" - arduino.switch13on() - } -} -def relay13off(evt) -{ - if (arduino.currentValue("switch13") != "off") { - log.debug "relay13event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning Off Arduino Relay to match Virtual Switch" - arduino.switch13off() - } -} - -//--------------- Relay 14 handlers --------------- -def switch14on(evt) -{ - if (virtual_switch_14.currentValue("switch") != "on") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping On Virtual Switch to match Arduino" - virtual_switch_14.on() - } -} -def switch14off(evt) -{ - if (virtual_switch_14.currentValue("switch") != "off") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping Off Virtual Switch to match Arduino" - virtual_switch_14.off() - } -} -def relay14on(evt) -{ - if (arduino.currentValue("switch14") != "on") { - log.debug "relay14event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning On Arduino Relay to match Virtual Switch" - arduino.switch14on() - } -} -def relay14off(evt) -{ - if (arduino.currentValue("switch14") != "off") { - log.debug "relay14event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning Off Arduino Relay to match Virtual Switch" - arduino.switch14off() - } -} - -//--------------- Relay 15 handlers --------------- -def switch15on(evt) -{ - if (virtual_switch_15.currentValue("switch") != "on") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping On Virtual Switch to match Arduino" - virtual_switch_15.on() - } -} -def switch15off(evt) -{ - if (virtual_switch_15.currentValue("switch") != "off") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping Off Virtual Switch to match Arduino" - virtual_switch_15.off() - } -} -def relay15on(evt) -{ - if (arduino.currentValue("switch15") != "on") { - log.debug "relay15event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning On Arduino Relay to match Virtual Switch" - arduino.switch15on() - } -} -def relay15off(evt) -{ - if (arduino.currentValue("switch15") != "off") { - log.debug "relay15event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning Off Arduino Relay to match Virtual Switch" - arduino.switch15off() - } -} - -//--------------- Relay 16 handlers --------------- -def switch16on(evt) -{ - if (virtual_switch_16.currentValue("switch") != "on") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping On Virtual Switch to match Arduino" - virtual_switch_16.on() - } -} -def switch16off(evt) -{ - if (virtual_switch_16.currentValue("switch") != "off") { - log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" - log.debug "Flipping Off Virtual Switch to match Arduino" - virtual_switch_16.off() - } -} -def relay16on(evt) -{ - if (arduino.currentValue("switch16") != "on") { - log.debug "relay16event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning On Arduino Relay to match Virtual Switch" - arduino.switch16on() - } -} -def relay16off(evt) -{ - if (arduino.currentValue("switch16") != "off") { - log.debug "relay16event($evt.name: $evt.value: $evt.deviceId)" - log.debug "Turning Off Arduino Relay to match Virtual Switch" - arduino.switch16off() - } -} diff --git a/Groovy/ST_Anything_Relays/SmartApps/readme.txt b/Groovy/ST_Anything_Relays/SmartApps/readme.txt deleted file mode 100644 index 0c7a0fcf..00000000 --- a/Groovy/ST_Anything_Relays/SmartApps/readme.txt +++ /dev/null @@ -1,2 +0,0 @@ -Make sure you also get the Virtual Switch Device - VirtualSwitch.device.groovy - -from the \Groovy\VirtualDevices\ folder. \ No newline at end of file diff --git a/Groovy/ST_Anything_Switch_Dimmer/ST_Anything_Switch_Dimmer.device.groovy b/Groovy/ST_Anything_Switch_Dimmer/ST_Anything_Switch_Dimmer.device.groovy deleted file mode 100644 index c31029d8..00000000 --- a/Groovy/ST_Anything_Switch_Dimmer/ST_Anything_Switch_Dimmer.device.groovy +++ /dev/null @@ -1,92 +0,0 @@ -/** - * ST_AnyThing_Switch_Dimmer.groovy - * - * Copyright 2016 Dan G Ogorchock - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License - * for the specific language governing permissions and limitations under the License. - * - * Change History: - * - * Date Who What - * ---- --- ---- - * 2016-04-30 Dan Ogorchock Original Creation - * - */ - -metadata { - definition (name: "ST_AnyThing_Switch_Dimmer", namespace: "ogiewon", author: "Daniel Ogorchock") { - capability "Switch" - capability "Switch Level" - capability "Sensor" - capability "Actuator" - } - - simulator { - - } - - // Preferences - preferences { - } - - // Tile Definitions - tiles { - standardTile("switch", "device.switch", width: 1, height: 1, canChangeIcon: true) { - state "off", label: '${name}', action: "switch.on", icon: "st.switches.switch.off", backgroundColor: "#ffffff" - state "on", label: '${name}', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#79b821" - } - controlTile("levelSliderControl", "device.level", "slider", height: 1, width: 3, inactiveLabel: false) { - state "level", action:"switch level.setLevel" - } - valueTile("level", "device.level", inactiveLabel: false, decoration: "flat") { - state "level", label: 'Dim ${currentValue}' - } - - main(["switch"]) - details(["switch", "levelSliderControl", "level"]) - } -} - -// parse events into attributes -def parse(String description) { - log.debug "Parsing '${description}'" - def msg = zigbee.parse(description)?.text - log.debug "Parse got '${msg}'" - - def parts = msg.split(" ") - def name = parts.length>0?parts[0].trim():null - def value = parts.length>1?parts[1].trim():null - - name = value != "ping" ? name : null - - def result = createEvent(name: name, value: value) - - log.debug result - - return result -} - -// handle commands - -def on() { - log.debug "Executing 'switch on'" - zigbee.smartShield(text: "switch on").format() -} - -def off() { - log.debug "Executing 'switch off'" - zigbee.smartShield(text: "switch off").format() -} - -def setLevel(value) { - sendEvent(name: "level", value: value) - log.debug "Executing 'switch ${value}'" - zigbee.smartShield(text: "switch ${value}").format() -} \ No newline at end of file diff --git a/Groovy/ST_Anything_Temperatures/ST_Anything_Temperatures.device.groovy b/Groovy/ST_Anything_Temperatures/ST_Anything_Temperatures.device.groovy deleted file mode 100644 index 9cefa041..00000000 --- a/Groovy/ST_Anything_Temperatures/ST_Anything_Temperatures.device.groovy +++ /dev/null @@ -1,212 +0,0 @@ -/** - * ST_Anything_Temperatures.device.groovy - * - * Copyright 2014 Dan Ogorchock - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License - * for the specific language governing permissions and limitations under the License. - * - * Change History: - * - * Date Who What - * ---- --- ---- - * 2015-03-24 Dan Ogorchock Original Creation - * - */ - -metadata { - definition (name: "ST_AnyThing_Temperatures", namespace: "ogiewon", author: "Daniel Ogorchock") { - capability "Configuration" - capability "Temperature Measurement" - capability "Relative Humidity Measurement" - capability "Sensor" - capability "Polling" - - attribute "t_Oven", "string" - attribute "t_Broiler", "string" - attribute "t_Fridge", "string" - attribute "t_Freezer", "string" - attribute "t_Othercrisp", "string" - attribute "t_Moistcrisp", "string" - attribute "h_Fridge", "string" - attribute "h_Freezer", "string" - attribute "h_Othercrisp", "string" - attribute "h_Moistcrisp", "string" - } - - simulator { - - } - - - // Preferences - preferences { - input "temphumidSampleRate", "number", title: "Temperature/Humidity Sensors Sampling Interval (seconds)", description: "Sampling Interval (seconds)", defaultValue: 30, required: true, displayDuringSetup: true - input "thermocoupleSampleRate", "number", title: "Thermocouple Sensors Sampling Interval (seconds)", description: "Sampling Interval (seconds)", defaultValue: 30, required: true, displayDuringSetup: true - } - - - // Tile Definitions - tiles { - - valueTile("t_Oven", "device.t_Oven", width: 1, height: 1, inactiveLabel: false) { - state("temperature", label: 'Oven ${currentValue}°F', unit:"F", - backgroundColors: [ - [value: 31, color: "#153591"], - [value: 44, color: "#1e9cbb"], - [value: 59, color: "#90d2a7"], - [value: 74, color: "#44b621"], - [value: 84, color: "#f1d801"], - [value: 95, color: "#d04e00"], - [value: 96, color: "#bc2323"] - ] - ) - } - - valueTile("t_Broiler", "device.t_Broiler", width: 1, height: 1, inactiveLabel: false) { - state("temperature", label: 'Broiler ${currentValue}°F', unit:"F", - backgroundColors: [ - [value: 31, color: "#153591"], - [value: 44, color: "#1e9cbb"], - [value: 59, color: "#90d2a7"], - [value: 74, color: "#44b621"], - [value: 84, color: "#f1d801"], - [value: 95, color: "#d04e00"], - [value: 96, color: "#bc2323"] - ] - ) - } - - valueTile("t_Fridge", "device.t_Fridge", width: 1, height: 1, inactiveLabel: false) { - state("temperature", label: 'Fridge\n${currentValue}°F', unit:"F", - backgroundColors: [ - [value: 31, color: "#153591"], - [value: 44, color: "#1e9cbb"], - [value: 59, color: "#90d2a7"], - [value: 74, color: "#44b621"], - [value: 84, color: "#f1d801"], - [value: 95, color: "#d04e00"], - [value: 96, color: "#bc2323"] - ] - ) - } - - valueTile("t_Freezer", "device.t_Freezer", width: 1, height: 1, inactiveLabel: false) { - state("temperature", label: 'Freezer\n${currentValue}°F', unit:"F", - backgroundColors: [ - [value: 31, color: "#153591"], - [value: 44, color: "#1e9cbb"], - [value: 59, color: "#90d2a7"], - [value: 74, color: "#44b621"], - [value: 84, color: "#f1d801"], - [value: 95, color: "#d04e00"], - [value: 96, color: "#bc2323"] - ] - ) - } - - valueTile("t_Othercrisp", "device.t_Othercrisp", width: 1, height: 1, inactiveLabel: false) { - state("temperature", label: 'Other Crisper\n${currentValue}°F', unit:"F", - backgroundColors: [ - [value: 31, color: "#153591"], - [value: 44, color: "#1e9cbb"], - [value: 59, color: "#90d2a7"], - [value: 74, color: "#44b621"], - [value: 84, color: "#f1d801"], - [value: 95, color: "#d04e00"], - [value: 96, color: "#bc2323"] - ] - ) - } - - valueTile("t_Moistcrisp", "device.t_Moistcrisp", width: 1, height: 1, inactiveLabel: false) { - state("temperature", label: 'Moist Crisper\n${currentValue}°F', unit:"F", - backgroundColors: [ - [value: 31, color: "#153591"], - [value: 44, color: "#1e9cbb"], - [value: 59, color: "#90d2a7"], - [value: 74, color: "#44b621"], - [value: 84, color: "#f1d801"], - [value: 95, color: "#d04e00"], - [value: 96, color: "#bc2323"] - ] - ) - } - - valueTile("h_Fridge", "device.h_Fridge", width: 1, height: 1, inactiveLabel: false) { - state "humidity", label:'Fridge\n${currentValue}% humidity', unit:"" - } - - valueTile("h_Freezer", "device.h_Freezer", width: 1, height: 1, inactiveLabel: false) { - state "humidity", label:'Freezer\n${currentValue}% humidity', unit:"" - } - - valueTile("h_Moistcrisp", "device.h_Moistcrisp", width: 1, height: 1, inactiveLabel: false) { - state "humidity", label:'Moist\nCrisper ${currentValue}% humidity', unit:"" - } - - valueTile("h_Othercrisp", "device.h_Othercrisp", width: 1, height: 1, inactiveLabel: false) { - state "humidity", label:'Other\nCrisper ${currentValue}% humidity', unit:"" - } - - standardTile("configure", "device.configure", inactiveLabel: false, decoration: "flat") { - state "configure", label:'', action:"configuration.configure", icon:"st.secondary.configure" - } - - main (["t_Oven", "t_Broiler", "t_Fridge", "t_Freezer", "t_Moistcrisp", "t_Othercrisp", "h_Fridge", "h_Freezer", "h_Moistcrisp", "h_Othercrisp"]) - details(["t_Oven", "t_Broiler", "t_Fridge", "t_Freezer", "t_Moistcrisp", "t_Othercrisp", "h_Fridge", "h_Freezer", "h_Moistcrisp", "h_Othercrisp", "configure"]) - } -} - -// parse events into attributes -def parse(String description) { - log.debug "Parsing '${description}'" - def msg = zigbee.parse(description)?.text - log.debug "Parse got '${msg}'" - - def parts = msg.split(" ") - def name = parts.length>0?parts[0].trim():null - def value = parts.length>1?parts[1].trim():null - - name = value != "ping" ? name : null - - def result = createEvent(name: name, value: value) - - log.debug result - - return result -} - -// handle commands - -def poll() { - //temporarily implement poll() to issue a configure() command to send the polling interval settings to the arduino - //use the Pollster SmartApp to execute this polling routine about once per hour in case Arduino gets power cycled - configure() -} - - -def configure() { - log.debug "Executing 'configure'" - log.debug "temphumid SampleRate = " + temphumidSampleRate - log.debug "thermocouple SampleRate = " + thermocoupleSampleRate - [ - zigbee.smartShield(text: "th_Freezer " + temphumidSampleRate).format(), - "delay 1000", - zigbee.smartShield(text: "th_Fridge " + temphumidSampleRate).format(), - "delay 1000", - zigbee.smartShield(text: "th_Moistcrisp " + temphumidSampleRate).format(), - "delay 1000", - zigbee.smartShield(text: "th_Othercrisp " + temphumidSampleRate).format(), - "delay 1000", - zigbee.smartShield(text: "t_Broiler " + thermocoupleSampleRate).format(), - "delay 1000", - zigbee.smartShield(text: "t_Oven " + thermocoupleSampleRate).format() - ] -} \ No newline at end of file diff --git a/Groovy/ST_Anything.groovy b/Groovy/ST_Anything_ThingShield/DeviceHandlers/ST_Anything_ThingShield.device.groovy similarity index 91% rename from Groovy/ST_Anything.groovy rename to Groovy/ST_Anything_ThingShield/DeviceHandlers/ST_Anything_ThingShield.device.groovy index 58568376..d54f16df 100644 --- a/Groovy/ST_Anything.groovy +++ b/Groovy/ST_Anything_ThingShield/DeviceHandlers/ST_Anything_ThingShield.device.groovy @@ -1,5 +1,5 @@ /** - * ST_AnyThing.groovy + * ST_AnyThing_ThingShield.device.groovy * * Copyright 2014 Dan G Ogorchock & Daniel J Ogorchock * @@ -17,11 +17,12 @@ * Date Who What * ---- --- ---- * 2015-01-03 Dan & Daniel Original Creation + * 2017-02-12 Dan Ogorchock Renamed to reflect use only with ThingShield * */ metadata { - definition (name: "ST_AnyThing", namespace: "ogiewon", author: "Daniel Ogorchock") { + definition (name: "ST_AnyThing_ThingShield", namespace: "ogiewon", author: "Daniel Ogorchock") { capability "Configuration" capability "Illuminance Measurement" capability "Temperature Measurement" @@ -46,9 +47,9 @@ metadata { // Preferences preferences { - input "illuminanceSampleRate", "number", title: "Light Sensor Sampling Interval (seconds)", description: "Sampling Interval (seconds)", defaultValue: 30, required: true, displayDuringSetup: true - input "temphumidSampleRate", "number", title: "Temperature/Humidity Sensor Sampling Interval (seconds)", description: "Sampling Interval (seconds)", defaultValue: 30, required: true, displayDuringSetup: true - input "waterSampleRate", "number", title: "Water Sensor Sampling Interval (seconds)", description: "Sampling Interval (seconds)", defaultValue: 30, required: true, displayDuringSetup: true + input "illuminanceSampleRate", "number", title: "Light Sensor Inputs", description: "Sampling Interval (seconds)", defaultValue: 30, required: true, displayDuringSetup: true + input "temphumidSampleRate", "number", title: "Temperature/Humidity Sensor Inputs", description: "Sampling Interval (seconds)", defaultValue: 30, required: true, displayDuringSetup: true + input "waterSampleRate", "number", title: "Water Sensor Inputs", description: "Sampling Interval (seconds)", defaultValue: 30, required: true, displayDuringSetup: true } // Tile Definitions diff --git a/Groovy/ST_Anything_TimedRelay/ST_Anything_TimedRelay.device.groovy b/Groovy/ST_Anything_TimedRelay/ST_Anything_TimedRelay.device.groovy deleted file mode 100644 index af403513..00000000 --- a/Groovy/ST_Anything_TimedRelay/ST_Anything_TimedRelay.device.groovy +++ /dev/null @@ -1,72 +0,0 @@ -/** - * ST_Anything_TimedRelay Device Type - ST_Anything_TimedRelay.device.groovy - * - * Copyright 2015 Daniel Ogorchock - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License - * for the specific language governing permissions and limitations under the License. - * - */ -metadata { - definition (name: "ST_Anything_TimedRelay", namespace: "ogiewon", author: "Daniel Ogorchock") { - capability "Momentary" - capability "Switch" - } - - simulator { - // TODO: define status and reply messages here - } - - tiles { - standardTile("switch", "device.switch", width: 1, height: 1, canChangeIcon: true) { - state "off", label: '${name}', action: "switch.on", icon: "st.switches.switch.off", backgroundColor: "#ffffff" - state "on", label: '${name}', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#79b821" - } - - main("switch") - details("switch") - - } -} - -// parse events into attributes -def parse(String description) { - log.debug "Parsing '${description}'" - def msg = zigbee.parse(description)?.text - log.debug "Parse got '${msg}'" - - def parts = msg.split(" ") - def name = parts.length>0?parts[0].trim():null - def value = parts.length>1?parts[1].trim():null - - name = value != "ping" ? name : null - - def result = createEvent(name: name, value: value) - - log.debug result - - return result -} - - -// handle commands -def push() { - log.debug "Executing 'push'" - zigbee.smartShield(text: "switch on").format() -} - -def on() { - log.debug "Executing 'switch on'" - zigbee.smartShield(text: "switch on").format() -} - -def off() { - log.debug "Executing 'switch off'" - zigbee.smartShield(text: "switch off").format() -} diff --git a/README.md b/README.md index 7ac3011b..10790f71 100644 --- a/README.md +++ b/README.md @@ -6,38 +6,51 @@ History: - v1.4 2015-04-14 Memory Optimizations - v1.5 2015-12-06 Added Alarm_Panel MEGA 2560 example, as well as adding Smoke Detector capability - v1.6 2017-02-11 Final release prior to the new version 2.0 baseline +- v2.0 2017-02-12 Initial release of v2.x paltform with additonal support for Ethernet connectivity to SmartThings + +ST_Anything v2.0 +================ +Note: We created a ST_Anything v1.6 release on 2017-02-11 to make sure everyone can still get back to the original ThingShield-only code if necessary. + +Note: ST_Anything v2.0 was built using the Arduino IDE v1.8.1. Please make sure to upgrade your IDE. + +Turn your Arduino UNO/MEGA or NodeMCU ESP8266 into an AnyThing. ST_Anything is an Arduino library, sketch, and Device Handler that works with your Arduino/ThingShield, Arduino/W5100 Ethernet shield, or a NodeMCU ESP8266 to create an all-in-one SmartThings device. + +Note: There are some significant changes as compared to the old v1.x platform. A signiciant rewrite of the "SmartThings" Arduino library was completed to incorporate Ethernet communications support. To use ST_Anything v2.x, you must also use all of the other supporting libaries found in this GitHub repository. Included is a the new SmartThings v2.x Arduino library which can be used standalone (examples are included in the library), or in conjunction with the ST_Anything library. + +For now, I focused on getting something together for the user community to take a look at. All of my previous examples have not been modified yet to support the new SmartThings v2.x library. Therefore I have removed them from this initial release to avoid confusion. The original "ST_Anything" examples are still here to get you started. I hope to add the others back back when I have more time. + +THIS IS A WORK IN PROGRESS! So please be patient. The essential code is all here and has been tested. Documentation is still lacking somewhat, so feel free to submit a pull request to improve this ReadMe as you try to get things working. + -ST_Anything -=========== -Turn your Arduino into an AnyThing. ST_Anything is an Arduino library, sketch, and Device Type that works with your SmartThings ThingShield to create an all-in-one SmartThings device. ![screenshot](https://cloud.githubusercontent.com/assets/5206084/12374289/021d4434-bc65-11e5-9efa-1457365a6cd5.PNG) This package currently implements the following SmartThings Device Capabilities: -- Alarm (Siren only currently) (HoneyWell Wave 2 Siren (http://amzn.com/B0006BCCAE) + relay) +- Alarm (Siren only currently) (digital output to a relay) - Configuration - Illuminance Measurement (photo resistor) - Motion Sensor (HC-SR501 Infrared PIR) -- Relative Humidity Measurement (DHT22) +- Relative Humidity Measurement (DHT22, DHT11) - Switch (Sunfounder Relay - http://amzn.com/B00E0NTPP4) -- Temperature Measurement (DHT22 - requires DHT Library, see below) +- Temperature Measurement (DHT22 - requires Rob Tillaart's DHT 0.1.13 Library, included in this repo) - Water Sensor (http://amzn.com/B00HTSL7QC) - Contact Sensor (Magnetic Door Switch) -- Door Control (i.e. Garage Door Contact Sensor + Relay Output) - New! See 'ST_Anything_Doors' example -- RCSwitch Control (i.e. Radio Control Switch) - New! See 'ST_Anything_RCSwitch' example (Requires RCSwitch library, see below) -- Thermocouple Temperature Measurement (via the Adafruit MAX31855 library) +- Door Control (i.e. Garage Door Contact Sensor + Relay Output) - See 'ST_Anything_Doors' example +- RCSwitch Control (i.e. Radio Control Switch) - New! See 'ST_Anything_RCSwitch' example (Requires RCSwitch library, included in this repo) +- Thermocouple Temperature Measurement (via the Adafruit MAX31855 library, included in this repo) - Smoke Detector (as a simple digital input) -Note: Attempting to use all of these at once on an Arduino UNO is likely to result in running out of SRAM on the UNO (the UNO only has 2 kilobytes of RAM.) Using an Arduino MEGA 2560 with 8 kilobytes of SRAM is recommended if you want to run everything at once. +Note: Attempting to use all of these at once on an Arduino UNO R3 is likely to result in running out of SRAM on the UNO (the UNO only has 2 kilobytes of RAM.) Using an Arduino MEGA 2560 with 8 kilobytes of SRAM is recommended if you want to run everything at once. ## Overview ST_Anything (original example) consists of four parts: -- The ST_Anything.ino Arduino sketch -- The ST_Anything Arduino library -- The SmartThings (ThingShield) library - A modified, more efficient version -- The ST_Anything.groovy DeviceType +- The ST_Anything_ThingShield.ino, ST_Anything_EthernetW5100.ino, and ST_Anything_ESP8266WiFi.ino example Arduino sketches +- The ST_Anything Arduino libraries +- The SmartThings library - A modified, more efficient version +- The ST_Anything_ThingShield.device.groovy (ThingShield) and ST_Anything_Ethernet.device.groovy (W5100 and ESP8266) Device Handlers that correspond to the sketches above. ##ST_Anything Arduino Setup Instructions - Download the ST_Anything repository. @@ -45,12 +58,10 @@ ST_Anything (original example) consists of four parts: - On Mac, it's located in `~/Documents/Arduino/`. - On Windows, it's located in `C:\My Documents\Arduino`. - Look inside the `Arduino/Sketches` folder of the repo. -- Copy and paste the `ST_Anything` sketch folder into your local Arduino sketches directory. If you haven't created any sketches, you may not see the folder. In this case, feel free to create it. +- Copy and paste all of the `ST_Anything...` sketch folders into your local Arduino sketches directory. If you haven't created any sketches, you may not see the folder. In this case, feel free to create it. - Look inside the `Arduino/libraries` folder of the repo. -- Copy and paste both the `ST_Anything` and `SmartThings` (as well as all of the other new libraries from v1.2 and v1.3) folders into your local Arduino libraries directory. (Note: it may be wise to rename your existing 'SmartThings' library to prevent any overwriting if you have already downloaded the official release.) -- Download DHT library from https://github.com/RobTillaart/Arduino/tree/master/libraries/DHTlib and copy dht.h, dht.cpp, and ReadMe.txt to your 'Arduino\libraries\DHT' folder. NOTE: This library is now included in my github repo (v1.2) -- Download the RCSwitch library from http://code.google.com/p/rc-switch/downloads/list?can=3&q= and copy it to your 'Arduino\libraries\RCSwitch' folder. NOTE: This library is now included in my github repo (v1.2) -- Open the ST_Anything.ino and see if it successfully compiles. +- Copy and paste both the `ST_Anything` and `SmartThings` (as well as all of the other library folders) into your local Arduino libraries directory. +- Open the ST_Anything_ThingsShield.ino and see if it successfully compiles. - WARNING: If you are using an Arduino UNO, you will most likely need to comment out some of the devices in the sketch (both in the global variable declaration section as well as the setup() function) due to the UNO's limited 2 kilobytes of SRAM. Failing to do so will most likely result in unpredictable behavior. The Arduino MEGA 2560 has 8k of SRAM and has four Hardware Serial ports (UARTs). If you plan on using lots of devices, get the MEGA 2560. ##ST_Anything SmartThings Device Handler Installation Instructions @@ -59,7 +70,7 @@ ST_Anything (original example) consists of four parts: - Click on "My Device Handlers" from the navigation menu. - Click on "+ New Device Handler" button. - Select the "From Code" Tab near the top of the page -- Paste the code from the ST_Anything.groovy file from this repo. +- Paste the code from the ST_Anything_ThingShield.device.groovy file from this repo. - If you commented out any of the devices in the sketch, be sure to comment out the corresponding tiles & preferences in the ST_Anything.groovy code as well. - Click on "Create" near the bottom of the page. - Click on "Save" in the IDE. @@ -67,86 +78,21 @@ ST_Anything (original example) consists of four parts: - Click on My Devices from navigation menu - Select your "Arduino ThingShield" device from the list - Click the Edit button at the bottom of the screen -- Change the Type to "ST_Anything" +- Change the Type to "ST_Anything_ThingShield" - Click the Update button at the bottom of the screen - On your phone, log out of SmartThings in the app, and then log back into SmartThings to refresh its settings - Your Arduino Device Tile should now look like the image above in this ReadMe -- Be sure to go into the Preferences section to set the polling rates for the sensors. These are sent to the Arduino if you press the Configure tile. (Note: Currently, these settings do not persist after an Arduino reboot. I am hoping to figure out a method to have SmartThings send the Configure() command each time the Arduino starts up. Gotta leave something for the future! :) ) +- Be sure to go into the Preferences section to set the polling rates for the sensors. These are sent to the Arduino if you press the Configure tile. (Note: Currently, these settings do not persist after an Arduino reboot.) -##Updated SmartThings ThingShield Library -While developing the ST_Anything library and Arduino sketch, it was discovered that the Arduino UNO R3's 2 kilobytes of SRAM was quickly limiting the number of devices that could be hosted simultaneously. Numerous optimizations were made to the ST_Anything library which resulted in significant savings. Focus was then turned to the SmartThings ThingShield library. - -Improvements to the SmartThings ThingShield library include: -- 100% backwards compatible for use with your existing Arduino code -- Performance improvements -- SRAM memory optimizations (~150 bytes saved) -- Elimination of unnecessary temporary dynamic memory allocations (255 bytes per send command) -- Elimination of unused variables and dead code paths -- The additon of a Hardware Serial communications constructor -- Support for the 3 additional hardware UARTS on the Arduino MEGA 2560 - -If you choose to use the complete ST_Anything package (i.e. ST_Anything.ino, ST_Anything library, and ST_Anything.groovy) the following choices are automatically made: -- If using an Arduino UNO - SoftwareSerial is used on pins 2/3 -- If using an Arduino Leonardo - SoftwareSerial is used on pins 2/10 (add jumper from pin 10 to pin 2) -- If using an Arduino MEGA, Hardware Serial is used on pins 14/15 (add jumpers from Pin14 to Pin2 and another from Pin15 to Pin3) - -. -. -. - -###WARNING - Geeky Material Ahead!!! - -. -. -. - -If you want to use the new SmartThings libary with your existing sketches (or to just learn more about how all this stuff works, keep reading...) - -The Arduino UNO should typically use the SoftwareSerial library Constructor since the UNO has only one Hardware UART port ("Serial") which is used by the USB port for programming and debugging. -To use SoftwareSerial: -- Use the original SoftwareSerial constructor passing in pinRX=3 and pinTX=2 - - SmartThings(uint8_t pinRX, uint8_t pinTX, SmartThingsCallout_t *callout) call. -- Make sure the ThingShield's switch in the "D2/D3" position -- Be certain to not use Pins 2 & 3 in your Arduino sketch for I/O since they are electrically connected to the ThingShield. Pin6 is also reserved by the ThingShield. Best to avoid using it. - -The Arduino Leonardo and Mega can use SoftwareSerial BUT cannot use Pin3 for Rx since that pin does not support interrupts on these boards. -To use SoftwareSerial: -- Use Pin 10 for Rx and add a wire jumper from Pin10 to Pin3. Use Pin 2 for Tx as usual -- Use the original SoftwareSerial constructor passing in pinRX=10 and pinTX=2 - - SmartThings(uint8_t pinRX, uint8_t pinTX, SmartThingsCallout_t *callout); -- Make sure the ThingShield's switch in the "D2/D3" position -- Be certain to not use Pins 2 & 3 in your Arduino sketch for I/O since they are electrically connected to the ThingShield. Pin6 is also reserved by the ThingShield. Best to avoid using it. - -The Arduino UNO, Leonardo, and MEGA can use the Hardware "Serial" (pins 0,1) if desired, but USB programming and debug will be troublesome. -To use Hardware Serial: -- Use the new Hardware Serial constructor passing in the Arduino's pin 0/1 UART (i.e "HW_SERIAL") - - SmartThings(SmartThingsSerialType_t hwSerialPort, SmartThingsCallout_t *callout); - - Note: SmartThingsSerialType_t is a new enum declared in SmartThings.h. For the pin 0/1 UART, pass in "HW_SERIAL" -- Download your sketch from the IDE with the ThingShield's switch in the "D2/D3" position -- After the download is complete, move the switch to the "D0/D1" position and press RESET to allow the program to restart -- You must suppress any and all "Serial.begin(), Serial.print(), Serial.println(), Serial.write(), Serial.read(), Serial.end(), Serial..." commands from your code when using Hardware Serial on pins 0/1 to avoid conflicts with the ThingShield's communication with the SmartThings library. -- Pin6 is also reserved by the ThingShield. Best to avoid using it. - -The Arduino MEGA should use the new Hardware Serial Constructor since it has 4 UARTs. -To use Hardware Serial on "Serial3": -- The "Serial3" port uses pins 14(Tx) and 15(Rx). Wire a jumper Pin14 to Pin2 and another from Pin15 to Pin3. -- Use the new Hardware Serial constructor passing in the Arduino's pin 14/15 UART (i.e "HW_SERIAL3") - - SmartThings(SmartThingsSerialType_t hwSerialPort, SmartThingsCallout_t *callout); - - Note: SmartThingsSerialType_t is a new enum declared in SmartThings.h. For the pin 14/15 UART, pass in "HW_SERIAL3" -- Make sure the ThingShield's switch in the "D2/D3" position -- Be certain to not use Pins 2 & 3 in your Arduino sketch for I/O since they are electrically connected to the ThingShield. Pin6 is also reserved by the ThingShield. Best to avoid using it. - -Additional Information: -The SoftwareSerial library has the following known limitations: -- If using multiple software serial ports, only one can receive data at a time. -- Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8(62), A9(63), A10(64), A11(65), A12(66), A13(67), A14(68), A15(69). -- Not all pins on the Leonardo and Micro support change interrupts, so only the following can be used for RX : 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI). +##Ethernet (Arduino/W5100 and ESP8266) Examples +The steps for using the Arduino/W5100 and NodeMCU ESP8266 sample code is very similar to above, with the added hassle of staic IP assignements, MAC addresses, SSID and Passwords, etc... +For now, please refer to the SmartThings library's Readme.md for these details https://github.com/DanielOgorchock/ST_Anything/tree/master/Arduino/libraries/SmartThings -For more details on the methods used in ST_Anything to measure and optimize the amount of free RAM, please refer to https://learn.adafruit.com/memories-of-an-arduino/measuring-free-memory and https://learn.adafruit.com/memories-of-an-arduino/optimizing-sram. This is a great site for any Arduino programmer. -More instructions coming soon: - -For now, reference the header files of the ST_Anything library for explanation of specific classes. +##Updated SmartThings ThingShield Library +As mentioned previously, the "SmartThings" v2.x library was extensively modified for Ethernet support. Please see the readme.md file for that particular library for more detailed information. + +Plese refer to the header files of the ST_Anything library for explanation of specific classes, constructor arguments, etc... -Look at the documentation in the 'ST_Anything.ino' file for explanation of general use of the library. +Look at the documentation in the 'ST_Anything_ThingShield.ino' file for explanation of general use of the library.