From c9c4adf8d783b2be5459f2c84e89fd4f9d4a90e9 Mon Sep 17 00:00:00 2001 From: Henrik Ekblad Date: Sun, 20 Sep 2015 22:57:23 +0200 Subject: [PATCH] Clean up the header files --- .../core/MyGatewayTransportEthernet.cpp | 7 ++ .../core/MyGatewayTransportEthernet.h | 44 --------- .../core/MyGatewayTransportSerial.cpp | 10 +- .../MySensors/core/MyGatewayTransportSerial.h | 30 ------ .../MySensors/core/MyProtocolMySensors.cpp | 8 +- .../MySensors/core/MyProtocolMySensors.h | 30 ------ libraries/MySensors/core/MySigning.h | 1 + .../MySensors/core/MySigningAtsha204.cpp | 3 +- libraries/MySensors/core/MySigningAtsha204.h | 46 ---------- .../MySensors/core/MySigningAtsha204Soft.cpp | 4 +- .../MySensors/core/MySigningAtsha204Soft.h | 53 ----------- libraries/MySensors/core/MySigningNone.cpp | 92 ------------------- libraries/MySensors/core/MySigningNone.h | 41 --------- libraries/MySensors/core/MyTransportNRF24.cpp | 16 +++- libraries/MySensors/core/MyTransportNRF24.h | 38 -------- libraries/MySensors/core/MyTransportRFM69.cpp | 4 +- libraries/MySensors/core/MyTransportRFM69.h | 29 ------ .../examples/LightSensor/LightSensor.ino | 19 ++-- .../SecureActuator/SecureActuator.ino | 2 +- 19 files changed, 55 insertions(+), 422 deletions(-) delete mode 100644 libraries/MySensors/core/MyGatewayTransportEthernet.h delete mode 100644 libraries/MySensors/core/MyGatewayTransportSerial.h delete mode 100644 libraries/MySensors/core/MyProtocolMySensors.h delete mode 100644 libraries/MySensors/core/MySigningAtsha204.h delete mode 100644 libraries/MySensors/core/MySigningAtsha204Soft.h delete mode 100644 libraries/MySensors/core/MySigningNone.cpp delete mode 100644 libraries/MySensors/core/MySigningNone.h delete mode 100644 libraries/MySensors/core/MyTransportNRF24.h delete mode 100644 libraries/MySensors/core/MyTransportRFM69.h diff --git a/libraries/MySensors/core/MyGatewayTransportEthernet.cpp b/libraries/MySensors/core/MyGatewayTransportEthernet.cpp index 8e661fd..cebf6cc 100644 --- a/libraries/MySensors/core/MyGatewayTransportEthernet.cpp +++ b/libraries/MySensors/core/MyGatewayTransportEthernet.cpp @@ -35,6 +35,13 @@ MyMessage _ethernetMsg; #endif /* USE_UDP */ +#define MAX_RECEIVE_LENGTH 100 // Maximum message length for messages coming from controller + +#ifndef MY_IP_ADDRESS + void gatewayTransportRenewIP(); +#endif + + bool gatewayTransportInit() { #ifdef MY_IP_ADDRESS Ethernet.begin(_ethernetGatewayMAC, _ethernetGatewayIP); diff --git a/libraries/MySensors/core/MyGatewayTransportEthernet.h b/libraries/MySensors/core/MyGatewayTransportEthernet.h deleted file mode 100644 index c949d81..0000000 --- a/libraries/MySensors/core/MyGatewayTransportEthernet.h +++ /dev/null @@ -1,44 +0,0 @@ -/** - * The MySensors Arduino library handles the wireless radio link and protocol - * between your home built sensors/actuators and HA controller of choice. - * The sensors forms a self healing radio network with optional repeaters. Each - * repeater and gateway builds a routing tables in EEPROM which keeps track of the - * network topology allowing messages to be routed to nodes. - * - * Created by Tomas Hozza - * Copyright (C) 2015 Tomas Hozza - * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors - * - * Documentation: http://www.mysensors.org - * Support Forum: http://forum.mysensors.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - */ - -#ifndef MyGatewayTransportEthernet_h -#define MyGatewayTransportEthernet_h - -#include "MyConfig.h" -#include "MyMessage.h" -#include "MyProtocol.h" -#include "MyProtocolMySensors.h" -#include "MyGatewayTransport.h" - - -// Use this if you have attached a Ethernet ENC28J60 shields -//#include - - - -#define CONTROLLER_PORT 5003 -#define IP_RENEWAL_INTERVAL 60000 // in milliseconds -#define MAX_RECEIVE_LENGTH 100 // Maximum message length for messages coming from controller - - -#ifndef MY_IP_ADDRESS - void gatewayTransportRenewIP(); -#endif - -#endif /* MyGatewayTransportEthernet_h */ diff --git a/libraries/MySensors/core/MyGatewayTransportSerial.cpp b/libraries/MySensors/core/MyGatewayTransportSerial.cpp index 390dc17..ed6b5ce 100644 --- a/libraries/MySensors/core/MyGatewayTransportSerial.cpp +++ b/libraries/MySensors/core/MyGatewayTransportSerial.cpp @@ -18,14 +18,18 @@ */ -#include "MyGatewayTransportSerial.h" +#include "MyConfig.h" +#include "MyProtocolMySensors.h" +#include "MyGatewayTransport.h" +#include "MyMessage.h" +#include "MyProtocol.h" + +#define MAX_RECEIVE_LENGTH 100 // Maximum message length for messages coming from controller char _serialInputString[MAX_RECEIVE_LENGTH]; // A buffer for incoming commands from serial interface int _serialInputPos; MyMessage _serialMsg; - - bool gatewayTransportInit() { return true; } diff --git a/libraries/MySensors/core/MyGatewayTransportSerial.h b/libraries/MySensors/core/MyGatewayTransportSerial.h deleted file mode 100644 index 8b81905..0000000 --- a/libraries/MySensors/core/MyGatewayTransportSerial.h +++ /dev/null @@ -1,30 +0,0 @@ -/** - * The MySensors Arduino library handles the wireless radio link and protocol - * between your home built sensors/actuators and HA controller of choice. - * The sensors forms a self healing radio network with optional repeaters. Each - * repeater and gateway builds a routing tables in EEPROM which keeps track of the - * network topology allowing messages to be routed to nodes. - * - * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB - * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors - * - * Documentation: http://www.mysensors.org - * Support Forum: http://forum.mysensors.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - */ - -#ifndef MyGatewayTransportSerial_h -#define MyGatewayTransportSerial_h - -#include "MyMessage.h" -#include "MyGatewayTransport.h" -#include "MyProtocol.h" -#include "MyProtocolMySensors.h" - -#define MAX_RECEIVE_LENGTH 100 // Maximum message length for messages coming from controller - -#endif diff --git a/libraries/MySensors/core/MyProtocolMySensors.cpp b/libraries/MySensors/core/MyProtocolMySensors.cpp index 2fa527a..f231cd9 100644 --- a/libraries/MySensors/core/MyProtocolMySensors.cpp +++ b/libraries/MySensors/core/MyProtocolMySensors.cpp @@ -17,9 +17,13 @@ * version 2 as published by the Free Software Foundation. */ -#include "MyProtocol.h" -#include "MyProtocolMySensors.h" +#include "MyConfig.h" #include "MyTransport.h" +#include "MyProtocol.h" + +#define MAX_FORMAT_BUFFER_LENGTH 120 // Max buffersize when formatting messages + +uint8_t protocolH2i(char c); char _fmtBuffer[MAX_FORMAT_BUFFER_LENGTH]; char _convBuffer[MAX_PAYLOAD*2+1]; diff --git a/libraries/MySensors/core/MyProtocolMySensors.h b/libraries/MySensors/core/MyProtocolMySensors.h deleted file mode 100644 index 4583abd..0000000 --- a/libraries/MySensors/core/MyProtocolMySensors.h +++ /dev/null @@ -1,30 +0,0 @@ -/** - * The MySensors Arduino library handles the wireless radio link and protocol - * between your home built sensors/actuators and HA controller of choice. - * The sensors forms a self healing radio network with optional repeaters. Each - * repeater and gateway builds a routing tables in EEPROM which keeps track of the - * network topology allowing messages to be routed to nodes. - * - * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB - * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors - * - * Documentation: http://www.mysensors.org - * Support Forum: http://forum.mysensors.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - */ - -#ifndef MyProtocolDefault_h -#define MyProtocolDefault_h - -#include "MyConfig.h" -#include "MyTransport.h" - -#define MAX_FORMAT_BUFFER_LENGTH 120 // Max buffersize when formatting messages - -uint8_t protocolH2i(char c); - -#endif diff --git a/libraries/MySensors/core/MySigning.h b/libraries/MySensors/core/MySigning.h index 2e430c1..5027160 100644 --- a/libraries/MySensors/core/MySigning.h +++ b/libraries/MySensors/core/MySigning.h @@ -27,6 +27,7 @@ #ifndef MySigning_h #define MySigning_h +#include "MyConfig.h" #include #include "MyMessage.h" #include "drivers/ATSHA204/ATSHA204.h" diff --git a/libraries/MySensors/core/MySigningAtsha204.cpp b/libraries/MySensors/core/MySigningAtsha204.cpp index ae32dc2..6bc735c 100644 --- a/libraries/MySensors/core/MySigningAtsha204.cpp +++ b/libraries/MySensors/core/MySigningAtsha204.cpp @@ -27,7 +27,6 @@ #if defined(ARDUINO_ARCH_AVR) #include "MySigning.h" -#include "MySigningAtsha204.h" #define SIGNING_IDENTIFIER (1) @@ -46,6 +45,8 @@ uint8_t _singning_tx_buffer[SHA204_CMD_SIZE_MAX]; const whitelist_entry_t _signing_whitelist[] = MY_SIGNING_NODE_WHITELISTING; #endif +void signerCalculateSignature(MyMessage &msg); +uint8_t* signerSha256(const uint8_t* data, size_t sz); #ifdef DEBUG_SIGNING diff --git a/libraries/MySensors/core/MySigningAtsha204.h b/libraries/MySensors/core/MySigningAtsha204.h deleted file mode 100644 index da9bee3..0000000 --- a/libraries/MySensors/core/MySigningAtsha204.h +++ /dev/null @@ -1,46 +0,0 @@ -/** - * The MySensors Arduino library handles the wireless radio link and protocol - * between your home built sensors/actuators and HA controller of choice. - * The sensors forms a self healing radio network with optional repeaters. Each - * repeater and gateway builds a routing tables in EEPROM which keeps track of the - * network topology allowing messages to be routed to nodes. - * - * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB - * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors - * - * Documentation: http://www.mysensors.org - * Support Forum: http://forum.mysensors.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - ******************************* - * - * DESCRIPTION - * Signing support created by Patrick "Anticimex" Fallberg - * ATSHA204 signing backend. The Atmel ATSHA204 offers true random number generation and - * HMAC-SHA256 authentication with a readout-protected key. - * - */ - -#ifndef MySigningAtsha204_h -#define MySigningAtsha204_h - -#include "MyConfig.h" -#include "MySigning.h" -#include "drivers/ATSHA204/ATSHA204.h" -#include - - - -// The ATSHA204 is capable of generating proper random numbers for nonce -// and can calculate HMAC-SHA256 signatures. This is enterprise- -// level of security and ought to implement the signing needs for anybody. - -void signerCalculateSignature(MyMessage &msg); -uint8_t* signerSha256(const uint8_t* data, size_t sz); - - -#endif diff --git a/libraries/MySensors/core/MySigningAtsha204Soft.cpp b/libraries/MySensors/core/MySigningAtsha204Soft.cpp index d5e8b09..140124f 100644 --- a/libraries/MySensors/core/MySigningAtsha204Soft.cpp +++ b/libraries/MySensors/core/MySigningAtsha204Soft.cpp @@ -28,9 +28,7 @@ * */ -#include "MyConfig.h" #include "MySigning.h" -#include "MySigningAtsha204Soft.h" #include "drivers/ATSHA204/sha256.h" #define SIGNING_IDENTIFIER (1) @@ -49,6 +47,8 @@ uint8_t _signing_hmac[32]; const whitelist_entry_t _signing_whitelist[] = MY_SIGNING_NODE_WHITELISTING; #endif +void signerCalculateSignature(MyMessage &msg); + // Uncomment this to get some useful serial debug info (Serial.print and Serial.println expected) //#define DEBUG_SIGNING diff --git a/libraries/MySensors/core/MySigningAtsha204Soft.h b/libraries/MySensors/core/MySigningAtsha204Soft.h deleted file mode 100644 index 99c72fa..0000000 --- a/libraries/MySensors/core/MySigningAtsha204Soft.h +++ /dev/null @@ -1,53 +0,0 @@ -/** - * The MySensors Arduino library handles the wireless radio link and protocol - * between your home built sensors/actuators and HA controller of choice. - * The sensors forms a self healing radio network with optional repeaters. Each - * repeater and gateway builds a routing tables in EEPROM which keeps track of the - * network topology allowing messages to be routed to nodes. - * - * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB - * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors - * - * Documentation: http://www.mysensors.org - * Support Forum: http://forum.mysensors.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - ******************************* - * - * DESCRIPTION - * Signing support created by Patrick "Anticimex" Fallberg - * ATSHA204 emulated signing backend. The emulated ATSHA204 implementation offers pseudo random - * number generation and HMAC-SHA256 authentication compatible with a "physical" ATSHA204. - * NOTE: Key is stored in clear text in the Arduino firmware. Therefore, the use of this back-end - * could compromise the key used in the signed message infrastructure if device is lost and its memory - * dumped. - * - */ - -#ifndef MySigningHmac256Soft_h -#define MySigningHmac256Soft_h - -#include "MyConfig.h" -#include "MySigning.h" -#include "drivers/ATSHA204/ATSHA204.h" -#include "drivers/ATSHA204/sha256.h" -#include - - - -// This implementation is the pure software variant of the ATSHA204. -// It is designed to work fully compliant with nodes using ATSHA204 in the network -// and therefore uses the same signing identifier as ATSHA204. -// Because it is completely software based, the quality of the generated random numbers -// is weaker though. Random numbers are generated using the Arduino library and seed -// is sampled from an analog pin. This pin should unconnected in the hardware. -// The pin is selected using MY_SIGNING_SOFT_RANDOMSEED_PIN in MyConfig.h. - -void signerCalculateSignature(MyMessage &msg); - - -#endif diff --git a/libraries/MySensors/core/MySigningNone.cpp b/libraries/MySensors/core/MySigningNone.cpp deleted file mode 100644 index 7edbad6..0000000 --- a/libraries/MySensors/core/MySigningNone.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/** - * The MySensors Arduino library handles the wireless radio link and protocol - * between your home built sensors/actuators and HA controller of choice. - * The sensors forms a self healing radio network with optional repeaters. Each - * repeater and gateway builds a routing tables in EEPROM which keeps track of the - * network topology allowing messages to be routed to nodes. - * - * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB - * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors - * - * Documentation: http://www.mysensors.org - * Support Forum: http://forum.mysensors.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - ******************************* - * - * DESCRIPTION - * Signing support created by Patrick "Anticimex" Fallberg - * Disabled signing backend. Does not provide any security measures. - * - */ - - -#include "MyConfig.h" -#include "MySigning.h" -#include "MySigningNone.h" - -#define SIGNING_IDENTIFIER (0) - -// Uncomment this to get some useful serial debug info (Serial.print and Serial.println expected) -//#define DEBUG_SIGNING - -#ifdef DEBUG_SIGNING -#define DEBUG_SIGNING_PRINTLN(args) Serial.println(args) -#else -#define DEBUG_SIGNING_PRINTLN(args) -#endif - -#ifdef DEBUG_SIGNING -static void DEBUG_NONE_PRINTBUF(const __FlashStringHelper* str, uint8_t* buf, uint8_t sz) -{ - int i; - Serial.println(str); - for (int i=0; i MAX_PAYLOAD-2) { - DEBUG_SIGNING_PRINTLN(F("MTOL")); // Message too large for signature to fit - return false; - } - mSetSigned(msg, 1); // make sure signing flag is set before signature is calculated - msg.data[mGetLength(msg)] = SIGNING_IDENTIFIER; // Add signing identifier - return true; -} - -bool signerVerifyMsg(MyMessage &msg) { - if (msg.data[mGetLength(msg)] != SIGNING_IDENTIFIER) - return false; - else - return true; -} diff --git a/libraries/MySensors/core/MySigningNone.h b/libraries/MySensors/core/MySigningNone.h deleted file mode 100644 index 4f7a32f..0000000 --- a/libraries/MySensors/core/MySigningNone.h +++ /dev/null @@ -1,41 +0,0 @@ -/** - * The MySensors Arduino library handles the wireless radio link and protocol - * between your home built sensors/actuators and HA controller of choice. - * The sensors forms a self healing radio network with optional repeaters. Each - * repeater and gateway builds a routing tables in EEPROM which keeps track of the - * network topology allowing messages to be routed to nodes. - * - * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB - * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors - * - * Documentation: http://www.mysensors.org - * Support Forum: http://forum.mysensors.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - ******************************* - * - * DESCRIPTION - * Signing support created by Patrick "Anticimex" Fallberg - * Disabled signing backend. Does not provide any security measures. - * - */ - - -#ifndef MySigningNone_h -#define MySigningNone_h - -#include "MyConfig.h" -#include "MySigning.h" -#include - -// The "none" signing driver that can be used for nodes -// not requiring signing -// It does check SIGNING_IDENTIFIER byte to avoid illegal mixing of signing back-ends in -// the network (as seen by this node) and it does verify proper execution order on the API. -// The "none" driver rejects all other back-ends. - -#endif diff --git a/libraries/MySensors/core/MyTransportNRF24.cpp b/libraries/MySensors/core/MyTransportNRF24.cpp index ab44888..a051fb3 100644 --- a/libraries/MySensors/core/MyTransportNRF24.cpp +++ b/libraries/MySensors/core/MyTransportNRF24.cpp @@ -17,7 +17,21 @@ * version 2 as published by the Free Software Foundation. */ -#include "MyTransportNRF24.h" +#include "MyConfig.h" +#include "MyTransport.h" +#include +#include "drivers/RF24/RF24.h" +#include "drivers/RF24/RF24_config.h" +#if defined(MY_RF24_ENABLE_ENCRYPTION) +#include "drivers/AES/AES.h" +#endif + +#define TO_ADDR(x) (MY_RF24_BASE_RADIO_ID + x) + +#define WRITE_PIPE ((uint8_t)0) +#define CURRENT_NODE_PIPE ((uint8_t)1) +#define BROADCAST_PIPE ((uint8_t)2) + RF24 _rf24(MY_RF24_CE_PIN, MY_RF24_CS_PIN); uint8_t _address; diff --git a/libraries/MySensors/core/MyTransportNRF24.h b/libraries/MySensors/core/MyTransportNRF24.h deleted file mode 100644 index a852848..0000000 --- a/libraries/MySensors/core/MyTransportNRF24.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * The MySensors Arduino library handles the wireless radio link and protocol - * between your home built sensors/actuators and HA controller of choice. - * The sensors forms a self healing radio network with optional repeaters. Each - * repeater and gateway builds a routing tables in EEPROM which keeps track of the - * network topology allowing messages to be routed to nodes. - * - * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB - * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors - * - * Documentation: http://www.mysensors.org - * Support Forum: http://forum.mysensors.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - */ - -#ifndef MyTransportNRF24_h -#define MyTransportNRF24_h - -#include "MyConfig.h" -#include "MyTransport.h" -#include -#include "drivers/RF24/RF24.h" -#include "drivers/RF24/RF24_config.h" -#if defined(MY_RF24_ENABLE_ENCRYPTION) -#include "drivers/AES/AES.h" -#endif - -#define TO_ADDR(x) (MY_RF24_BASE_RADIO_ID + x) - -#define WRITE_PIPE ((uint8_t)0) -#define CURRENT_NODE_PIPE ((uint8_t)1) -#define BROADCAST_PIPE ((uint8_t)2) - -#endif diff --git a/libraries/MySensors/core/MyTransportRFM69.cpp b/libraries/MySensors/core/MyTransportRFM69.cpp index fc3deb1..b48805d 100644 --- a/libraries/MySensors/core/MyTransportRFM69.cpp +++ b/libraries/MySensors/core/MyTransportRFM69.cpp @@ -17,8 +17,10 @@ * version 2 as published by the Free Software Foundation. */ +#include "MyConfig.h" #include "MyTransport.h" -#include "MyTransportRFM69.h" +#include +#include "drivers/RFM69/RFM69.h" RFM69 _radio(MY_RF69_SPI_CS, MY_RF69_IRQ_PIN, MY_IS_RFM69HW, MY_RF69_IRQ_NUM); uint8_t _address; diff --git a/libraries/MySensors/core/MyTransportRFM69.h b/libraries/MySensors/core/MyTransportRFM69.h deleted file mode 100644 index 967a7b3..0000000 --- a/libraries/MySensors/core/MyTransportRFM69.h +++ /dev/null @@ -1,29 +0,0 @@ -/** - * The MySensors Arduino library handles the wireless radio link and protocol - * between your home built sensors/actuators and HA controller of choice. - * The sensors forms a self healing radio network with optional repeaters. Each - * repeater and gateway builds a routing tables in EEPROM which keeps track of the - * network topology allowing messages to be routed to nodes. - * - * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB - * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors - * - * Documentation: http://www.mysensors.org - * Support Forum: http://forum.mysensors.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - */ - -#ifndef MyTransportRF69_h -#define MyTransportRF69_h - -#include "MyConfig.h" -#include "MyTransport.h" -#include -#include "drivers/RFM69/RFM69.h" - - -#endif diff --git a/libraries/MySensors/examples/LightSensor/LightSensor.ino b/libraries/MySensors/examples/LightSensor/LightSensor.ino index b63c96b..8c27775 100644 --- a/libraries/MySensors/examples/LightSensor/LightSensor.ino +++ b/libraries/MySensors/examples/LightSensor/LightSensor.ino @@ -26,7 +26,13 @@ * http://www.mysensors.org/build/light */ -#include +// Enable debug prints to serial monitor +#define MY_DEBUG + +// Enable and select radio type attached +#define MY_RADIO_NRF24 +//#define MY_RADIO_RFM69 + #include #define CHILD_ID_LIGHT 0 @@ -34,19 +40,16 @@ unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds) -MySensor gw; MyMessage msg(CHILD_ID_LIGHT, V_LIGHT_LEVEL); int lastLightLevel; void setup() { - gw.begin(); - // Send the sketch version information to the gateway and Controller - gw.sendSketchInfo("Light Sensor", "1.0"); + sendSketchInfo("Light Sensor", "1.0"); // Register all sensors to gateway (they will be created as child devices) - gw.present(CHILD_ID_LIGHT, S_LIGHT_LEVEL); + present(CHILD_ID_LIGHT, S_LIGHT_LEVEL); } void loop() @@ -54,10 +57,10 @@ void loop() int lightLevel = (1023-analogRead(LIGHT_SENSOR_ANALOG_PIN))/10.23; Serial.println(lightLevel); if (lightLevel != lastLightLevel) { - gw.send(msg.set(lightLevel)); + send(msg.set(lightLevel)); lastLightLevel = lightLevel; } - gw.sleep(SLEEP_TIME); + sleep(SLEEP_TIME); } diff --git a/libraries/MySensors/examples/SecureActuator/SecureActuator.ino b/libraries/MySensors/examples/SecureActuator/SecureActuator.ino index 589c0bc..a3c0b15 100644 --- a/libraries/MySensors/examples/SecureActuator/SecureActuator.ino +++ b/libraries/MySensors/examples/SecureActuator/SecureActuator.ino @@ -65,7 +65,7 @@ void setup() { - // Initialize library and add callback for incoming messages (signing is required) + // Add callback for incoming messages (signing is required) setIncomingCallback(incomingMessage); // Send the sketch version information to the gateway and Controller sendSketchInfo("Secure Lock", "1.0");