From 866e7cf08b0dc55c0b0d8549e1c7ee631be8c220 Mon Sep 17 00:00:00 2001 From: tekka007 Date: Tue, 5 Jan 2016 14:48:23 +0100 Subject: [PATCH 1/3] HW-independent ClearEepromConfig, substitutes #314 --- libraries/MySensors/MySensor.h | 24 +++++++++++-------- .../ClearEepromConfig/ClearEepromConfig.ino | 10 ++++---- libraries/MySensors/keywords.txt | 3 ++- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/libraries/MySensors/MySensor.h b/libraries/MySensors/MySensor.h index d795655..c07402a 100644 --- a/libraries/MySensors/MySensor.h +++ b/libraries/MySensors/MySensor.h @@ -48,8 +48,10 @@ //#undef F //#define F(x) (x) #include "core/MyHwESP8266.cpp" - // For ESP8266, we always enable gateway feature - #define MY_GATEWAY_ESP8266 + // Enable gateway feature + #if !defined(MY_CORE_ONLY) + #define MY_GATEWAY_ESP8266 + #endif #elif defined(ARDUINO_ARCH_AVR) #include "core/MyHwATMega328.cpp" #elif defined(ARDUINO_ARCH_SAMD) @@ -219,22 +221,24 @@ #undef MY_INCLUSION_BUTTON_FEATURE #endif -#if !defined(MY_GATEWAY_FEATURE) && !defined(MY_RADIO_FEATURE) - #error No forward link or gateway feature activated. This means nowhere to send messages! Pretty pointless. +#if !defined(MY_CORE_ONLY) + #if !defined(MY_GATEWAY_FEATURE) && !defined(MY_RADIO_FEATURE) + #error No forward link or gateway feature activated. This means nowhere to send messages! Pretty pointless. + #endif #endif - #include "core/MyCapabilities.h" #include "core/MyMessage.cpp" #include "core/MySensorCore.cpp" #include -#if defined(MY_GATEWAY_ESP8266) - #include "core/MyMainESP8266.cpp" -#else - #include "core/MyMainDefault.cpp" +#if !defined(MY_CORE_ONLY) + #if defined(MY_GATEWAY_ESP8266) + #include "core/MyMainESP8266.cpp" + #else + #include "core/MyMainDefault.cpp" + #endif #endif - #endif diff --git a/libraries/MySensors/examples/ClearEepromConfig/ClearEepromConfig.ino b/libraries/MySensors/examples/ClearEepromConfig/ClearEepromConfig.ino index fffc4f9..272bf43 100644 --- a/libraries/MySensors/examples/ClearEepromConfig/ClearEepromConfig.ino +++ b/libraries/MySensors/examples/ClearEepromConfig/ClearEepromConfig.ino @@ -23,16 +23,18 @@ * This sketch clears radioId, relayId and other routing information in EEPROM back to factory default * */ +// load core modules only +#define MY_CORE_ONLY -#include #include +#include void setup() { Serial.begin(MY_BAUD_RATE); Serial.println("Started clearing. Please wait..."); - for (int i=0;i<512;i++) { - EEPROM.write(i, 0xff); + for (int i=0;i Date: Mon, 11 Jan 2016 21:27:40 +0100 Subject: [PATCH 2/3] Added MY_CORE_ONLY flag to MySensors.h --- libraries/MySensors/MyConfig.h | 3 +++ libraries/MySensors/keywords.txt | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libraries/MySensors/MyConfig.h b/libraries/MySensors/MyConfig.h index d47f22a..ac9d1df 100644 --- a/libraries/MySensors/MyConfig.h +++ b/libraries/MySensors/MyConfig.h @@ -42,6 +42,9 @@ // Enable this in sketch if you want to use TX(1), RX(0) as normal I/O pin //#define MY_DISABLED_SERIAL +// Enable MY_CORE_ONLY flag if you want to use core functions without loading the framework +//#define MY_CORE_ONLY + // Turn off debug if serial pins is used for other stuff #ifdef MY_DISABLED_SERIAL #undef MY_DEBUG diff --git a/libraries/MySensors/keywords.txt b/libraries/MySensors/keywords.txt index a670de7..3ee0f8a 100644 --- a/libraries/MySensors/keywords.txt +++ b/libraries/MySensors/keywords.txt @@ -31,6 +31,7 @@ smartSleep KEYWORD2 ####################################### AUTO LITERAL1 MY_DEBUG LITERAL1 +MY_CORE_ONLY LITERAL1 MY_REPEATER_FEATURE LITERAL1 MY_RADIO_NRF24 LITERAL1 MY_RADIO_RFM69 LITERAL1 @@ -109,5 +110,4 @@ MY_GATEWAY_MQTT_CLIENT LITERAL1 MY_DISABLE_REMOTE_RESET LITERAL1 MY_RS485_DE_PIN LITERAL1 MY_SIGNING_REQUEST_SIGNATURES LITERAL1 -MY_SMART_SLEEP_WAIT_DURATION LITERAL1 -MY_CORE_ONLY LITERAL1 \ No newline at end of file +MY_SMART_SLEEP_WAIT_DURATION LITERAL1 \ No newline at end of file From b4879f0dced0e8b912bb11b918f035b8a28c520b Mon Sep 17 00:00:00 2001 From: tekka007 Date: Mon, 11 Jan 2016 21:47:18 +0100 Subject: [PATCH 3/3] void unused parameter --- libraries/MySensors/core/MySensorCore.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libraries/MySensors/core/MySensorCore.cpp b/libraries/MySensors/core/MySensorCore.cpp index 809a32e..2984513 100644 --- a/libraries/MySensors/core/MySensorCore.cpp +++ b/libraries/MySensors/core/MySensorCore.cpp @@ -190,6 +190,9 @@ ControllerConfig getConfig() { boolean _sendRoute(MyMessage &message) { // increment heartbeat counter _heartbeat++; + #if defined(MY_CORE_ONLY) + (void)message; + #endif #if defined(MY_GATEWAY_FEATURE) if (message.destination == _nc.nodeId) { // This is a message sent from a sensor attached on the gateway node.