Own fork of MbedSmartRestMain
Dependencies: C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed
Fork of MbedSmartRestMain by
Diff: io/Storage.cpp
- Revision:
- 112:3872569be2af
- Parent:
- 110:ee9ae4a5e55c
--- a/io/Storage.cpp Fri May 15 10:14:05 2015 +0000 +++ b/io/Storage.cpp Fri May 15 14:07:51 2015 +0000 @@ -6,16 +6,16 @@ #define CONFIGURATION_FILE "002_CONFIGURATION" extern MDMSerial *pMdm; -bool loadCredential(char *username, char *password, size_t len) +bool loadCredential(char *tenant, char *username, char *password, size_t len) { - char buffer[len*2+3]; + char buffer[len*3+3]; int res = pMdm->readFile(CREDENTIALS_FILE, buffer, sizeof(buffer)); if (res <= 0) { return false; } else { buffer[res] = 0; - int l = sscanf(buffer, "%s\n%s\n", username, password); - return l==2; + int l = sscanf(buffer, "%[^/]/%s\n%s\n", tenant, username, password); + return l==3; } } @@ -24,10 +24,11 @@ return pMdm->delFile(CREDENTIALS_FILE); } -bool saveCredential(char *username, char *password, size_t len) +bool saveCredential(const char *tenant, const char *username, + const char *password, size_t len) { - char buffer[len*2+3]; - int res = snprintf(buffer, sizeof(buffer), "%s\n%s\n", username, password); + char buffer[len*3+3]; + int res = snprintf(buffer, sizeof(buffer), "%s/%s\n%s\n", tenant, username, password); pMdm->delFile(CREDENTIALS_FILE); return pMdm->writeFile(CREDENTIALS_FILE, buffer, res)==res; }