Validate device state for RFNOP
[platform/upstream/iotivity.git] / examples / OICSensorBoard / server.h
1 //******************************************************************
2 //
3 // Copyright 2014 Intel Corporation.
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 SERVER_H_
22 #define SERVER_H_
23
24 #include <string>
25 #include <iostream>
26 #include <memory>
27 #include "ocstack.h"
28 #include "observer.h"
29 #include "OCPlatform.h"
30 #include "OCApi.h"
31
32 using namespace std;
33 using namespace OC;
34
35 class IoTServer
36 {
37     shared_ptr<PlatformConfig> m_platformConfig;
38     OCRepresentation m_temperatureRepresentation;
39     OCResourceHandle m_temperatureResource;
40     OCRepresentation m_ambientLightRepresentation;
41     OCResourceHandle m_ambientLightResource;
42     OCRepresentation m_ledRepresentation;
43     OCResourceHandle m_ledResource;
44     ObservationIds m_ambientLightObservers;
45     ObservationIds m_temperatureObservers;
46     shared_ptr<IoTObserver> m_ambientLightObserverLoop;
47     shared_ptr<IoTObserver> m_temperatureObserverLoop;
48
49     void initializePlatform();
50     void setupResources();
51     void createResource(string, string, EntityHandler, OCResourceHandle&);
52
53     OCRepresentation getTemperatureRepresentation();
54     OCRepresentation getLightRepresentation();
55     OCRepresentation getLEDRepresentation();
56     void putLEDRepresentation();
57
58     //Polling threads to periodically query sensor values and notify
59     //subscribers.
60     void temperatureObserverLoop();
61     void lightObserverLoop();
62
63     OCEntityHandlerResult temperatureEntityHandler(shared_ptr<OCResourceRequest>);
64     OCEntityHandlerResult lightEntityHandler(shared_ptr<OCResourceRequest>);
65     OCEntityHandlerResult LEDEntityHandler(shared_ptr<OCResourceRequest>);
66 public:
67     IoTServer();
68     virtual ~IoTServer();
69 };
70
71 #endif /* SERVER_H_ */