Merge branch 'cloud-interface'
[platform/upstream/iotivity.git] / service / easy-setup / enrollee / src / resourcehandler.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 // Do not remove the include below
22
23 #include <string.h>
24 #include "logger.h"
25 #include "ocstack.h"
26 #include "escommon.h"
27 #include "ESEnrolleeCommon.h"
28 #include "octypes.h"
29
30 #ifndef ES_RESOURCE_HANDLER_H_
31 #define ES_RESOURCE_HANDLER_H_
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 typedef void (*ESWiFiCB) (ESResult, ESWiFiProvData *);
38 typedef void (*ESCloudCB) (ESResult, ESCloudProvData *);
39 typedef void (*ESDevConfCB) (ESResult, ESDevConfProvData *);
40
41 typedef void (*ESWriteUserdataCb)(OCRepPayload* payload, char* resourceType);
42 typedef void (*ESReadUserdataCb)(OCRepPayload* payload, char* resourceType, void** userdata);
43
44 /* Structure to represent a Light resource */
45 typedef struct PROVRESOURCE
46 {
47     OCResourceHandle handle;
48     ProvStatus status; // provisiong status
49     ESErrorCode lastErrCode;
50     char ocfWebLinks[MAX_WEBLINKLEN];
51 } ProvResource;
52
53 typedef struct
54 {
55     OCResourceHandle handle;
56     WIFI_MODE supportedMode[NUM_WIFIMODE];
57     uint8_t numMode;        // the number of device's supported wifi modes
58     WIFI_FREQ supportedFreq;
59     char ssid[MAX_SSIDLEN]; // SSID
60     char cred[MAX_CREDLEN]; // credential information.
61     WIFI_AUTHTYPE authType;
62     WIFI_ENCTYPE encType;
63 } WiFiResource;
64
65 typedef struct
66 {
67     OCResourceHandle handle;
68     char authCode[OIC_STRING_MAX_VALUE];
69     char authProvider[OIC_STRING_MAX_VALUE];
70     char ciServer[OIC_STRING_MAX_VALUE];
71 } CloudResource;
72
73 typedef struct
74 {
75     OCResourceHandle handle;
76     char devName[MAX_DEVICELEN];
77     char language[OIC_STRING_MAX_VALUE];
78     char country[OIC_STRING_MAX_VALUE];
79 } DevConfResource;
80
81 OCStackResult CreateEasySetupResources(bool isSecured, ESResourceMask resourceMask);
82 OCStackResult DeleteEasySetupResources();
83
84 OCStackResult SetDeviceProperty(ESDeviceProperty *deviceProperty);
85 OCStackResult SetEnrolleeState(ESEnrolleeState esState);
86 OCStackResult SetEnrolleeErrCode(ESErrorCode esErrCode);
87
88 void GetTargetNetworkInfoFromProvResource(char *, char *);
89 void RegisterWifiRsrcEventCallBack(ESWiFiCB);
90 void RegisterCloudRsrcEventCallBack(ESCloudCB);
91 void RegisterDevConfRsrcEventCallBack(ESDevConfCB);
92 void UnRegisterResourceEventCallBack(void);
93 ESResult SetCallbackForUserData(ESReadUserdataCb readCb, ESWriteUserdataCb writeCb);
94
95 #ifdef __cplusplus
96 }
97 #endif
98
99 #endif //ES_RESOURCE_HANDLER_H_