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.
Dependencies: Chainable_RGB_LED DHT LED_Bar mbed mbedConnectorInterface mbedEndpointNetwork_mjk_regfix
PresenceResource.h
00001 /** 00002 * @file PresenceResource.h 00003 * @brief mbed CoAP Endpoint 00004 * @author Michael Koster 00005 * @version 1.0 00006 * @see 00007 * 00008 * Copyright (c) 2015 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 __PRES_RESOURCE_H__ 00024 #define __PRES_RESOURCE_H__ 00025 00026 // Base class 00027 #include "DynamicResource.h" 00028 00029 // Presence Sensor connected to D2 00030 DigitalIn pres_in(D2); 00031 00032 /** TempResource class 00033 */ 00034 class PresenceResource : public DynamicResource 00035 { 00036 public: 00037 /** 00038 Default constructor 00039 @param logger input logger instance for this resource 00040 @param name input the resource name 00041 @param observable input the resource is Observable (default: FALSE) 00042 */ 00043 PresenceResource(const Logger *logger,const char *name,const bool observable = false) : 00044 DynamicResource(logger,name,"Presence", SN_GRS_GET_ALLOWED,observable) { 00045 } 00046 00047 /** 00048 Get the value of the Presence Sensor 00049 @returns string containing 1 for presence detected, 0 for no presence detected 00050 */ 00051 virtual string get() { 00052 if(pres_in.read()) 00053 return("1"); 00054 else 00055 return("0"); 00056 } 00057 }; 00058 00059 #endif // __PRES_RESOURCE_H__
Generated on Wed Jul 13 2022 19:30:15 by
1.7.2