portable version of the cumulocity demo
Dependencies: C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed
Fork of MbedSmartRestMain by
DeviceBootstrap.h@46:f6976fd64387, 2014-07-24 (annotated)
- Committer:
- Cumulocity
- Date:
- Thu Jul 24 16:02:47 2014 +0000
- Revision:
- 46:f6976fd64387
- Parent:
- 41:804f6a0bda26
- Child:
- 52:8f1370084268
implement device credential reset; show username/password on display
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Cumulocity | 41:804f6a0bda26 | 1 | #ifndef DEVICEBOOTSTRAP_H |
Cumulocity | 41:804f6a0bda26 | 2 | #define DEVICEBOOTSTRAP_H |
Cumulocity | 41:804f6a0bda26 | 3 | |
Cumulocity | 41:804f6a0bda26 | 4 | #include <stddef.h> |
Cumulocity | 41:804f6a0bda26 | 5 | #include "MDM.h" |
Cumulocity | 41:804f6a0bda26 | 6 | #include "SmartRest.h" |
Cumulocity | 41:804f6a0bda26 | 7 | #include "DeviceInfo.h" |
Cumulocity | 41:804f6a0bda26 | 8 | |
Cumulocity | 41:804f6a0bda26 | 9 | /** The username used for device bootstrapping. */ |
Cumulocity | 41:804f6a0bda26 | 10 | #define DEVICE_BOOTSTRAP_USERNAME "management/devicebootstrap" |
Cumulocity | 41:804f6a0bda26 | 11 | |
Cumulocity | 41:804f6a0bda26 | 12 | /** The password used for device bootstrapping. */ |
Cumulocity | 41:804f6a0bda26 | 13 | #define DEVICE_BOOTSTRAP_PASSWORD "Fhdt1bb1f" |
Cumulocity | 41:804f6a0bda26 | 14 | |
Cumulocity | 41:804f6a0bda26 | 15 | #define DEVICE_BOOTSTRAP_CREDENTIALS_LENGTH 256 |
Cumulocity | 41:804f6a0bda26 | 16 | |
Cumulocity | 41:804f6a0bda26 | 17 | #define CREDENTIALS_FILE "001_CREDENTIALS" |
Cumulocity | 41:804f6a0bda26 | 18 | |
Cumulocity | 41:804f6a0bda26 | 19 | class DeviceBootstrap |
Cumulocity | 41:804f6a0bda26 | 20 | { |
Cumulocity | 41:804f6a0bda26 | 21 | public: |
Cumulocity | 41:804f6a0bda26 | 22 | DeviceBootstrap(SmartRest&, MDMSerial&, DeviceInfo&); |
Cumulocity | 41:804f6a0bda26 | 23 | |
Cumulocity | 41:804f6a0bda26 | 24 | bool setUpCredentials(); |
Cumulocity | 46:f6976fd64387 | 25 | const char * username(); |
Cumulocity | 46:f6976fd64387 | 26 | const char * password(); |
Cumulocity | 41:804f6a0bda26 | 27 | |
Cumulocity | 41:804f6a0bda26 | 28 | protected: |
Cumulocity | 41:804f6a0bda26 | 29 | bool obtainFromStorage(); |
Cumulocity | 41:804f6a0bda26 | 30 | bool obtainFromPlatform(); |
Cumulocity | 41:804f6a0bda26 | 31 | |
Cumulocity | 41:804f6a0bda26 | 32 | private: |
Cumulocity | 41:804f6a0bda26 | 33 | bool writeToStorage(); |
Cumulocity | 41:804f6a0bda26 | 34 | void setCredentials(const char *, const char*, const char*); |
Cumulocity | 41:804f6a0bda26 | 35 | |
Cumulocity | 41:804f6a0bda26 | 36 | private: |
Cumulocity | 41:804f6a0bda26 | 37 | SmartRest& _client; |
Cumulocity | 41:804f6a0bda26 | 38 | MDMSerial& _mdm; |
Cumulocity | 41:804f6a0bda26 | 39 | DeviceInfo& _deviceInfo; |
Cumulocity | 41:804f6a0bda26 | 40 | char _username[DEVICE_BOOTSTRAP_CREDENTIALS_LENGTH], |
Cumulocity | 41:804f6a0bda26 | 41 | _password[DEVICE_BOOTSTRAP_CREDENTIALS_LENGTH]; |
Cumulocity | 41:804f6a0bda26 | 42 | }; |
Cumulocity | 41:804f6a0bda26 | 43 | |
Cumulocity | 41:804f6a0bda26 | 44 | #endif |