1 //******************************************************************
3 // Copyright 2016 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 ES_COMMON_RICH_H_
22 #define ES_COMMON_RICH_H_
40 * Attributes used to form a proper easysetup conforming JSON message.
42 #define OC_RSRVD_ES_PROVSTATUS "ps"
43 #define OC_RSRVD_ES_TRIGGER "tr"
44 #define OC_RSRVD_ES_SSID "tnn"
45 #define OC_RSRVD_ES_CRED "cd"
46 #define OC_RSRVD_ES_SUPPORTEDWIFIMODE "swmt"
47 #define OC_RSRVD_ES_SUPPORTEDWIFIFREQ "swf"
48 #define OC_RSRVD_ES_AUTHTYPE "wat"
49 #define OC_RSRVD_ES_ENCTYPE "wet"
50 #define OC_RSRVD_ES_AUTHCODE "ac"
51 #define OC_RSRVD_ES_AUTHPROVIDER "apn"
52 #define OC_RSRVD_ES_CISERVER "cisurl"
53 #define OC_RSRVD_ES_DEVNAME "dn"
54 #define OC_RSRVD_ES_LANGUAGE "lang"
55 #define OC_RSRVD_ES_COUNTRY "cont"
56 #define OC_RSRVD_ES_TNT "tnt"
57 #define OC_RSRVD_ES_ANT "ant"
60 * Easysetup defined resoruce types and uris.
62 #define OC_RSRVD_ES_PROV_RES_TYPE "ocf.r.prov"
63 #define OC_RSRVD_ES_URI_PROV "/.well-known/ocf/prov"
64 #define OC_RSRVD_ES_RES_TYPE_WIFI "ocf.r.wifi"
65 #define OC_RSRVD_ES_URI_WIFI "/.well-known/ocf/prov/wifi"
66 #define OC_RSRVD_ES_RES_TYPE_CLOUDSERVER "ocf.r.cloudserver"
67 #define OC_RSRVD_ES_URI_CLOUDSERVER "/.well-known/ocf/prov/cloudserver"
68 #define OC_RSRVD_ES_RES_TYPE_DEVCONF "ocf.r.devconf"
69 #define OC_RSRVD_ES_URI_DEVCONF "/.well-known/ocf/prov/devconf"
72 * @brief Defines for Provisioning status accepted values
74 #define ES_PS_NEED_PROVISIONING 1
75 #define ES_PS_PROVISIONING_COMPLETED 2
76 #define ES_PS_TRIGGER_INIT_VALUE 0
77 #define ES_PS_TRIGGER_CONNECTION 1
90 ES_NETWORKNOTCONNECTED,
91 ES_RESOURCECREATED = 11,
92 ES_RECVREQOFPROVRES = 21,
94 ES_RECVUPDATEOFPROVRES,
95 ES_RECVTRIGGEROFPROVRES,
100 * @brief WIFI Authentication type of the Enroller
111 * @brief WIFI ecnrytion type of the Enroller
150 string ssid; /**< ssid of the Enroller**/
151 string pwd; /**< pwd of the Enroller**/
152 WIFI_AUTHTYPE authtype; /**< auth type of the Enroller**/
153 WIFI_ENCTYPE enctype; /**< encryption type of the Enroller**/
173 vector<WIFI_MODE> types;
179 ES_PROVISIONING_ERROR = -1,
180 ES_NEED_PROVISIONING,
181 ES_PROVISIONED_ALREADY,
182 ES_PROVISIONING_SUCCESS
187 ES_CLOUD_PROVISIONING_ERROR = -1,
188 ES_CLOUD_PROVISIONING_SUCCESS,
189 ES_CLOUD_ENROLLEE_FOUND,
190 ES_CLOUD_ENROLLEE_NOT_FOUND
197 ES_SEC_ACL_PROVISIONED,
198 ES_SEC_CREDS_PROVISIONED
202 * Security Provisioning Status
204 class SecProvisioningStatus
207 SecProvisioningStatus(string deviceUUID, ESResult result) :
208 m_devUUID(deviceUUID), m_result(result)
212 const string getDeviceUUID()
217 ESResult getESResult()
233 PropertyData(DeviceConfig devConfig, NetworkInfo netInfo, bool cloudable) :
234 m_devConfig(devConfig), m_netInfo(netInfo), m_cloudable(cloudable)
238 const DeviceConfig& getDevConf() const
243 const NetworkInfo& getNetInfo() const
248 const bool isCloudable() const
254 DeviceConfig m_devConfig;
255 NetworkInfo m_netInfo;
259 class RequestPropertyDataStatus
262 RequestPropertyDataStatus(ESResult result, const PropertyData& data) :
263 m_result(result), m_propertyData(data)
267 ESResult getESResult()
272 const PropertyData& getPropertyData()
274 return m_propertyData;
279 PropertyData m_propertyData;
282 class DataProvisioningStatus
285 DataProvisioningStatus(ESResult result, ESDataProvState dataProvState) :
286 m_result(result), m_state(dataProvState)
290 ESResult getESResult()
295 ESDataProvState getESDataProvState()
302 ESDataProvState m_state;
305 class CloudProvisioningStatus
308 CloudProvisioningStatus(ESResult result, ESCloudProvState state) :
309 m_result(result), m_esCloudState(state)
313 ESResult getESResult()
318 ESCloudProvState getESCloudState()
320 return m_esCloudState;
325 ESCloudProvState m_esCloudState;
329 * Callback function definition for providing Enrollee security status .
331 typedef function< void(shared_ptr< RequestPropertyDataStatus >) > RequestPropertyDataStatusCb;
334 * Callback function definition for providing Enrollee security status .
336 typedef function< void(shared_ptr< DataProvisioningStatus >) > DataProvStatusCb;
339 * Callback function definition for providing Enrollee security status .
341 typedef function< void(shared_ptr< CloudProvisioningStatus >) > CloudProvStatusCb;
344 * Callback function definition for providing Enrollee security status .
346 typedef function< void(shared_ptr<SecProvisioningStatus>) > SecurityProvStatusCb;
349 * Callback definition to be invoked when the security stack expects a pin from application.
351 typedef function< void(string&) > SecurityPinCb;
354 * Callback definition to be invoked when the stack expects a db path.
356 typedef function< void(string&) > SecProvisioningDbPathCb;
360 #endif //WITH_ARDUINO
362 #endif //ES_COMMON_RICH_H_