Commit 77e1fddc authored by Jihun Ha's avatar Jihun Ha Committed by Madan Lanka

Add an API for handling user-specific properties in Enrollee side

User can register two function pointers to easy setup stack for handling
user-specific properties for incomming and outgoing payload if needed.
This API helps the easy setup code not changed even user wants to deliver
more properties in addition to easy setup properties in OCF spec.

Change-Id: I4e543d0abfbd6820db055d763421997cf39f5cab
Signed-off-by: default avatarJihun Ha <jihun.ha@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/9837Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: default avatarMadan Lanka <lanka.madan@samsung.com>
parent 193ab8a4
......@@ -24,6 +24,8 @@
#include "escommon.h"
#include "ocpayload.h"
/**
* @file
*
......@@ -34,16 +36,10 @@
extern "C" {
#endif // __cplusplus
/*
* Callback function for updating the Enrollee OnBoarding and Provisioning status result
* to the application
*
* @param esResult ESResult provides the current state of the Enrollee Device
/**
* A set of functions pointers for callback functions which are called after provisioning data is
* received from Mediator.
*/
typedef void (*ESEnrolleeEventCallback)(ESResult esResult, ESEnrolleeState enrolleeState);
typedef struct
{
void (*WiFiProvCb) (ESWiFiProvData *);
......@@ -51,6 +47,27 @@ typedef struct
void (*CloudDataProvCb) (ESCloudProvData *);
} ESProvisioningCallbacks;
/**
* A function pointer for registering a user-defined function to set user-specific properties to a
* response going back to a client.
* @param payload Represents a response. You can set a specific value with specific property key
* to the payload. If a client receives the response and know the property key, then it can
* extract the value.
* @param resourceType Used to distinguish which resource the received property belongs to.
*/
typedef void (*ESWriteUserdataCb)(OCRepPayload* payload, char* resourceType);
/**
* A function pointer for registering a user-defined function to parse user-specific properties from
* received POST request.
* @param payload Represents a received POST request. If you know user-specific property key,
* then you can extract a corresponding value if it exists.
* @param resourceType Used to distinguish which resource the received property belongs to
* @param userdata User-specific data you want to deliver to desired users, i.e. application.
* The user should know a data structure of passed userdata.
*/
typedef void (*ESReadUserdataCb)(OCRepPayload* payload, char* resourceType, void* userdata);
/**
* This function Initializes the EasySetup. This API must be called prior to invoking any other API
*
......@@ -105,6 +122,22 @@ ESResult ESSetErrorCode(ESErrorCode esErrCode);
*/
ESResult ESTerminateEnrollee();
/**
* This function is to set two function pointer to handle user-specific properties in in-comming
* POST request and to out-going response for GET or POST request.
* If you register certain functions with this API, you have to handle OCRepPayload structure to
* set and get properties you want.
*
* @param readCb a callback for parsing properties from POST request
* @param writeCb a callback for putting properties to a response to be sent
*
* @return ::ES_OK on success, some other value upon failure.
*
* @see ESReadUserdataCb
* @see ESWriteUserdataCb
*/
ESResult ESSetCallbackForUserdata(ESReadUserdataCb readCb, ESWriteUserdataCb writeCb);
#ifdef __cplusplus
}
#endif // __cplusplus
......
......@@ -256,3 +256,15 @@ ESResult ESTerminateEnrollee()
OIC_LOG(ERROR, ES_ENROLLEE_TAG, "ESTerminateEnrollee success");
return ES_OK;
}
ESResult ESSetCallbackForUserdata(ESReadUserdataCb readCb, ESWriteUserdataCb writeCb)
{
if(!readCb && !writeCb)
{
OIC_LOG(INFO, ES_ENROLLEE_TAG, "Both of callbacks for user data are null");
return ES_ERROR;
}
SetCallbackForUserData(readCb, writeCb);
return ES_OK;
}
\ No newline at end of file
......@@ -20,10 +20,9 @@
#include "resourcehandler.h"
#include <stdio.h>
#include "ocpayload.h"
#include "oic_string.h"
#include "oic_malloc.h"
/**
* @var ES_RH_TAG
......@@ -44,28 +43,6 @@ 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
//-----------------------------------------------------------------------------
......@@ -84,6 +61,21 @@ ESWiFiCB gWifiRsrcEvtCb = NULL;
ESCloudCB gCloudRsrcEvtCb = NULL;
ESDevConfCB gDevConfRsrcEvtCb = NULL;
ESReadUserdataCb gReadUserdataCb = NULL;
ESWriteUserdataCb gWriteUserdataCb = NULL;
ESResult SetCallbackForUserData(ESReadUserdataCb readCb, ESWriteUserdataCb writeCb)
{
if(!readCb && !writeCb)
{
OIC_LOG(INFO, ES_RH_TAG, "Both of callbacks for user data are null");
return ES_ERROR;
}
gReadUserdataCb = readCb;
gWriteUserdataCb = writeCb;
return ES_OK;
}
void RegisterWifiRsrcEventCallBack(ESWiFiCB cb)
{
gWifiRsrcEvtCb = cb;
......@@ -273,11 +265,18 @@ void updateProvResource(OCEntityHandlerRequest* ehRequest, OCRepPayload* input)
void updateWiFiResource(OCRepPayload* input)
{
ESWiFiProvData* wiFiData = (ESWiFiProvData*)OICMalloc(sizeof(ESWiFiProvData));
if(wiFiData == NULL)
{
OIC_LOG(DEBUG, ES_RH_TAG, "OICMalloc is failed");
}
wiFiData->userdata = NULL;
char* ssid = NULL;
if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_SSID, &ssid))
{
OICStrcpy(gWiFiResource.ssid, sizeof(gWiFiResource.ssid), ssid);
OICStrcpy(gWiFiData.ssid, sizeof(gWiFiData.ssid), ssid);
OICStrcpy(wiFiData->ssid, sizeof(wiFiData->ssid), ssid);
OIC_LOG_V(INFO, ES_RH_TAG, "gWiFiResource.ssid : %s", gWiFiResource.ssid);
}
......@@ -285,7 +284,7 @@ void updateWiFiResource(OCRepPayload* input)
if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_CRED, &cred))
{
OICStrcpy(gWiFiResource.cred, sizeof(gWiFiResource.cred), cred);
OICStrcpy(gWiFiData.pwd, sizeof(gWiFiData.pwd), cred);
OICStrcpy(wiFiData->pwd, sizeof(wiFiData->pwd), cred);
OIC_LOG_V(INFO, ES_RH_TAG, "gWiFiResource.cred %s", gWiFiResource.cred);
}
......@@ -293,7 +292,7 @@ void updateWiFiResource(OCRepPayload* input)
if (OCRepPayloadGetPropInt(input, OC_RSRVD_ES_AUTHTYPE, &authType))
{
gWiFiResource.authType = authType;
gWiFiData.authtype = gWiFiResource.authType;
wiFiData->authtype = gWiFiResource.authType;
OIC_LOG_V(INFO, ES_RH_TAG, "gWiFiResource.authType %u", gWiFiResource.authType);
}
......@@ -301,10 +300,13 @@ void updateWiFiResource(OCRepPayload* input)
if (OCRepPayloadGetPropInt(input, OC_RSRVD_ES_ENCTYPE, &encType))
{
gWiFiResource.encType = encType;
gWiFiData.enctype = gWiFiResource.encType;
wiFiData->enctype = gWiFiResource.encType;
OIC_LOG_V(INFO, ES_RH_TAG, "gWiFiResource.encType %u", gWiFiResource.encType);
}
if(gReadUserdataCb)
gReadUserdataCb(input, OC_RSRVD_ES_RES_TYPE_WIFI, wiFiData->userdata);
if(ssid || cred || authType!= -1 || encType != -1)
{
OIC_LOG(INFO, ES_RH_TAG, "Send WiFiRsrc Callback To ES");
......@@ -312,7 +314,7 @@ void updateWiFiResource(OCRepPayload* input)
// TODO : Need to check appropriateness of gWiFiData
if(gWifiRsrcEvtCb != NULL)
{
gWifiRsrcEvtCb(ES_OK, &gWiFiData);
gWifiRsrcEvtCb(ES_OK, wiFiData);
}
else
{
......@@ -320,15 +322,23 @@ void updateWiFiResource(OCRepPayload* input)
}
}
OICFree(wiFiData);
}
void updateCloudResource(OCRepPayload* input)
{
ESCloudProvData* cloudData = (ESCloudProvData*)OICMalloc(sizeof(ESCloudProvData));
if(cloudData == NULL)
{
OIC_LOG(DEBUG, ES_RH_TAG, "OICMalloc is failed");
}
cloudData->userdata = NULL;
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);
OICStrcpy(cloudData->authCode, sizeof(cloudData->authCode), authCode);
OIC_LOG_V(INFO, ES_RH_TAG, "gCloudResource.authCode %s", gCloudResource.authCode);
}
......@@ -336,7 +346,7 @@ void updateCloudResource(OCRepPayload* input)
if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_AUTHPROVIDER, &authProvider))
{
OICStrcpy(gCloudResource.authProvider, sizeof(gCloudResource.authProvider), authProvider);
OICStrcpy(gCloudData.authProvider, sizeof(gCloudData.authProvider), authProvider);
OICStrcpy(cloudData->authProvider, sizeof(cloudData->authProvider), authProvider);
OIC_LOG_V(INFO, ES_RH_TAG, "gCloudResource.authServerUrl %s", gCloudResource.authProvider);
}
......@@ -344,17 +354,12 @@ void updateCloudResource(OCRepPayload* input)
if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_CISERVER, &ciServer))
{
OICStrcpy(gCloudResource.ciServer, sizeof(gCloudResource.ciServer), ciServer);
OICStrcpy(gCloudData.ciServer, sizeof(gCloudData.ciServer), ciServer);
OICStrcpy(cloudData->ciServer, sizeof(cloudData->ciServer), ciServer);
OIC_LOG_V(INFO, ES_RH_TAG, "gCloudResource.ciServer %s", gCloudResource.ciServer);
}
char *serverID = NULL;
if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_SERVERID, &serverID))
{
OICStrcpy(gCloudResource.serverID, sizeof(gCloudResource.serverID), serverID);
OICStrcpy(gCloudData.serverID, sizeof(gCloudData.serverID), serverID);
OIC_LOG_V(INFO, ES_RH_TAG, "gCloudResource.serverID %s", gCloudResource.serverID);
}
if(gReadUserdataCb)
gReadUserdataCb(input, OC_RSRVD_ES_RES_TYPE_CLOUDSERVER, cloudData->userdata);
if(authCode || authProvider || ciServer)
{
......@@ -363,22 +368,31 @@ void updateCloudResource(OCRepPayload* input)
// TODO : Need to check appropriateness of gCloudData
if(gCloudRsrcEvtCb != NULL)
{
gCloudRsrcEvtCb(ES_OK, &gCloudData);
gCloudRsrcEvtCb(ES_OK, cloudData);
}
else
{
OIC_LOG(ERROR, ES_RH_TAG, "gCloudRsrcEvtCb is NULL");
}
}
OICFree(cloudData);
}
void updateDevConfResource(OCRepPayload* input)
{
ESDevConfProvData* devConfData = (ESDevConfProvData*)OICMalloc(sizeof(ESDevConfProvData));
if(devConfData == NULL)
{
OIC_LOG(DEBUG, ES_RH_TAG, "OICMalloc is failed");
}
devConfData->userdata = NULL;
char *country = NULL;
if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_COUNTRY, &country))
{
OICStrcpy(gDevConfResource.country, sizeof(gDevConfResource.country), country);
OICStrcpy(gDevConfData.country, sizeof(gDevConfData.country), country);
OICStrcpy(devConfData->country, sizeof(devConfData->country), country);
OIC_LOG_V(INFO, ES_RH_TAG, "gDevConfResource.country %s", gDevConfResource.country);
}
......@@ -386,10 +400,13 @@ void updateDevConfResource(OCRepPayload* input)
if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_LANGUAGE, &language))
{
OICStrcpy(gDevConfResource.language, sizeof(gDevConfResource.language), language);
OICStrcpy(gDevConfData.language, sizeof(gDevConfData.language), language);
OICStrcpy(devConfData->language, sizeof(devConfData->language), language);
OIC_LOG_V(INFO, ES_RH_TAG, "gDevConfResource.language %s", gDevConfResource.language);
}
if(gReadUserdataCb)
gReadUserdataCb(input, OC_RSRVD_ES_RES_TYPE_DEVCONF, devConfData->userdata);
if(country || language)
{
OIC_LOG(INFO, ES_RH_TAG, "Send DevConfRsrc Callback To ES");
......@@ -397,13 +414,15 @@ void updateDevConfResource(OCRepPayload* input)
// TODO : Need to check appropriateness of gDevConfData
if(gDevConfRsrcEvtCb != NULL)
{
gDevConfRsrcEvtCb(ES_OK, &gDevConfData);
gDevConfRsrcEvtCb(ES_OK, devConfData);
}
else
{
OIC_LOG(ERROR, ES_RH_TAG, "gDevConfRsrcEvtCb is NULL");
}
}
OICFree(devConfData);
}
OCRepPayload* constructResponseOfWiFi()
......@@ -419,7 +438,7 @@ OCRepPayload* constructResponseOfWiFi()
OCRepPayloadSetUri(payload, OC_RSRVD_ES_URI_WIFI);
size_t dimensions[MAX_REP_ARRAY_DEPTH] = {gWiFiResource.numMode, 0, 0};
int64_t *modes_64 = (int64_t *)malloc(gWiFiResource.numMode * sizeof(int64_t));
int64_t *modes_64 = (int64_t *)OICMalloc(gWiFiResource.numMode * sizeof(int64_t));
for(int i = 0 ; i < gWiFiResource.numMode ; ++i)
modes_64[i] = gWiFiResource.supportedMode[i];
OCRepPayloadSetIntArray(payload, OC_RSRVD_ES_SUPPORTEDWIFIMODE, (int64_t *)modes_64, dimensions);
......@@ -430,6 +449,9 @@ OCRepPayload* constructResponseOfWiFi()
OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_AUTHTYPE, (int) gWiFiResource.authType);
OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_ENCTYPE, (int) gWiFiResource.encType);
if(gWriteUserdataCb)
gWriteUserdataCb(payload, OC_RSRVD_ES_RES_TYPE_WIFI);
return payload;
}
......@@ -447,7 +469,9 @@ OCRepPayload* constructResponseOfCloud()
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_AUTHCODE, gCloudResource.authCode);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_AUTHPROVIDER, gCloudResource.authProvider);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_CISERVER, gCloudResource.ciServer);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_SERVERID, gCloudResource.serverID);
if(gWriteUserdataCb)
gWriteUserdataCb(payload, OC_RSRVD_ES_RES_TYPE_CLOUDSERVER);
return payload;
}
......@@ -467,6 +491,9 @@ OCRepPayload* constructResponseOfDevConf()
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_LANGUAGE, gDevConfResource.language);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_COUNTRY, gDevConfResource.country);
if(gWriteUserdataCb)
gWriteUserdataCb(payload, OC_RSRVD_ES_RES_TYPE_DEVCONF);
return payload;
}
......@@ -485,6 +512,9 @@ OCRepPayload* constructResponseOfProv(OCEntityHandlerRequest *ehRequest)
OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_LAST_ERRORCODE, gProvResource.lastErrCode);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_LINKS, gProvResource.ocfWebLinks);
if(gWriteUserdataCb)
gWriteUserdataCb(payload, OC_RSRVD_ES_RES_TYPE_PROV);
if(ehRequest->query)
{
if(strstr(ehRequest->query, OC_RSRVD_INTERFACE_BATCH))
......@@ -692,7 +722,7 @@ OCEntityHandlerResult ProcessPostRequest(OCEntityHandlerRequest *ehRequest, OCRe
else if(ehRequest->resource == gCloudResource.handle)
updateCloudResource(input);
else if(ehRequest->resource == gDevConfResource.handle)
updateDevConfResource(input);
updateDevConfResource(input);
OCRepPayload *getResp = NULL;
if(ehRequest->resource == gProvResource.handle)
......
......@@ -37,6 +37,9 @@ typedef void (*ESWiFiCB) (ESResult, ESWiFiProvData *);
typedef void (*ESCloudCB) (ESResult, ESCloudProvData *);
typedef void (*ESDevConfCB) (ESResult, ESDevConfProvData *);
typedef void (*ESWriteUserdataCb)(OCRepPayload* payload, char* resourceType);
typedef void (*ESReadUserdataCb)(OCRepPayload* payload, char* resourceType, void* userdata);
/* Structure to represent a Light resource */
typedef struct PROVRESOURCE
{
......@@ -52,7 +55,7 @@ typedef struct
WIFI_MODE supportedMode[NUM_WIFIMODE];
uint8_t numMode; // the number of device's supported wifi modes
WIFI_FREQ supportedFreq;
char ssid[MAX_SSIDLEN]; // target network name, i.e. SSID for WLAN, MAC address for BT.
char ssid[MAX_SSIDLEN]; // SSID
char cred[MAX_CREDLEN]; // credential information.
WIFI_AUTHTYPE authType;
WIFI_ENCTYPE encType;
......@@ -64,7 +67,6 @@ typedef struct
char authCode[OIC_STRING_MAX_VALUE];
char authProvider[OIC_STRING_MAX_VALUE];
char ciServer[OIC_STRING_MAX_VALUE];
char serverID[OIC_STRING_MAX_VALUE];
} CloudResource;
typedef struct
......@@ -75,7 +77,6 @@ typedef struct
char country[OIC_STRING_MAX_VALUE];
} DevConfResource;
OCStackResult CreateEasySetupResources(bool isSecured, ESResourceMask resourceMask);
OCStackResult DeleteEasySetupResources();
......@@ -88,6 +89,7 @@ void RegisterWifiRsrcEventCallBack(ESWiFiCB);
void RegisterCloudRsrcEventCallBack(ESCloudCB);
void RegisterDevConfRsrcEventCallBack(ESDevConfCB);
void UnRegisterResourceEventCallBack(void);
ESResult SetCallbackForUserData(ESReadUserdataCb readCb, ESWriteUserdataCb writeCb);
#ifdef __cplusplus
}
......
......@@ -160,6 +160,7 @@ typedef struct
char pwd[MAX_CREDLEN]; /**< Pwd of the Enroller**/
WIFI_AUTHTYPE authtype; /**< Auth type of the Enroller**/
WIFI_ENCTYPE enctype; /**< Encryption type of the Enroller**/
void *userdata; /**< Vender-specific data**/
} ESWiFiProvData;
/**
......@@ -169,6 +170,7 @@ typedef struct
{
char language[OIC_STRING_MAX_VALUE]; /**< IETF language tag using ISO 639X **/
char country[OIC_STRING_MAX_VALUE]; /**< ISO Country Code (ISO 3166-1 Alpha-2) **/
void *userdata; /**< Vender-specific data**/
} ESDevConfProvData;
/**
......@@ -179,7 +181,7 @@ typedef struct
char authCode[OIC_STRING_MAX_VALUE]; /**< Auth code issued by OAuth2.0-compatible account server **/
char authProvider[OIC_STRING_MAX_VALUE]; /**< Auth provider ID **/
char ciServer[OIC_STRING_MAX_VALUE]; /**< Cloud interface server URL which an Enrollee is going to registered **/
char serverID[OIC_STRING_MAX_VALUE]; /**< Cloud interface server UUID **/
void *userdata; /**< Vender-specific data**/
} ESCloudProvData;
/**
......
......@@ -59,7 +59,7 @@ enrollee_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'ocsrm', 'pth
if enrollee_env.get('SECURED') == '1':
enrollee_env.PrependUnique(LIBS = ['ocpmapi', 'ocprovision'])
enrollee = enrollee_env.Program('enrollee', 'enrolleewifi.c')
enrollee = enrollee_env.Program('enrollee', ['enrolleewifi.c', 'easysetup_x.c'])
i_enrollee = enrollee_env.Install(env.get('BUILD_DIR'), enrollee)
......
//******************************************************************
//
// Copyright 2015 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.
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#include "easysetup_x.h"
#include "string.h"
#include "oic_malloc.h"
#include "logger.h"
/**
* @var ESX_ENROLLEE_TAG
* @brief Logging tag for module name.
*/
#define ESX_ENROLLEE_TAG "ESX"
UserProperties g_userProperties;
void SetUserProperties(const UserProperties *prop)
{
if(prop != NULL)
{
strncpy(g_userProperties.userValue_str, prop->userValue_str, MAXLEN_STRING);
g_userProperties.userValue_int = prop->userValue_int;
}
}
void ReadUserdataCb(OCRepPayload* payload, char* resourceType, void* userdata)
{
OIC_LOG(DEBUG, ESX_ENROLLEE_TAG, "ReadUserdataCb IN");
if(payload != NULL)
{
if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_WIFI))
{
int64_t value = -1;
if (OCRepPayloadGetPropInt(payload, USERPROPERTY_KEY_INT, &value))
{
if(userdata != NULL)
userdata = (void*)OICMalloc(sizeof(UserProperties));
OIC_LOG_V(INFO, ESX_ENROLLEE_TAG, "[User specific property] %s : %ld",
USERPROPERTY_KEY_INT, value);
((UserProperties*)userdata)->userValue_int = value;
g_userProperties.userValue_int = value;
}
}
}
OIC_LOG(DEBUG, ESX_ENROLLEE_TAG, "ReadUserdataCb OUT");
}
void WriteUserdataCb(OCRepPayload* payload, char* resourceType)
{
OIC_LOG(DEBUG, ESX_ENROLLEE_TAG, "WriteUserdataCb IN");
if(payload != NULL)
{
if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_WIFI))
{
OCRepPayloadSetPropInt(payload, USERPROPERTY_KEY_INT, g_userProperties.userValue_int);
}
if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_DEVCONF))
{
OCRepPayloadSetPropString(payload, USERPROPERTY_KEY_STR, g_userProperties.userValue_str);
}
}
OIC_LOG(DEBUG, ESX_ENROLLEE_TAG, "WriteUserdataCb OUT");
}
//******************************************************************
//
// Copyright 2016 Samsung Electronics All Rights Reserved.
// Copyright 2015 Samsung Electronics All Rights Reserved.
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//
......@@ -18,52 +18,27 @@
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
/**
* @file
*
* This file contains private internal callback function
* prototypes for Easy setup [Enrollee]
*/
#ifndef EASYSETUP_ENROLLEE_CALLBACKS_H__
#define EASYSETUP_ENROLLEE_CALLBACKS_H__
#include "easysetup.h"
#include "escommon.h"
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
//-----------------------------------------------------------------------------
// Private internal callback function prototypes for Easy setup [Enrollee]
//-----------------------------------------------------------------------------
/*
* Callback for on boarding
*/
void ESOnboardingCallback(ESResult esResult);
/*
* Callback for provisioning
*/
void ESProvisioningCallback(ESResult SSSS);
#ifndef EASYSETUPX_ENROLLEE_H__
#define EASYSETUPX_ENROLLEE_H__
/*
* Callback for on boarding target Network
*/
void ESOnboardingCallbackTargetNet(ESResult esResult);
#define MAXLEN_STRING 100
/*
* Function for validating the parameter for ESInitEnrollee API
*/
static bool ESEnrolleeValidateParam(OCConnectivityType networkType, const char *ssid,
const char *passwd, ESEnrolleeEventCallback cb);
typedef struct UserProperties_t
{
int userValue_int; /**< User-specific property in WiFi resource **/
char userValue_str[MAXLEN_STRING]; /**< User-specific property in DevConf resource **/
} UserProperties;
#ifdef __cplusplus
}
#endif // __cplusplus
#define USERPROPERTY_KEY_INT "x.user.property.int"
#define USERPROPERTY_KEY_STR "x.user.property.str"
void ReadUserdataCb(OCRepPayload* payload, char* resourceType, void* userdata);
void WriteUserdataCb(OCRepPayload* payload, char* resourceType);
#endif /* EASYSETUP_ENROLLEE_CALLBACKS_H__ */
void SetUserProperties(const UserProperties *prop);