add saveDefaults()

This commit is contained in:
Rohit Grover 2014-12-01 08:42:13 +00:00
parent dc40eb8113
commit da85949113

View file

@ -91,11 +91,7 @@ public:
configure();
if (initSucceeded) {
/* Preserve the originals to be able to reset() upon request. */
memcpy(defaultURIData, uriDataIn, MAX_SIZE_URI_DATA_CHAR_VALUE);
defaultFlags = flagsIn;
defaultEffectiveTxPower = effectiveTxPowerIn;
defaultBeaconPeriod = beaconPeriodIn;
saveDefaults();
}
GattCharacteristic *charTable[] = {&lockedStateChar, &uriDataChar, &flagsChar, &txPowerLevelsChar, &beaconPeriodChar, &resetChar};
@ -310,6 +306,14 @@ private:
ble.setAdvertisingPayload();
}
/* Preserve the defaults to be able to reset() upon request. */
void saveDefaults(void) {
memcpy(defaultURIData, uriData, MAX_SIZE_URI_DATA_CHAR_VALUE);
defaultFlags = flags;
defaultEffectiveTxPower = effectiveTxPower;
defaultBeaconPeriod = beaconPeriod;
}
void resetDefaults(void) {
memcpy(uriData, defaultURIData, MAX_SIZE_URI_DATA_CHAR_VALUE);
memset(powerLevels, 0, sizeof(powerLevels));