Correcting the INPUT in Doxygen file.
[platform/upstream/iotivity.git] / service / resource-container / examples / BMISensorBundle / src / inputSensors / WeightSensorApp / include / WeightSensorApp.h
1 //******************************************************************
2 //
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
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
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
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.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 #ifndef WEIGHTSENSORAPP_H_
22 #define WEIGHTSENSORAPP_H_
23
24 #include <functional>
25 #include <pthread.h>
26 #include "OCPlatform.h"
27 #include "OCApi.h"
28
29 #include <string>
30 #include <cstdlib>
31
32 #define COAP_IP                 "0.0.0.0"
33 #define COAP_PORT               0
34 #define COAP_MODE               OC::ModeType::Server
35 #define COAP_SRVTYPE            OC::ServiceType::InProc
36
37 #define RESOURCE_TYPE_NAME          "oic.r.sensor.weight"
38
39 //  testing case
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
44
45
46 class WeightResource
47 {
48     public:
49         // Access this property from a TB client
50         double m_weight;
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;
57
58     public:
59         // Constructor
60         WeightResource() : m_weight(INIT_VAL), m_resourceHandle(0)
61         {
62             m_resourceUri = "/Thing_WeightSensor";
63             m_resourceTypes.push_back(RESOURCE_TYPE_NAME);
64             m_resourceInterfaces.push_back(OC::DEFAULT_INTERFACE);
65
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);
70         }
71
72         ~WeightResource()
73         {
74         }
75
76         void registerResource();
77
78         OCResourceHandle getHandle();
79
80         void setResourceRepresentation(OC::OCRepresentation &rep);
81
82         OC::OCRepresentation getResourceRepresentation();
83 };
84
85 #endif /* THINGRESOURCESERVER_H_ */