Skip to content

Commit 866e7cf

Browse files
committed
HW-independent ClearEepromConfig, substitutes arduino#314
1 parent 60318a7 commit 866e7cf

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

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/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

+2-1
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,5 @@ MY_GATEWAY_MQTT_CLIENT LITERAL1
109109
MY_DISABLE_REMOTE_RESET LITERAL1
110110
MY_RS485_DE_PIN LITERAL1
111111
MY_SIGNING_REQUEST_SIGNATURES LITERAL1
112-
MY_SMART_SLEEP_WAIT_DURATION LITERAL1
112+
MY_SMART_SLEEP_WAIT_DURATION LITERAL1
113+
MY_CORE_ONLY LITERAL1

0 commit comments

Comments
 (0)