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
DeviceBootstrap.h@55:a0f7295ed6b6, 2014-10-23 (annotated)
- Committer:
- vwochnik
- Date:
- Thu Oct 23 12:50:07 2014 +0000
- Revision:
- 55:a0f7295ed6b6
- Parent:
- 52:8f1370084268
- Child:
- 67:c360a2b2c948
thread safe smartrest
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" |
vwochnik | 52:8f1370084268 | 6 | #include "DeviceIO.h" |
vwochnik | 55:a0f7295ed6b6 | 7 | #include "AbstractSmartRest.h" |
Cumulocity | 41:804f6a0bda26 | 8 | #include "DeviceInfo.h" |
Cumulocity | 41:804f6a0bda26 | 9 | |
Cumulocity | 41:804f6a0bda26 | 10 | /** The username used for device bootstrapping. */ |
Cumulocity | 41:804f6a0bda26 | 11 | #define DEVICE_BOOTSTRAP_USERNAME "management/devicebootstrap" |
Cumulocity | 41:804f6a0bda26 | 12 | |
Cumulocity | 41:804f6a0bda26 | 13 | /** The password used for device bootstrapping. */ |
Cumulocity | 41:804f6a0bda26 | 14 | #define DEVICE_BOOTSTRAP_PASSWORD "Fhdt1bb1f" |
Cumulocity | 41:804f6a0bda26 | 15 | |
Cumulocity | 41:804f6a0bda26 | 16 | #define DEVICE_BOOTSTRAP_CREDENTIALS_LENGTH 256 |
Cumulocity | 41:804f6a0bda26 | 17 | |
Cumulocity | 41:804f6a0bda26 | 18 | #define CREDENTIALS_FILE "001_CREDENTIALS" |
Cumulocity | 41:804f6a0bda26 | 19 | |
Cumulocity | 41:804f6a0bda26 | 20 | class DeviceBootstrap |
Cumulocity | 41:804f6a0bda26 | 21 | { |
Cumulocity | 41:804f6a0bda26 | 22 | public: |
vwochnik | 55:a0f7295ed6b6 | 23 | DeviceBootstrap(AbstractSmartRest&, MDMSerial&, DeviceIO&, DeviceInfo&); |
Cumulocity | 41:804f6a0bda26 | 24 | |
Cumulocity | 41:804f6a0bda26 | 25 | bool setUpCredentials(); |
Cumulocity | 46:f6976fd64387 | 26 | const char * username(); |
Cumulocity | 46:f6976fd64387 | 27 | const char * password(); |
Cumulocity | 41:804f6a0bda26 | 28 | |
Cumulocity | 41:804f6a0bda26 | 29 | protected: |
Cumulocity | 41:804f6a0bda26 | 30 | bool obtainFromStorage(); |
Cumulocity | 41:804f6a0bda26 | 31 | bool obtainFromPlatform(); |
Cumulocity | 41:804f6a0bda26 | 32 | |
Cumulocity | 41:804f6a0bda26 | 33 | private: |
Cumulocity | 41:804f6a0bda26 | 34 | bool writeToStorage(); |
Cumulocity | 41:804f6a0bda26 | 35 | void setCredentials(const char *, const char*, const char*); |
Cumulocity | 41:804f6a0bda26 | 36 | |
Cumulocity | 41:804f6a0bda26 | 37 | private: |
vwochnik | 55:a0f7295ed6b6 | 38 | AbstractSmartRest& _client; |
Cumulocity | 41:804f6a0bda26 | 39 | MDMSerial& _mdm; |
Cumulocity | 41:804f6a0bda26 | 40 | DeviceInfo& _deviceInfo; |
vwochnik | 52:8f1370084268 | 41 | DeviceIO& _io; |
Cumulocity | 41:804f6a0bda26 | 42 | char _username[DEVICE_BOOTSTRAP_CREDENTIALS_LENGTH], |
Cumulocity | 41:804f6a0bda26 | 43 | _password[DEVICE_BOOTSTRAP_CREDENTIALS_LENGTH]; |
Cumulocity | 41:804f6a0bda26 | 44 | }; |
Cumulocity | 41:804f6a0bda26 | 45 | |
Cumulocity | 41:804f6a0bda26 | 46 | #endif |