Christopher Wu / Mbed 2 deprecated Trail

Dependencies:   Chainable_RGB_LED mbed mbedConnectorInterface mbedEndpointNetwork

Fork of IoT_LED_demo by MBED_DEMOS

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers UV.h Source File

UV.h

00001 /**
00002  * @file    LightResource.h
00003  * @brief   mbed CoAP Endpoint Light resource supporting CoAP GET and PUT
00004  * @author  Doug Anson, Michael Koster
00005  * @version 1.0
00006  * @see
00007  *
00008  * Copyright (c) 2014
00009  *
00010  * Licensed under the Apache License, Version 2.0 (the "License");
00011  * you may not use this file except in compliance with the License.
00012  * You may obtain a copy of the License at
00013  *
00014  *     http://www.apache.org/licenses/LICENSE-2.0
00015  *
00016  * Unless required by applicable law or agreed to in writing, software
00017  * distributed under the License is distributed on an "AS IS" BASIS,
00018  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00019  * See the License for the specific language governing permissions and
00020  * limitations under the License.
00021  */
00022 
00023 #ifndef __UV_RESOURCE_H__
00024 #define __UV_RESOURCE_H__
00025 
00026 
00027 // Base class
00028 #include "DynamicResource.h"
00029 #include "mbed.h"
00030 
00031 
00032 AnalogIn sensorUV(A1);
00033 
00034 static char * uvValue = {"uv"}; //RRGGBBII
00035 
00036 /** LightResource class
00037  */
00038 class UVResource : public DynamicResource
00039 {
00040 
00041 public:
00042     /**
00043     Default constructor
00044     @param logger input logger instance for this resource
00045     @param name input the Light resource name
00046     @param observable input the resource is Observable (default: FALSE)
00047     */
00048     UVResource(const Logger *logger,const char *name,const bool observable = false) : DynamicResource(logger,name,"UV",SN_GRS_GET_ALLOWED,observable) {
00049     }
00050 
00051     /**
00052     Get the value of the LED
00053     @returns string containing the last setting
00054     */
00055     virtual string get() {
00056         float value = sensorUV;
00057         char result[8];
00058         sprintf(result, "%f", value);
00059         return(result);
00060     }
00061 };
00062 
00063 #endif // __UV_RESOURCE_H__
00064