diff options
author | Mike Beattie <mike@ethernal.org> | 2012-03-22 18:25:00 +1300 |
---|---|---|
committer | Mike Beattie <mike@ethernal.org> | 2012-03-22 18:25:00 +1300 |
commit | 38f52e440655f1617f236065567169fabe53b230 (patch) | |
tree | 7e67616bf425802722d2c8f9d1e303cd8c58e366 /HouseControl.ino | |
parent | 697792c698fbbd31965c25d1dc93c6addc74cd2c (diff) |
Add versioned config support
* Allows automatic initialisation of eeprom
Signed-off-by: Mike Beattie <mike@ethernal.org>
Diffstat (limited to 'HouseControl.ino')
-rw-r--r-- | HouseControl.ino | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/HouseControl.ino b/HouseControl.ino index 6e6ec71..a8f7650 100644 --- a/HouseControl.ino +++ b/HouseControl.ino @@ -13,8 +13,6 @@ #include <EEPROM.h> #include "EEPROM_IO.h" -#define RECONFIGURE 0 - /*********************************************************************************/ /* Pin definitions */ @@ -405,7 +403,8 @@ void toggleDoorControl(struct st_door *door) { /* Setup function */ void setup() { -#if RECONFIGURE + byte eepromVersion; + config.configVersion = 3; config.mac[0] = 0x00; @@ -438,10 +437,14 @@ void setup() { config.dawn = 7; config.dusk = 21; - eepromWrite(0, config); -#endif - eepromRead(0, config); + eepromRead(0, eepromVersion); + + if (config.configVersion > eepromVersion) + eepromWrite(0, config); + + if (config.configVersion > 0) + eepromRead(0, config); if(Ethernet.begin(config.mac) == 0) { Ethernet.begin(config.mac, config.def_ip, config.def_gateway, config.def_netmask); |