*/
struct
{
- char ipAddress[IPV4_ADDR_SIZE]; /**< IP Address of the Enroller**/
char ssid[NET_WIFI_SSID_SIZE]; /**< ssid of the Enroller**/
char pwd[NET_WIFI_PWD_SIZE]; /**< pwd of the Enroller**/
} WIFI;
-} EnrolleeInfo;
-
+} ProvData;
/**
* @brief Network Information
*/
typedef struct
{
- EnrolleeInfo netAddressInfo; /**< Enroller Network Info**/
+ ProvData provData; /**< Enroller Network Info**/
OCConnectivityType connType; /**< Connectivity Type**/
- bool isSecured; /**< Secure connection**/
- // TODO : Ideally isSecured should be renamed to needSecuredEasysetup.
- // To provide backward compatibility to v1.0 release, a new variable is being added.
- // If isSecured is not used by other applications, isSecured will be depricated.
- bool needSecuredEasysetup; /**< Need of secure ownership transfer during easysetup**/
-} EnrolleeNWProvInfo;
+} ProvConfig;
/**
* Client applications implement this callback to consume responses received from Servers.
*/
typedef void (*OCProvisioningStatusCB)(EasySetupInfo *easySetupInfo);
+/**
+ * @brief This structure represent configuration information to create wifi onboarding SoftAP or connection.
+*/
+
+
+// Note : Below structure is not currently used but added for future purpose.
+typedef struct {
+ char ssid[NET_WIFI_SSID_SIZE]; /**< ssid of the onboarding Adhoc Wifi network**/
+ char pwd[NET_WIFI_PWD_SIZE]; /**< pwd of the onboarding Adhoc wifi network**/
+ bool isSecured; /**< Secure connection**/
+}WiFiOnboardingConfig;
+
+/**
+ * @brief This structure represent onboarding connection instance.
+*/
+typedef struct {
+ /*Actual use of ipAddress is for unicast discovery, but also used to identify the Enrollee device as of now,
+ device identification should be based on DeviceID in next release.*/
+ char ipAddress[IPV4_ADDR_SIZE]; /**< IP Address of the Enrollee **/
+ bool isSecured; /**< Secure connection**/
+}WiFiOnboadingConnection;
+
#endif //ES_COMMON_H_
void UnRegisterCallback();
-OCStackResult StartProvisioning(const EnrolleeNWProvInfo *netInfo);
+OCStackResult StartProvisioning(const ProvConfig *netInfo, WiFiOnboadingConnection *onboardConn);
OCStackResult StopProvisioning(OCConnectivityType connectivityType);
OCStackResult GetProvisioningStatus(OCQualityOfService qos, const char *query,
const OCDevAddr *destination);
-OCStackResult StartProvisioningProcess(const EnrolleeNWProvInfo *netInfo,
+OCStackResult StartProvisioningProcess(const ProvConfig *netInfo,WiFiOnboadingConnection *onboardConn,
OCProvisioningStatusCB provisioningStatusCallback,
char *findResQuery);
void LogProvisioningResponse(OCRepPayloadValue * val);
-bool ConfigEnrolleeObject(const EnrolleeNWProvInfo *netInfo);
+bool ConfigEnrolleeObject(const ProvConfig *netInfo, WiFiOnboadingConnection *onboardConn);
bool ClearMemory();
bool InProgress();
-bool ValidateEasySetupParams(const EnrolleeNWProvInfo *netInfo,
+bool ValidateEasySetupParams(const ProvConfig *netInfo,WiFiOnboadingConnection *onboardConn,
OCProvisioningStatusCB provisioningStatusCallback);
bool IsSetupStopped();
}
}
-OCStackResult StartProvisioning(const EnrolleeNWProvInfo *netInfo) {
+OCStackResult StartProvisioning(const ProvConfig *provConfig, WiFiOnboadingConnection *onboardConn) {
char findQuery[64] = {0};
//Arduino Enrollee needs mediator application provide IP and port55555 which is specific
// to Arduino WiFi enrollee
snprintf(findQuery, sizeof(findQuery) - 1, UNICAST_PROVISIONING_QUERY,
- netInfo->netAddressInfo.WIFI.ipAddress, IP_PORT);
+ onboardConn->ipAddress, IP_PORT);
#else
OICStrcpy(findQuery, sizeof(findQuery)-1, UNICAST_PROVISIONING_QUERY);
#endif
- return StartProvisioningProcess(netInfo, cbData, findQuery);
+ return StartProvisioningProcess(provConfig, onboardConn, cbData, findQuery);
}
OCStackResult StopProvisioning(OCConnectivityType /*connectivityType*/) {
#define ES_PROV_TAG "EASY_SETUP_PROVISIONING"
-bool g_provisioningCondFlag = false;
+bool gProvisioningCondFlag = false;
-static EnrolleeNWProvInfo *netProvInfo;
-
-char szFindResourceQueryUri[64] = {0};
+static ProvConfig *gProvConfig;
+static WiFiOnboadingConnection *gOnboardConn;
+static char gSzFindResourceQueryUri[64] = {0};
/**
* @var cbData
OIC_LOG(ERROR, ES_PROV_TAG, "OCStack stop error");
}
- g_provisioningCondFlag = true;
+ gProvisioningCondFlag = true;
ret = OC_STACK_OK;
return ret;
}
void *listeningFunc(void* /*data*/) {
- while (!g_provisioningCondFlag) {
+ while (!gProvisioningCondFlag) {
OCStackResult result;
result = OCProcess();
}
if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_TNN, &tnn)) {
- if (!strcmp(tnn, netProvInfo->netAddressInfo.WIFI.ssid)) {
+ if (!strcmp(tnn, gProvConfig->provData.WIFI.ssid)) {
OIC_LOG_V(DEBUG, ES_PROV_TAG, "SSID is proper");
input = input->next;
continue;
}
if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_CD, &cd)) {
- if (!strcmp(cd, netProvInfo->netAddressInfo.WIFI.pwd)) {
+ if (!strcmp(cd, gProvConfig->provData.WIFI.pwd)) {
OIC_LOG_V(DEBUG, ES_PROV_TAG, "Password is proper");
input = input->next;
continue;
}
-OCStackResult StartProvisioningProcess(const EnrolleeNWProvInfo *netInfo,
+OCStackResult StartProvisioningProcess(const ProvConfig *netInfo,WiFiOnboadingConnection *onboardConn,
OCProvisioningStatusCB provisioningStatusCallback,
char *findResQuery) {
if(findResQuery != NULL)
{
- OICStrcpy(szFindResourceQueryUri, sizeof(szFindResourceQueryUri) - 1, findResQuery);
+ OICStrcpy(gSzFindResourceQueryUri, sizeof(gSzFindResourceQueryUri) - 1, findResQuery);
}
else
{
pthread_t thread_handle;
- if (!ValidateEasySetupParams(netInfo, provisioningStatusCallback)) {
+ if (!ValidateEasySetupParams(netInfo, onboardConn, provisioningStatusCallback)) {
goto Error;
}
goto Error;
}
- if (!ConfigEnrolleeObject(netInfo)) {
+ if (!ConfigEnrolleeObject(netInfo, onboardConn)) {
goto Error;
}
bool ClearMemory() {
OIC_LOG(DEBUG, ES_PROV_TAG, "thread_pool_add_task of FindProvisioningResource failed");
- OICFree(netProvInfo);
+ OICFree(gProvConfig);
+ OICFree(gOnboardConn);
+
return true;
}
-bool ConfigEnrolleeObject(const EnrolleeNWProvInfo *netInfo) {
+bool ConfigEnrolleeObject(const ProvConfig *netInfo, WiFiOnboadingConnection *connection) {
//Copy Network Provisioning Information
- netProvInfo = (EnrolleeNWProvInfo *) OICCalloc(1, sizeof(EnrolleeNWProvInfo));
+ gProvConfig = (ProvConfig *) OICCalloc(1, sizeof(ProvConfig));
+ gOnboardConn = (WiFiOnboadingConnection *) OICCalloc(1, sizeof(WiFiOnboadingConnection));
+
+ if (gProvConfig == NULL) {
+ OIC_LOG(ERROR, ES_PROV_TAG, "Invalid input..");
+ return false;
+ }
- if (netProvInfo == NULL) {
+ if (gOnboardConn == NULL) {
OIC_LOG(ERROR, ES_PROV_TAG, "Invalid input..");
return false;
}
- memcpy(netProvInfo, netInfo, sizeof(EnrolleeNWProvInfo));
+ memcpy(gProvConfig, netInfo, sizeof(ProvConfig));
+ memcpy(gOnboardConn, connection, sizeof(WiFiOnboadingConnection));
OIC_LOG_V(DEBUG, ES_PROV_TAG, "Network Provisioning Info. SSID = %s",
- netProvInfo->netAddressInfo.WIFI.ssid);
+ gProvConfig->provData.WIFI.ssid);
OIC_LOG_V(DEBUG, ES_PROV_TAG, "Network Provisioning Info. PWD = %s",
- netProvInfo->netAddressInfo.WIFI.pwd);
+ gProvConfig->provData.WIFI.pwd);
return true;
ProvisioningInfo *provInfo = CreateCallBackObject();
OICStrcpy(provInfo->provDeviceInfo.addr->addr, sizeof(provInfo->provDeviceInfo.addr->addr),
- netProvInfo->netAddressInfo.WIFI.ipAddress);
+ gOnboardConn->ipAddress);
provInfo->provDeviceInfo.addr->port = IP_PORT;
provInfo->provStatus = status;
OCStackResult ret = OC_STACK_ERROR;
- OIC_LOG_V(DEBUG, ES_PROV_TAG, "szFindResourceQueryUri = %s", szFindResourceQueryUri);
+ OIC_LOG_V(DEBUG, ES_PROV_TAG, "szFindResourceQueryUri = %s", gSzFindResourceQueryUri);
OCCallbackData ocCBData;
ocCBData.cd = NULL;
- ret = OCDoResource(NULL, OC_REST_DISCOVER, szFindResourceQueryUri, NULL, NULL,
- netProvInfo->connType, OC_LOW_QOS,
+ ret = OCDoResource(NULL, OC_REST_DISCOVER, gSzFindResourceQueryUri, NULL, NULL,
+ gProvConfig->connType, OC_LOW_QOS,
&ocCBData, NULL, 0);
if (ret != OC_STACK_OK) {
cbData.context = (void *) EASY_SETUP_DEFAULT_CONTEXT_VALUE;
cbData.cd = NULL;
- ret = OCDoResource(NULL, method, query, dest, (OCPayload *) payload, netProvInfo->connType, qos,
+ ret = OCDoResource(NULL, method, query, dest, (OCPayload *) payload, gProvConfig->connType, qos,
&cbData, options, numOptions);
if (ret != OC_STACK_OK) {
OCRepPayload *payload = OCRepPayloadCreate();
OCRepPayloadSetUri(payload, resUri);
- OCRepPayloadSetPropString(payload, OC_RSRVD_ES_TNN, netProvInfo->netAddressInfo.WIFI.ssid);
- OCRepPayloadSetPropString(payload, OC_RSRVD_ES_CD, netProvInfo->netAddressInfo.WIFI.pwd);
+ OCRepPayloadSetPropString(payload, OC_RSRVD_ES_TNN, gProvConfig->provData.WIFI.ssid);
+ OCRepPayloadSetPropString(payload, OC_RSRVD_ES_CD, gProvConfig->provData.WIFI.pwd);
OIC_LOG_V(DEBUG, ES_PROV_TAG, "OCPayload ready for ProvisionEnrollee");
}
-bool ValidateEasySetupParams(const EnrolleeNWProvInfo *netInfo,
+bool ValidateEasySetupParams(const ProvConfig *netInfo,WiFiOnboadingConnection *onboardConn,
OCProvisioningStatusCB provisioningStatusCallback) {
- if (netInfo == NULL || strlen(netInfo->netAddressInfo.WIFI.ipAddress) == 0) {
+
+ if (onboardConn == NULL || strlen(onboardConn->ipAddress) == 0) {
OIC_LOG(ERROR, ES_WIFI_PROV_TAG, "Request URI is NULL");
return false;
}
JNIEXPORT jobject JNICALL
Java_org_iotivity_service_easysetup_mediator_EasySetupService_nativeCreateEnrolleeDevice
(JNIEnv *env, jobject interfaceClass, jstring ip, jstring ssid, jstring password,
- jint connectivityType, jboolean needSecuredEasysetup)
+ jint connectivityType, jboolean isSecured)
{
LOGI("JniEasySetup::nativeCreateEnrolleeDevice enter");
std::shared_ptr<RemoteEnrollee> nativeRemoteEnrollee;
jobject jRemoteEnrollee;
- EnrolleeNWProvInfo netInfo;
+ ProvConfig netInfo;
+ WiFiOnboadingConnection onboardConn;
const char *cIp = (env)->GetStringUTFChars(ip, NULL);
const char *cSssid = (env)->GetStringUTFChars(ssid, NULL);
std::string sPassword(cPassword);
netInfo.connType = getOCConnectivityTypeFromInt(connectivityType);
- netInfo.isSecured = bool(
- needSecuredEasysetup); // may be need to remove, if removed from c++ layer
- netInfo.needSecuredEasysetup = bool(needSecuredEasysetup);
- OICStrcpy(netInfo.netAddressInfo.WIFI.ipAddress, IPV4_ADDR_SIZE - 1, sIp.c_str());
- OICStrcpy(netInfo.netAddressInfo.WIFI.ssid, NET_WIFI_SSID_SIZE - 1, sSssid.c_str());
- OICStrcpy(netInfo.netAddressInfo.WIFI.pwd, NET_WIFI_PWD_SIZE - 1, sPassword.c_str());
+ onboardConn.isSecured = bool(isSecured);
+
+ OICStrcpy(onboardConn.ipAddress, IPV4_ADDR_SIZE - 1, sIp.c_str());
+ OICStrcpy(netInfo.provData.WIFI.ssid, NET_WIFI_SSID_SIZE - 1, sSssid.c_str());
+ OICStrcpy(netInfo.provData.WIFI.pwd, NET_WIFI_PWD_SIZE - 1, sPassword.c_str());
try
{
- nativeRemoteEnrollee = EasySetup::getInstance()->createEnrolleeDevice(netInfo);
+ nativeRemoteEnrollee = EasySetup::getInstance()->createEnrolleeDevice(netInfo,onboardConn);
//create the java object
jRemoteEnrollee = env->NewObject(g_cls_RemoteEnrollee, g_mid_RemoteEnrollee_ctor);
if (!jRemoteEnrollee)
#include <jni.h>
#include <string>
-#include "escommon.h"
-#include "Utility.h"
+#include "esrichcommon.h"
#include "octypes.h"
#include "JniJvm.h"
+using namespace OIC::Service;
+
/**
* @brief Throw the Exception to the java layer
*/
#include <jni.h>
#include "RemoteEnrollee.h"
-#include "escommon.h"
-#include "Utility.h"
+#include "esrichcommon.h"
#include "JniJvm.h"
#define __JNI_ES_REMOTEENROLLEE_H
#include "RemoteEnrollee.h"
-#include "escommon.h"
-#include "Utility.h"
+#include "esrichcommon.h"
#include "ESException.h"
#include "JniJvm.h"
#include <memory>
#include <vector>
-#include "escommon.h"
-#include "Utility.h"
+#include "esrichcommon.h"
#include "RemoteEnrollee.h"
namespace OIC
* @return Pointer to RemoteEnrollee instance.
*/
std::shared_ptr<RemoteEnrollee> createEnrolleeDevice (
- const EnrolleeNWProvInfo& enrolleeNWProvInfo);
+ const ProvConfig& enrolleeNWProvInfo, const WiFiOnboadingConnection& wifiOnboardingconn);
private:
EasySetup();
~EasySetup();
RemoteEnrollee::shared_ptr findDeviceInProvisioningList(
- const EnrolleeNWProvInfo& enrolleeNWProvInfo);
+ const ProvConfig& enrolleeNWProvInfo, const WiFiOnboadingConnection& wifiOnboardingconn);
bool addDeviceToProvisioningList(const RemoteEnrollee::shared_ptr remoteEnrollee);
- bool deleteDeviceFromProvisioningList (const EnrolleeNWProvInfo& enrolleeNWProvInfo);
+ bool deleteDeviceFromProvisioningList (const ProvConfig& enrolleeNWProvInfo);
std::vector< RemoteEnrollee::shared_ptr > m_activeEnrolleeList;
static EasySetup *s_instance;
#include <functional>
-#include "escommon.h"
-#include "Utility.h"
+#include "esrichcommon.h"
#include "OCProvisioningManager.h"
namespace OIC
#ifndef REMOTE_ENROLLEE_H_
#define REMOTE_ENROLLEE_H_
-#include "escommon.h"
-#include "Utility.h"
+#include "esrichcommon.h"
namespace OIC
{
*
* @throw ESBadRequestException is thrown if the parameters are invalid
*/
- RemoteEnrollee(const EnrolleeNWProvInfo& enrolleeNWProvInfo) ;
+ RemoteEnrollee(const ProvConfig& enrolleeNWProvInfo, const WiFiOnboadingConnection& connection) ;
~RemoteEnrollee() = default;
/**
* Get the Provisioning information provided for the current Enrollee.
*
- * @return EnrolleeNWProvInfo Provisioning information provided for the current Enrollee.
+ * @return ProvConfig Provisioning information provided for the current Enrollee.
*/
- EnrolleeNWProvInfo& getEnrolleeProvisioningInfo ();
+ ProvConfig getProvConfig ();
+
+ /**
+ * Get the Onboarding connection information between Mediator and Enrollee.
+ *
+ * @return WiFiOnboadingConnection information between Mediator and Enrollee.
+ */
+
+ WiFiOnboadingConnection getOnboardConn();
private:
std::shared_ptr< RemoteEnrolleeResource > m_remoteResource;
EnrolleeSecStatusCb m_enrolleeSecStatusCb;
SecurityPinCb m_securityPinCb;
SecProvisioningDbPathCb m_secProvisioningDbPathCb;
- EnrolleeNWProvInfo m_enrolleeNWProvInfo;
+ ProvConfig m_ProvConfig;
+ WiFiOnboadingConnection m_wifiOnboardingconn;
+
std::shared_ptr< EnrolleeSecurity > m_enrolleeSecurity;
CurrentESState m_currentESState;
- bool m_needSecuredEasysetup;
+ bool m_isSecured;
void provisioningStatusHandler (std::shared_ptr< ProvisioningStatus > provStatus);
void easySetupSecurityStatusCallback(
#include <mutex>
#include <memory>
-#include "escommon.h"
-#include "Utility.h"
+#include "esrichcommon.h"
#include "OCApi.h"
*
* @throw ESBadRequestException is thrown if the parameters are invalid
*/
- RemoteEnrolleeResource(EnrolleeNWProvInfo enrolleeNWProvInfo);
+ RemoteEnrolleeResource(ProvConfig enrolleeNWProvInfo, WiFiOnboadingConnection onboardingconn);
~RemoteEnrolleeResource() = default;
std::shared_ptr< OC::OCResource > m_ocResource;
std::mutex m_mutex;
ProvStatusCb m_provStatusCb;
- EnrolleeNWProvInfo m_enrolleeNWProvInfo;
+ ProvConfig m_ProvConfig;
+ WiFiOnboadingConnection m_wifiOnboardingconn;
bool m_discoveryResponse;
void getProvStatusResponse(const HeaderOptions& headerOptions, const OCRepresentation& rep,
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2016 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-#ifndef UTILITY_H_
-#define UTILITY_H_
-
-#ifndef WITH_ARDUINO
-#include <memory>
-#endif
-
-#include "ocstack.h"
-#include "octypes.h"
-
-#ifndef WITH_ARDUINO
-namespace OIC
-{
- namespace Service
- {
- typedef enum
- {
- ES_PROVISIONING_ERROR = -1,
- ES_NEED_PROVISIONING,
- ES_PROVISIONED_ALREADY,
- ES_PROVISIONING_SUCCESS
- } ESState;
-
- typedef enum
- {
- ES_UNKNOWN = 0,
- ES_ONBOARDED,
- ES_OWNED,
- ES_PROVISIONED
- } CurrentESState;
-
- typedef enum
- {
- ES_SEC_UNKNOWN = 0,
- ES_SEC_OWNED,
- ES_SEC_ACL_PROVISIONED,
- ES_SEC_CREDS_PROVISIONED
- } EnrolleeSecState;
-
- /**
- * Security Provisioning Status
- */
- class SecProvisioningResult
- {
- public:
- std::shared_ptr< SecProvisioningResult > shared_ptr;
- SecProvisioningResult(std::string deviceUUID, ESResult result) :
- m_devUUID(deviceUUID), m_result(result)
- {
-
- }
-
- std::string getDeviceUUID()
- {
- return m_devUUID;
- }
-
- ESResult getResult()
- {
- return m_result;
- }
- private:
- std::string m_devUUID;
- ESResult m_result;
- };
-
- /**
- * Callback function definition for providing Enrollee security status .
- */
- typedef std::function< void(std::shared_ptr<SecProvisioningResult>) > EnrolleeSecStatusCb;
-
- /**
- * Callback definition to be invoked when the security stack expects a pin from application.
- */
- typedef std::function< void(std::string&) > SecurityPinCb;
-
- /**
- * Callback definition to be invoked when the stack expects a db path.
- */
- typedef std::function< void(std::string&) > SecProvisioningDbPathCb;
-
- class ProvisioningStatus
- {
- public:
- std::shared_ptr< ProvisioningStatus > shared_ptr;
- ProvisioningStatus(ESResult result, ESState esState) :
- m_result(result), m_esState(esState)
- {
-
- }
-
- ESResult& getESResult()
- {
- return m_result;
- }
-
- ESState& getESState()
- {
- return m_esState;
- }
- private:
- ESResult m_result;
- ESState m_esState;
- };
-
- class EasySetupStatus
- {
- public:
- std::shared_ptr< EasySetupStatus > shared_ptr;
- EasySetupStatus(const EasySetupState& easySetupState,
- const EnrolleeNWProvInfo& enrolleeNWProvInfo) :
- m_easySetupState(easySetupState), m_enrolleeNWProvInfo(enrolleeNWProvInfo)
- {
-
- }
-
- EnrolleeNWProvInfo& getEasySetupNWProvInfo()
- {
- return m_enrolleeNWProvInfo;
- }
-
- EasySetupState& getEasySetupState()
- {
- return m_easySetupState;
- }
- private:
- EasySetupState m_easySetupState;
- EnrolleeNWProvInfo m_enrolleeNWProvInfo;
- };
- }
-}
-#endif //WITH_ARDUINO
-
-#endif //UTILITY_H_
\ No newline at end of file
--- /dev/null
+//******************************************************************
+//
+// Copyright 2016 Samsung Electronics All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+#ifndef ES_COMMON_RICH_H_
+#define ES_COMMON_RICH_H_
+
+#include <iostream>
+#include <string>
+#ifndef WITH_ARDUINO
+#include <memory>
+#endif
+
+#include "ocstack.h"
+#include "octypes.h"
+
+using namespace std;
+
+// Defines
+#define OIC_STRING_MAX_VALUE 100
+#define IPV4_ADDR_SIZE 16
+#define IP_PORT 55555
+#define NET_WIFI_SSID_SIZE 100
+#define NET_WIFI_PWD_SIZE 100
+
+/**
+ * @brief Mac address length for BT port
+ */
+#define NET_MACADDR_SIZE 18
+
+/**
+ * Attributes used to form a proper easysetup conforming JSON message.
+ */
+#define OC_RSRVD_ES_PS "ps"
+#define OC_RSRVD_ES_TNN "tnn"
+#define OC_RSRVD_ES_CD "cd"
+#define OC_RSRVD_ES_TR "tr"
+#define OC_RSRVD_ES_TNT "tnt"
+#define OC_RSRVD_ES_ANT "ant"
+
+/**
+ * Easysetup defined resoruce types and uris.
+ */
+#define OC_RSRVD_ES_PROV_RES_TYPE "oic.r.prov"
+#define OC_RSRVD_ES_URI_PROV "/oic/prov"
+#define OC_RSRVD_ES_URI_NET "/oic/net"
+
+/**
+ * @brief Defines for Provisioning status accepted values
+ */
+#define ES_PS_NEED_PROVISIONING 1
+#define ES_PS_PROVISIONING_COMPLETED 2
+
+#ifndef WITH_ARDUINO
+namespace OIC
+{
+ namespace Service
+ {
+
+ /**
+ * Device Roles defined for each device type used in easy setup
+ */
+ typedef enum
+ {
+ ENROLLEE,
+ MEDIATOR,
+ ENROLLER,
+ } DeviceRole;
+
+ /**
+ * On-boarding connection to create Adhoc network.
+ */
+ typedef enum
+ {
+ SOFTAP,
+ BLE,
+ } OBConnection;
+
+ typedef enum
+ {
+ ES_ERROR = -1,
+ ES_OK = 0,
+ ES_NETWORKFOUND = 1,
+ ES_NETWORKCONNECTED,
+ ES_NETWORKNOTCONNECTED,
+ ES_RESOURCECREATED = 11,
+ ES_RECVREQOFPROVRES = 21,
+ ES_RECVREQOFNETRES,
+ ES_RECVUPDATEOFPROVRES,
+ ES_RECVTRIGGEROFPROVRES,
+ } ESResult;
+
+ typedef enum
+ {
+ /**
+ * Default state of the device
+ */
+ ES_INIT_STATE,
+
+ /**
+ * Device will move to this state once the on boarding begins
+ */
+ ES_ON_BOARDING_STATE,
+
+ /**
+ * Device will move to this state after successful on-boarding of the device
+ */
+ ES_ON_BOARDED_STATE,
+
+ /**
+ * Device will move to this state once the on boarding is done
+ */
+ ES_PROVISIONING_STATE,
+
+ /**
+ * Easy setup process is successful.
+ */
+ ES_PROVISIONED_STATE,
+
+ /**
+ * This state is arbitrary one, any time device can come into this state
+ * Device will move to this state if the ownership transfer initiated by the Application
+ */
+ ES_OWNERSHIP_TRANSFERRING_STATE,
+
+ /**
+ * This state is arbitrary one, any time device can come into this state
+ * Device will move to this state if the ownership transfer is completed
+ */
+ ES_OWNERSHIP_TRANSFERRED_STATE,
+
+ /**
+ * This state is arbitrary one, any time device can come into this state
+ * Device will move to this state once the Application factory reset the device
+ */
+ ES_FACTORY_RESET_STATE,
+
+ /**
+ * Enrollee moves to this state after connecting to target network
+ */
+ ES_ON_BOARDED_TARGET_NETWORK_STATE,
+ }EnrolleeState;
+
+ /**
+ * Provisioning Device Status
+ */
+ typedef struct
+ {
+ // Address of remote server
+ OCDevAddr * addr;
+ // Indicates adaptor type on which the response was received
+ OCConnectivityType connType;
+ } EasySetupDeviceInfo;
+
+ /**
+ * Provosioning Status
+ */
+ typedef enum
+ {
+ DEVICE_PROVISIONED = 0,
+ DEVICE_NOT_PROVISIONED,
+ DEVICE_OWNED,
+ DEVICE_NOT_OWNED
+ } EasySetupState, ProvStatus;
+
+ /**
+ * Response from queries to remote servers.
+ */
+ typedef struct
+ {
+ // EasySetup Status
+ EasySetupState provStatus;
+ // EasySetup Device Info
+ EasySetupDeviceInfo provDeviceInfo;
+ } EasySetupInfo, ProvisioningInfo;
+
+ /**
+ * @brief Network information of the Enroller
+ */
+ typedef union
+ {
+ /**
+ * @brief BT Mac Information
+ */
+ struct
+ {
+ char btMacAddress[NET_MACADDR_SIZE]; /**< BT mac address **/
+ } BT;
+
+ /**
+ * @brief LE MAC Information
+ */
+ struct
+ {
+ char leMacAddress[NET_MACADDR_SIZE]; /**< BLE mac address **/
+ } LE;
+
+ /**
+ * @brief IP Information
+ */
+ struct
+ {
+ char ssid[NET_WIFI_SSID_SIZE]; /**< ssid of the Enroller**/
+ char pwd[NET_WIFI_PWD_SIZE]; /**< pwd of the Enroller**/
+ } WIFI;
+ } ProvData;
+
+ /**
+ * @brief Network Information
+ */
+ typedef struct
+ {
+ ProvData provData; /**< Enroller Network Info**/
+ OCConnectivityType connType; /**< Connectivity Type**/
+ } ProvConfig;
+
+ /**
+ * Client applications implement this callback to consume responses received from Servers.
+ */
+ typedef void (*OCProvisioningStatusCB)(EasySetupInfo *easySetupInfo);
+
+ /**
+ * @brief This structure represent configuration information to create wifi onboarding SoftAP or connection.
+ */
+
+ // Note : Below structure is not currently used but added for future purpose.
+ typedef struct
+ {
+ char ssid[NET_WIFI_SSID_SIZE]; /**< ssid of the onboarding Adhoc Wifi network**/
+ char pwd[NET_WIFI_PWD_SIZE]; /**< pwd of the onboarding Adhoc wifi network**/
+ bool isSecured; /**< Secure connection**/
+ }WiFiOnboardingConfig;
+
+ /**
+ * @brief This structure represent onboarding connection instance.
+ */
+ typedef struct
+ {
+ /*Actual use of ipAddress is for unicast discovery, but also used to identify the Enrollee device as of now,
+ device identification should be based on DeviceID in next release.*/
+ char ipAddress[IPV4_ADDR_SIZE]; /**< IP Address of the Enrollee **/
+ bool isSecured; /**< Secure connection**/
+ }WiFiOnboadingConnection;
+
+ typedef enum
+ {
+ ES_PROVISIONING_ERROR = -1,
+ ES_NEED_PROVISIONING,
+ ES_PROVISIONED_ALREADY,
+ ES_PROVISIONING_SUCCESS
+ } ESState;
+
+ typedef enum
+ {
+ ES_UNKNOWN = 0,
+ ES_ONBOARDED,
+ ES_OWNED,
+ ES_PROVISIONED
+ } CurrentESState;
+
+ typedef enum
+ {
+ ES_SEC_UNKNOWN = 0,
+ ES_SEC_OWNED,
+ ES_SEC_ACL_PROVISIONED,
+ ES_SEC_CREDS_PROVISIONED
+ } EnrolleeSecState;
+
+ /**
+ * Security Provisioning Status
+ */
+ class SecProvisioningResult
+ {
+ public:
+ std::shared_ptr< SecProvisioningResult > shared_ptr;
+ SecProvisioningResult(std::string deviceUUID, ESResult result) :
+ m_devUUID(deviceUUID), m_result(result)
+ {
+
+ }
+
+ std::string getDeviceUUID()
+ {
+ return m_devUUID;
+ }
+
+ ESResult getResult()
+ {
+ return m_result;
+ }
+ private:
+ std::string m_devUUID;
+ ESResult m_result;
+ };
+
+ /**
+ * Callback function definition for providing Enrollee security status .
+ */
+ typedef std::function< void(std::shared_ptr<SecProvisioningResult>) > EnrolleeSecStatusCb;
+
+ /**
+ * Callback definition to be invoked when the security stack expects a pin from application.
+ */
+ typedef std::function< void(std::string&) > SecurityPinCb;
+
+ /**
+ * Callback definition to be invoked when the stack expects a db path.
+ */
+ typedef std::function< void(std::string&) > SecProvisioningDbPathCb;
+
+ class ProvisioningStatus
+ {
+ public:
+ std::shared_ptr< ProvisioningStatus > shared_ptr;
+ ProvisioningStatus(ESResult result, ESState esState) :
+ m_result(result), m_esState(esState)
+ {
+
+ }
+
+ ESResult& getESResult()
+ {
+ return m_result;
+ }
+
+ ESState& getESState()
+ {
+ return m_esState;
+ }
+ private:
+ ESResult m_result;
+ ESState m_esState;
+ };
+
+ class EasySetupStatus
+ {
+ public:
+ std::shared_ptr< EasySetupStatus > shared_ptr;
+ EasySetupStatus(const EasySetupState& easySetupState,
+ const ProvConfig& provConfig) :
+ m_easySetupState(easySetupState), m_ProvConfig(provConfig)
+ {
+
+ }
+
+ ProvConfig& getProvConfig()
+ {
+ return m_ProvConfig;
+ }
+
+ EasySetupState& getEasySetupState()
+ {
+ return m_easySetupState;
+ }
+ private:
+ EasySetupState m_easySetupState;
+ ProvConfig m_ProvConfig;
+ };
+ }
+}
+#endif //WITH_ARDUINO
+
+#endif //ES_COMMON_RICH_H_
}
RemoteEnrollee::shared_ptr EasySetup::findDeviceInProvisioningList (
- const EnrolleeNWProvInfo& enrolleeNWProvInfo)
+ const ProvConfig& provConfig, const WiFiOnboadingConnection& onboardingconn)
{
OC_LOG(DEBUG,EASYSETUP_TAG,"Entered findDeviceInProvisioningList ()");
{
OC_LOG_V(DEBUG,EASYSETUP_TAG,"entered the iterator");
- if (0 == memcmp(&it->getEnrolleeProvisioningInfo().netAddressInfo,
- &enrolleeNWProvInfo.netAddressInfo, sizeof(EnrolleeNWProvInfo)))
+ ProvConfig activeEnrolleConfig = it->getProvConfig();
+ WiFiOnboadingConnection activeEnrolleConn = it->getOnboardConn();
+ if ((0 == memcmp(&activeEnrolleConfig.provData,
+ &provConfig.provData, sizeof(ProvConfig))) &&
+ (0 == memcmp(&activeEnrolleConn.ipAddress,
+ &onboardingconn.ipAddress, sizeof(onboardingconn.ipAddress))))
{
remoteEnrollee = it;
return remoteEnrollee;
bool EasySetup::addDeviceToProvisioningList(const RemoteEnrollee::shared_ptr remoteEnrollee)
{
+ ProvConfig remoteEnrolleConfig = remoteEnrollee->getProvConfig();
+ WiFiOnboadingConnection remoteEnrolleConn = remoteEnrollee->getOnboardConn();
+
for (auto it : m_activeEnrolleeList)
{
- if (0 == memcmp(&it->getEnrolleeProvisioningInfo().netAddressInfo,
- &remoteEnrollee->getEnrolleeProvisioningInfo().netAddressInfo,
- sizeof(EnrolleeNWProvInfo)))
+ ProvConfig activeEnrolleConfig = it->getProvConfig();
+ WiFiOnboadingConnection activeEnrolleConn = it->getOnboardConn();
+ if ( (0 == memcmp(&activeEnrolleConfig.provData,
+ &remoteEnrolleConfig.provData,
+ sizeof(ProvConfig))) &&
+ (0 == memcmp(&activeEnrolleConn.ipAddress,
+ &remoteEnrolleConn.ipAddress,
+ sizeof(remoteEnrolleConn.ipAddress)))
+ )
{
return false;
}
}
std::shared_ptr<RemoteEnrollee> EasySetup::createEnrolleeDevice (
- const EnrolleeNWProvInfo& enrolleeNWProvInfo)
+ const ProvConfig& provConfig, const WiFiOnboadingConnection& wifiOnboardingconn)
{
- if (findDeviceInProvisioningList(enrolleeNWProvInfo) != nullptr)
+ if (findDeviceInProvisioningList(provConfig,wifiOnboardingconn) != nullptr)
{
throw ESBadRequestException { "Device already created exception" };
}
RemoteEnrollee::shared_ptr remoteEnrollee;
- remoteEnrollee = std::make_shared< RemoteEnrollee > (enrolleeNWProvInfo);
+ remoteEnrollee = std::make_shared< RemoteEnrollee > (provConfig, wifiOnboardingconn);
if (!addDeviceToProvisioningList (remoteEnrollee))
std::shared_ptr< OC::OCSecureResource > ownedDevice =
findEnrollee(
std::string(
- m_remoteEnrolleeResource->m_enrolleeNWProvInfo.netAddressInfo.WIFI.ipAddress),
+ m_remoteEnrolleeResource->m_wifiOnboardingconn.ipAddress),
pOwnedDevList);
if (ownedDevice)
{
m_unownedDevice =
findEnrollee(
- m_remoteEnrolleeResource->m_enrolleeNWProvInfo.netAddressInfo.WIFI.ipAddress,
+ m_remoteEnrolleeResource->m_wifiOnboardingconn.ipAddress,
pUnownedDevList);
if (m_unownedDevice)
{
namespace Service
{
- RemoteEnrollee::RemoteEnrollee(const EnrolleeNWProvInfo& enrolleeNWProvInfo) :
- m_enrolleeNWProvInfo(enrolleeNWProvInfo)
+ RemoteEnrollee::RemoteEnrollee(const ProvConfig& provConfig, const WiFiOnboadingConnection& connection) :
+ m_ProvConfig(provConfig), m_wifiOnboardingconn(connection)
{
m_currentESState = CurrentESState::ES_UNKNOWN;
- m_needSecuredEasysetup = enrolleeNWProvInfo.needSecuredEasysetup;
+ m_isSecured = connection.isSecured; //enrolleeNWProvInfo.needSecuredEasysetup;
OC_LOG ( DEBUG, ES_REMOTE_ENROLLEE_TAG, "Inside RemoteEnrollee constr");
}
{
m_easySetupStatusCb = callback;
- m_remoteResource = std::make_shared< RemoteEnrolleeResource >(m_enrolleeNWProvInfo);
+ m_remoteResource = std::make_shared< RemoteEnrolleeResource >(m_ProvConfig, m_wifiOnboardingconn);
}
}
OC_LOG(DEBUG, ES_REMOTE_ENROLLEE_TAG, "Ownership and ACL are successful");
std::shared_ptr< EasySetupStatus > easySetupStatus = nullptr;
easySetupStatus = std::make_shared< EasySetupStatus >(DEVICE_NOT_PROVISIONED,
- m_enrolleeNWProvInfo);
+ m_ProvConfig);
if (m_easySetupStatusCb)
{
if (easySetupStatus)
std::shared_ptr< EasySetupStatus > easySetupStatus = nullptr;
- if (m_enrolleeNWProvInfo.isSecured)
+ if (m_isSecured)
{
if (m_currentESState > CurrentESState::ES_OWNED)
{
if (provStatus->getESState() >= ESState::ES_PROVISIONED_ALREADY)
{
easySetupStatus = std::make_shared< EasySetupStatus >(DEVICE_PROVISIONED,
- m_enrolleeNWProvInfo);
+ m_ProvConfig);
}
else
{
easySetupStatus = std::make_shared< EasySetupStatus >(DEVICE_NOT_PROVISIONED,
- m_enrolleeNWProvInfo);
+ m_ProvConfig);
}
}
else
{
easySetupStatus = std::make_shared< EasySetupStatus >(DEVICE_NOT_PROVISIONED,
- m_enrolleeNWProvInfo);
+ m_ProvConfig);
}
if (m_easySetupStatusCb)
FAILURE:
easySetupStatus = std::make_shared< EasySetupStatus >(DEVICE_NOT_PROVISIONED,
- m_enrolleeNWProvInfo);
+ m_ProvConfig);
if (easySetupStatus)
{
m_currentESState = CurrentESState::ES_ONBOARDED;
#ifdef __WITH_DTLS__
- if (m_needSecuredEasysetup && m_currentESState < CurrentESState::ES_OWNED)
+ if (m_isSecured && m_currentESState < CurrentESState::ES_OWNED)
{
EnrolleeSecStatusCb securityProvStatusCb = std::bind(
&RemoteEnrollee::easySetupSecurityStatusCallback,
}
}
- EnrolleeNWProvInfo& RemoteEnrollee::getEnrolleeProvisioningInfo ()
+ ProvConfig RemoteEnrollee::getProvConfig ()
{
- return m_enrolleeNWProvInfo;
+ return m_ProvConfig;
}
+
+ WiFiOnboadingConnection RemoteEnrollee::getOnboardConn()
+ {
+ return m_wifiOnboardingconn;
+ }
+
}
}
static const char ES_PROV_RES_URI[] = "/oic/prov";
static const char ES_PROV_RES_TYPE[] = "oic.r.prov";
- RemoteEnrolleeResource::RemoteEnrolleeResource(EnrolleeNWProvInfo enrolleeNWProvInfo)
+ RemoteEnrolleeResource::RemoteEnrolleeResource(ProvConfig provConfig,
+ WiFiOnboadingConnection onboardingconn)
{
- m_enrolleeNWProvInfo = enrolleeNWProvInfo;
+ m_ProvConfig = provConfig;
+ m_wifiOnboardingconn = onboardingconn;
m_discoveryResponse = false;
}
//Provisioning status check
if (ps == ES_PS_PROVISIONING_COMPLETED)
{
- if (tnn != std::string(m_enrolleeNWProvInfo.netAddressInfo.WIFI.ssid))
+ if (tnn != std::string(m_ProvConfig.provData.WIFI.ssid))
{
OC_LOG_V (ERROR, ES_REMOTE_ENROLLEE_RES_TAG,
"checkProvInformationCb : Network SSID is not the same as the "
return;
}
- if (cd != std::string(m_enrolleeNWProvInfo.netAddressInfo.WIFI.pwd))
+ if (cd != std::string(m_ProvConfig.provData.WIFI.pwd))
{
OC_LOG_V (ERROR, ES_REMOTE_ENROLLEE_RES_TAG,
"checkProvInformationCb : Network PWD is not the same as the "
OCRepresentation provisioningRepresentation;
provisioningRepresentation.setValue(OC_RSRVD_ES_TNN,
- std::string(m_enrolleeNWProvInfo.netAddressInfo.WIFI.ssid));
+ std::string(m_ProvConfig.provData.WIFI.ssid));
provisioningRepresentation.setValue(OC_RSRVD_ES_CD,
- std::string(m_enrolleeNWProvInfo.netAddressInfo.WIFI.pwd));
+ std::string(m_ProvConfig.provData.WIFI.pwd));
OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getProvStatusResponse : ssid - %s",
- m_enrolleeNWProvInfo.netAddressInfo.WIFI.ssid);
+ m_ProvConfig.provData.WIFI.ssid);
OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getProvStatusResponse : pwd - %s",
- m_enrolleeNWProvInfo.netAddressInfo.WIFI.pwd);
+ m_ProvConfig.provData.WIFI.pwd);
m_ocResource->put(provisioningRepresentation, QueryParamsMap(),
std::function<
std::size_t foundIP =
hostAddress.find(
- std::string(m_enrolleeNWProvInfo.netAddressInfo.WIFI.ipAddress));
+ std::string(m_wifiOnboardingconn.ipAddress));
if(resourceURI == ES_PROV_RES_URI && foundIP!=std::string::npos)
{
OC_LOG(DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "Before OCPlatform::constructResourceObject");
OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "m_host = %s",
- m_enrolleeNWProvInfo.netAddressInfo.WIFI.ipAddress);
+ m_wifiOnboardingconn.ipAddress);
OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "ES_PROV_RES_URI = %s", ES_PROV_RES_URI);
OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "m_connectivityType = %d",
- m_enrolleeNWProvInfo.connType);
+ m_ProvConfig.connType);
OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "resTypes = %s",
resTypes.at(0).c_str());
OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "interface = %s", interface.at(0).c_str());
std::string host;
- if(m_enrolleeNWProvInfo.needSecuredEasysetup)
+ if(m_wifiOnboardingconn.isSecured)
{
host.append("coaps://");
}
host.append("coap://");
}
- if(m_enrolleeNWProvInfo.connType == CT_ADAPTER_IP)
+ if(m_ProvConfig.connType == CT_ADAPTER_IP)
{
// TODO : RemoteEnrollee is current handling easysetup on IP transport.
// WiFiRemoteEnrollee need to extend RemoteEnrollee for providing IP specific
// Enrollee easysetup.
- host.append(m_enrolleeNWProvInfo.netAddressInfo.WIFI.ipAddress);
+ host.append(m_wifiOnboardingconn.ipAddress);
//TODO : If the target Enrollee is not a Arduino Wi-Fi device,
// then the port number will be found during resource discovery instead of
// using 55555
m_ocResource = OC::OCPlatform::constructResourceObject(host,
ES_PROV_RES_URI,
- m_enrolleeNWProvInfo.connType,
+ m_ProvConfig.connType,
true,
resTypes,
interface);
std::string host("");
std::string query("");
- if (m_enrolleeNWProvInfo.needSecuredEasysetup)
+ if (m_wifiOnboardingconn.isSecured)
{
host.append("coaps://");
}
host.append("coap://");
}
- if (m_enrolleeNWProvInfo.connType == CT_ADAPTER_IP)
+ if (m_ProvConfig.connType == CT_ADAPTER_IP)
{
// TODO : RemoteEnrollee is current handling easysetup on IP transport.
// WiFiRemoteEnrollee need to extend RemoteEnrollee for providing IP specific
// Enrollee easysetup.
- host.append(m_enrolleeNWProvInfo.netAddressInfo.WIFI.ipAddress);
+ host.append(m_wifiOnboardingconn.ipAddress);
}
query.append(ES_BASE_RES_URI);
host.c_str());
OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "query = %s", query.c_str());
OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "m_connectivityType = %d",
- m_enrolleeNWProvInfo.connType);
+ m_ProvConfig.connType);
m_discoveryResponse = false;
std::function< void (std::shared_ptr<OC::OCResource>) > onDeviceDiscoveredCb =
int main(int argc, char **argv) {
int opt;
- EnrolleeNWProvInfo netInfo;
+
+ ProvConfig provConfig;
+ //WiFiOnboardingConfig onboardConfig;
+ WiFiOnboadingConnection onboardConn;
+
PrintUsage();
InitProvProcess();
while ((opt = getopt(argc, argv, "d:s:p:")) != -1) {
switch (opt) {
case 'd':
- strncpy(netInfo.netAddressInfo.WIFI.ipAddress, optarg, IPV4_ADDR_SIZE - 1);
+ strncpy(onboardConn.ipAddress, optarg, IPV4_ADDR_SIZE - 1);
break;
case 's':
- strncpy(netInfo.netAddressInfo.WIFI.ssid, optarg, NET_WIFI_SSID_SIZE - 1);
+ strncpy(provConfig.provData.WIFI.ssid, optarg, NET_WIFI_SSID_SIZE - 1);
break;
case 'p':
- strncpy(netInfo.netAddressInfo.WIFI.pwd, optarg, NET_WIFI_PWD_SIZE - 1);
+ strncpy(provConfig.provData.WIFI.pwd, optarg, NET_WIFI_PWD_SIZE - 1);
break;
default:
PrintUsage();
}
}
- netInfo.connType = CT_ADAPTER_IP;
+ provConfig.connType = CT_ADAPTER_IP;
OIC_LOG_V(INFO, ES_MEDIATOR_TAG, "IP Address of the Provisioning device is =%s\n",
- netInfo.netAddressInfo.WIFI.ipAddress);
- OIC_LOG_V(INFO, ES_MEDIATOR_TAG, "SSID of the Enroller is =%s\n", netInfo.netAddressInfo.WIFI.ssid);
- OIC_LOG_V(INFO, ES_MEDIATOR_TAG, "Password of the Enroller is =%s\n", netInfo.netAddressInfo.WIFI.pwd);
+ onboardConn.ipAddress);
+ OIC_LOG_V(INFO, ES_MEDIATOR_TAG, "SSID of the Enroller is =%s\n", provConfig.provData.WIFI.ssid);
+ OIC_LOG_V(INFO, ES_MEDIATOR_TAG, "Password of the Enroller is =%s\n", provConfig.provData.WIFI.pwd);
- StartProvisioning(&netInfo);
+ StartProvisioning(&provConfig, &onboardConn);
signal(SIGINT, handleSigInt);
while (!quitFlag) {
using namespace OIC::Service;
static EasySetup *easySetupIntance = nullptr;
-static EnrolleeNWProvInfo netInfo;
+static ProvConfig netInfo;
+static WiFiOnboadingConnection onboardingConn;
static RemoteEnrollee::shared_ptr remoteEnrollee = nullptr;
static std::string ipaddress, ssid, pwd;
void easySetupStatusCallback (std::shared_ptr< EasySetupStatus > easySetupStatus)
{
- OC_LOG_V(DEBUG, ES_SAMPLE_APP_TAG, "easySetupStatusCallback status is, IP = %s, Status = %d",
- easySetupStatus->getEasySetupNWProvInfo().netAddressInfo.WIFI.ipAddress,
+ OC_LOG_V(DEBUG, ES_SAMPLE_APP_TAG, "easySetupStatusCallback status is Status = %d",
easySetupStatus->getEasySetupState());
}
easySetupIntance = EasySetup::getInstance();
- ipaddress = "10.113.64.106";
+ ipaddress = "192.168.1.104";
//std::cout << "Enter the target enrollee ipv4 address ";
//std::cin >> pwd;
netInfo.connType = CT_ADAPTER_IP;
- netInfo.isSecured = false;
- netInfo.needSecuredEasysetup = false;
- OICStrcpy(netInfo.netAddressInfo.WIFI.ipAddress, IPV4_ADDR_SIZE - 1, ipaddress.c_str());
- OICStrcpy(netInfo.netAddressInfo.WIFI.ssid, NET_WIFI_SSID_SIZE - 1, ssid.c_str());
- OICStrcpy(netInfo.netAddressInfo.WIFI.pwd, NET_WIFI_PWD_SIZE - 1, pwd.c_str());
+ //netInfo.isSecured = false;
+ //netInfo.needSecuredEasysetup = false;
+
+ OICStrcpy(netInfo.provData.WIFI.ssid, NET_WIFI_SSID_SIZE - 1, ssid.c_str());
+ OICStrcpy(netInfo.provData.WIFI.pwd, NET_WIFI_PWD_SIZE - 1, pwd.c_str());
+
+ onboardingConn.isSecured = false;
+ OICStrcpy(onboardingConn.ipAddress, IPV4_ADDR_SIZE - 1, ipaddress.c_str());
+
try
{
- remoteEnrollee = easySetupIntance->createEnrolleeDevice(netInfo);
+ remoteEnrollee = easySetupIntance->createEnrolleeDevice(netInfo,onboardingConn);
}
catch (OCException &e)
{