Skip to content

Commit

Permalink
New command "get all"
Browse files Browse the repository at this point in the history
-Added new command "get all" for retrieving all config info from the kit in a single line, it's fast :).
-Changed printNetWorks() function so it can output data without new line at the end.
  • Loading branch information
vicobarberan committed Apr 10, 2016
1 parent 21e5211 commit 0ed5a35
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions sck-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ This commands are commands to talk talk to the SCK configuration interface.
* `get wlan phrase\r` Retrieve the phrase and KEY saved on the kit
* `get wlan auth\r` Retrieve the authentication methods saved on the kit
* `get wlan ext_antenna\r` Retrieve the antenna types saved on the kit
* `get all\r` Retrieve all config saved on the kit in a single line (`|version|MAC|ssid1 ssid2,pass1 pass2,auth1 auth2,ant1 ant2|timeUpdate|numPosts|`)
* `clear nets\r` Remove all saved Wi-Fi configuration information (except hardcoded)
* `clear memory\r` Remove all configuration information
* `exit\r` Goes back to normal operational mode
Expand Down
24 changes: 22 additions & 2 deletions sck_beta_v0_9/SCKAmbient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ int SCKAmbient::addData(byte inByte)
}


boolean SCKAmbient::printNetWorks(unsigned int address_eeprom)
boolean SCKAmbient::printNetWorks(unsigned int address_eeprom, boolean endLine=true)
{
int nets_temp = base_.readData(EE_ADDR_NUMBER_NETS, INTERNAL);
if (nets_temp>0){
Expand All @@ -887,7 +887,8 @@ boolean SCKAmbient::printNetWorks(unsigned int address_eeprom)
Serial.print(base_.readData(address_eeprom, i, INTERNAL));
if (i<(nets_temp - 1)) Serial.print(' ');
}
Serial.println();}
if (endLine) Serial.println();
}
}

void SCKAmbient::addNetWork(unsigned int address_eeprom, char* text)
Expand Down Expand Up @@ -964,6 +965,25 @@ void SCKAmbient::serialRequests()
else if (base_.checkText("get time update\r", buffer_int)) Serial.println(base_.readData(EE_ADDR_TIME_UPDATE, INTERNAL));
else if (base_.checkText("get number updates\r", buffer_int)) Serial.println(base_.readData(EE_ADDR_NUMBER_UPDATES, INTERNAL));
else if (base_.checkText("get apikey\r", buffer_int)) Serial.println(base_.readData(EE_ADDR_APIKEY, 0, INTERNAL));
else if (base_.checkText("get all\r", buffer_int)) {
Serial.print(F("|"));
Serial.print(FirmWare);
Serial.print(F("|"));
Serial.print(base_.readData(EE_ADDR_MAC, 0, INTERNAL)); //MAC
Serial.print(F("|"));
printNetWorks(DEFAULT_ADDR_SSID, false);
Serial.print(F(","));
printNetWorks(DEFAULT_ADDR_PASS, false);
Serial.print(F(","));
printNetWorks(DEFAULT_ADDR_ANTENNA, false);
Serial.print(F(","));
printNetWorks(DEFAULT_ADDR_AUTH, false);
Serial.print(F("|"));
Serial.print(base_.readData(EE_ADDR_TIME_UPDATE, INTERNAL));
Serial.print(F("|"));
Serial.print(base_.readData(EE_ADDR_NUMBER_UPDATES, INTERNAL));
Serial.println(F("|"));
}
/*Write commands*/
else if (base_.checkText("set wlan ssid ", buffer_int))
{
Expand Down
2 changes: 1 addition & 1 deletion sck_beta_v0_9/SCKAmbient.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class SCKAmbient {
uint16_t readSHT21(uint8_t type);
boolean DhtRead(uint8_t pin);
int addData(byte inByte);
boolean printNetWorks(unsigned int address_eeprom);
boolean printNetWorks(unsigned int address_eeprom, boolean endLine);
void addNetWork(unsigned int address_eeprom, char* text);
};
#endif

0 comments on commit 0ed5a35

Please sign in to comment.