![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Own fork of MbedSmartRestMain
Dependencies: C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed
Fork of MbedSmartRestMain by
Diff: io/DeviceMemory.cpp
- Revision:
- 68:0dc778a16d0d
- Parent:
- 67:c360a2b2c948
- Child:
- 69:237c01eb36c2
--- a/io/DeviceMemory.cpp Sun Nov 30 19:34:49 2014 +0000 +++ b/io/DeviceMemory.cpp Sat Dec 06 19:47:23 2014 +0000 @@ -4,6 +4,7 @@ #include <string.h> #define PLATFORM_CREDENTIALS_FILE "001_CREDENTIALS" +#define CONFIGURATION_FILE "002_CONFIGURATION" DeviceMemory::DeviceMemory(MDMSerial& mdm) : _mdm(mdm) @@ -30,10 +31,35 @@ if ((res < 0) || (res >= sizeof(buffer))) return false; - return res == _mdm.writeFile(PLATFORM_CREDENTIALS_FILE, buffer, res); + return ((_mdm.delFile(PLATFORM_CREDENTIALS_FILE)) && (res == _mdm.writeFile(PLATFORM_CREDENTIALS_FILE, buffer, res))); } bool DeviceMemory::resetPlatformCredentials() { return _mdm.delFile(PLATFORM_CREDENTIALS_FILE); } + + +bool DeviceMemory::loadConfiguration(char *cfg, size_t len) +{ + int res; + + if ((res = _mdm.readFile(CONFIGURATION_FILE, cfg, len)) < 0) + return false; + + cfg[(size_t)res] = '\0'; + return true; +} + +bool DeviceMemory::saveConfiguration(char *cfg) +{ + size_t len; + + len = strlen(cfg); + return ((_mdm.delFile(CONFIGURATION_FILE)) && (_mdm.writeFile(CONFIGURATION_FILE, cfg, len) == len)); +} + +bool DeviceMemory::resetConfiguration() +{ + return _mdm.delFile(CONFIGURATION_FILE); +}