Commit 59b33701 authored by sy01.youn's avatar sy01.youn Committed by Madan Lanka

[Enrollee] Implement ESInitEnrollee() API

1. Add new data structure
  : ResourceMask, ESProvisioningCallbacks, ESWiFiProvData, ESDevConfProvData, ESCloudProvData
2. Update ResourceHandler's post handling
  : update wifi data, dev conf data, cloud prov data which are delivered to easysetup callback

* Need to develop sample app. (enrollee side)
* Need to erase unused code

Change-Id: Iaae6776f476566b9fd3dd0d883843d131d755630
Signed-off-by: default avatarsy01.youn <sy01.youn@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/8805Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: default avatarMadan Lanka <lanka.madan@samsung.com>
parent 1c51f672
......@@ -42,27 +42,28 @@ extern "C" {
*/
typedef void (*ESEnrolleeEventCallback)(ESResult esResult, ESEnrolleeState enrolleeState);
typedef struct
{
void (*WiFiProvCb) (ESWiFiProvData *);
void (*DevConfProvCb) (ESDevConfProvData *);
void (*CloudDataProvCb) (ESCloudProvData *);
} ESProvisioningCallbacks;
/**
* This function Initializes the EasySetup. This API must be called prior to invoking any other API
*
* @param networkType NetworkType on which OnBoarding has to be performed.
* @param ssid SSID of the target SoftAP network to which the Enrollee is connecting.
* @param passwd Password of the target SoftAP network to which the Enrollee is
* connecting
* @param isSecured True if the Enrollee is operating in secured mode.
* @param eventCallback ESEnrolleeEventCallback for for updating the Enrollee OnBoarding status
* result to the application
* @param resourceMask Provisining Resource Type which application wants to make
* ES_WIFI_RESOURCE = 0x01,
* ES_CLOUD_RESOURCE = 0x02,
* ES_DEVCONF_RESOURCE = 0x04
* @param callbacks ESProvisioningCallbacks for updating Provisioning Resources' data to the application
* @return ::ES_OK on success, some other value upon failure.
*/
ESResult ESInitEnrollee(OCConnectivityType networkType, const char *ssid, const char *passwd,
bool isSecured, ESEnrolleeEventCallback eventCallback);
ESResult ESInitEnrollee(bool isSecured, ESResourceMask resourceMask, ESProvisioningCallbacks callbacks);
/**
* This function performs initialization of Provisioning and Network resources needed for EasySetup
* process.
* @return ::ES_OK on success, some other value upon failure.
*/
ESResult ESInitProvisioning();
/**
* This function performs termination of Provisioning and Network resources.
......
......@@ -25,8 +25,6 @@
*/
#include "easysetup.h"
//#include "softap.h"
//#include "onboarding.h"
#include "logger.h"
#include "resourcehandler.h"
#include "easysetupcallbacks.h"
......@@ -40,117 +38,126 @@
//-----------------------------------------------------------------------------
// Private variables
//-----------------------------------------------------------------------------
static bool gIsSecured = false;
/**
* @var gTargetSsid
* @brief Target SSID of the Soft Access point to which the device has to connect
*/
static char gTargetSsid[MAXSSIDLEN];
static ESProvisioningCallbacks gESProvisioningCb;
/**
* @var gTargetPass
* @brief Password of the target access point to which the device has to connect
*/
static char gTargetPass[MAXNETCREDLEN];
/**
* @var gEnrolleeStatusCb
* @brief Fucntion pointer holding the callback for intimation of EasySetup Enrollee status callback
*/
static ESEnrolleeEventCallback gEnrolleeStatusCb = NULL;
void ESWiFiRsrcCallback(ESResult esResult, ESWiFiProvData *eventData)
{
OIC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "ESWiFiRsrcCallback IN");
/**
* @var gIsSecured
* @brief Variable to check if secure mode is enabled or not.
*/
static bool gIsSecured = false;
if(esResult != ES_OK)
{
OIC_LOG_V(ERROR, ES_ENROLLEE_TAG, "ESWiFiRsrcCallback Error Occured");
return;
}
void ESOnboardingCallback(ESResult esResult)
{
OIC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "ESOnboardingCallback with result = %d", esResult);
if(esResult == ES_OK)
{
gEnrolleeStatusCb(esResult, ES_ON_BOARDED_STATE);
}
else
{
OIC_LOG_V(DEBUG, ES_ENROLLEE_TAG,
"Onboarding is failed callback result is = %d", esResult);
gEnrolleeStatusCb(esResult, ES_INIT_STATE);
}
// deliver data to ESProvisioningCallbacks
if(gESProvisioningCb.WiFiProvCb != NULL)
{
gESProvisioningCb.WiFiProvCb(eventData);
}
else
{
OIC_LOG_V(ERROR, ES_ENROLLEE_TAG, "WiFiProvCb is NULL");
return;
}
}
void ESProvisioningCallback(ESResult esResult)
void ESCloudRsrcCallback(ESResult esResult, ESCloudProvData *eventData)
{
OIC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "ESProvisioningCallback with result = %d", esResult);
OIC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "ESCloudRsrcCallback IN");
if (esResult == ES_RECVTRIGGEROFPROVRES)
if(esResult != ES_OK)
{
GetTargetNetworkInfoFromProvResource(gTargetSsid, gTargetPass);
gEnrolleeStatusCb(ES_OK, ES_PROVISIONED_STATE);
OIC_LOG(DEBUG, ES_ENROLLEE_TAG, "Connecting with target network");
OIC_LOG_V(ERROR, ES_ENROLLEE_TAG, "ESCloudRsrcCallback Error Occured");
return;
}
// Connecting/onboarding to target network
//ConnectToWiFiNetwork(gTargetSsid, gTargetPass, ESOnboardingCallbackTargetNet);
if(gESProvisioningCb.CloudDataProvCb != NULL)
{
gESProvisioningCb.CloudDataProvCb(eventData);
}
else
{
OIC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Provisioning is failed callback result is = %d", esResult);
// Resetting Enrollee to ONBOARDED_STATE as Enrollee is alreday onboarded in previous step
gEnrolleeStatusCb(ES_OK, ES_ON_BOARDED_STATE);
OIC_LOG_V(ERROR, ES_ENROLLEE_TAG, "CloudDataProvCb is NULL");
return;
}
}
void ESOnboardingCallbackTargetNet(ESResult esResult)
void ESDevconfRsrcallback(ESResult esResult, ESDevConfProvData *eventData)
{
OIC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "ESOnboardingCallback on target network with result = %d",
esResult);
if(esResult == ES_OK)
OIC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "ESDevconfRsrcallback IN");
if(esResult != ES_OK)
{
OIC_LOG_V(ERROR, ES_ENROLLEE_TAG, "ESDevconfRsrcallback Error Occured");
return;
}
if(gESProvisioningCb.DevConfProvCb != NULL)
{
gEnrolleeStatusCb(esResult, ES_ON_BOARDED_TARGET_NETWORK_STATE);
gESProvisioningCb.DevConfProvCb(eventData);
}
else
{
OIC_LOG_V(DEBUG, ES_ENROLLEE_TAG,
"Onboarding is failed on target network and callback result is = %d", esResult);
// Resetting Enrollee state to the ES_PROVISIONED_STATE
// as device is already being provisioned with target network creds.
gEnrolleeStatusCb(esResult, ES_PROVISIONED_STATE);
OIC_LOG_V(ERROR, ES_ENROLLEE_TAG, "DevConfProvCb is NULL");
return;
}
}
ESResult ESInitEnrollee(OCConnectivityType networkType, const char *ssid, const char *passwd,
bool isSecured,
ESEnrolleeEventCallback cb)
ESResult ESInitEnrollee(bool isSecured, ESResourceMask resourceMask, ESProvisioningCallbacks callbacks)
{
OIC_LOG(INFO, ES_ENROLLEE_TAG, "ESInitEnrollee IN");
if(!ESEnrolleeValidateParam(networkType,ssid,passwd,cb))
{
OIC_LOG(ERROR, ES_ENROLLEE_TAG,
"ESInitEnrollee::Stopping Easy setup due to invalid parameters");
return ES_ERROR;
}
//Init callback
gEnrolleeStatusCb = cb;
gIsSecured = isSecured;
// TODO : This onboarding state has to be set by lower layer, as they better
// knows when actually on-boarding started.
cb(ES_ERROR,ES_ON_BOARDING_STATE);
/*
OIC_LOG(INFO, ES_ENROLLEE_TAG, "received callback");
OIC_LOG(INFO, ES_ENROLLEE_TAG, "onboarding now..");
if((resourceMask & ES_WIFI_RESOURCE) == ES_WIFI_RESOURCE)
{
if(callbacks.WiFiProvCb != NULL)
{
gESProvisioningCb.WiFiProvCb = callbacks.WiFiProvCb;
RegisterWifiRsrcEventCallBack(ESWiFiRsrcCallback);
}
else
{
OIC_LOG(ERROR, ES_ENROLLEE_TAG, "WiFiProvCb NULL");
return ES_ERROR;
}
}
if((resourceMask & ES_DEVCONF_RESOURCE) == ES_DEVCONF_RESOURCE)
{
if(callbacks.DevConfProvCb != NULL)
{
gESProvisioningCb.DevConfProvCb = callbacks.DevConfProvCb;
RegisterDevConfRsrcEventCallBack(ESDevconfRsrcallback);
}
else
{
OIC_LOG(ERROR, ES_ENROLLEE_TAG, "DevConfProvCb NULL");
return ES_ERROR;
}
}
if((resourceMask & ES_CLOUD_RESOURCE) == ES_CLOUD_RESOURCE)
{
if(callbacks.DevConfProvCb != NULL)
{
gESProvisioningCb.CloudDataProvCb = callbacks.CloudDataProvCb;
RegisterCloudRsrcEventCallBack(ESCloudRsrcCallback);
}
else
{
OIC_LOG(ERROR, ES_ENROLLEE_TAG, "CloudDataProvCb NULL");
return ES_ERROR;
}
}
if(!ESOnboard(ssid, passwd, ESOnboardingCallback))
if(CreateEasySetupResources(gIsSecured, resourceMask) != OC_STACK_OK)
{
OIC_LOG(ERROR, ES_ENROLLEE_TAG, "ESInitEnrollee::On-boarding failed");
cb(ES_ERROR, ES_INIT_STATE);
// TODO : Error Handling
return ES_ERROR;
}
*/
OIC_LOG(INFO, ES_ENROLLEE_TAG, "ESInitEnrollee OUT");
return ES_OK;
......@@ -171,22 +178,6 @@ ESResult ESTerminateEnrollee()
return ES_OK;
}
ESResult ESInitProvisioning()
{
OIC_LOG(INFO, ES_ENROLLEE_TAG, "ESInitProvisioning <<IN>>");
if (CreateEasySetupResources(gIsSecured) != OC_STACK_OK)
{
OIC_LOG(ERROR, ES_ENROLLEE_TAG, "CreateProvisioningResource error");
return ES_ERROR;
}
RegisterResourceEventCallBack(ESProvisioningCallback);
OIC_LOG(INFO, ES_ENROLLEE_TAG, "ESInitProvisioning <<OUT>>");
return ES_RESOURCECREATED;
}
static bool ESEnrolleeValidateParam(OCConnectivityType networkType, const char *ssid,
const char *passwd, ESEnrolleeEventCallback cb)
{
......
......@@ -44,6 +44,28 @@ static WiFiResource gWiFiResource;
static CloudResource gCloudResource;
static DevConfResource gDevConfResource;
/**
* @var gWiFiData
* @brief Structure for holding the target information required to
* connect to the target network
*/
static ESWiFiProvData gWiFiData;
/**
* @var gDevConfData
* @brief Structure for holding the device information
*/
static ESDevConfProvData gDevConfData;
/**
* @var gCloudData
* @brief Structure for holding the cloud information required to
* connect to CI Server
*/
static ESCloudProvData gCloudData;
//-----------------------------------------------------------------------------
// Private internal function prototypes
//-----------------------------------------------------------------------------
......@@ -54,22 +76,42 @@ OCEntityHandlerResult ProcessGetRequest(OCEntityHandlerRequest *ehRequest, OCRep
OCEntityHandlerResult ProcessPutRequest(OCEntityHandlerRequest *ehRequest, OCRepPayload** payload);
OCEntityHandlerResult ProcessPostRequest(OCEntityHandlerRequest *ehRequest, OCRepPayload** payload);
void updateProvResource(OCEntityHandlerRequest* ehRequest, OCRepPayload* input);
void updateWiFiResource(OCEntityHandlerRequest* ehRequest, OCRepPayload* input);
void updateCloudResource(OCEntityHandlerRequest* ehRequest, OCRepPayload* input);
void updateDevConfResource(OCEntityHandlerRequest* ehRequest, OCRepPayload* input);
void updateWiFiResource(OCRepPayload* input);
void updateCloudResource(OCRepPayload* input);
void updateDevConfResource(OCRepPayload* input);
ESEnrolleeResourceEventCallback gNetworkInfoProvEventCb = NULL;
ESWiFiCB gWifiRsrcEvtCb = NULL;
ESCloudCB gCloudRsrcEvtCb = NULL;
ESDevConfCB gDevConfRsrcEvtCb = NULL;
void RegisterResourceEventCallBack(ESEnrolleeResourceEventCallback cb)
void RegisterWifiRsrcEventCallBack(ESWiFiCB cb)
{
gNetworkInfoProvEventCb = cb;
gWifiRsrcEvtCb = cb;
}
void RegisterCloudRsrcEventCallBack(ESCloudCB cb)
{
gCloudRsrcEvtCb = cb;
}
void RegisterDevConfRsrcEventCallBack(ESDevConfCB cb)
{
gDevConfRsrcEvtCb = cb;
}
void UnRegisterResourceEventCallBack()
{
if (gNetworkInfoProvEventCb)
if (gWifiRsrcEvtCb)
{
gNetworkInfoProvEventCb = NULL;
gWifiRsrcEvtCb = NULL;
}
if (gCloudRsrcEvtCb)
{
gCloudRsrcEvtCb = NULL;
}
if (gDevConfRsrcEvtCb)
{
gDevConfRsrcEvtCb = NULL;
}
}
......@@ -212,104 +254,151 @@ OCStackResult initDevConfResource(bool isSecured)
}
void updateProvResource(OCEntityHandlerRequest *ehRequest, OCRepPayload* input)
void updateProvResource(OCEntityHandlerRequest* ehRequest, OCRepPayload* input)
{
OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.status %lld", gProvResource.status);
bool trigger;
if (OCRepPayloadGetPropBool(input, OC_RSRVD_ES_TRIGGER, &trigger))
{
// Triggering
gProvResource.trigger = trigger;
}
if(ehRequest->query)
{
if(strstr(ehRequest->query, OC_RSRVD_INTERFACE_BATCH))
{// When Provisioning resource has a POST with BatchInterface
updateCloudResource(ehRequest, input);
updateWiFiResource(ehRequest, input);
updateDevConfResource(ehRequest, input);
{
// When Provisioning resource has a POST with BatchInterface
updateCloudResource(input);
updateWiFiResource(input);
updateDevConfResource(input);
}
}
}
void updateWiFiResource(OCEntityHandlerRequest* ehRequest, OCRepPayload* input)
void updateWiFiResource(OCRepPayload* input)
{
(void) ehRequest;
char* ssid;
char* ssid = NULL;
if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_SSID, &ssid))
{
OICStrcpy(gWiFiResource.ssid, sizeof(gWiFiResource.ssid), ssid);
OIC_LOG(INFO, ES_RH_TAG, "got ssid");
OICStrcpy(gWiFiData.ssid, sizeof(gWiFiData.ssid), ssid);
OIC_LOG_V(INFO, ES_RH_TAG, "gWiFiResource.ssid : %s", gWiFiResource.ssid);
}
char* cred;
char* cred = NULL;
if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_CRED, &cred))
{
OICStrcpy(gWiFiResource.cred, sizeof(gWiFiResource.cred), cred);
OICStrcpy(gWiFiData.pwd, sizeof(gWiFiData.pwd), cred);
OIC_LOG_V(INFO, ES_RH_TAG, "gWiFiResource.cred %s", gWiFiResource.cred);
}
int64_t authType;
int64_t authType = -1;
if (OCRepPayloadGetPropInt(input, OC_RSRVD_ES_AUTHTYPE, &authType))
{
gWiFiResource.authType = authType;
gWiFiData.authtype = gWiFiResource.authType;
OIC_LOG_V(INFO, ES_RH_TAG, "gWiFiResource.authType %u", gWiFiResource.authType);
}
int64_t encType;
int64_t encType = -1;
if (OCRepPayloadGetPropInt(input, OC_RSRVD_ES_ENCTYPE, &encType))
{
gWiFiResource.encType = encType;
gWiFiData.enctype = gWiFiResource.encType;
OIC_LOG_V(INFO, ES_RH_TAG, "gWiFiResource.encType %u", gWiFiResource.encType);
}
if(ssid || cred || authType!= -1 || encType != -1)
{
OIC_LOG(INFO, ES_RH_TAG, "Send WiFiRsrc Callback To ES");
// TODO : Need to check appropriateness of gWiFiData
if(gWifiRsrcEvtCb != NULL)
{
gWifiRsrcEvtCb(ES_OK, &gWiFiData);
}
else
{
OIC_LOG(ERROR, ES_RH_TAG, "gWifiRsrcEvtCb is NULL");
}
}
}
void updateCloudResource(OCEntityHandlerRequest* ehRequest, OCRepPayload* input)
void updateCloudResource(OCRepPayload* input)
{
(void) ehRequest;
char *authCode;
char *authCode = NULL;
if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_AUTHCODE, &authCode))
{
OICStrcpy(gCloudResource.authCode, sizeof(gCloudResource.authCode), authCode);
OICStrcpy(gCloudData.authCode, sizeof(gCloudData.authCode), authCode);
OIC_LOG_V(INFO, ES_RH_TAG, "gCloudResource.authCode %s", gCloudResource.authCode);
}
char *authProvider;
char *authProvider = NULL;
if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_AUTHPROVIDER, &authProvider))
{
OICStrcpy(gCloudResource.authProvider, sizeof(gCloudResource.authProvider), authProvider);
OICStrcpy(gCloudData.authProvider, sizeof(gCloudData.authProvider), authProvider);
OIC_LOG_V(INFO, ES_RH_TAG, "gCloudResource.authServerUrl %s", gCloudResource.authProvider);
}
char *ciServer;
char *ciServer = NULL;
if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_CISERVER, &ciServer))
{
OICStrcpy(gCloudResource.ciServer, sizeof(gCloudResource.ciServer), ciServer);
OICStrcpy(gCloudData.ciServer, sizeof(gCloudData.ciServer), ciServer);
OIC_LOG_V(INFO, ES_RH_TAG, "gCloudResource.ciServer %s", gCloudResource.ciServer);
}
if(authCode || authProvider || ciServer)
{
OIC_LOG(INFO, ES_RH_TAG, "Send CloudRsrc Callback To ES");
// TODO : Need to check appropriateness of gCloudData
if(gCloudRsrcEvtCb != NULL)
{
gCloudRsrcEvtCb(ES_OK, &gCloudData);
}
else
{
OIC_LOG(ERROR, ES_RH_TAG, "gCloudRsrcEvtCb is NULL");
}
}
}
void updateDevConfResource(OCEntityHandlerRequest* ehRequest, OCRepPayload* input)
void updateDevConfResource(OCRepPayload* input)
{
(void) ehRequest;
char *country;
char *country = NULL;
if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_AUTHCODE, &country))
{
OICStrcpy(gDevConfResource.country, sizeof(gDevConfResource.country), country);
OICStrcpy(gDevConfData.country, sizeof(gDevConfData.country), country);
OIC_LOG_V(INFO, ES_RH_TAG, "gDevConfResource.country %s", gDevConfResource.country);
}
char *language;
char *language = NULL;
if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_AUTHPROVIDER, &language))
{
OICStrcpy(gDevConfResource.language, sizeof(gDevConfResource.language), language);
OICStrcpy(gDevConfData.language, sizeof(gDevConfData.language), language);
OIC_LOG_V(INFO, ES_RH_TAG, "gDevConfResource.language %s", gDevConfResource.language);
}
if(country || language)
{
OIC_LOG(INFO, ES_RH_TAG, "Send DevConfRsrc Callback To ES");
// TODO : Need to check appropriateness of gDevConfData
if(gDevConfRsrcEvtCb != NULL)
{
gDevConfRsrcEvtCb(ES_OK, &gDevConfData);
}
else
{
OIC_LOG(ERROR, ES_RH_TAG, "gDevConfRsrcEvtCb is NULL");
}
}
}
OCRepPayload* constructResponseOfWiFi(OCEntityHandlerRequest *ehRequest)
OCRepPayload* constructResponseOfWiFi()
{
(void) ehRequest;
OCRepPayload* payload = OCRepPayloadCreate();
if (!payload)
{
......@@ -321,22 +410,21 @@ OCRepPayload* constructResponseOfWiFi(OCEntityHandlerRequest *ehRequest)
OCRepPayloadSetUri(payload, OC_RSRVD_ES_URI_WIFI);
size_t dimensions[MAX_REP_ARRAY_DEPTH] = {gWiFiResource.numMode, 0, 0};
OCRepPayloadSetIntArray(payload, OC_RSRVD_ES_SUPPORTEDWIFIMODE, gWiFiResource.supportedMode, dimensions);
OCRepPayloadSetIntArray(payload, OC_RSRVD_ES_SUPPORTEDWIFIMODE, (int64_t *)gWiFiResource.supportedMode, dimensions);
OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_SUPPORTEDWIFIFREQ, gWiFiResource.supportedFreq);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_SSID, gWiFiResource.ssid);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_CRED, gWiFiResource.cred);
OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_AUTHTYPE, gWiFiResource.authType);
OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_ENCTYPE, gWiFiResource.encType);
OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_AUTHTYPE, (int) gWiFiResource.authType);
OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_ENCTYPE, (int) gWiFiResource.encType);
printf("%s\n", gWiFiResource.ssid);
return payload;
}
OCRepPayload* constructResponseOfCloud(OCEntityHandlerRequest *ehRequest)
OCRepPayload* constructResponseOfCloud()
{
(void) ehRequest;
OCRepPayload* payload = OCRepPayloadCreate();
if (!payload)
{
......@@ -353,9 +441,8 @@ OCRepPayload* constructResponseOfCloud(OCEntityHandlerRequest *ehRequest)
return payload;
}
OCRepPayload* constructResponseOfDevConf(OCEntityHandlerRequest *ehRequest)
OCRepPayload* constructResponseOfDevConf()
{
(void) ehRequest;
OCRepPayload* payload = OCRepPayloadCreate();
if (!payload)
{
......@@ -390,15 +477,15 @@ OCRepPayload* constructResponseOfProv(OCEntityHandlerRequest *ehRequest)
{
if(strstr(ehRequest->query, OC_RSRVD_INTERFACE_BATCH))
{// When Provisioning resource has a GET with BatchInterface
payload->next = constructResponseOfWiFi(ehRequest);
payload->next = constructResponseOfWiFi();
if(payload->next)
payload->next->next = constructResponseOfCloud(ehRequest);
payload->next->next = constructResponseOfCloud();
else
return payload;
if(payload->next->next)
payload->next->next->next = constructResponseOfDevConf(ehRequest);
payload->next->next->next = constructResponseOfDevConf();
else
return payload;
}
......@@ -408,42 +495,95 @@ OCRepPayload* constructResponseOfProv(OCEntityHandlerRequest *ehRequest)
}
OCStackResult CreateEasySetupResources(bool isSecured)
OCStackResult CreateEasySetupResources(bool isSecured, ESResourceMask resourceMask)
{
OCStackResult res = OC_STACK_ERROR;
bool maskFlag = false;
res = initProvResource(isSecured);
if(res)
if(res != OC_STACK_OK)
{
// TODO: destroy logic will be added
OIC_LOG_V(ERROR, ES_RH_TAG, "initProvResource result: %s", getResult(res));
return res;
}
res = initWiFiResource(isSecured);
if(res)
if((resourceMask & ES_WIFI_RESOURCE) == ES_WIFI_RESOURCE)
{
// TODO: destroy logic will be added
return res;
maskFlag = true;
res = initWiFiResource(isSecured);
if(res != OC_STACK_OK)