TrailTraffic
Dependencies: Chainable_RGB_LED mbed mbedConnectorInterface mbedEndpointNetwork
Fork of IoT_LED_demo by
mbedEndpointResources/UV.h@1:b96a11b680dc, 2015-05-22 (annotated)
- Committer:
- cjwu15
- Date:
- Fri May 22 00:39:20 2015 +0000
- Revision:
- 1:b96a11b680dc
Share;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cjwu15 | 1:b96a11b680dc | 1 | /** |
cjwu15 | 1:b96a11b680dc | 2 | * @file LightResource.h |
cjwu15 | 1:b96a11b680dc | 3 | * @brief mbed CoAP Endpoint Light resource supporting CoAP GET and PUT |
cjwu15 | 1:b96a11b680dc | 4 | * @author Doug Anson, Michael Koster |
cjwu15 | 1:b96a11b680dc | 5 | * @version 1.0 |
cjwu15 | 1:b96a11b680dc | 6 | * @see |
cjwu15 | 1:b96a11b680dc | 7 | * |
cjwu15 | 1:b96a11b680dc | 8 | * Copyright (c) 2014 |
cjwu15 | 1:b96a11b680dc | 9 | * |
cjwu15 | 1:b96a11b680dc | 10 | * Licensed under the Apache License, Version 2.0 (the "License"); |
cjwu15 | 1:b96a11b680dc | 11 | * you may not use this file except in compliance with the License. |
cjwu15 | 1:b96a11b680dc | 12 | * You may obtain a copy of the License at |
cjwu15 | 1:b96a11b680dc | 13 | * |
cjwu15 | 1:b96a11b680dc | 14 | * http://www.apache.org/licenses/LICENSE-2.0 |
cjwu15 | 1:b96a11b680dc | 15 | * |
cjwu15 | 1:b96a11b680dc | 16 | * Unless required by applicable law or agreed to in writing, software |
cjwu15 | 1:b96a11b680dc | 17 | * distributed under the License is distributed on an "AS IS" BASIS, |
cjwu15 | 1:b96a11b680dc | 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
cjwu15 | 1:b96a11b680dc | 19 | * See the License for the specific language governing permissions and |
cjwu15 | 1:b96a11b680dc | 20 | * limitations under the License. |
cjwu15 | 1:b96a11b680dc | 21 | */ |
cjwu15 | 1:b96a11b680dc | 22 | |
cjwu15 | 1:b96a11b680dc | 23 | #ifndef __UV_RESOURCE_H__ |
cjwu15 | 1:b96a11b680dc | 24 | #define __UV_RESOURCE_H__ |
cjwu15 | 1:b96a11b680dc | 25 | |
cjwu15 | 1:b96a11b680dc | 26 | |
cjwu15 | 1:b96a11b680dc | 27 | // Base class |
cjwu15 | 1:b96a11b680dc | 28 | #include "DynamicResource.h" |
cjwu15 | 1:b96a11b680dc | 29 | #include "mbed.h" |
cjwu15 | 1:b96a11b680dc | 30 | |
cjwu15 | 1:b96a11b680dc | 31 | |
cjwu15 | 1:b96a11b680dc | 32 | AnalogIn sensorUV(A1); |
cjwu15 | 1:b96a11b680dc | 33 | |
cjwu15 | 1:b96a11b680dc | 34 | static char * uvValue = {"uv"}; //RRGGBBII |
cjwu15 | 1:b96a11b680dc | 35 | |
cjwu15 | 1:b96a11b680dc | 36 | /** LightResource class |
cjwu15 | 1:b96a11b680dc | 37 | */ |
cjwu15 | 1:b96a11b680dc | 38 | class UVResource : public DynamicResource |
cjwu15 | 1:b96a11b680dc | 39 | { |
cjwu15 | 1:b96a11b680dc | 40 | |
cjwu15 | 1:b96a11b680dc | 41 | public: |
cjwu15 | 1:b96a11b680dc | 42 | /** |
cjwu15 | 1:b96a11b680dc | 43 | Default constructor |
cjwu15 | 1:b96a11b680dc | 44 | @param logger input logger instance for this resource |
cjwu15 | 1:b96a11b680dc | 45 | @param name input the Light resource name |
cjwu15 | 1:b96a11b680dc | 46 | @param observable input the resource is Observable (default: FALSE) |
cjwu15 | 1:b96a11b680dc | 47 | */ |
cjwu15 | 1:b96a11b680dc | 48 | UVResource(const Logger *logger,const char *name,const bool observable = false) : DynamicResource(logger,name,"UV",SN_GRS_GET_ALLOWED,observable) { |
cjwu15 | 1:b96a11b680dc | 49 | } |
cjwu15 | 1:b96a11b680dc | 50 | |
cjwu15 | 1:b96a11b680dc | 51 | /** |
cjwu15 | 1:b96a11b680dc | 52 | Get the value of the LED |
cjwu15 | 1:b96a11b680dc | 53 | @returns string containing the last setting |
cjwu15 | 1:b96a11b680dc | 54 | */ |
cjwu15 | 1:b96a11b680dc | 55 | virtual string get() { |
cjwu15 | 1:b96a11b680dc | 56 | float value = sensorUV; |
cjwu15 | 1:b96a11b680dc | 57 | char result[8]; |
cjwu15 | 1:b96a11b680dc | 58 | sprintf(result, "%f", value); |
cjwu15 | 1:b96a11b680dc | 59 | return(result); |
cjwu15 | 1:b96a11b680dc | 60 | } |
cjwu15 | 1:b96a11b680dc | 61 | }; |
cjwu15 | 1:b96a11b680dc | 62 | |
cjwu15 | 1:b96a11b680dc | 63 | #endif // __UV_RESOURCE_H__ |
cjwu15 | 1:b96a11b680dc | 64 |