|
|
@ -21,26 +21,27 @@
|
|
|
|
#include "crc.h"
|
|
|
|
#include "crc.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace FocusHooks {
|
|
|
|
namespace FocusHooks {
|
|
|
|
|
|
|
|
|
|
|
|
bool settings(const char *command) {
|
|
|
|
bool settings(const char *command) {
|
|
|
|
enum {
|
|
|
|
enum {
|
|
|
|
ISVALID,
|
|
|
|
ISVALID,
|
|
|
|
GETVERSION,
|
|
|
|
GETVERSION,
|
|
|
|
CRC,
|
|
|
|
CRC,
|
|
|
|
} subCommand;
|
|
|
|
} sub_command;
|
|
|
|
|
|
|
|
|
|
|
|
if (strncmp_P(command, PSTR("settings."), 9) != 0)
|
|
|
|
if (strncmp_P(command, PSTR("settings."), 9) != 0)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
if (strcmp_P(command + 9, PSTR("valid?")) == 0)
|
|
|
|
if (strcmp_P(command + 9, PSTR("valid?")) == 0)
|
|
|
|
subCommand = ISVALID;
|
|
|
|
sub_command = ISVALID;
|
|
|
|
else if (strcmp_P(command + 9, PSTR("version")) == 0)
|
|
|
|
else if (strcmp_P(command + 9, PSTR("version")) == 0)
|
|
|
|
subCommand = GETVERSION;
|
|
|
|
sub_command = GETVERSION;
|
|
|
|
else if (strcmp_P(command + 9, PSTR("crc")) == 0)
|
|
|
|
else if (strcmp_P(command + 9, PSTR("crc")) == 0)
|
|
|
|
subCommand = CRC;
|
|
|
|
sub_command = CRC;
|
|
|
|
else
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
switch (subCommand) {
|
|
|
|
switch (sub_command) {
|
|
|
|
case ISVALID:
|
|
|
|
case ISVALID:
|
|
|
|
Focus.printBool(EEPROMSettings.isValid());
|
|
|
|
Focus.printBool(EEPROMSettings.isValid());
|
|
|
|
Serial.println();
|
|
|
|
Serial.println();
|
|
|
@ -62,16 +63,16 @@ bool eeprom(const char *command) {
|
|
|
|
enum {
|
|
|
|
enum {
|
|
|
|
CONTENTS,
|
|
|
|
CONTENTS,
|
|
|
|
FREE,
|
|
|
|
FREE,
|
|
|
|
} subCommand;
|
|
|
|
} sub_command;
|
|
|
|
|
|
|
|
|
|
|
|
if (strcmp_P(command, PSTR("eeprom.contents")) == 0)
|
|
|
|
if (strcmp_P(command, PSTR("eeprom.contents")) == 0)
|
|
|
|
subCommand = CONTENTS;
|
|
|
|
sub_command = CONTENTS;
|
|
|
|
else if (strcmp_P(command, PSTR("eeprom.free")) == 0)
|
|
|
|
else if (strcmp_P(command, PSTR("eeprom.free")) == 0)
|
|
|
|
subCommand = FREE;
|
|
|
|
sub_command = FREE;
|
|
|
|
else
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
switch (subCommand) {
|
|
|
|
switch (sub_command) {
|
|
|
|
case CONTENTS: {
|
|
|
|
case CONTENTS: {
|
|
|
|
if (Serial.peek() == '\n') {
|
|
|
|
if (Serial.peek() == '\n') {
|
|
|
|
for (uint16_t i = 0; i < EEPROM.length(); i++) {
|
|
|
|
for (uint16_t i = 0; i < EEPROM.length(); i++) {
|
|
|
@ -96,4 +97,5 @@ bool eeprom(const char *command) {
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|