mbedConnectorInterface sample endpoint utilizing 3g cellular radio as the underlying connection transport.
Dependencies: LM75B mbed mbedConnectorInterface mbedEndpointNetwork_Ublox
TemperatureResource.h
00001 /** 00002 * @file TemperatureResource.h 00003 * @brief mbed CoAP Endpoint Temperature sensor resource supporting CoAP GET 00004 * @author Doug Anson 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 __TEMPERATURE_RESOURCE_H__ 00024 #define __TEMPERATURE_RESOURCE_H__ 00025 00026 // Base class 00027 #include "DynamicResource.h" 00028 00029 // our Temperature sensor 00030 #include "LM75B.h" 00031 LM75B temp_sensor(D14,D15); 00032 00033 /** TemperatureResource class 00034 */ 00035 class TemperatureResource : public DynamicResource 00036 { 00037 public: 00038 /** 00039 Default constructor 00040 @param logger input logger instance for this resource 00041 @param name input the Temperature resource name 00042 @param observable input the resource is Observable (default: FALSE) 00043 */ 00044 TemperatureResource(const Logger *logger,const char *name,const bool observable = false) : DynamicResource(logger,name,"Temperature",SN_GRS_GET_ALLOWED,observable) { 00045 } 00046 00047 /** 00048 Get the value of the Temperature sensor 00049 @returns string containing the temperature sensor value 00050 */ 00051 virtual string get() { 00052 char temp[7]; 00053 memset(temp,0,7); 00054 sprintf(temp,"%3.2f", temp_sensor.temp()); 00055 return string(temp); 00056 } 00057 }; 00058 00059 #endif // __TEMPERATURE_RESOURCE_H__
Generated on Sat Jul 30 2022 21:39:30 by 1.7.2