diff options
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | kbc.c | 16 |
2 files changed, 14 insertions, 4 deletions
@@ -17,3 +17,3 @@ LDXX=g++ -g -love: kbc.flash +love: kbc.flash kbc.eeprom @@ -7,2 +7,3 @@ #include <avr/pgmspace.h> +#include <avr/eeprom.h> #include <util/delay.h> @@ -333,3 +334,3 @@ static uint8_t error; -static const char passwd[sizeof(PIN) - 1] = PIN; +static const EEMEM char passwd[sizeof(PIN) - 1] = PIN; static char code[sizeof(PIN)]; @@ -545,2 +546,4 @@ static void handle_keypress(uint8_t data) if (lock || unlock) { + uint8_t eebyte, pos, ok = 1; + /* passwd: a b c d @@ -548,4 +551,7 @@ static void handle_keypress(uint8_t data) */ + + if (code[0]) + ok = 0; #ifdef KILLSWITCH - if (code[0] || !memcmp("9164", code + 1, 4)) { + if (!memcmp("9164", code + 1, 4)) { error = 0; @@ -555,3 +561,7 @@ static void handle_keypress(uint8_t data) #endif - if (code[0] || memcmp(passwd, code + 1, sizeof(passwd))) { + for (pos = 1; pos < sizeof(code); pos++) + if (code[pos] != eeprom_read_byte(passwd + pos - 1)) + ok = 0; + + if (!ok) { dbg_wr(0x20); |
