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_
36 #define OIC_STRING_MAX_VALUE 100
37 #define IPV4_ADDR_SIZE 16
39 #define NET_WIFI_SSID_SIZE 100
40 #define NET_WIFI_PWD_SIZE 100
43 * @brief Mac address length for BT port
45 #define NET_MACADDR_SIZE 18
48 * Attributes used to form a proper easysetup conforming JSON message.
50 #define OC_RSRVD_ES_PS "ps"
51 #define OC_RSRVD_ES_TNN "tnn"
52 #define OC_RSRVD_ES_CD "cd"
53 #define OC_RSRVD_ES_TR "tr"
54 #define OC_RSRVD_ES_TNT "tnt"
55 #define OC_RSRVD_ES_ANT "ant"
58 * Easysetup defined resoruce types and uris.
60 #define OC_RSRVD_ES_PROV_RES_TYPE "oic.r.prov"
61 #define OC_RSRVD_ES_URI_PROV "/oic/prov"
62 #define OC_RSRVD_ES_URI_NET "/oic/net"
65 * @brief Defines for Provisioning status accepted values
67 #define ES_PS_NEED_PROVISIONING 1
68 #define ES_PS_PROVISIONING_COMPLETED 2
69 #define ES_PS_TRIGGER_INIT_VALUE 0
70 #define ES_PS_TRIGGER_CONNECTION 1
79 * Device Roles defined for each device type used in easy setup
89 * On-boarding connection to create Adhoc network.
103 ES_NETWORKNOTCONNECTED,
104 ES_RESOURCECREATED = 11,
105 ES_RECVREQOFPROVRES = 21,
107 ES_RECVUPDATEOFPROVRES,
108 ES_RECVTRIGGEROFPROVRES,
114 * Default state of the device
119 * Device will move to this state once the on boarding begins
121 ES_ON_BOARDING_STATE,
124 * Device will move to this state after successful on-boarding of the device
129 * Device will move to this state once the on boarding is done
131 ES_PROVISIONING_STATE,
134 * Easy setup process is successful.
136 ES_PROVISIONED_STATE,
139 * This state is arbitrary one, any time device can come into this state
140 * Device will move to this state if the ownership transfer initiated by the Application
142 ES_OWNERSHIP_TRANSFERRING_STATE,
145 * This state is arbitrary one, any time device can come into this state
146 * Device will move to this state if the ownership transfer is completed
148 ES_OWNERSHIP_TRANSFERRED_STATE,
151 * This state is arbitrary one, any time device can come into this state
152 * Device will move to this state once the Application factory reset the device
154 ES_FACTORY_RESET_STATE,
157 * Enrollee moves to this state after connecting to target network
159 ES_ON_BOARDED_TARGET_NETWORK_STATE,
163 * Provisioning Device Status
167 // Address of remote server
169 // Indicates adaptor type on which the response was received
170 OCConnectivityType connType;
171 } EasySetupDeviceInfo;
174 * Provosioning Status
178 DEVICE_PROVISIONED = 0,
179 DEVICE_NOT_PROVISIONED,
182 } EasySetupState, ProvStatus;
185 * Response from queries to remote servers.
190 EasySetupState provStatus;
191 // EasySetup Device Info
192 EasySetupDeviceInfo provDeviceInfo;
193 } EasySetupInfo, ProvisioningInfo;
196 * @brief Network information of the Enroller
201 * @brief BT Mac Information
205 char btMacAddress[NET_MACADDR_SIZE]; /**< BT mac address **/
209 * @brief LE MAC Information
213 char leMacAddress[NET_MACADDR_SIZE]; /**< BLE mac address **/
217 * @brief IP Information
221 char ssid[NET_WIFI_SSID_SIZE]; /**< ssid of the Enroller**/
222 char pwd[NET_WIFI_PWD_SIZE]; /**< pwd of the Enroller**/
227 * @brief Network Information
231 ProvData provData; /**< Enroller Network Info**/
232 OCConnectivityType connType; /**< Connectivity Type**/
236 * Client applications implement this callback to consume responses received from Servers.
238 typedef void (*OCProvisioningStatusCB)(EasySetupInfo *easySetupInfo);
241 * @brief This structure represent configuration information to create wifi onboarding SoftAP or connection.
244 // Note : Below structure is not currently used but added for future purpose.
247 char ssid[NET_WIFI_SSID_SIZE]; /**< ssid of the onboarding Adhoc Wifi network**/
248 char pwd[NET_WIFI_PWD_SIZE]; /**< pwd of the onboarding Adhoc wifi network**/
249 bool isSecured; /**< Secure connection**/
250 }WiFiOnboardingConfig;
253 * @brief This structure represent onboarding connection instance.
257 /*Actual use of ipAddress is for unicast discovery, but also used to identify the Enrollee device as of now,
258 device identification should be based on DeviceID in next release.*/
259 char ipAddress[IPV4_ADDR_SIZE]; /**< IP Address of the Enrollee **/
260 bool isSecured; /**< Secure connection**/
261 }WiFiOnboadingConnection;
265 ES_PROVISIONING_ERROR = -1,
266 ES_NEED_PROVISIONING,
267 ES_PROVISIONED_ALREADY,
268 ES_PROVISIONING_SUCCESS
283 ES_SEC_ACL_PROVISIONED,
284 ES_SEC_CREDS_PROVISIONED
288 * Security Provisioning Status
290 class SecProvisioningResult
293 std::shared_ptr< SecProvisioningResult > shared_ptr;
294 SecProvisioningResult(std::string deviceUUID, ESResult result) :
295 m_devUUID(deviceUUID), m_result(result)
300 std::string getDeviceUUID()
310 std::string m_devUUID;
315 * Callback function definition for providing Enrollee security status .
317 typedef std::function< void(std::shared_ptr<SecProvisioningResult>) > EnrolleeSecStatusCb;
320 * Callback definition to be invoked when the security stack expects a pin from application.
322 typedef std::function< void(std::string&) > SecurityPinCb;
325 * Callback definition to be invoked when the stack expects a db path.
327 typedef std::function< void(std::string&) > SecProvisioningDbPathCb;
329 class ProvisioningStatus
332 std::shared_ptr< ProvisioningStatus > shared_ptr;
333 ProvisioningStatus(ESResult result, ESState esState) :
334 m_result(result), m_esState(esState)
339 ESResult getESResult()
353 class EasySetupStatus
356 std::shared_ptr< EasySetupStatus > shared_ptr;
357 EasySetupStatus(const EasySetupState& easySetupState,
358 const ProvConfig& provConfig) :
359 m_easySetupState(easySetupState), m_ProvConfig(provConfig)
364 ProvConfig getProvConfig()
369 EasySetupState getEasySetupState()
371 return m_easySetupState;
374 EasySetupState m_easySetupState;
375 ProvConfig m_ProvConfig;
379 #endif //WITH_ARDUINO
381 #endif //ES_COMMON_RICH_H_