b31db1dbfb06665bc0c1fe41d00e8ba698809ff9
[platform/upstream/iotivity.git] / service / easy-setup / enrollee / inc / samsung / sc_easysetup.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 #include "easysetup.h"
22 #include "escommon.h"
23
24 #ifndef EASYSETUPX_ENROLLEE_H__
25 #define EASYSETUPX_ENROLLEE_H__
26
27 #define MAXLEN_STRING 1000
28 #define MAXNUM_LOCATION 20
29 #define MAXLEN_DATE_TIME 33
30 #define MAXNUM_CANDIDATE_AP 20
31
32 #define SC_RSRVD_ES_VENDOR_NETCONNECTION_STATE  "x.com.samsung.ncs"
33 #define SC_RSRVD_ES_VENDOR_DISCOVERY_CHANNEL    "x.com.samsung.chn"
34 #define SC_RSRVD_ES_VENDOR_DEVICE_TYPE          "x.com.samsung.dt"
35 #define SC_RSRVD_ES_VENDOR_DEVICE_SUBTYPE       "x.com.samsung.sdt"
36 #define SC_RSRVD_ES_VENDOR_LOCATION             "x.com.samsung.location"
37 #define SC_RSRVD_ES_VENDOR_CLIENTID             "x.com.samsung.clientid"
38 #define SC_RSRVD_ES_VENDOR_REGISTER_MOBILE_DEV  "x.com.samsung.rmd"
39 #define SC_RSRVD_ES_VENDOR_REGISTER_SET_DEV     "x.com.samsung.rsd"
40 #define SC_RSRVD_ES_VENDOR_NETWORK_PROV_INFO    "x.com.samsung.npi"
41 #define SC_RSRVD_ES_VENDOR_ACCOUNT              "x.com.samsung.account"
42 #define SC_RSRVD_ES_VENDOR_SSO_LIST             "x.com.samsung.ssolist"
43 #define SC_RSRVD_ES_VENDOR_AAC                  "x.com.samsung.aac"
44 #define SC_RSRVD_ES_VENDOR_TNC_HEADER           "x.com.samsung.tcheader"
45 #define SC_RSRVD_ES_VENDOR_TNC_VERSION          "x.com.samsung.tcversion"
46 #define SC_RSRVD_ES_VENDOR_TNC_RESULT           "x.com.samsung.tcresult"
47 #define SC_RSRVD_ES_VENDOR_TNC_STATUS           "x.com.samsung.tcstatus"
48 #define SC_RSRVD_ES_VENDOR_REFRESH_TOKEN        "x.com.samsung.refreshtoken"
49 #define SC_RSRVD_ES_VENDOR_UID                  "x.com.samsung.uid"
50 #define SC_RSRVD_ES_VENDOR_BSSID                "x.com.samsung.bssid"
51 #define SC_RSRVD_ES_VENDOR_PNP_PIN              "x.com.samsung.pnppin"
52 #define SC_RSRVD_ES_VENDOR_MODEL_NUMBER         "x.com.samsung.modelnumber"
53 #define SC_RSRVD_ES_VENDOR_LANGUAGE             "x.com.samsung.language"
54 #define SC_RSRVD_ES_VENDOR_COUNTRY              "x.com.samsung.country"
55 #define SC_RSRVD_ES_VENDOR_GPSLOCATION          "x.com.samsung.gpslocation"
56 #define SC_RSRVD_ES_VENDOR_UTC_DATE_TIME        "x.com.samsung.datetime"
57 #define SC_RSRVD_ES_VENDOR_REGIONAL_DATE_TIME   "x.com.samsung.regionaldatetime"
58 #define SC_RSRVD_ES_VENDOR_ES_PROTOCOL_VERSION  "x.com.samsung.espv"
59 #define SC_RSRVD_ES_VENDOR_TIMEZONE_ID          "x.com.samsung.timezoneid"
60 #define SC_RSRVD_ES_VENDOR_HIDDEN               "x.com.samsung.hidden"
61 #define SC_RSRVD_ES_VENDOR_HUB_ID               "x.com.samsung.hubid"
62 #define SC_RSRVD_ES_VENDOR_DEPLOY_ENVIRONMENT   "x.com.samsung.deployenv"
63 #define SC_RSRVD_ES_VENDOR_IATT                 "x.com.samsung.iatt"
64 #define SC_RSRVD_ES_VENDOR_CANDIDATEAPS         "x.com.samsung.candidateaps"
65 #define SC_RSRVD_ES_VENDOR_CANDIDATE_SSID       "ssid"
66 #define SC_RSRVD_ES_VENDOR_CANDIDATE_PASSPHRASE "passphrase"
67 #define SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL    "channel"
68 #define SC_RSRVD_ES_VENDOR_CANDIDATE_BSSID      "bssid"
69
70 #define WIFI_DISCOVERY_CHANNEL_INIT             -1
71
72 /**
73  * @brief  Supported WIFI frequency like 2.4G and 5G
74  */
75 typedef enum
76 {
77     NET_STATE_INIT = -1,                /**< Init state **/
78     NET_STATE_WIRED_CONNECTED = 0,      /**< Wired connected **/
79     NET_STATE_WIRELESS_CONNECTED,       /**< Wireless connected **/
80     NET_STATE_NOT_CONNECTED             /**< Not connected, at all **/
81 } NETCONNECTION_STATE;
82
83 typedef struct SCCandidateAPInfo
84 {
85     char ssid[MAXLEN_STRING];
86     char passphrase[MAXLEN_STRING];
87     int channel;
88     char bssid[MAXLEN_STRING];
89 } SCCandidateAPInfo;
90
91 typedef struct SCWiFiConfProperties
92 {
93     int discoveryChannel;                   /**< Wi-Fi AP Channel used for fast discovery **/
94     char bssid[MAXLEN_STRING];              /**< Wi-Fi bssid information. **/
95     bool isHidden;
96     int numCandidateAP;
97     SCCandidateAPInfo candidateAPInfo[MAXNUM_CANDIDATE_AP];
98 } SCWiFiConfProperties;
99
100 typedef struct SCTncInfo
101 {
102     char header[MAXLEN_STRING]; /**< Terms & Conditions header **/
103     char version[MAXLEN_STRING];    /**< Terms & Conditions version **/
104 }SCTncInfo;
105
106 typedef struct SCDevConfProperties
107 {
108     int numLocation;
109     char location[MAXNUM_LOCATION][MAXLEN_STRING];  /**< Samsung-specific location-related information **/
110     char regMobileDev[MAXLEN_STRING];               /**< Samsung-specific mobile device information for 'register TV' **/
111     char account[MAXLEN_STRING];  /**< Samsung-specific account-related information **/
112     char ssoList[MAXLEN_STRING];            /**< Samsung-specific SSO list information which is registered in device **/
113     SCTncInfo scTnCInfo;    /**< Samsung-specific Terms & Conditions information **/
114     char modelNumber[MAXLEN_STRING];                /**< Samsung-specific model number **/
115     char language[MAXLEN_STRING];                   /**< IETF language tag using ISO 639X **/
116     char country[MAXLEN_STRING];                    /**< ISO Country Code (ISO 3166-1 Alpha-2) **/
117     char gpsLocation[MAXLEN_STRING];                /**< GPS information of device. Longitude and latitude in json format **/
118     char utcDateTime[MAXLEN_DATE_TIME];             /**< UTC date time **/
119     char regionalDateTime[MAXLEN_DATE_TIME];        /**< Regional date time **/
120     char timeZoneId[MAXLEN_STRING];                 /** Name of Time Zone **/
121     char hubId[MAXLEN_STRING];                      /** HubId of device **/
122 } SCDevConfProperties;
123
124 typedef struct SCCoapCloudServerConfProperties
125 {
126     char clientID[MAXLEN_STRING];               /**< Samsung-specific clientId for sign-up to IoT Cloud **/
127     char aac[MAXLEN_STRING];                    /**< Samsung-specific aac information **/
128     char tncResult[MAXLEN_STRING];              /**< Samsung-specific Terms & Conditions result **/
129     char refreshToken[MAXLEN_STRING];           /**< Samsung-specific refreshToken information. Indicate refresh token to be used if the access token is expired**/
130     char uid[MAXLEN_STRING];                    /**< Samsung-specific aac information. Indicate user ID corresponding to user account **/
131     char deployEnv[MAXLEN_STRING];              /**< Samsung-specific deployment server with which device is connected to. For example "PROD", "STG" and etc **/
132     int iatt;                                   /**< Samsung-specific Access token type indicator. 0 for SA token, 1 for IoT JWT **/
133 } SCCoapCloudServerConfProperties;
134
135 typedef struct SCProperties
136 {
137     NETCONNECTION_STATE netConnectionState; /**< A state of network connection **/
138     int discoveryChannel;                   /**< Wi-Fi AP Channel used for fast discovery **/
139     char deviceType[MAXLEN_STRING];         /**< Generated with Device Type + Icon Type **/
140     char deviceSubType[MAXLEN_STRING];      /**< Device Sub Category **/
141     int numLocation;
142     char location[MAXNUM_LOCATION][MAXLEN_STRING];  /**< Samsung-specific location-related information **/
143     char clientID[MAXLEN_STRING];           /**< Samsung-specific clientId for sign-up to IoT Cloud **/
144     char regMobileDev[MAXLEN_STRING];       /**< Samsung-specific mobile device information for 'register TV' **/
145     char regSetDev[MAXLEN_STRING];          /**< Samsung-specific set device information for 'register TV' **/
146     char nwProvInfo[MAXLEN_STRING];         /**< Samsung-specific network provisioning information for cellular network vendor **/
147     char account[MAXLEN_STRING];            /**< Samsung-specific account-related information **/
148     char ssoList[MAXLEN_STRING];            /**< Samsung-specific SSO list information which is registered in device **/
149     char aac[MAXLEN_STRING];                /**< Samsung-specific aac information **/
150     SCTncInfo tncInfo;                      /**< Samsung-specific Terms & Conditions information **/
151     char tncResult[MAXLEN_STRING];          /**< Samsung-specific Terms & Conditions result **/
152     int tncStatus;                          /**< Samsung-specific Terms & Conditions status **/
153     char refreshToken[MAXLEN_STRING];       /**< Samsung-specific refreshToken information. Indicate refresh token to be used if the access token is expired**/
154     char uid[MAXLEN_STRING];                /**< Samsung-specific aac information. Indicate user ID corresponding to user account **/
155     char bssid[MAXLEN_STRING];              /**< Samsung-specific Wi-Fi bssid information. **/
156     char pnpPin[MAXLEN_STRING];             /**< Samsung-specific PnP Pin **/
157     char modelNumber[MAXLEN_STRING];                /**< Samsung-specific model number **/
158     char language[MAXLEN_STRING];                   /**< IETF language tag using ISO 639X **/
159     char country[MAXLEN_STRING];                    /**< ISO Country Code (ISO 3166-1 Alpha-2) **/
160     char gpsLocation[MAXLEN_STRING];                /**< GPS information of device. Longitude and latitude in json format **/
161     char utcDateTime[MAXLEN_DATE_TIME];             /**< UTC date time **/
162     char regionalDateTime[MAXLEN_DATE_TIME];        /**< Regional date time **/
163     char esProtocolVersion[MAXLEN_STRING];          /**< Samsung Easy Setup Protocol Version **/
164     char timeZoneId[MAXLEN_STRING];
165     bool isHidden;
166     char hubId[MAXLEN_STRING];                /**< HubId of device **/
167     int numCandidateAP;
168     SCCandidateAPInfo candidateAPInfo[MAXNUM_CANDIDATE_AP];
169     char deployEnv[MAXLEN_STRING];
170     int iatt;
171 } SCProperties;
172
173 void ReadUserdataCb(OCRepPayload* payload, char* resourceType, void** userdata);
174 void WriteUserdataCb(OCRepPayload* payload, char* resourceType);
175
176 ESResult SetSCProperties(const SCProperties *prop);
177
178 ESResult SetRegisterSetDevice(const char *regSetDevice);
179 ESResult SetNetworkProvInfo(const char *nwProvInfo);
180
181 ESResult SetSCTncInfo(SCTncInfo *tncInfo);
182 ESResult SetSCTncStatus(int status);
183 ESResult SetSCNetConnectionState(NETCONNECTION_STATE netConnectionState);
184 ESResult SetSCPnPPin(const char *pnp);
185
186 ESResult SetESVersionInfo(const char *esVersionInfo);
187 ESResult SetSSOList(const char *ssoList);
188
189 #endif /* EASYSETUPX_ENROLLEE_H__ */