From da859491138bda24548d544007c5c49b545052c1 Mon Sep 17 00:00:00 2001 From: Rohit Grover Date: Mon, 1 Dec 2014 08:42:13 +0000 Subject: [PATCH] add saveDefaults() --- services/URIBeacon2Service.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/services/URIBeacon2Service.h b/services/URIBeacon2Service.h index 3cbb2f0..7c157bc 100644 --- a/services/URIBeacon2Service.h +++ b/services/URIBeacon2Service.h @@ -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));