if target_os in ['linux']:
easy_setup_env.AppendUnique(LIBS = ['pthread', 'dl', 'coap'])
-if target_os in ['android']:
- easy_setup_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
- if env.get('SECURED') == '1':
- easy_setup_env.AppendUnique(LIBPATH = [env.get('SRC_DIR')+'/android/android_api/base/libs/armeabi'])
- easy_setup_env.AppendUnique(RPATH = [env.get('BUILD_DIR')])
- easy_setup_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
- easy_setup_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'connectivity_abstraction', 'gnustl_shared'])
- if env.get('SECURED') == '1':
- easy_setup_env.AppendUnique(LIBS = ['ocpmapi','ocprovision'])
- if not env.get('RELEASE'):
- easy_setup_env.AppendUnique(LIBS = ['log'])
+#if target_os in ['android']:
+# easy_setup_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
+# if env.get('SECURED') == '1':
+# easy_setup_env.AppendUnique(LIBPATH = [env.get('SRC_DIR')+'/android/android_api/base/libs/armeabi'])
+# easy_setup_env.AppendUnique(RPATH = [env.get('BUILD_DIR')])
+# easy_setup_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
+# easy_setup_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'connectivity_abstraction', 'gnustl_shared'])
+# if env.get('SECURED') == '1':
+# easy_setup_env.AppendUnique(LIBS = ['ocpmapi','ocprovision'])
+# if not env.get('RELEASE'):
+# easy_setup_env.AppendUnique(LIBS = ['log'])
if target_os in ['linux']:
easy_setup_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
if env.get('SECURED') == '1':
easy_setup_env.AppendUnique(LIBS = ['ocpmapi', 'ocprovision'])
-if target_os in ['android','linux']:
+#if target_os in ['android','linux']:
+if target_os in ['linux']:
easy_setup_env.PrependUnique(CPPPATH = [
env.get('SRC_DIR') + '/resource/c_common/oic_malloc/include',
env.get('SRC_DIR') + '/resource/include',
es_src = None
-if target_os in ['android','linux']:
+#if target_os in ['android','linux']:
+if target_os in ['linux']:
if env.get('SECURED') == '1':
env.AppendUnique(es_src = [os.path.join(easysetup_path, 'src/EnrolleeSecurity.cpp')])
es_common_src = ['src/RemoteEnrollee.cpp',
- 'src/RemoteEnrolleeResource.cpp',
+ 'src/EnrolleeResource.cpp',
'src/EasySetup.cpp',
'src/ESException.cpp']
######################################################################
# Build RichSDK Mediator Sample App
################################################ ######################
-if target_os == 'linux':
- SConscript('../../sampleapp/mediator/linux/richsdk_sample/SConscript')
+#if target_os == 'linux':
+# SConscript('../../sampleapp/mediator/linux/richsdk_sample/SConscript')
######################################################################
#Build UnitTestcases for Mediator[RichSDK]
################################################ ######################
-if target_os == 'linux':
- SConscript('unittests/SConscript')
+#if target_os == 'linux':
+# SConscript('unittests/SConscript')
#define IP_PORT 55555
#define NET_WIFI_SSID_SIZE 100
#define NET_WIFI_PWD_SIZE 100
+#define NET_WIFI_AUTH_SIZE 100
/**
* @brief Mac address length for BT port
/**
* 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"
+#define OC_RSRVD_ES_PROVSTATUS "ps"
+#define OC_RSRVD_ES_TRIGGER "tr"
+#define OC_RSRVD_ES_SSID "tnn"
+#define OC_RSRVD_ES_CRED "cd"
+#define OC_RSRVD_ES_AUTHTYPE "wat"
+#define OC_RSRVD_ES_ENCTYPE "wet"
+#define OC_RSRVD_ES_AUTHCODE "ac"
+#define OC_RSRVD_ES_AUTHPROVIDER "apn"
+#define OC_RSRVD_ES_CISERVER "cisurl"
+#define OC_RSRVD_ES_DEVNAME "dn"
+#define OC_RSRVD_ES_LANGUAGE "lang"
+#define OC_RSRVD_ES_COUNTRY "cont"
+#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"
+#define OC_RSRVD_ES_PROV_RES_TYPE "oic.r.prov"
+#define OC_RSRVD_ES_URI_PROV "/.well-known/ocf/prov"
+#define OC_RSRVD_ES_RES_TYPE_WIFI "ocf.r.wifi"
+#define OC_RSRVD_ES_URI_WIFI "/.well-known/ocf/prov/wifi"
+#define OC_RSRVD_ES_RES_TYPE_CLOUDSERVER "ocf.r.cloudserver"
+#define OC_RSRVD_ES_URI_CLOUDSERVER "/.well-known/ocf/prov/cloudserver"
+#define OC_RSRVD_ES_RES_TYPE_DEVCONF "ocf.r.devconf"
+#define OC_RSRVD_ES_URI_DEVCONF "/.well-known/ocf/prov/devconf"
+#define OC_RSRVD_ES_URI_NET "/oic/net"
/**
* @brief Defines for Provisioning status accepted values
{
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_RECVREQOFNETRES,
ES_RECVUPDATEOFPROVRES,
ES_RECVTRIGGEROFPROVRES,
+ ES_UNAUTHORIZED = 31
} 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
*/
DEVICE_NOT_PROVISIONED,
DEVICE_OWNED,
DEVICE_NOT_OWNED
- } EasySetupState, ProvStatus;
+ } EasySetupState;
/**
- * Response from queries to remote servers.
+ * @brief WIFI Authentication type of the Enroller
*/
- typedef struct
+ typedef enum
{
- // EasySetup Status
- EasySetupState provStatus;
- // EasySetup Device Info
- EasySetupDeviceInfo provDeviceInfo;
- } EasySetupInfo, ProvisioningInfo;
+ NONE_AUTH = 0,
+ WEP,
+ WPA_PSK,
+ WPA2_PSK
+ } WIFI_AUTHTYPE;
+
+ /**
+ * @brief WIFI ecnrytion type of the Enroller
+ */
+ typedef enum
+ {
+ NONE_ENC = 0,
+ WEP_64,
+ WEP_128,
+ TKIP,
+ AES,
+ TKIP_AES
+ } WIFI_ENCTYPE;
/**
* @brief Network information of the Enroller
{
char ssid[NET_WIFI_SSID_SIZE]; /**< ssid of the Enroller**/
char pwd[NET_WIFI_PWD_SIZE]; /**< pwd of the Enroller**/
+ WIFI_AUTHTYPE authtype; /**< auth type of the Enroller**/
+ WIFI_ENCTYPE enctype; /**< encryption type of the Enroller**/
+ char authcode[NET_WIFI_AUTH_SIZE];
+ char authserverUrl[NET_WIFI_AUTH_SIZE];
+ char apiserverUrl[NET_WIFI_AUTH_SIZE];
} WIFI;
} ProvData;
} 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
/**
* Security Provisioning Status
*/
- class SecProvisioningResult
+ class SecProvisioningStatus
{
public:
- std::shared_ptr< SecProvisioningResult > shared_ptr;
- SecProvisioningResult(std::string deviceUUID, ESResult result) :
+ SecProvisioningStatus(std::string deviceUUID, ESResult result) :
m_devUUID(deviceUUID), m_result(result)
{
ESResult m_result;
};
- /**
- * Callback function definition for providing Enrollee security status .
- */
- typedef std::function< void(std::shared_ptr<SecProvisioningResult>) > EnrolleeSecStatusCb;
+ class CapabilityData
+ {
+ public:
+ CapabilityData()
+ {
- /**
- * Callback definition to be invoked when the security stack expects a pin from application.
- */
- typedef std::function< void(std::string&) > SecurityPinCb;
+ }
+ private:
+ };
- /**
- * Callback definition to be invoked when the stack expects a db path.
- */
- typedef std::function< void(std::string&) > SecProvisioningDbPathCb;
+ class InitRemoteEnrolleeStatus
+ {
+ public:
+ InitRemoteEnrolleeStatus(ESResult result) :
+ m_result(result)
+ {
+
+ }
+
+ ESResult getESResult()
+ {
+ return m_result;
+ }
+ private:
+ ESResult m_result;
+ };
+
+ class RequestCapabilityStatus
+ {
+ public:
+ RequestCapabilityStatus(ESResult result, const CapabilityData& data) :
+ m_result(result), m_capabilityData(data)
+ {
+ }
+ ESResult getESResult()
+ {
+ return m_result;
+ }
+ CapabilityData getCapabilityData()
+ {
+ return m_capabilityData;
+ }
+ private:
+ ESResult m_result;
+ CapabilityData m_capabilityData;
+ };
class ProvisioningStatus
{
public:
- std::shared_ptr< ProvisioningStatus > shared_ptr;
ProvisioningStatus(ESResult result, ESState esState) :
m_result(result), m_esState(esState)
{
class EasySetupStatus
{
public:
- std::shared_ptr< EasySetupStatus > shared_ptr;
EasySetupStatus(const EasySetupState& easySetupState,
const ProvConfig& provConfig) :
m_easySetupState(easySetupState), m_ProvConfig(provConfig)
EasySetupState m_easySetupState;
ProvConfig m_ProvConfig;
};
+
+ /**
+ * Callback function definition for providing Enrollee security status .
+ */
+ typedef std::function< void(std::shared_ptr< InitRemoteEnrolleeStatus >) > InitRemoteEnrolleeStatusCb;
+
+ /**
+ * Callback function definition for providing Enrollee security status .
+ */
+ typedef std::function< void(std::shared_ptr< RequestCapabilityStatus >) > RequestCapabilityStatusCb;
+ /**
+ * Callback function definition for providing Enrollee security status .
+ */
+ typedef std::function< void(std::shared_ptr< ProvisioningStatus >) > DataProvStatusCb;
+
+ /**
+ * Callback function definition for providing Enrollee security status .
+ */
+ typedef std::function< void(std::shared_ptr<SecProvisioningStatus>) > 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;
+
}
}
#endif //WITH_ARDUINO
static EasySetup* getInstance();
/**
- * This API is used for creating a remote Enrollee device instance.
- * @param ProvConfig Provisioning information for configuring the Enrollee.
+ * This API is used for creating a remote Enrollee instance.
* @param WiFiOnboadingConnection Onboarding connection information for configuring the Enrollee.
*
* @throws ESBadRequestException If createEnrolleeDevice is invoked with the same
*
* @return Pointer to RemoteEnrollee instance.
*/
- std::shared_ptr<RemoteEnrollee> createEnrolleeDevice (
- const ProvConfig& enrolleeNWProvInfo,
- const WiFiOnboadingConnection& wifiOnboardingconn);
+ std::shared_ptr<RemoteEnrollee> createRemoteEnrollee(const WiFiOnboadingConnection& wifiOnboardingconn);
+
private:
EasySetup();
~EasySetup();
- RemoteEnrollee::shared_ptr findDeviceInProvisioningList(
- const ProvConfig& enrolleeNWProvInfo,
- const WiFiOnboadingConnection& wifiOnboardingconn);
- bool addDeviceToProvisioningList(const RemoteEnrollee::shared_ptr remoteEnrollee);
- bool deleteDeviceFromProvisioningList (const ProvConfig& enrolleeNWProvInfo);
-
- std::vector< RemoteEnrollee::shared_ptr > m_activeEnrolleeList;
static EasySetup *s_instance;
};
}
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-#ifndef REMOTE_ENROLLEE_RESOURCE_H_
-#define REMOTE_ENROLLEE_RESOURCE_H_
+#ifndef ENROLLEE_RESOURCE_H_
+#define ENROLLEE_RESOURCE_H_
#include <mutex>
#include <memory>
/**
* This class contains the resource discovery methods.
*
- * @see RemoteEnrolleeResource
+ * @see EnrolleeResource
*/
- class RemoteEnrolleeResource
+ class EnrolleeResource
{
friend class EnrolleeSecurity;
public:
- typedef std::shared_ptr< RemoteEnrolleeResource > Ptr;
-
- typedef std::function< void(std::shared_ptr< ProvisioningStatus >) > ProvStatusCb;
/**
- * RemoteEnrolleeResource constructor
+ * EnrolleeResource constructor
*
* @param enrolleeNWProvInfo Provisioning information for the Enrollee
*
* @throw ESBadRequestException is thrown if the parameters are invalid
*/
- RemoteEnrolleeResource(const ProvConfig &enrolleeNWProvInfo,
- const WiFiOnboadingConnection &onboardingconn);
+ EnrolleeResource(const WiFiOnboadingConnection &onboardingconn);
+ // EnrolleeResource(const ProvConfig &enrolleeNWProvInfo,
+ // const WiFiOnboadingConnection &onboardingconn);
- ~RemoteEnrolleeResource() = default;
+ ~EnrolleeResource() = default;
/**
* Register provisioning status handler.
*
* @see ProvisioningStatus
*/
- void registerProvStatusCallback (ProvStatusCb provStatusCb);
+ void registerInitRemoteEnrolleeStatusCallback (InitRemoteEnrolleeStatusCb callback);
+ void registerCapabilityStatusCallback (RequestCapabilityStatusCb callback);
+ void registerProvStatusCallback (DataProvStatusCb callback);
/**
* Construct Remote OIC resource using the enrollee host and connectivity information
- * provided in the constructor of RemoteEnrolleeResource.
+ * provided in the constructor of EnrolleeResource.
*
* @throws InvalidParameterException If the provided information is invalid.
* @throws ESBadRequestException If resource is already constructed.
*/
ESResult constructResourceObject();
+ void getCapabilityData();
+
/**
* Function for provisioning of Remote Enrollee resource using the information provided.
*
private:
std::shared_ptr< OC::OCResource > m_ocResource;
std::mutex m_mutex;
- ProvStatusCb m_provStatusCb;
+ InitRemoteEnrolleeStatusCb m_initRemoteEnrolleeStatusCb;
+ RequestCapabilityStatusCb m_requestCapabilityStatusCb;
+ DataProvStatusCb m_dataProvStatusCb;
ProvConfig m_ProvConfig;
WiFiOnboadingConnection m_wifiOnboardingconn;
bool m_discoveryResponse;
+ void getCapabilityResponse(const HeaderOptions& headerOptions, const OCRepresentation& rep,
+ const int eCode);
+
void getProvStatusResponse(const HeaderOptions& headerOptions, const OCRepresentation& rep,
const int eCode);
{
#define ENROLEE_SECURITY_TAG "ENROLEE_SECURITY"
- class RemoteEnrolleeResource;
+ class EnrolleeResource;
class OCSecureResource;
/**
class EnrolleeSecurity
{
public:
- EnrolleeSecurity(std::shared_ptr< RemoteEnrolleeResource > remoteEnrolleeResource,
+ EnrolleeSecurity(std::shared_ptr< EnrolleeResource > EnrolleeResource,
std::string secDbPath);
ESResult registerCallbackHandler(EnrolleeSecStatusCb enrolleeSecStatusCb,
SecurityPinCb securityPinCb, SecProvisioningDbPathCb secProvisioningDbPathCb);
EasySetupState performOwnershipTransfer();
private:
- std::shared_ptr< RemoteEnrolleeResource > m_remoteEnrolleeResource;
+ std::shared_ptr< EnrolleeResource > m_EnrolleeResource;
EnrolleeSecStatusCb m_enrolleeSecStatusCb;
SecurityPinCb m_securityPinCb;
SecProvisioningDbPathCb m_secProvisioningDbPathCb;
{
namespace Service
{
- class RemoteEnrolleeResource;
+ class EnrolleeResource;
class EnrolleeSecurity;
/**
*
* @throw ESBadRequestException is thrown if the parameters are invalid
*/
- RemoteEnrollee(const ProvConfig& enrolleeNWProvInfo, const WiFiOnboadingConnection& connection) ;
+ RemoteEnrollee(const WiFiOnboadingConnection& wifiOnboardingconn);
~RemoteEnrollee() = default;
- typedef std::shared_ptr< RemoteEnrollee > shared_ptr;
-
- /**
- * Callback definition to be invoked when EasySetup status is changed.
- * The same callback will be invoked when there is an error in the
- * EasySetup process.
- *
- * @see registerResourceHandler
- * @see ResourceState
- */
- typedef std::function< void(std::shared_ptr< EasySetupStatus >) >
- EasySetupStatusCB;
-
#ifdef __WITH_DTLS__
/**
* Register Security status and other information callback handlers.
#endif //__WITH_DTLS__
/**
- * Register EasySetup status handler.
+ * Start provisioning of target Enrollers information to the Enrollee.
*
- * @param callback Callback to get EasySetup status.
- * @param secProvisioningDbCB Callback to be invoked when the stack expects a
- * path for the provisioning db.
+ * @throws ESBadRequestException If RemoteEnrollee device not created prior to this call.
*
- * @throws InvalidParameterException If callback is an empty function or null.
- * @throws ESBadRequestException If registration is already completed.
+ * @see RemoteEnrollee
+ */
+ void initRemoteEnrollee(InitRemoteEnrolleeStatusCb callback);
+
+ /**
+ * Start provisioning of target Enrollers information to the Enrollee.
+ *
+ * @throws ESBadRequestException If RemoteEnrollee device not created prior to this call.
+ *
+ * @see RemoteEnrollee
+ */
+ void startSecurityProvisioning(EnrolleeSecStatusCb callback);
+
+ /**
+ * Start provisioning of target Enrollers information to the Enrollee.
*
- * @see EasySetupStatus
+ * @throws ESBadRequestException If RemoteEnrollee device not created prior to this call.
+ *
+ * @see RemoteEnrollee
*/
- void registerEasySetupStatusHandler(EasySetupStatusCB callback);
+ void getCapabilityData(RequestCapabilityStatusCb callback);
/**
* Start provisioning of target Enrollers information to the Enrollee.
*
* @see RemoteEnrollee
*/
- void startProvisioning();
+ void startDataProvisioning(const ProvConfig& dataProvConfig, DataProvStatusCb callback);
/**
* Stop provisioning process that is currently in progress.
WiFiOnboadingConnection getOnboardConn();
private:
- std::shared_ptr< RemoteEnrolleeResource > m_remoteResource;
- EasySetupStatusCB m_easySetupStatusCb;
+ std::shared_ptr< EnrolleeResource > m_remoteResource;
EnrolleeSecStatusCb m_enrolleeSecStatusCb;
+ InitRemoteEnrolleeStatusCb m_initRemoteEnrolleeStatusCb;
+ RequestCapabilityStatusCb m_requestCapabilityStatusCb;
SecurityPinCb m_securityPinCb;
SecProvisioningDbPathCb m_secProvisioningDbPathCb;
+ DataProvStatusCb m_dataProvStatusCb;
ProvConfig m_ProvConfig;
WiFiOnboadingConnection m_wifiOnboardingconn;
CurrentESState m_currentESState;
bool m_isSecured;
- void provisioningStatusHandler (std::shared_ptr< ProvisioningStatus > provStatus);
+ void InitRemoteEnrolleeStatusHandler (std::shared_ptr< InitRemoteEnrolleeStatus > initRemoteEnrolleeStatus);
+ void requestCapabilityStatusHandler (std::shared_ptr< RequestCapabilityStatus > requestCapabilityStatus);
+ void dataProvisioningStatusHandler (std::shared_ptr< ProvisioningStatus > provStatus);
void easySetupSecurityStatusCallback(
- std::shared_ptr< SecProvisioningResult > secProvisioningResult);
+ std::shared_ptr< SecProvisioningStatus > secProvisioningResult);
};
}
}
return s_instance;
}
- RemoteEnrollee::shared_ptr EasySetup::findDeviceInProvisioningList (
- const ProvConfig& provConfig, const WiFiOnboadingConnection& onboardingconn)
+ std::shared_ptr<RemoteEnrollee> EasySetup::createRemoteEnrollee (const WiFiOnboadingConnection& wifiOnboardingconn)
{
- OIC_LOG(DEBUG,EASYSETUP_TAG,"Entered findDeviceInProvisioningList ()");
-
- std::vector< std::shared_ptr< RemoteEnrollee > >::iterator it;
-
- std::shared_ptr< RemoteEnrollee > remoteEnrollee = nullptr;
- for(auto it : m_activeEnrolleeList)
- {
- OIC_LOG_V(DEBUG,EASYSETUP_TAG,"entered the iterator");
-
- 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;
- }
- }
-
- OIC_LOG_V(DEBUG,EASYSETUP_TAG,"Return nullptr for findDeviceInProvisioningList call");
- return remoteEnrollee;
- }
-
- bool EasySetup::addDeviceToProvisioningList(const RemoteEnrollee::shared_ptr remoteEnrollee)
- {
- ProvConfig remoteEnrolleConfig = remoteEnrollee->getProvConfig();
- WiFiOnboadingConnection remoteEnrolleConn = remoteEnrollee->getOnboardConn();
-
- for (auto it : m_activeEnrolleeList)
- {
- 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;
- }
- }
-
- OIC_LOG_V(DEBUG,EASYSETUP_TAG,"Adding new device RemoteEnrollee list");
- m_activeEnrolleeList.push_back(remoteEnrollee);
- return true;
+ return std::make_shared< RemoteEnrollee > (wifiOnboardingconn);
}
-
- std::shared_ptr<RemoteEnrollee> EasySetup::createEnrolleeDevice (
- const ProvConfig& provConfig, const WiFiOnboadingConnection& wifiOnboardingconn)
- {
- if (findDeviceInProvisioningList(provConfig,wifiOnboardingconn) != nullptr)
- {
- throw ESBadRequestException { "Device already created exception" };
- }
-
- RemoteEnrollee::shared_ptr remoteEnrollee;
-
- remoteEnrollee = std::make_shared< RemoteEnrollee > (provConfig, wifiOnboardingconn);
-
-
- if (!addDeviceToProvisioningList (remoteEnrollee))
- {
- return nullptr;
- }
-
- return remoteEnrollee;
- }
-
-
}
}
#include <functional>
#include <time.h>
-#include "RemoteEnrolleeResource.h"
+#include "EnrolleeResource.h"
#include "OCPlatform.h"
#include "ESException.h"
static const char ES_PROV_RES_URI[] = "/oic/prov";
static const char ES_PROV_RES_TYPE[] = "oic.r.prov";
- RemoteEnrolleeResource::RemoteEnrolleeResource(const ProvConfig &provConfig,
+ EnrolleeResource::EnrolleeResource(const WiFiOnboadingConnection &onboardingconn)
+ {
+ m_wifiOnboardingconn = onboardingconn;
+ m_discoveryResponse = false;
+ }
+/*
+ EnrolleeResource::EnrolleeResource(const ProvConfig &provConfig,
const WiFiOnboadingConnection &onboardingconn)
{
m_ProvConfig = provConfig;
m_wifiOnboardingconn = onboardingconn;
m_discoveryResponse = false;
}
-
- void RemoteEnrolleeResource::triggerNetworkConnectionCb(
+*/
+ void EnrolleeResource::triggerNetworkConnectionCb(
const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep,
const int eCode)
{
"triggerNetworkConnectionCb : Trigger action failed ");
std::shared_ptr< ProvisioningStatus > provStatus = std::make_shared<
ProvisioningStatus >(ESResult::ES_ERROR, ESState::ES_PROVISIONING_ERROR);
- m_provStatusCb(provStatus);
+ m_dataProvStatusCb(provStatus);
return;
}
else
"triggerNetworkConnectionCb : Provisioning is success ");
std::shared_ptr< ProvisioningStatus > provStatus = std::make_shared<
ProvisioningStatus >(ESResult::ES_OK, ESState::ES_PROVISIONING_SUCCESS);
- m_provStatusCb(provStatus);
+ m_dataProvStatusCb(provStatus);
return;
}
}
- void RemoteEnrolleeResource::triggerNetworkConnection()
+ void EnrolleeResource::triggerNetworkConnection()
{
if (m_ocResource == nullptr)
{
OCRepresentation provisioningRepresentation;
- provisioningRepresentation.setValue(OC_RSRVD_ES_TR, 1);
+ provisioningRepresentation.setValue(OC_RSRVD_ES_TRIGGER, 1);
m_ocResource->post(provisioningRepresentation, QueryParamsMap(),
std::function<
void(const HeaderOptions& headerOptions, const OCRepresentation& rep,
const int eCode) >(
- std::bind(&RemoteEnrolleeResource::triggerNetworkConnectionCb, this,
+ std::bind(&EnrolleeResource::triggerNetworkConnectionCb, this,
std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3)));
}
- void RemoteEnrolleeResource::checkProvInformationCb(const HeaderOptions& /*headerOptions*/,
+ void EnrolleeResource::checkProvInformationCb(const HeaderOptions& /*headerOptions*/,
const OCRepresentation& rep, const int eCode)
{
OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "checkProvInformationCb : %s, eCode = %d",
"checkProvInformationCb : Provisioning is failed ");
std::shared_ptr< ProvisioningStatus > provStatus = std::make_shared<
ProvisioningStatus >(ESResult::ES_ERROR, ESState::ES_PROVISIONING_ERROR);
- m_provStatusCb(provStatus);
+ m_dataProvStatusCb(provStatus);
return;
}
int ps = -1;
- rep.getValue(OC_RSRVD_ES_PS, ps);
+ rep.getValue(OC_RSRVD_ES_PROVSTATUS, ps);
OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "checkProvInformationCb : ps - %d", ps);
#ifdef REMOTE_ARDUINO_ENROLEE
std::shared_ptr< ProvisioningStatus > provStatus = std::make_shared<
ProvisioningStatus >(ESResult::ES_OK, ESState::ES_PROVISIONING_SUCCESS);
- m_provStatusCb(provStatus);
+ m_dataProvStatusCb(provStatus);
#endif
triggerNetworkConnection();
"checkProvInformationCb : Provisioning is failed ");
std::shared_ptr< ProvisioningStatus > provStatus = std::make_shared<
ProvisioningStatus >(ESResult::ES_ERROR, ESState::ES_PROVISIONING_ERROR);
- m_provStatusCb(provStatus);
+ m_dataProvStatusCb(provStatus);
+ return;
+ }
+ }
+
+ void EnrolleeResource::getCapabilityResponse(const HeaderOptions& /*headerOptions*/,
+ const OCRepresentation& rep, const int eCode)
+ {
+ OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getCapabilityResponse : %s, eCode = %d",
+ rep.getUri().c_str(), eCode);
+
+ if (eCode != 0)
+ {
+ ESResult result = ESResult::ES_ERROR;
+
+ OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG,"getCapabilityResponse : getCapabilityResponse is failed ");
+
+ if (eCode == OCStackResult::OC_STACK_UNAUTHORIZED_REQ)
+ {
+ OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG,
+ "Mediator is unauthorized from Enrollee.");
+ result = ESResult::ES_UNAUTHORIZED;
+ }
+
+ CapabilityData capabilityData;
+ std::shared_ptr< RequestCapabilityStatus > requestCapabilityStatus = std::make_shared<
+ RequestCapabilityStatus >(result, capabilityData);
+ m_requestCapabilityStatusCb(requestCapabilityStatus);
+
return;
}
+
+ CapabilityData capabilityData = CapabilityData();
+ std::shared_ptr< RequestCapabilityStatus > requestCapabilityStatus = std::make_shared<
+ RequestCapabilityStatus >(ESResult::ES_OK, capabilityData);
+ m_requestCapabilityStatusCb(requestCapabilityStatus);
}
- void RemoteEnrolleeResource::getProvStatusResponse(const HeaderOptions& /*headerOptions*/,
+ void EnrolleeResource::getProvStatusResponse(const HeaderOptions& /*headerOptions*/,
const OCRepresentation& rep, const int eCode)
{
OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getProvStatusResponse : %s, eCode = %d",
if (eCode != 0)
{
- OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG,
- "getProvStatusResponse : Provisioning is failed ");
+ ESResult result = ESResult::ES_ERROR;
+
+ OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG,"getProvStatusResponse : Provisioning is failed ");
+
+ if (eCode == OCStackResult::OC_STACK_UNAUTHORIZED_REQ)
+ {
+ OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG,
+ "Mediator is unauthorized from Enrollee.");
+ result = ESResult::ES_UNAUTHORIZED;
+ }
std::shared_ptr< ProvisioningStatus > provStatus = std::make_shared<
- ProvisioningStatus >(ESResult::ES_ERROR, ESState::ES_PROVISIONING_ERROR);
- m_provStatusCb(provStatus);
+ ProvisioningStatus >(result, ESState::ES_PROVISIONING_ERROR);
+ m_dataProvStatusCb(provStatus);
+
return;
}
int ps = -1;
- rep.getValue(OC_RSRVD_ES_PS, ps);
+ rep.getValue(OC_RSRVD_ES_PROVSTATUS, ps);
OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getProvStatusResponse : ps - %d",
ps);
{
OCRepresentation provisioningRepresentation;
- provisioningRepresentation.setValue(OC_RSRVD_ES_TNN,
+ provisioningRepresentation.setValue(OC_RSRVD_ES_SSID,
std::string(m_ProvConfig.provData.WIFI.ssid));
- provisioningRepresentation.setValue(OC_RSRVD_ES_CD,
+ provisioningRepresentation.setValue(OC_RSRVD_ES_CRED,
std::string(m_ProvConfig.provData.WIFI.pwd));
+ provisioningRepresentation.setValue(OC_RSRVD_ES_AUTHCODE,
+ std::string(m_ProvConfig.provData.WIFI.authcode));
+ provisioningRepresentation.setValue(OC_RSRVD_ES_AUTHPROVIDER,
+ std::string(m_ProvConfig.provData.WIFI.authserverUrl));
+ provisioningRepresentation.setValue(OC_RSRVD_ES_CISERVER,
+ std::string(m_ProvConfig.provData.WIFI.apiserverUrl));
+ provisioningRepresentation.setValue( OC_RSRVD_ES_AUTHTYPE,
+ m_ProvConfig.provData.WIFI.authtype);
+ provisioningRepresentation.setValue(OC_RSRVD_ES_ENCTYPE,
+ m_ProvConfig.provData.WIFI.enctype);
OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getProvStatusResponse : ssid - %s",
m_ProvConfig.provData.WIFI.ssid);
OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getProvStatusResponse : pwd - %s",
m_ProvConfig.provData.WIFI.pwd);
+ OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getProvStatusResponse : AuthCode - %s",
+ m_ProvConfig.provData.WIFI.authcode);
+ OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getProvStatusResponse : AuthServerUrl - %s",
+ m_ProvConfig.provData.WIFI.authserverUrl);
+ OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getProvStatusResponse : APIServerUrl - %s",
+ m_ProvConfig.provData.WIFI.apiserverUrl);
+ OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getProvStatusResponse : authtype - %d",
+ m_ProvConfig.provData.WIFI.authtype);
+ OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getProvStatusResponse : enctype - %d",
+ m_ProvConfig.provData.WIFI.enctype);
m_ocResource->post(provisioningRepresentation, QueryParamsMap(),
std::function<
void(const HeaderOptions& headerOptions,
const OCRepresentation& rep, const int eCode) >(
- std::bind(&RemoteEnrolleeResource::checkProvInformationCb, this,
+ std::bind(&EnrolleeResource::checkProvInformationCb, this,
std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3)));
}
"getProvStatusResponse : Provisioning is successful");
std::shared_ptr< ProvisioningStatus > provStatus = std::make_shared<
ProvisioningStatus >(ESResult::ES_OK, ESState::ES_PROVISIONED_ALREADY);
- m_provStatusCb(provStatus);
+ m_dataProvStatusCb(provStatus);
}
}
- void RemoteEnrolleeResource::registerProvStatusCallback(ProvStatusCb provStatusCb)
+ void EnrolleeResource::registerInitRemoteEnrolleeStatusCallback (InitRemoteEnrolleeStatusCb callback)
+ {
+ m_initRemoteEnrolleeStatusCb = callback;
+ }
+
+ void EnrolleeResource::registerCapabilityStatusCallback(RequestCapabilityStatusCb callback)
+ {
+ m_requestCapabilityStatusCb = callback;
+ }
+
+ void EnrolleeResource::registerProvStatusCallback(DataProvStatusCb callback)
{
- m_provStatusCb = provStatusCb;
+ m_dataProvStatusCb = callback;
}
- ESResult RemoteEnrolleeResource::ESDiscoveryTimeout(unsigned short waittime)
+ ESResult EnrolleeResource::ESDiscoveryTimeout(unsigned short waittime)
{
struct timespec startTime;
startTime.tv_sec=0;
if (0 != clock_res)
{
+ std::shared_ptr< InitRemoteEnrolleeStatus > initRemoteEnrolleeStatus = std::make_shared<
+ InitRemoteEnrolleeStatus >(ESResult::ES_ERROR);
+ m_initRemoteEnrolleeStatusCb(initRemoteEnrolleeStatus);
return ES_ERROR;
}
long elapsed = (currTime.tv_sec - startTime.tv_sec);
return res;
}
- void RemoteEnrolleeResource::onDeviceDiscovered(std::shared_ptr<OC::OCResource> resource)
+ void EnrolleeResource::onDeviceDiscovered(std::shared_ptr<OC::OCResource> resource)
{
OIC_LOG (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "onDeviceDiscovered");
std::string resourceURI;
std::string hostAddress;
+ std::string hostDeviceID;
try
{
if(resource)
OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG,
"Host address of the resource: %s", hostAddress.c_str());
+ hostDeviceID = resource->sid();
+ OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG,
+ "Host DeviceID of the resource: %s", hostDeviceID.c_str());
/*
* Easysetup is always performed with a single Enrollee device and
* in a private network (SoftAP or BLE), so the assumption is that
*/
m_ocResource = resource;
m_discoveryResponse = true;
+
+ std::shared_ptr< InitRemoteEnrolleeStatus > initRemoteEnrolleeStatus = std::make_shared<
+ InitRemoteEnrolleeStatus >(ESResult::ES_OK);
+ m_initRemoteEnrolleeStatusCb(initRemoteEnrolleeStatus);
}
else
{
OIC_LOG (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "Resource is invalid");
+
+ std::shared_ptr< InitRemoteEnrolleeStatus > initRemoteEnrolleeStatus = std::make_shared<
+ InitRemoteEnrolleeStatus >(ESResult::ES_ERROR);
+ m_initRemoteEnrolleeStatusCb(initRemoteEnrolleeStatus);
}
}
}
- ESResult RemoteEnrolleeResource::constructResourceObject()
+ ESResult EnrolleeResource::constructResourceObject()
{
if (m_ocResource != nullptr)
{
host.append("coap://");
}
- 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_wifiOnboardingconn.ipAddress);
- }
-
query.append(ES_BASE_RES_URI);
query.append("?rt=");
query.append(ES_PROV_RES_TYPE);
OIC_LOG(DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "Before OCPlatform::constructResourceObject");
- OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "host = %s",
- host.c_str());
+ OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "host = %s", host.c_str());
OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "query = %s", query.c_str());
OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "m_connectivityType = %d",
m_ProvConfig.connType);
m_discoveryResponse = false;
std::function< void (std::shared_ptr<OC::OCResource>) > onDeviceDiscoveredCb =
- std::bind(&RemoteEnrolleeResource::onDeviceDiscovered, this,
+ std::bind(&EnrolleeResource::onDeviceDiscovered, this,
std::placeholders::_1);
OCStackResult result = OC::OCPlatform::findResource("", query, CT_DEFAULT,
onDeviceDiscoveredCb);
#endif
}
- void RemoteEnrolleeResource::provisionEnrollee()
+ void EnrolleeResource::getCapabilityData()
+ {
+ if (m_ocResource == nullptr)
+ {
+ throw ESBadRequestException("Resource is not initialized");
+ }
+
+ OC::QueryParamsMap query;
+ OC::OCRepresentation rep;
+
+ std::function< OCStackResult(void) > getCapabilityStatus = [&]
+ { return m_ocResource->get(m_ocResource->getResourceTypes().at(0),
+ BATCH_INTERFACE, query, std::function<void(const HeaderOptions& headerOptions,
+ const OCRepresentation& rep, const int eCode) >(
+ std::bind(&EnrolleeResource::getCapabilityResponse, this,
+ std::placeholders::_1, std::placeholders::_2,
+ std::placeholders::_3)));
+ };
+
+ OCStackResult result = getCapabilityStatus();
+
+ if (result != OCStackResult::OC_STACK_OK)
+ {
+ CapabilityData capabilityData;
+ std::shared_ptr< RequestCapabilityStatus > requestCapabilityStatus = std::make_shared<
+ RequestCapabilityStatus >(ESResult::ES_ERROR, capabilityData);
+ m_requestCapabilityStatusCb(requestCapabilityStatus);
+ return;
+ }
+ }
+
+ void EnrolleeResource::provisionEnrollee()
{
if (m_ocResource == nullptr)
std::function<
void(const HeaderOptions& headerOptions, const OCRepresentation& rep,
const int eCode) >(
- std::bind(&RemoteEnrolleeResource::getProvStatusResponse, this,
+ std::bind(&EnrolleeResource::getProvStatusResponse, this,
std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3)));
};
{
std::shared_ptr< ProvisioningStatus > provStatus = std::make_shared<
ProvisioningStatus >(ESResult::ES_ERROR, ESState::ES_PROVISIONING_ERROR);
- m_provStatusCb(provStatus);
+ m_dataProvStatusCb(provStatus);
return;
}
}
- void RemoteEnrolleeResource::unprovisionEnrollee()
+ void EnrolleeResource::unprovisionEnrollee()
{
if (m_ocResource == nullptr)
{
OCRepresentation provisioningRepresentation;
- provisioningRepresentation.setValue(OC_RSRVD_ES_TNN, "");
- provisioningRepresentation.setValue(OC_RSRVD_ES_CD, "");
+ provisioningRepresentation.setValue(OC_RSRVD_ES_SSID, "");
+ provisioningRepresentation.setValue(OC_RSRVD_ES_CRED, "");
m_ocResource->post(provisioningRepresentation, QueryParamsMap(),
std::function<
void(const HeaderOptions& headerOptions, const OCRepresentation& rep,
const int eCode) >(
- std::bind(&RemoteEnrolleeResource::checkProvInformationCb, this,
+ std::bind(&EnrolleeResource::checkProvInformationCb, this,
std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3)));
}
#include "EnrolleeSecurity.h"
#include "oxmjustworks.h"
#include "oxmrandompin.h"
-#include "RemoteEnrolleeResource.h"
+#include "EnrolleeResource.h"
#include "logger.h"
#include "ESException.h"
#include "oic_malloc.h"
#define ES_SEC_DISCOVERY_TIMEOUT 5
EnrolleeSecurity::EnrolleeSecurity(
- std::shared_ptr< RemoteEnrolleeResource > remoteEnrolleeResource,
+ std::shared_ptr< EnrolleeResource > EnrolleeResource,
std::string secDbPath)
{
m_enrolleeSecState = EnrolleeSecState::ES_SEC_UNKNOWN;
- m_remoteEnrolleeResource = remoteEnrolleeResource;
+ m_EnrolleeResource = EnrolleeResource;
}
ESResult EnrolleeSecurity::registerCallbackHandler(EnrolleeSecStatusCb enrolleeSecStatusCb,
{
OIC_LOG(ERROR, ENROLEE_SECURITY_TAG,"Error!!! in OwnershipTransfer");
- std::shared_ptr< SecProvisioningResult > securityProvisioningStatus = nullptr;
+ std::shared_ptr< SecProvisioningStatus > securityProvisioningStatus = nullptr;
std::string uuid;
convertUUIDToString(result->at(0).deviceId, uuid);
- securityProvisioningStatus = std::make_shared< SecProvisioningResult >(uuid,
+ securityProvisioningStatus = std::make_shared< SecProvisioningStatus >(uuid,
ES_ERROR);
m_enrolleeSecStatusCb(securityProvisioningStatus);
convertUUIDToString(result->at(0).deviceId, uuid);
OIC_LOG_V(DEBUG, ENROLEE_SECURITY_TAG, "UUID : %s",uuid.c_str());
- std::shared_ptr< SecProvisioningResult > securityProvisioningStatus = nullptr;
- securityProvisioningStatus = std::make_shared< SecProvisioningResult >(uuid,
+ std::shared_ptr< SecProvisioningStatus > securityProvisioningStatus = nullptr;
+ securityProvisioningStatus = std::make_shared< SecProvisioningStatus >(uuid,
ES_OK);
m_enrolleeSecStatusCb(securityProvisioningStatus);
ownershipStatus = DEVICE_NOT_OWNED;
return ownershipStatus;
}
- ownershipStatus = DEVICE_NOT_OWNED;
+ ownershipStatus = DEVICE_OWNED;
}
}
else
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#include "RemoteEnrollee.h"
-#include "RemoteEnrolleeResource.h"
+#include "EnrolleeResource.h"
#include "ESException.h"
#include "logger.h"
#ifdef __WITH_DTLS__
namespace Service
{
- RemoteEnrollee::RemoteEnrollee(const ProvConfig& provConfig, const WiFiOnboadingConnection& connection) :
- m_ProvConfig(provConfig), m_wifiOnboardingconn(connection)
+ RemoteEnrollee::RemoteEnrollee(const WiFiOnboadingConnection& wifiOnboardingconn) :
+ m_wifiOnboardingconn(wifiOnboardingconn)
{
- m_currentESState = CurrentESState::ES_UNKNOWN;
- m_isSecured = connection.isSecured; //enrolleeNWProvInfo.needSecuredEasysetup;
+ m_requestCapabilityStatusCb = nullptr;
+ m_currentESState = CurrentESState::ES_ONBOARDED;
+ m_isSecured = m_wifiOnboardingconn.isSecured;
+
+ m_remoteResource = std::make_shared< EnrolleeResource >(m_wifiOnboardingconn);
OIC_LOG ( DEBUG, ES_REMOTE_ENROLLEE_TAG, "Inside RemoteEnrollee constr");
}
}
#endif //__WITH_DTLS__
- void RemoteEnrollee::registerEasySetupStatusHandler(EasySetupStatusCB callback)
- {
- OIC_LOG ( DEBUG, ES_REMOTE_ENROLLEE_TAG, "Entered registerStatusHandler");
- if(!callback)
- {
- throw ESInvalidParameterException("Callback is empty");
- }
-
- if (m_easySetupStatusCb)
- {
- throw ESBadRequestException("Callback handler already registered");
- }
- else
- {
- m_easySetupStatusCb = callback;
-
- m_remoteResource = std::make_shared< RemoteEnrolleeResource >(m_ProvConfig, m_wifiOnboardingconn);
- }
- }
-
void RemoteEnrollee::easySetupSecurityStatusCallback(
- std::shared_ptr< SecProvisioningResult > secProvisioningResult)
+ std::shared_ptr< SecProvisioningStatus > secProvisioningStatus)
{
OIC_LOG_V(DEBUG, ES_REMOTE_ENROLLEE_TAG, "easySetupStatusCallback status is, UUID = %s, "
- "Status = %d", secProvisioningResult->getDeviceUUID().c_str(),
- secProvisioningResult->getResult());
+ "Status = %d", secProvisioningStatus->getDeviceUUID().c_str(),
+ secProvisioningStatus->getResult());
- if(secProvisioningResult->getResult() == ES_OK)
+ if(secProvisioningStatus->getResult() == ES_OK)
{
OIC_LOG(DEBUG, ES_REMOTE_ENROLLEE_TAG, "Ownership and ACL are successful. "
"Continue with Network information provisioning");
OIC_LOG(DEBUG,ES_REMOTE_ENROLLEE_TAG,"Before ProvisionEnrollee");
- RemoteEnrolleeResource::ProvStatusCb provStatusCb = std::bind(
- &RemoteEnrollee::provisioningStatusHandler, this, std::placeholders::_1);
-
- m_remoteResource->registerProvStatusCallback(provStatusCb);
- m_remoteResource->provisionEnrollee();
+ m_enrolleeSecStatusCb(secProvisioningStatus);
}
else
{
- OIC_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_ProvConfig);
- if (m_easySetupStatusCb)
- {
- if (easySetupStatus)
- {
- m_easySetupStatusCb(easySetupStatus);
- }
- else
- {
- m_easySetupStatusCb(nullptr);
- }
- }
+ OIC_LOG(DEBUG, ES_REMOTE_ENROLLEE_TAG, "Ownership and ACL are fail");
+
+ m_enrolleeSecStatusCb(secProvisioningStatus);
}
}
- void RemoteEnrollee::provisioningStatusHandler(
- std::shared_ptr< ProvisioningStatus > provStatus)
+ void RemoteEnrollee::InitRemoteEnrolleeStatusHandler (
+ std::shared_ptr< InitRemoteEnrolleeStatus > initRemoteEnrolleeStatus)
{
- OIC_LOG(DEBUG,ES_REMOTE_ENROLLEE_TAG,"Entering ProvisioningStatusHandler");
+ OIC_LOG(DEBUG,ES_REMOTE_ENROLLEE_TAG,"Entering InitRemoteEnrolleeStatusHandler");
- OIC_LOG_V(DEBUG,ES_REMOTE_ENROLLEE_TAG,"ProvStatus = %d", provStatus->getESResult());
+ OIC_LOG_V(DEBUG,ES_REMOTE_ENROLLEE_TAG,"initRemoteEnrolleeStatus = %d", initRemoteEnrolleeStatus->getESResult());
- std::shared_ptr< EasySetupStatus > easySetupStatus = nullptr;
+ m_initRemoteEnrolleeStatusCb(initRemoteEnrolleeStatus);
+ }
- if (m_isSecured)
- {
- if (m_currentESState >= CurrentESState::ES_OWNED)
- {
- goto CALLBACK_CHECK;
- }
- else
- {
- goto FAILURE;
- }
- }
- else
- {
- goto CALLBACK_CHECK;
- }
+ void RemoteEnrollee::requestCapabilityStatusHandler (
+ std::shared_ptr< RequestCapabilityStatus > requestCapabilityStatus)
+ {
+ OIC_LOG(DEBUG,ES_REMOTE_ENROLLEE_TAG,"Entering requestCapabilityStatusHandler");
+
+ OIC_LOG_V(DEBUG,ES_REMOTE_ENROLLEE_TAG,"requestCapabilityStatus = %d", requestCapabilityStatus->getESResult());
- CALLBACK_CHECK:
+ m_requestCapabilityStatusCb(requestCapabilityStatus);
+ }
+
+ void RemoteEnrollee::dataProvisioningStatusHandler(
+ std::shared_ptr< ProvisioningStatus > provStatus)
+ {
+ OIC_LOG(DEBUG,ES_REMOTE_ENROLLEE_TAG,"Entering dataprovisioningStatusHandler");
+
+ OIC_LOG_V(DEBUG,ES_REMOTE_ENROLLEE_TAG,"ProvStatus = %d", provStatus->getESResult());
if (provStatus->getESResult() == ES_OK)
{
if (provStatus->getESState() >= ESState::ES_PROVISIONED_ALREADY)
{
- easySetupStatus = std::make_shared< EasySetupStatus >(DEVICE_PROVISIONED,
- m_ProvConfig);
- }
- else
- {
- easySetupStatus = std::make_shared< EasySetupStatus >(DEVICE_NOT_PROVISIONED,
- m_ProvConfig);
- }
- }
- else
- {
- easySetupStatus = std::make_shared< EasySetupStatus >(DEVICE_NOT_PROVISIONED,
- m_ProvConfig);
- }
-
- if (m_easySetupStatusCb)
- {
- if (easySetupStatus)
- {
- m_easySetupStatusCb(easySetupStatus);
- }
- else
- {
- m_easySetupStatusCb(nullptr);
+ OIC_LOG_V(DEBUG,ES_REMOTE_ENROLLEE_TAG,"ProvStatus = %d", provStatus->getESResult());
+ m_currentESState = CurrentESState::ES_PROVISIONED;
}
}
+ m_dataProvStatusCb(provStatus);
return;
+ }
- FAILURE:
-
- easySetupStatus = std::make_shared< EasySetupStatus >(DEVICE_NOT_PROVISIONED,
- m_ProvConfig);
+ void RemoteEnrollee::initRemoteEnrollee(InitRemoteEnrolleeStatusCb callback)
+ {
+ ESResult result = ES_ERROR;
- if (easySetupStatus)
- {
- m_easySetupStatusCb(easySetupStatus);
- }
- else
+ if(!callback)
{
- m_easySetupStatusCb(nullptr);
+ throw ESInvalidParameterException("Callback is empty");
}
- return;
- }
- void RemoteEnrollee::startProvisioning()
- {
- OIC_LOG(DEBUG,ES_REMOTE_ENROLLEE_TAG,"Entering startProvisioning");
- if (m_remoteResource == nullptr)
+ m_initRemoteEnrolleeStatusCb = callback;
+
+ if (m_remoteResource != nullptr)
{
- throw ESBadRequestException ("Device not created");
+ throw ESBadRequestException ("Already created");
}
- ESResult result = ES_ERROR;
+ InitRemoteEnrolleeStatusCb initRemoteEnrolleeStatusCb = std::bind(
+ &RemoteEnrollee::InitRemoteEnrolleeStatusHandler, this, std::placeholders::_1);
+ m_remoteResource->registerInitRemoteEnrolleeStatusCallback(initRemoteEnrolleeStatusCb);
result = m_remoteResource->constructResourceObject();
"Failed to create device using constructResourceObject");
throw ESBadRequestException ("Device not created");
}
+ }
- m_currentESState = CurrentESState::ES_ONBOARDED;
-
+ void RemoteEnrollee::startSecurityProvisioning(EnrolleeSecStatusCb callback)
+ {
#ifdef __WITH_DTLS__
+
+ m_enrolleeSecStatusCb = callback;
+
if (m_isSecured && m_currentESState < CurrentESState::ES_OWNED)
{
EnrolleeSecStatusCb securityProvStatusCb = std::bind(
"performOwnershipTransfer returned : %d",
easySetupState);
OIC_LOG(DEBUG,ES_REMOTE_ENROLLEE_TAG,"Before ProvisionEnrollee");
-
- RemoteEnrolleeResource::ProvStatusCb provStatusCb = std::bind(
- &RemoteEnrollee::provisioningStatusHandler,
- this, std::placeholders::_1);
-
- m_remoteResource->registerProvStatusCallback(provStatusCb);
- m_remoteResource->provisionEnrollee();
}
}
catch (OCException & e)
return ;
}
}
-#else
+#endif
+ }
+
+ void RemoteEnrollee::getCapabilityData(RequestCapabilityStatusCb callback)
+ {
+ ESResult result = ES_ERROR;
+
+ if(!callback)
+ {
+ throw ESInvalidParameterException("Callback is empty");
+ }
+
+ m_requestCapabilityStatusCb = callback;
+
+ if (m_remoteResource == nullptr)
+ {
+ throw ESBadRequestException ("Device not created");
+ }
+
+ RequestCapabilityStatusCb requestCapabilityStatusCb = std::bind(
+ &RemoteEnrollee::requestCapabilityStatusHandler, this, std::placeholders::_1);
+ m_remoteResource->registerCapabilityStatusCallback(requestCapabilityStatusCb);
+ m_remoteResource->getCapabilityData();
+ }
+
+ void RemoteEnrollee::startDataProvisioning(const ProvConfig& dataProvConfig, DataProvStatusCb callback)
+ {
OIC_LOG(DEBUG,ES_REMOTE_ENROLLEE_TAG,"Before ProvisionEnrollee");
- RemoteEnrolleeResource::ProvStatusCb provStatusCb = std::bind(
- &RemoteEnrollee::provisioningStatusHandler, this, std::placeholders::_1);
+ m_ProvConfig = dataProvConfig;
+ m_dataProvStatusCb = callback;
+
+ DataProvStatusCb dataProvStatusCb = std::bind(
+ &RemoteEnrollee::dataProvisioningStatusHandler, this, std::placeholders::_1);
- m_remoteResource->registerProvStatusCallback(provStatusCb);
+ m_remoteResource->registerProvStatusCallback(dataProvStatusCb);
m_remoteResource->provisionEnrollee();
-#endif
}
void RemoteEnrollee::stopProvisioning()