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 WEIGHTSENSORAPP_H_
22 #define WEIGHTSENSORAPP_H_
26 #include "OCPlatform.h"
32 #define COAP_IP "0.0.0.0"
34 #define COAP_MODE OC::ModeType::Server
35 #define COAP_SRVTYPE OC::ServiceType::InProc
37 #define RESOURCE_TYPE_NAME "oic.r.sensor.weight"
40 #define INTERVAL_FOR_CHECK 14 // seconds
41 #define INTERVAL_FOR_MEASUREMENT 3 // seconds
42 #define INIT_VAL 33 // default value
43 #define DIFF_VAL 0.01 // default value
49 // Access this property from a TB client
51 std::string m_resourceUri;
52 std::vector<std::string> m_resourceTypes;
53 std::vector<std::string> m_resourceInterfaces;
54 OCResourceHandle m_resourceHandle;
55 OC::OCRepresentation m_resourceRep;
56 OC::ObservationIds m_interestedObservers;
60 WeightResource() : m_weight(INIT_VAL), m_resourceHandle(0)
62 m_resourceUri = "/Thing_WeightSensor";
63 m_resourceTypes.push_back(RESOURCE_TYPE_NAME);
64 m_resourceInterfaces.push_back(OC::DEFAULT_INTERFACE);
66 printf("Running thing as %s\n", m_resourceUri.c_str());
67 m_resourceRep.setUri(m_resourceUri);
68 m_resourceRep.setResourceTypes(m_resourceTypes);
69 m_resourceRep.setResourceInterfaces(m_resourceInterfaces);
76 void registerResource();
78 OCResourceHandle getHandle();
80 void setResourceRepresentation(OC::OCRepresentation &rep);
82 OC::OCRepresentation getResourceRepresentation();
85 #endif /* THINGRESOURCESERVER_H_ */