Skip to content

Commit b64f676

Browse files
committed
Merge pull request arduino#325 from tekka007/ClearConfig
HW-independent ClearEepromConfig, substitutes arduino#314
2 parents 60318a7 + b4879f0 commit b64f676

File tree

5 files changed

+27
-14
lines changed

5 files changed

+27
-14
lines changed

Diff for: libraries/MySensors/MyConfig.h

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
// Enable this in sketch if you want to use TX(1), RX(0) as normal I/O pin
4343
//#define MY_DISABLED_SERIAL
4444

45+
// Enable MY_CORE_ONLY flag if you want to use core functions without loading the framework
46+
//#define MY_CORE_ONLY
47+
4548
// Turn off debug if serial pins is used for other stuff
4649
#ifdef MY_DISABLED_SERIAL
4750
#undef MY_DEBUG

Diff for: libraries/MySensors/MySensor.h

+14-10
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@
4848
//#undef F
4949
//#define F(x) (x)
5050
#include "core/MyHwESP8266.cpp"
51-
// For ESP8266, we always enable gateway feature
52-
#define MY_GATEWAY_ESP8266
51+
// Enable gateway feature
52+
#if !defined(MY_CORE_ONLY)
53+
#define MY_GATEWAY_ESP8266
54+
#endif
5355
#elif defined(ARDUINO_ARCH_AVR)
5456
#include "core/MyHwATMega328.cpp"
5557
#elif defined(ARDUINO_ARCH_SAMD)
@@ -219,22 +221,24 @@
219221
#undef MY_INCLUSION_BUTTON_FEATURE
220222
#endif
221223

222-
#if !defined(MY_GATEWAY_FEATURE) && !defined(MY_RADIO_FEATURE)
223-
#error No forward link or gateway feature activated. This means nowhere to send messages! Pretty pointless.
224+
#if !defined(MY_CORE_ONLY)
225+
#if !defined(MY_GATEWAY_FEATURE) && !defined(MY_RADIO_FEATURE)
226+
#error No forward link or gateway feature activated. This means nowhere to send messages! Pretty pointless.
227+
#endif
224228
#endif
225229

226-
227230
#include "core/MyCapabilities.h"
228231
#include "core/MyMessage.cpp"
229232
#include "core/MySensorCore.cpp"
230233

231234
#include <Arduino.h>
232235

233-
#if defined(MY_GATEWAY_ESP8266)
234-
#include "core/MyMainESP8266.cpp"
235-
#else
236-
#include "core/MyMainDefault.cpp"
236+
#if !defined(MY_CORE_ONLY)
237+
#if defined(MY_GATEWAY_ESP8266)
238+
#include "core/MyMainESP8266.cpp"
239+
#else
240+
#include "core/MyMainDefault.cpp"
241+
#endif
237242
#endif
238243

239-
240244
#endif

Diff for: libraries/MySensors/core/MySensorCore.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ ControllerConfig getConfig() {
190190
boolean _sendRoute(MyMessage &message) {
191191
// increment heartbeat counter
192192
_heartbeat++;
193+
#if defined(MY_CORE_ONLY)
194+
(void)message;
195+
#endif
193196
#if defined(MY_GATEWAY_FEATURE)
194197
if (message.destination == _nc.nodeId) {
195198
// This is a message sent from a sensor attached on the gateway node.

Diff for: libraries/MySensors/examples/ClearEepromConfig/ClearEepromConfig.ino

+6-4
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,23 @@
2323
* This sketch clears radioId, relayId and other routing information in EEPROM back to factory default
2424
*
2525
*/
26+
// load core modules only
27+
#define MY_CORE_ONLY
2628

27-
#include <MyConfig.h>
2829
#include <EEPROM.h>
30+
#include <MySensor.h>
2931

3032
void setup()
3133
{
3234
Serial.begin(MY_BAUD_RATE);
3335
Serial.println("Started clearing. Please wait...");
34-
for (int i=0;i<512;i++) {
35-
EEPROM.write(i, 0xff);
36+
for (int i=0;i<EEPROM_LOCAL_CONFIG_ADDRESS;i++) {
37+
hwWriteConfig(i,0xFF);
3638
}
3739
Serial.println("Clearing done. You're ready to go!");
3840
}
3941

4042
void loop()
4143
{
4244
// Nothing to do here...
43-
}
45+
}

Diff for: libraries/MySensors/keywords.txt

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ smartSleep KEYWORD2
3131
#######################################
3232
AUTO LITERAL1
3333
MY_DEBUG LITERAL1
34+
MY_CORE_ONLY LITERAL1
3435
MY_REPEATER_FEATURE LITERAL1
3536
MY_RADIO_NRF24 LITERAL1
3637
MY_RADIO_RFM69 LITERAL1

0 commit comments

Comments
 (0)