Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed
Fork of MbedSmartRestMain by
Diff: config/ConfigSync.cpp
- Revision:
- 111:ee9ae4a5e55c
- Parent:
- 106:c61f0d62b625
- Child:
- 117:5de54f09f754
--- a/config/ConfigSync.cpp Wed May 13 15:00:24 2015 +0000 +++ b/config/ConfigSync.cpp Fri May 15 10:13:19 2015 +0000 @@ -8,7 +8,7 @@ #define INTERVAL_KEY "interval" #define DEFAULT_INTERVAL "20" -bool validateConfiguration(Dict& d) +static bool validateConfiguration(const Dict& d) { const Dict::Item *p = d.get(INTERVAL_KEY); if (p) { @@ -61,10 +61,12 @@ void ConfigSync::loadConfiguration() { char buf[(MAX_KEY_LEN+MAX_VALUE_LEN+4)*MAX_ITEM_SIZE+1]; + resetConfiguration(); int l = loadConfigFile(buf, sizeof(buf)); - if (l > 0) { + if (l > 0) updateConfiguration(buf); - } + else + saveConfiguration(); } void ConfigSync::saveConfiguration() const @@ -72,8 +74,7 @@ char s[(MAX_KEY_LEN+MAX_VALUE_LEN+3)*dict.size()+1]; size_t l = dict.dump(s); if (l) { - if (!saveConfigFile(s, l)) { + if (!saveConfigFile(s, l)) aError("Save config.\n"); - } } } \ No newline at end of file