Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbedConnectorInterfaceV3 by
mbed-connector-interface/DeviceStringResource.h@14:d9ce4e56684e, 2016-06-09 (annotated)
- Committer:
- ansond
- Date:
- Thu Jun 09 19:05:18 2016 +0000
- Revision:
- 14:d9ce4e56684e
- Parent:
- 13:9edad7677211
- Child:
- 15:c11dbe4d354c
updates for DM functions
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| ansond | 13:9edad7677211 | 1 | /** |
| ansond | 13:9edad7677211 | 2 | * @file DeviceStringResource.h |
| ansond | 13:9edad7677211 | 3 | * @brief mbed CoAP Endpoint Device String Resource |
| ansond | 13:9edad7677211 | 4 | * @author Doug Anson |
| ansond | 13:9edad7677211 | 5 | * @version 1.0 |
| ansond | 13:9edad7677211 | 6 | * @see |
| ansond | 13:9edad7677211 | 7 | * |
| ansond | 13:9edad7677211 | 8 | * Copyright (c) 2014 |
| ansond | 13:9edad7677211 | 9 | * |
| ansond | 13:9edad7677211 | 10 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| ansond | 13:9edad7677211 | 11 | * you may not use this file except in compliance with the License. |
| ansond | 13:9edad7677211 | 12 | * You may obtain a copy of the License at |
| ansond | 13:9edad7677211 | 13 | * |
| ansond | 13:9edad7677211 | 14 | * http://www.apache.org/licenses/LICENSE-2.0 |
| ansond | 13:9edad7677211 | 15 | * |
| ansond | 13:9edad7677211 | 16 | * Unless required by applicable law or agreed to in writing, software |
| ansond | 13:9edad7677211 | 17 | * distributed under the License is distributed on an "AS IS" BASIS, |
| ansond | 13:9edad7677211 | 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| ansond | 13:9edad7677211 | 19 | * See the License for the specific language governing permissions and |
| ansond | 13:9edad7677211 | 20 | * limitations under the License. |
| ansond | 13:9edad7677211 | 21 | */ |
| ansond | 13:9edad7677211 | 22 | |
| ansond | 13:9edad7677211 | 23 | #ifndef __DEVICE_STRING_RESOURCE_H__ |
| ansond | 13:9edad7677211 | 24 | #define __DEVICE_STRING_RESOURCE_H__ |
| ansond | 13:9edad7677211 | 25 | |
| ansond | 13:9edad7677211 | 26 | // Base class |
| ansond | 13:9edad7677211 | 27 | #include "mbed-connector-interface/DynamicResource.h" |
| ansond | 13:9edad7677211 | 28 | |
| ansond | 13:9edad7677211 | 29 | // Device Management Responder |
| ansond | 13:9edad7677211 | 30 | #include "mbed-connector-interface/DeviceManagementResponder.h" |
| ansond | 13:9edad7677211 | 31 | |
| ansond | 13:9edad7677211 | 32 | /** DeviceStringResource class |
| ansond | 13:9edad7677211 | 33 | */ |
| ansond | 13:9edad7677211 | 34 | class DeviceStringResource : public DynamicResource |
| ansond | 13:9edad7677211 | 35 | { |
| ansond | 13:9edad7677211 | 36 | public: |
| ansond | 13:9edad7677211 | 37 | /** |
| ansond | 13:9edad7677211 | 38 | Default constructor |
| ansond | 13:9edad7677211 | 39 | @param logger input logger instance for this resource |
| ansond | 13:9edad7677211 | 40 | @param obj_name input the String Object ID |
| ansond | 13:9edad7677211 | 41 | @param res_name input the String Resource ID |
| ansond | 13:9edad7677211 | 42 | @param res_type input the String Resource Type |
| ansond | 13:9edad7677211 | 43 | @param dm_responder input the DM responder instance |
| ansond | 13:9edad7677211 | 44 | @param observable input this String is observable |
| ansond | 13:9edad7677211 | 45 | */ |
| ansond | 13:9edad7677211 | 46 | DeviceStringResource(const Logger *logger,const char *obj_name,const char *res_name,const char *res_type,const void *dm_responder,bool observable = false) : |
| ansond | 13:9edad7677211 | 47 | DynamicResource(logger,obj_name,res_name,res_type,M2MBase::GET_PUT_ALLOWED,observable) |
| ansond | 13:9edad7677211 | 48 | { |
| ansond | 13:9edad7677211 | 49 | this->m_dm_responder = (DeviceManagementResponder *)dm_responder; |
| ansond | 13:9edad7677211 | 50 | } |
| ansond | 13:9edad7677211 | 51 | |
| ansond | 13:9edad7677211 | 52 | /** |
| ansond | 13:9edad7677211 | 53 | GET handler |
| ansond | 13:9edad7677211 | 54 | @returns string with this resource type |
| ansond | 13:9edad7677211 | 55 | */ |
| ansond | 13:9edad7677211 | 56 | virtual string get() { |
| ansond | 13:9edad7677211 | 57 | return this->m_value; |
| ansond | 13:9edad7677211 | 58 | } |
| ansond | 13:9edad7677211 | 59 | |
| ansond | 13:9edad7677211 | 60 | /** |
| ansond | 13:9edad7677211 | 61 | PUT handler |
| ansond | 13:9edad7677211 | 62 | @param value input input value |
| ansond | 13:9edad7677211 | 63 | */ |
| ansond | 13:9edad7677211 | 64 | virtual void put(string value) { |
| ansond | 13:9edad7677211 | 65 | this->m_value = value; |
| ansond | 14:d9ce4e56684e | 66 | if (this->isObservable() == true) { |
| ansond | 14:d9ce4e56684e | 67 | this->observe(); |
| ansond | 14:d9ce4e56684e | 68 | } |
| ansond | 13:9edad7677211 | 69 | } |
| ansond | 13:9edad7677211 | 70 | |
| ansond | 13:9edad7677211 | 71 | protected: |
| ansond | 13:9edad7677211 | 72 | DeviceManagementResponder *m_dm_responder; |
| ansond | 13:9edad7677211 | 73 | |
| ansond | 13:9edad7677211 | 74 | private: |
| ansond | 13:9edad7677211 | 75 | string m_value; |
| ansond | 13:9edad7677211 | 76 | }; |
| ansond | 13:9edad7677211 | 77 | |
| ansond | 13:9edad7677211 | 78 | #endif // __DEVICE_STRING_RESOURCE_H__ |
