1 //******************************************************************
3 // Copyright 2015 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 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
28 #define OIC_STRING_MAX_VALUE 100
29 #define IPV4_ADDR_SIZE 16
33 * @brief Mac address length for BT port
35 #define NET_MACADDR_SIZE 18
38 * Attributes used to form a proper easysetup conforming JSON message.
40 #define OC_RSRVD_ES_PROVSTATUS "ps"
41 #define OC_RSRVD_ES_LAST_ERRORCODE "lec"
42 #define OC_RSRVD_ES_ERRORMESSAGE "em"
43 #define OC_RSRVD_ES_LINKS "links"
44 #define OC_RSRVD_ES_TRIGGER "tr"
45 #define OC_RSRVD_ES_SUPPORTEDWIFIMODE "swmt"
46 #define OC_RSRVD_ES_SUPPORTEDWIFIFREQ "swf"
47 #define OC_RSRVD_ES_SSID "tnn"
48 #define OC_RSRVD_ES_CRED "cd"
49 #define OC_RSRVD_ES_AUTHTYPE "wat"
50 #define OC_RSRVD_ES_ENCTYPE "wet"
51 #define OC_RSRVD_ES_AUTHCODE "ac"
52 #define OC_RSRVD_ES_AUTHPROVIDER "apn"
53 #define OC_RSRVD_ES_CISERVER "cisurl"
54 #define OC_RSRVD_ES_DEVNAME "dn"
55 #define OC_RSRVD_ES_LANGUAGE "lang"
56 #define OC_RSRVD_ES_COUNTRY "cont"
59 * Easysetup defined resoruce types and uris.
61 #define OC_RSRVD_ES_RES_TYPE_PROV "ocf.r.prov"
62 #define OC_RSRVD_ES_URI_PROV "/.well-known/ocf/prov"
63 #define OC_RSRVD_ES_RES_TYPE_WIFI "ocf.r.wifi"
64 #define OC_RSRVD_ES_URI_WIFI "/.well-known/ocf/prov/wifi"
65 #define OC_RSRVD_ES_RES_TYPE_CLOUDSERVER "ocf.r.cloudserver"
66 #define OC_RSRVD_ES_URI_CLOUDSERVER "/.well-known/ocf/prov/cloudserver"
67 #define OC_RSRVD_ES_RES_TYPE_DEVCONF "ocf.r.devconf"
68 #define OC_RSRVD_ES_URI_DEVCONF "/.well-known/ocf/prov/devconf"
70 #define NUM_WIFIMODE 10
71 #define MAX_SSIDLEN 33
72 #define MAX_CREDLEN 20
74 #define MAX_DEVICELEN 100
75 #define MAX_ERRMSGLEN 100
76 #define MAX_WEBLINKLEN 100
121 * Device Roles defined for each device type used in easy setup
131 * On-boarding connection to create Adhoc network.
145 ES_NETWORKNOTCONNECTED,
146 ES_RESOURCECREATED = 11,
147 ES_RECVREQOFPROVRES = 21,
149 ES_RECVUPDATEOFPROVRES,
150 ES_RECVTRIGGEROFPROVRES,
156 ES_WIFI_RESOURCE = 0x01,
157 ES_CLOUD_RESOURCE = 0x02,
158 ES_DEVCONF_RESOURCE = 0x04
163 char ssid[MAX_SSIDLEN]; /**< ssid of the Enroller**/
164 char pwd[MAX_CREDLEN]; /**< pwd of the Enroller**/
165 WIFI_AUTHTYPE authtype; /**< auth type of the Enroller**/
166 WIFI_ENCTYPE enctype; /**< encryption type of the Enroller**/
171 char language[OIC_STRING_MAX_VALUE];
172 char country[OIC_STRING_MAX_VALUE];
177 char authCode[OIC_STRING_MAX_VALUE];
178 char authProvider[OIC_STRING_MAX_VALUE];
179 char ciServer[OIC_STRING_MAX_VALUE];
186 WIFI_MODE mode[NUM_WIFIMODE];
191 char deviceName[MAX_DEVICELEN];
198 * Default state of the device
203 * Status indicating successful cnnection to target network
205 ES_STATE_CONNECTED_TO_ENROLLER,
208 * Status indicating failure connection to target network
210 ES_STATE_CONNECTED_FAIL_TO_ENROLLER,
213 * Status indicating successful registration to cloud
215 ES_STATE_REGISTERED_TO_CLOUD,
218 * Status indicating failure registeration to cloud
220 ES_STATE_REGISTRRED_FAIL_TO_CLOUD
226 * Error Code that given WiFi's SSID is not found
228 ES_ERRCODE_SSID_NOTFOUND = 1,
231 * Error Code that given WiFi's Password is wrong
236 * Error Code that IP address is not allocated
238 ES_ERRCODE_IP_NOTALLOCATED,
241 * Error Code that there is no Internet connection
243 ES_ERRCODE_NO_INTERNETCONNECTION,
246 * Error Code that Timeout occured
251 * Error Code that Unknown error occured
258 ES_ERRCODE_NONE = 999
263 // Address of remote server
265 // Indicates adaptor type on which the response was received
266 OCConnectivityType connType;
267 } EasySetupDeviceInfo;
270 * Provosioning Status
274 ES_NEED_PROVISION = 1,
275 ES_CONNECTED_TO_ENROLLER,
276 ES_CONNECTED_FAIL_TO_ENROLLER,
277 ES_REGISTERED_TO_CLOUD,
278 ES_REGISTERED_FAIL_TO_CLOUD
279 } EasySetupState, ProvStatus;
282 * Response from queries to remote servers.
287 EasySetupState provStatus;
288 // EasySetup Device Info
289 EasySetupDeviceInfo provDeviceInfo;
290 } EasySetupInfo, ProvisioningInfo;
293 * @brief Network information of the Enroller
298 * @brief BT Mac Information
302 char btMacAddress[NET_MACADDR_SIZE]; /**< BT mac address **/
306 * @brief LE MAC Information
310 char leMacAddress[NET_MACADDR_SIZE]; /**< BLE mac address **/
314 * @brief IP Information
318 char ssid[MAX_SSIDLEN]; /**< ssid of the Enroller**/
319 char pwd[MAX_CREDLEN]; /**< pwd of the Enroller**/
324 * @brief Network Information
328 ProvData provData; /**< Enroller Network Info**/
329 OCConnectivityType connType; /**< Connectivity Type**/
333 * Client applications implement this callback to consume responses received from Servers.
335 typedef void (*OCProvisioningStatusCB)(EasySetupInfo *easySetupInfo);
338 * @brief This structure represent configuration information to create wifi onboarding SoftAP or connection.
342 // Note : Below structure is not currently used but added for future purpose.
344 char ssid[MAX_SSIDLEN]; /**< ssid of the onboarding Adhoc Wifi network**/
345 char pwd[MAX_CREDLEN]; /**< pwd of the onboarding Adhoc wifi network**/
346 bool isSecured; /**< Secure connection**/
347 }WiFiOnboardingConfig;
350 * @brief This structure represent onboarding connection instance.
353 /*Actual use of ipAddress is for unicast discovery, but also used to identify the Enrollee device as of now,
354 device identification should be based on DeviceID in next release.*/
355 char ipAddress[IPV4_ADDR_SIZE]; /**< IP Address of the Enrollee **/
356 bool isSecured; /**< Secure connection**/
357 }WiFiOnboadingConnection;
360 #endif //ES_COMMON_H_