
Own fork of MbedSmartRestMain
Dependencies: C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed
Fork of MbedSmartRestMain by
Revision 103:a3703ca4a4a4, committed 2015-05-08
- Comitter:
- xinlei
- Date:
- Fri May 08 13:15:29 2015 +0000
- Parent:
- 102:ede6611e064e
- Child:
- 104:fd3571349e5d
- Commit message:
- rename files to meaningful names
Changed in this revision
--- a/io/DeviceFeedback.cpp Fri May 08 13:03:41 2015 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -#include "mbed.h" - -DigitalOut shieldLEDRed(D5, 255); -DigitalOut shieldLEDBlue(D8, 255); -DigitalOut shieldLEDGreen(D9, 255); - -void closeRelay() -{ - shieldLEDRed = 255; - shieldLEDBlue = 255; - shieldLEDGreen = 0; -} - -void openRelay() -{ - shieldLEDRed = 255; - shieldLEDBlue = 255; - shieldLEDGreen = 255; -} \ No newline at end of file
--- a/io/DeviceFeedback.h Fri May 08 13:03:41 2015 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -#ifndef DEVICEFEEDBACK_H -#define DEVICEFEEDBACK_H - -void closeRelay(); -void openRelay(); - -#endif \ No newline at end of file
--- a/io/DeviceMemory.cpp Fri May 08 13:03:41 2015 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include "MDM.h" - -#define CREDENTIALS_FILE "001_CREDENTIALS" -#define CONFIGURATION_FILE "002_CONFIGURATION" -extern MDMSerial *pMdm; - -bool loadCredential(char *username, char *password, size_t len) -{ - char buffer[len*2+3]; - int res = pMdm->readFile(CREDENTIALS_FILE, buffer, sizeof(buffer)); - if (res < 0) { - return false; - } else { - buffer[res] = 0; - int l = 0; - sscanf(buffer, "%s\n%s\n%n", username, password, &l); - return res==l; - } -} - -bool delCredential() -{ - return pMdm->delFile(CREDENTIALS_FILE); -} - -bool saveCredential(char *username, char *password, size_t len) -{ - char buffer[len*2+3]; - int res = snprintf(buffer, sizeof(buffer), "%s\n%s\n", username, password); - delCredential(); - return pMdm->writeFile(CREDENTIALS_FILE, buffer, res)==res; -} - -int loadConfigFile(char *cfg, size_t len) -{ - int res = pMdm->readFile(CONFIGURATION_FILE, cfg, len); - if (res >= 0) - cfg[res] = 0; - return res; -} - -bool delConfigFile() -{ - return pMdm->delFile(CONFIGURATION_FILE); -} - -bool saveConfigFile(char *cfg, size_t len) -{ - delConfigFile(); - return pMdm->writeFile(CONFIGURATION_FILE, cfg, len)==len; -}
--- a/io/DeviceMemory.h Fri May 08 13:03:41 2015 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -#ifndef DEVICEMEMORY_H -#define DEVICEMEMORY_H - -#include <stddef.h> - -/** loads credentials from persistent memory */ -bool loadCredential(char *username, char *password, size_t len); - -/** saves credentials to persistent memory */ -bool delCredential(); - -/** removes credentials from persistent memory */ -bool saveCredential(char *username, char *password, size_t len); - -/** loads configuration from persistent memory */ -bool loadConfigFile(char *cfg, size_t len); - -/** saves configuration to persistent memory */ -bool saveConfigFile(char *cfg, size_t len); - -/** removes configuration from persistent memory */ -bool delConfigFile(); -#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/io/Peripheral.cpp Fri May 08 13:15:29 2015 +0000 @@ -0,0 +1,19 @@ +#include "mbed.h" + +DigitalOut shieldLEDRed(D5, 255); +DigitalOut shieldLEDBlue(D8, 255); +DigitalOut shieldLEDGreen(D9, 255); + +void closeRelay() +{ + shieldLEDRed = 255; + shieldLEDBlue = 255; + shieldLEDGreen = 0; +} + +void openRelay() +{ + shieldLEDRed = 255; + shieldLEDBlue = 255; + shieldLEDGreen = 255; +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/io/Peripheral.h Fri May 08 13:15:29 2015 +0000 @@ -0,0 +1,7 @@ +#ifndef PERIPHERAL_H +#define PERIPHERAL_H + +void closeRelay(); +void openRelay(); + +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/io/Storage.cpp Fri May 08 13:15:29 2015 +0000 @@ -0,0 +1,53 @@ +#include <stdio.h> +#include <string.h> +#include "MDM.h" + +#define CREDENTIALS_FILE "001_CREDENTIALS" +#define CONFIGURATION_FILE "002_CONFIGURATION" +extern MDMSerial *pMdm; + +bool loadCredential(char *username, char *password, size_t len) +{ + char buffer[len*2+3]; + int res = pMdm->readFile(CREDENTIALS_FILE, buffer, sizeof(buffer)); + if (res < 0) { + return false; + } else { + buffer[res] = 0; + int l = 0; + sscanf(buffer, "%s\n%s\n%n", username, password, &l); + return res==l; + } +} + +bool delCredential() +{ + return pMdm->delFile(CREDENTIALS_FILE); +} + +bool saveCredential(char *username, char *password, size_t len) +{ + char buffer[len*2+3]; + int res = snprintf(buffer, sizeof(buffer), "%s\n%s\n", username, password); + delCredential(); + return pMdm->writeFile(CREDENTIALS_FILE, buffer, res)==res; +} + +int loadConfigFile(char *cfg, size_t len) +{ + int res = pMdm->readFile(CONFIGURATION_FILE, cfg, len); + if (res >= 0) + cfg[res] = 0; + return res; +} + +bool delConfigFile() +{ + return pMdm->delFile(CONFIGURATION_FILE); +} + +bool saveConfigFile(char *cfg, size_t len) +{ + delConfigFile(); + return pMdm->writeFile(CONFIGURATION_FILE, cfg, len)==len; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/io/Storage.h Fri May 08 13:15:29 2015 +0000 @@ -0,0 +1,23 @@ +#ifndef STORAGE_H +#define STORAGE_H + +#include <stddef.h> + +/** loads credentials from persistent memory */ +bool loadCredential(char *username, char *password, size_t len); + +/** saves credentials to persistent memory */ +bool delCredential(); + +/** removes credentials from persistent memory */ +bool saveCredential(char *username, char *password, size_t len); + +/** loads configuration from persistent memory */ +bool loadConfigFile(char *cfg, size_t len); + +/** saves configuration to persistent memory */ +bool saveConfigFile(char *cfg, size_t len); + +/** removes configuration from persistent memory */ +bool delConfigFile(); +#endif \ No newline at end of file