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
77 * Device Roles defined for each device type used in easy setup
87 * On-boarding connection to create Adhoc network.
101 ES_NETWORKNOTCONNECTED,
102 ES_RESOURCECREATED = 11,
103 ES_RECVREQOFPROVRES = 21,
105 ES_RECVUPDATEOFPROVRES,
106 ES_RECVTRIGGEROFPROVRES,
112 * Default state of the device
117 * Device will move to this state once the on boarding begins
119 ES_ON_BOARDING_STATE,
122 * Device will move to this state after successful on-boarding of the device
127 * Device will move to this state once the on boarding is done
129 ES_PROVISIONING_STATE,
132 * Easy setup process is successful.
134 ES_PROVISIONED_STATE,
137 * This state is arbitrary one, any time device can come into this state
138 * Device will move to this state if the ownership transfer initiated by the Application
140 ES_OWNERSHIP_TRANSFERRING_STATE,
143 * This state is arbitrary one, any time device can come into this state
144 * Device will move to this state if the ownership transfer is completed
146 ES_OWNERSHIP_TRANSFERRED_STATE,
149 * This state is arbitrary one, any time device can come into this state
150 * Device will move to this state once the Application factory reset the device
152 ES_FACTORY_RESET_STATE,
155 * Enrollee moves to this state after connecting to target network
157 ES_ON_BOARDED_TARGET_NETWORK_STATE,
161 * Provisioning Device Status
165 // Address of remote server
167 // Indicates adaptor type on which the response was received
168 OCConnectivityType connType;
169 } EasySetupDeviceInfo;
172 * Provosioning Status
176 DEVICE_PROVISIONED = 0,
177 DEVICE_NOT_PROVISIONED,
180 } EasySetupState, ProvStatus;
183 * Response from queries to remote servers.
188 EasySetupState provStatus;
189 // EasySetup Device Info
190 EasySetupDeviceInfo provDeviceInfo;
191 } EasySetupInfo, ProvisioningInfo;
194 * @brief Network information of the Enroller
199 * @brief BT Mac Information
203 char btMacAddress[NET_MACADDR_SIZE]; /**< BT mac address **/
207 * @brief LE MAC Information
211 char leMacAddress[NET_MACADDR_SIZE]; /**< BLE mac address **/
215 * @brief IP Information
219 char ssid[NET_WIFI_SSID_SIZE]; /**< ssid of the Enroller**/
220 char pwd[NET_WIFI_PWD_SIZE]; /**< pwd of the Enroller**/
225 * @brief Network Information
229 ProvData provData; /**< Enroller Network Info**/
230 OCConnectivityType connType; /**< Connectivity Type**/
234 * Client applications implement this callback to consume responses received from Servers.
236 typedef void (*OCProvisioningStatusCB)(EasySetupInfo *easySetupInfo);
239 * @brief This structure represent configuration information to create wifi onboarding SoftAP or connection.
242 // Note : Below structure is not currently used but added for future purpose.
245 char ssid[NET_WIFI_SSID_SIZE]; /**< ssid of the onboarding Adhoc Wifi network**/
246 char pwd[NET_WIFI_PWD_SIZE]; /**< pwd of the onboarding Adhoc wifi network**/
247 bool isSecured; /**< Secure connection**/
248 }WiFiOnboardingConfig;
251 * @brief This structure represent onboarding connection instance.
255 /*Actual use of ipAddress is for unicast discovery, but also used to identify the Enrollee device as of now,
256 device identification should be based on DeviceID in next release.*/
257 char ipAddress[IPV4_ADDR_SIZE]; /**< IP Address of the Enrollee **/
258 bool isSecured; /**< Secure connection**/
259 }WiFiOnboadingConnection;
263 ES_PROVISIONING_ERROR = -1,
264 ES_NEED_PROVISIONING,
265 ES_PROVISIONED_ALREADY,
266 ES_PROVISIONING_SUCCESS
281 ES_SEC_ACL_PROVISIONED,
282 ES_SEC_CREDS_PROVISIONED
286 * Security Provisioning Status
288 class SecProvisioningResult
291 std::shared_ptr< SecProvisioningResult > shared_ptr;
292 SecProvisioningResult(std::string deviceUUID, ESResult result) :
293 m_devUUID(deviceUUID), m_result(result)
298 std::string getDeviceUUID()
308 std::string m_devUUID;
313 * Callback function definition for providing Enrollee security status .
315 typedef std::function< void(std::shared_ptr<SecProvisioningResult>) > EnrolleeSecStatusCb;
318 * Callback definition to be invoked when the security stack expects a pin from application.
320 typedef std::function< void(std::string&) > SecurityPinCb;
323 * Callback definition to be invoked when the stack expects a db path.
325 typedef std::function< void(std::string&) > SecProvisioningDbPathCb;
327 class ProvisioningStatus
330 std::shared_ptr< ProvisioningStatus > shared_ptr;
331 ProvisioningStatus(ESResult result, ESState esState) :
332 m_result(result), m_esState(esState)
337 ESResult getESResult()
351 class EasySetupStatus
354 std::shared_ptr< EasySetupStatus > shared_ptr;
355 EasySetupStatus(const EasySetupState& easySetupState,
356 const ProvConfig& provConfig) :
357 m_easySetupState(easySetupState), m_ProvConfig(provConfig)
362 ProvConfig getProvConfig()
367 EasySetupState getEasySetupState()
369 return m_easySetupState;
372 EasySetupState m_easySetupState;
373 ProvConfig m_ProvConfig;
377 #endif //WITH_ARDUINO
379 #endif //ES_COMMON_RICH_H_