Skip to content

Commit

Permalink
New command "clear memory"
Browse files Browse the repository at this point in the history
  • Loading branch information
miandehe committed Mar 15, 2016
1 parent a216d37 commit 565a6af
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 2 additions & 0 deletions sck-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ This commands are commands to talk directly to the Wi-Fi module (RN-XV WiFly) ow
* `set wlan key XXX\r` Add a new key to memory
* `set wlan auth XXX\r` Add an authentication method into memory
* `set wlan ext_antenna XXX\r` Add an antenna type into memory
* `set sys iofunc 0x7` Disable the Wi-Fi module blue LED's
* `exit\r` Go back to normal operational mode

### Special SCK commands
Expand All @@ -38,5 +39,6 @@ This commands are commands to talk talk to the SCK configuration interface.
* `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
* `clear nets\r` Remove all saved Wi-Fi configuration information
* `clear memory\r` Remove all configuration information
* `exit\r` Goes back to normal operational mode
* `#data\r` Retrieves sensor readings stored in memory
1 change: 1 addition & 0 deletions sck_beta_v0_9/SCKAmbient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,7 @@ void SCKAmbient::serialRequests()
eeprom_write_ok = true;
address_eeprom = EE_ADDR_APIKEY;
}
else if (base_.checkText("clear memory\r", buffer_int)) base_.clearmemory();
}
else if (check_data == -1) Serial.println("Invalid command.");
if (serial_bridge) Serial1.write(inByte);
Expand Down
17 changes: 10 additions & 7 deletions sck_beta_v0_9/SCKBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,7 @@ void SCKBase::config(){
if (!compareData(__TIME__, readData(EE_ADDR_TIME_VERSION, 0, INTERNAL)))
{
digitalWrite(AWAKE, HIGH);
for(uint16_t i=0; i<(DEFAULT_ADDR_ANTENNA + 160); i++) EEPROM.write(i, 0x00); // Memory erasing
writeData(EE_ADDR_TIME_VERSION, 0, __TIME__, INTERNAL);
writeData(EE_ADDR_SENSOR_MODE, DEFAULT_MODE_SENSOR, INTERNAL);
writeData(EE_ADDR_TIME_UPDATE, DEFAULT_TIME_UPDATE, INTERNAL);
writeData(EE_ADDR_NUMBER_UPDATES, DEFAULT_MIN_UPDATES, INTERNAL);
writeData(EE_ADDR_MAC, 0, MAC(), INTERNAL);

clearmemory();
#if (networks > 0)
for(byte i=0; i<networks; i++)
{
Expand All @@ -64,6 +58,15 @@ void SCKBase::config(){
timer1Initialize();
}

void SCKBase::clearmemory(){
for(uint16_t i=0; i<(DEFAULT_ADDR_ANTENNA + 160); i++) EEPROM.write(i, 0x00); // Memory erasing
writeData(EE_ADDR_TIME_VERSION, 0, __TIME__, INTERNAL);
writeData(EE_ADDR_SENSOR_MODE, DEFAULT_MODE_SENSOR, INTERNAL);
writeData(EE_ADDR_TIME_UPDATE, DEFAULT_TIME_UPDATE, INTERNAL);
writeData(EE_ADDR_NUMBER_UPDATES, DEFAULT_MIN_UPDATES, INTERNAL);
writeData(EE_ADDR_MAC, 0, MAC(), INTERNAL);
}

float SCKBase::average(int anaPin) {
int lecturas = 100;
long total = 0;
Expand Down
1 change: 1 addition & 0 deletions sck_beta_v0_9/SCKBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class SCKBase {
public:
void begin();
void config();
void clearmemory();
float average(int anaPin);
boolean checkText(char* text, char* text1);
boolean compareData(char* text, char* text1);
Expand Down

0 comments on commit 565a6af

Please sign in to comment.