Official reference client implementation for Cumulocity SmartREST on u-blox C027.
Dependencies: C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed
Fork of MbedSmartRestMain by
Diff: io/DeviceMemory.cpp
- Revision:
- 98:9f2de96941c4
- Parent:
- 97:ea056f6be2e8
- Child:
- 99:e369fc75c000
--- a/io/DeviceMemory.cpp Mon Apr 27 13:02:50 2015 +0000 +++ b/io/DeviceMemory.cpp Mon Apr 27 13:30:21 2015 +0000 @@ -1,14 +1,12 @@ -#include <stdlib.h> #include <stdio.h> #include <string.h> #include "MDM.h" -#include "DeviceMemory.h" #define PLATFORM_CREDENTIALS_FILE "001_CREDENTIALS" #define CONFIGURATION_FILE "002_CONFIGURATION" extern MDMSerial *pMdm; -bool DeviceMemory::loadPlatformCredentials(char *username, char *password, size_t len) +bool loadPlatformCredentials(char *username, char *password, size_t len) { char buffer[len*2+3]; int res = pMdm->readFile(PLATFORM_CREDENTIALS_FILE, buffer, sizeof(buffer)); @@ -21,23 +19,24 @@ return res == len2; } -bool DeviceMemory::savePlatformCredentials(char *username, char *password, size_t len) +bool resetPlatformCredentials() +{ + return pMdm->delFile(PLATFORM_CREDENTIALS_FILE); +} + +bool savePlatformCredentials(char *username, char *password, size_t len) { char buffer[len*2+3]; int res = snprintf(buffer, sizeof(buffer), "%s\n%s\n", username, password); if (res<0 || res>=sizeof(buffer)) return false; - return ((resetPlatformCredentials()) && (res == pMdm->writeFile(PLATFORM_CREDENTIALS_FILE, buffer, res))); -} - -bool DeviceMemory::resetPlatformCredentials() -{ - return pMdm->delFile(PLATFORM_CREDENTIALS_FILE); + return (resetPlatformCredentials() && res==pMdm->writeFile(PLATFORM_CREDENTIALS_FILE, buffer, res)); } -bool DeviceMemory::loadConfiguration(char *cfg, size_t len) + +bool loadConfiguration(char *cfg, size_t len) { int res = pMdm->readFile(CONFIGURATION_FILE, cfg, len); if (res < 0) @@ -47,13 +46,14 @@ return true; } -bool DeviceMemory::saveConfiguration(char *cfg) -{ - size_t len = strlen(cfg); - return ((resetConfiguration()) && (pMdm->writeFile(CONFIGURATION_FILE, cfg, len) == len)); -} - -bool DeviceMemory::resetConfiguration() +bool resetConfiguration() { return pMdm->delFile(CONFIGURATION_FILE); } + +bool saveConfiguration(char *cfg) +{ + size_t len = strlen(cfg); + return (resetConfiguration() && pMdm->writeFile(CONFIGURATION_FILE, cfg, len)==len); +} +