1 //******************************************************************
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #ifndef HEIGHTSENSORAPP_H_
22 #define HEIGHTSENSORAPP_H_
26 #include "OCPlatform.h"
33 #define COAP_IP "0.0.0.0"
35 #define COAP_MODE OC::ModeType::Server
36 #define COAP_SRVTYPE OC::ServiceType::InProc
38 #define RESOURCE_TYPE_NAME "oic.r.sensor.height"
41 #define INTERVAL_FOR_CHECK 4 // seconds
42 #define INTERVAL_FOR_MEASUREMENT 3 // seconds
43 #define INIT_VAL 1 // default value
44 #define DIFF_VAL 0.02 // default value
50 // Access this property from a TB client
52 std::string m_resourceUri;
53 std::vector<std::string> m_resourceTypes;
54 std::vector<std::string> m_resourceInterfaces;
55 OCResourceHandle m_resourceHandle;
56 OC::OCRepresentation m_resourceRep;
57 OC::ObservationIds m_interestedObservers;
61 HeightResource() : m_height(INIT_VAL), m_resourceHandle(0)
63 m_resourceUri = "/Thing_HeightSensor";
64 m_resourceTypes.push_back(RESOURCE_TYPE_NAME);
65 m_resourceInterfaces.push_back(OC::DEFAULT_INTERFACE);
67 printf("Running thing as %s\n", m_resourceUri.c_str());
68 m_resourceRep.setUri(m_resourceUri);
69 m_resourceRep.setResourceTypes(m_resourceTypes);
70 m_resourceRep.setResourceInterfaces(m_resourceInterfaces);
77 void registerResource();
79 OCResourceHandle getHandle();
81 void setResourceRepresentation(OC::OCRepresentation &rep);
83 OC::OCRepresentation getResourceRepresentation();
86 #endif /* THINGRESOURCESERVER_H_ */