1
mbed_cloud_client_resource.cpp@0:d193d40d4fa1, 2018-03-21 (annotated)
- Committer:
- group-STM32F031
- Date:
- Wed Mar 21 18:13:41 2018 +0000
- Revision:
- 0:d193d40d4fa1
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
group-STM32F031 | 0:d193d40d4fa1 | 1 | #include "mbed_cloud_client_resource.h" |
group-STM32F031 | 0:d193d40d4fa1 | 2 | #include "simple-mbed-cloud-client.h" |
group-STM32F031 | 0:d193d40d4fa1 | 3 | |
group-STM32F031 | 0:d193d40d4fa1 | 4 | unsigned int m2m_method_to_index(M2MMethod::M2MMethod method) { |
group-STM32F031 | 0:d193d40d4fa1 | 5 | switch (method) { |
group-STM32F031 | 0:d193d40d4fa1 | 6 | case M2MMethod::GET: |
group-STM32F031 | 0:d193d40d4fa1 | 7 | return 0; |
group-STM32F031 | 0:d193d40d4fa1 | 8 | break; |
group-STM32F031 | 0:d193d40d4fa1 | 9 | |
group-STM32F031 | 0:d193d40d4fa1 | 10 | case M2MMethod::PUT: |
group-STM32F031 | 0:d193d40d4fa1 | 11 | return 1; |
group-STM32F031 | 0:d193d40d4fa1 | 12 | break; |
group-STM32F031 | 0:d193d40d4fa1 | 13 | |
group-STM32F031 | 0:d193d40d4fa1 | 14 | case M2MMethod::POST: |
group-STM32F031 | 0:d193d40d4fa1 | 15 | return 2; |
group-STM32F031 | 0:d193d40d4fa1 | 16 | break; |
group-STM32F031 | 0:d193d40d4fa1 | 17 | |
group-STM32F031 | 0:d193d40d4fa1 | 18 | case M2MMethod::DELETE: |
group-STM32F031 | 0:d193d40d4fa1 | 19 | return 3; |
group-STM32F031 | 0:d193d40d4fa1 | 20 | break; |
group-STM32F031 | 0:d193d40d4fa1 | 21 | } |
group-STM32F031 | 0:d193d40d4fa1 | 22 | } |
group-STM32F031 | 0:d193d40d4fa1 | 23 | |
group-STM32F031 | 0:d193d40d4fa1 | 24 | MbedCloudClientResource::MbedCloudClientResource(SimpleMbedCloudClient *client, const char *path, const char *name) |
group-STM32F031 | 0:d193d40d4fa1 | 25 | : client(client) { |
group-STM32F031 | 0:d193d40d4fa1 | 26 | this->path = path; |
group-STM32F031 | 0:d193d40d4fa1 | 27 | this->name = name; |
group-STM32F031 | 0:d193d40d4fa1 | 28 | } |
group-STM32F031 | 0:d193d40d4fa1 | 29 | |
group-STM32F031 | 0:d193d40d4fa1 | 30 | void MbedCloudClientResource::observable(bool observable) { |
group-STM32F031 | 0:d193d40d4fa1 | 31 | this->isObservable = observable; |
group-STM32F031 | 0:d193d40d4fa1 | 32 | } |
group-STM32F031 | 0:d193d40d4fa1 | 33 | |
group-STM32F031 | 0:d193d40d4fa1 | 34 | void MbedCloudClientResource::methods(unsigned int methodMask) { |
group-STM32F031 | 0:d193d40d4fa1 | 35 | this->methodMask = methodMask; |
group-STM32F031 | 0:d193d40d4fa1 | 36 | } |
group-STM32F031 | 0:d193d40d4fa1 | 37 | |
group-STM32F031 | 0:d193d40d4fa1 | 38 | void MbedCloudClientResource::attach(M2MMethod::M2MMethod method, void *callback) { |
group-STM32F031 | 0:d193d40d4fa1 | 39 | this->callbacks[m2m_method_to_index(method)] = callback; |
group-STM32F031 | 0:d193d40d4fa1 | 40 | } |
group-STM32F031 | 0:d193d40d4fa1 | 41 | |
group-STM32F031 | 0:d193d40d4fa1 | 42 | void MbedCloudClientResource::attach_notification(M2MMethod::M2MMethod method, void *callback) { |
group-STM32F031 | 0:d193d40d4fa1 | 43 | this->notification_callbacks[m2m_method_to_index(method)] = callback; |
group-STM32F031 | 0:d193d40d4fa1 | 44 | } |
group-STM32F031 | 0:d193d40d4fa1 | 45 | |
group-STM32F031 | 0:d193d40d4fa1 | 46 | void MbedCloudClientResource::detatch(M2MMethod::M2MMethod method) { |
group-STM32F031 | 0:d193d40d4fa1 | 47 | this->callbacks[m2m_method_to_index(method)] = NULL; |
group-STM32F031 | 0:d193d40d4fa1 | 48 | } |
group-STM32F031 | 0:d193d40d4fa1 | 49 | |
group-STM32F031 | 0:d193d40d4fa1 | 50 | void MbedCloudClientResource::detatch_notification(M2MMethod::M2MMethod method) { |
group-STM32F031 | 0:d193d40d4fa1 | 51 | this->notification_callbacks[m2m_method_to_index(method)] = NULL; |
group-STM32F031 | 0:d193d40d4fa1 | 52 | } |
group-STM32F031 | 0:d193d40d4fa1 | 53 | |
group-STM32F031 | 0:d193d40d4fa1 | 54 | void MbedCloudClientResource::set_value(int value) { |
group-STM32F031 | 0:d193d40d4fa1 | 55 | // TODO |
group-STM32F031 | 0:d193d40d4fa1 | 56 | } |
group-STM32F031 | 0:d193d40d4fa1 | 57 | |
group-STM32F031 | 0:d193d40d4fa1 | 58 | void MbedCloudClientResource::set_value(char *value) { |
group-STM32F031 | 0:d193d40d4fa1 | 59 | // TODO |
group-STM32F031 | 0:d193d40d4fa1 | 60 | } |
group-STM32F031 | 0:d193d40d4fa1 | 61 | |
group-STM32F031 | 0:d193d40d4fa1 | 62 | char* MbedCloudClientResource::get_value() { |
group-STM32F031 | 0:d193d40d4fa1 | 63 | // TODO |
group-STM32F031 | 0:d193d40d4fa1 | 64 | return (char*)"test"; |
group-STM32F031 | 0:d193d40d4fa1 | 65 | } |