An application to log WiFi SSIDs for position lookup testing
Dependencies: C027_Support SWO mbed-rtos mbed picojson
Fork of lpc4088_ebb_ublox_Cellular_PubNubDemo_rtos by
Diff: device/DeviceMemory.cpp
- Revision:
- 1:cac9b2960637
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/device/DeviceMemory.cpp Sun Feb 15 22:04:12 2015 +0000 @@ -0,0 +1,37 @@ +#include "DeviceMemory.h" +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#define CONFIGURATION_FILE "001_CONFIGURATION" + +DeviceMemory::DeviceMemory(MDMSerial& mdm) : + _mdm(mdm) +{ +} + +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); + + resetConfiguration(); + return (_mdm.writeFile(CONFIGURATION_FILE, cfg, len) == len); +} + +bool DeviceMemory::resetConfiguration() +{ + return _mdm.delFile(CONFIGURATION_FILE); +}