Skip to content

Commit

Permalink
Fix for unnecessary clear memory
Browse files Browse the repository at this point in the history
The function MAC() now returns -1 when wifly don't give us a valid mac address.
Keep asking wifly for mac address until we get a valid response, avoiding unnecessary clearMemory().
  • Loading branch information
vicobarberan committed Jun 2, 2016
1 parent 26c2aac commit 9f125cc
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions sck_beta_v0_9/SCKBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ void SCKBase::eepromCheck() {
boolean doClearMemory = false;
char temp[17];
strncpy(temp, MAC(), 18);
while (compareData(temp, "-1")){
#if debugBASE
Serial.println(F("Can't get MAC from Wifly!!!"));
#endif
strncpy(temp, MAC(), 18);
}
if (!compareData(temp, readData(EE_ADDR_MAC, 0, INTERNAL))) doClearMemory = true;
uint32_t intTemp;
intTemp = readData(EE_ADDR_SENSOR_MODE, INTERNAL);
Expand Down Expand Up @@ -700,10 +706,9 @@ char* SCKBase::MAC() {
if (Serial1.available())
{
newChar = Serial1.read();
//Serial.println(newChar);
if ((newChar == '\n')||(newChar < '0')) {
buffer[offset] = '\x00';
break;
return buffer;
}
else if (newChar != -1) {
buffer[offset] = newChar;
Expand All @@ -715,8 +720,7 @@ char* SCKBase::MAC() {
exitCommandMode();
}
}

return buffer;
return "-1";
}

char* SCKBase::id() {
Expand Down

0 comments on commit 9f125cc

Please sign in to comment.