Commit d5e81612 authored by lankamadan's avatar lankamadan Committed by Madan Lanka

Changed PUT to POST, fix for not sending SSID/PWD in the get response & added...

Changed PUT to POST, fix for not sending SSID/PWD in the get response & added a trigger for network connection

- Changed PUT to POST
- Fix for not sending SSID/PWD in the get response
- Added a trigger for making Enrollee connect to network

Change-Id: I4e041bb1ea3543c595f37a6b59dbc55b420ae838
Signed-off-by: default avatarlankamadan <lanka.madan@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/5257Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
parent 6c35c753
......@@ -36,20 +36,21 @@ typedef void (*ResourceEventCallback)(ESResult);
typedef struct PROVRESOURCE
{
OCResourceHandle handle;
int ps; // provisiong status, 1 : need to provisioning, 2 : Connected to Enroller
int tnt; // target network type, 1: WLAN, 2: BT, 3: BLE, 4: Zigbee, ...
char tnn[MAXSSIDLEN]; // target network name, i.e. SSID for WLAN, MAC address for BT
char cd[MAXNETCREDLEN]; // credential information
int64_t ps; // provisiong status, 1 : need to provisioning, 2 : Connected to Enroller.
int64_t tr; // Trigger network connection, 0 : Init value, 1 : Connected to the target network.
int64_t tnt; // target network type, 1: WLAN, 2: BT, 3: BLE, 4: Zigbee.
char tnn[MAXSSIDLEN]; // target network name, i.e. SSID for WLAN, MAC address for BT.
char cd[MAXNETCREDLEN]; // credential information.
} ProvResource;
/* Structure to represent a Light resource */
typedef struct NETRESOURCE
{
OCResourceHandle handle;
int cnt; // current network type, 1: WLAN, 2: BT, 3: BLE, 4: Zigbee, ...
int ant[MAXNUMTYPE]; // available network type, 1: WLAN, 2: BT, 3: BLE, 4: Zigbee, ...
char ipaddr[MAXADDRLEN]; // ip address
char cnn[MAXSSIDLEN]; // current network name
int64_t cnt; // current network type, 1: WLAN, 2: BT, 3: BLE, 4: Zigbee.
int64_t ant[MAXNUMTYPE]; // available network type, 1: WLAN, 2: BT, 3: BLE, 4: Zigbee.
char ipaddr[MAXADDRLEN]; // ip address.
char cnn[MAXSSIDLEN]; // current network name.
} NetResource;
OCStackResult CreateProvisioningResource(bool isSecured);
......
......@@ -36,7 +36,8 @@
/**
* @var gProvResource
* @brief Structure for holding the Provisioning status and target information required to connect to the target network
* @brief Structure for holding the Provisioning status and target information required to
* connect to the target network
*/
static ProvResource gProvResource;
......@@ -49,19 +50,14 @@ static NetResource gNetResource;
//-----------------------------------------------------------------------------
// Private internal function prototypes
//-----------------------------------------------------------------------------
OCEntityHandlerResult OCEntityHandlerCb(OCEntityHandlerFlag flag,
OCEntityHandlerRequest *ehRequest, void *callback);
OCEntityHandlerResult OCEntityHandlerCb(OCEntityHandlerFlag flag, OCEntityHandlerRequest *ehRequest,
void *callback);
const char *getResult(OCStackResult result);
OCEntityHandlerResult ProcessGetRequest(OCEntityHandlerRequest *ehRequest,
OCRepPayload** payload);
OCEntityHandlerResult ProcessPutRequest(OCEntityHandlerRequest *ehRequest,
OCRepPayload** payload);
OCEntityHandlerResult ProcessPostRequest(OCEntityHandlerRequest *ehRequest,
OCRepPayload** payload);
OCEntityHandlerResult ProcessGetRequest(OCEntityHandlerRequest *ehRequest, OCRepPayload** payload);
OCEntityHandlerResult ProcessPutRequest(OCEntityHandlerRequest *ehRequest, OCRepPayload** payload);
OCEntityHandlerResult ProcessPostRequest(OCEntityHandlerRequest *ehRequest, OCRepPayload** payload);
OCRepPayload* constructResponse(OCEntityHandlerRequest *ehRequest);
static int g_flag = 0;
ResourceEventCallback gNetworkInfoProvEventCb = NULL;
void RegisterResourceEventCallBack(ResourceEventCallback cb)
......@@ -89,29 +85,26 @@ void GetTargetNetworkInfoFromProvResource(char *name, char *pass)
OCStackResult CreateProvisioningResource(bool isSecured)
{
gProvResource.ps = ES_PS_NEED_PROVISIONING;
gProvResource.tr = ES_PS_TRIGGER_INIT_VALUE;
gProvResource.tnt = CT_ADAPTER_IP;
OICStrcpy(gProvResource.tnn, sizeof(gProvResource.tnn),"Unknown");
OICStrcpy(gProvResource.tnn, sizeof(gProvResource.tnn), "Unknown");
OICStrcpy(gProvResource.cd, sizeof(gProvResource.cd), "Unknown");
OCStackResult res = OC_STACK_ERROR;
if (isSecured)
{
res = OCCreateResource(&gProvResource.handle, OC_RSRVD_ES_PROV_RES_TYPE,
OC_RSRVD_INTERFACE_DEFAULT,
OC_RSRVD_ES_URI_PROV,
OCEntityHandlerCb,
NULL,
OC_DISCOVERABLE | OC_OBSERVABLE | OC_SECURE);
OC_RSRVD_INTERFACE_DEFAULT,
OC_RSRVD_ES_URI_PROV, OCEntityHandlerCb,
NULL, OC_DISCOVERABLE | OC_OBSERVABLE | OC_SECURE);
}
else
{
res = OCCreateResource(&gProvResource.handle, OC_RSRVD_ES_PROV_RES_TYPE,
OC_RSRVD_INTERFACE_DEFAULT,
OC_RSRVD_ES_URI_PROV,
OCEntityHandlerCb,
NULL,
OC_DISCOVERABLE | OC_OBSERVABLE);
OC_RSRVD_INTERFACE_DEFAULT,
OC_RSRVD_ES_URI_PROV, OCEntityHandlerCb,
NULL, OC_DISCOVERABLE | OC_OBSERVABLE);
}
OIC_LOG_V(INFO, ES_RH_TAG, "Created Prov resource with result: %s", getResult(res));
......@@ -129,8 +122,7 @@ OCStackResult DeleteProvisioningResource()
return res;
}
OCEntityHandlerResult ProcessGetRequest(OCEntityHandlerRequest *ehRequest,
OCRepPayload **payload)
OCEntityHandlerResult ProcessGetRequest(OCEntityHandlerRequest *ehRequest, OCRepPayload **payload)
{
OCEntityHandlerResult ehResult = OC_EH_ERROR;
if (!ehRequest)
......@@ -157,10 +149,9 @@ OCEntityHandlerResult ProcessGetRequest(OCEntityHandlerRequest *ehRequest,
return ehResult;
}
OCEntityHandlerResult ProcessPutRequest(OCEntityHandlerRequest *ehRequest,
OCRepPayload** payload)
OCEntityHandlerResult ProcessPostRequest(OCEntityHandlerRequest *ehRequest, OCRepPayload** payload)
{
OIC_LOG(INFO, ES_RH_TAG, "ProcessPutRequest enter");
OIC_LOG(INFO, ES_RH_TAG, "ProcessPostRequest enter");
OCEntityHandlerResult ehResult = OC_EH_ERROR;
if (ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION)
{
......@@ -175,20 +166,44 @@ OCEntityHandlerResult ProcessPutRequest(OCEntityHandlerRequest *ehRequest,
return ehResult;
}
//TODO : ES_PS_PROVISIONING_COMPLETED state indicates that already provisioning is completed.
int64_t tr;
if (OCRepPayloadGetPropInt(input, OC_RSRVD_ES_TR, &tr))
{
// Triggering
gProvResource.tr = tr;
}
//ES_PS_PROVISIONING_COMPLETED state indicates that already provisioning is completed.
// A new request for provisioning means overriding existing network provisioning information.
// Metadata to indicate that it is override is needed. The metadata can be a new attribute
// should be added to the /oic/prov resource indicating to override the existing network
// information.
if (gProvResource.ps == ES_PS_PROVISIONING_COMPLETED)
if (gProvResource.ps == ES_PS_PROVISIONING_COMPLETED && tr == ES_PS_TRIGGER_CONNECTION)
{
OIC_LOG(DEBUG, ES_RH_TAG, "Provisioning already completed."
"Tiggering the network connection");
if (gNetworkInfoProvEventCb)
{
gNetworkInfoProvEventCb(ES_RECVTRIGGEROFPROVRES);
ehResult = OC_EH_OK;
}
else
{
OIC_LOG(ERROR, ES_RH_TAG, "gNetworkInfoProvEventCb is NULL."
"Network handler not registered. Failed to connect to the network");
ehResult = OC_EH_ERROR;
}
return ehResult;
}
else if (gProvResource.ps == ES_PS_PROVISIONING_COMPLETED)
{
OIC_LOG(DEBUG, ES_RH_TAG, "Provisioning already completed. "
"This a request to override the existing the network provisioning information");
}
else
{
OIC_LOG(DEBUG, ES_RH_TAG, "Provisioning the network information to the Enrollee.");
}
// PUT request is appropriate for provisioning information to the enrollee.
// When an enrollee receives the put request, the entire resource information should
// be overwritten.
OICStrcpy(gProvResource.tnn, sizeof(gProvResource.tnn), "");
OICStrcpy(gProvResource.cd, sizeof(gProvResource.cd), "");
......@@ -200,16 +215,17 @@ OCEntityHandlerResult ProcessPutRequest(OCEntityHandlerRequest *ehRequest,
}
OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.tnn %s", gProvResource.tnn);
char* cd;
if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_CD, &cd))
{
OICStrcpy(gProvResource.cd, sizeof(gProvResource.cd), cd);
OIC_LOG(INFO, ES_RH_TAG, "got password");
}
OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.cd %s", gProvResource.cd);
gProvResource.ps = 2;
OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.ps %d", gProvResource.ps);
g_flag = 1;
}OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.cd %s", gProvResource.cd);
gProvResource.ps = ES_PS_PROVISIONING_COMPLETED;
OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.ps %lld", gProvResource.ps);
OCRepPayload *getResp = constructResponse(ehRequest);
if (!getResp)
......@@ -224,34 +240,10 @@ OCEntityHandlerResult ProcessPutRequest(OCEntityHandlerRequest *ehRequest,
return ehResult;
}
OCEntityHandlerResult ProcessPostRequest(OCEntityHandlerRequest *ehRequest,
OCRepPayload** /*payload*/)
OCEntityHandlerResult ProcessPutRequest(OCEntityHandlerRequest * /*ehRequest*/,
OCRepPayload** /*payload*/)
{
OCEntityHandlerResult ehResult = OC_EH_ERROR;
if (!ehRequest)
{
OIC_LOG(ERROR, ES_RH_TAG, "Request is Null");
return ehResult;
}
if (ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION)
{
OIC_LOG(ERROR, ES_RH_TAG, "Incoming payload not a representation");
return ehResult;
}
OCRepPayload* input = (OCRepPayload*) (ehRequest->payload);
if (!input)
{
OIC_LOG(ERROR, ES_RH_TAG, "Failed to parse");
return ehResult;
}
char* tr;
if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_TR, &tr))
{
// Triggering
ehResult = OC_EH_OK;
}
g_flag = 1;
return ehResult;
}
......@@ -271,8 +263,6 @@ OCRepPayload* constructResponse(OCEntityHandlerRequest *ehRequest)
OCRepPayloadSetUri(payload, OC_RSRVD_ES_URI_PROV);
OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_PS, gProvResource.ps);
OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_TNT, gProvResource.tnt);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_TNN, gProvResource.tnn);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_CD, gProvResource.cd);
}
else if (ehRequest->requestHandle == gNetResource.handle)
{
......@@ -292,8 +282,12 @@ OCEntityHandlerResult OCEntityHandlerCb(OCEntityHandlerFlag flag,
{
(void) callback;
OCEntityHandlerResult ehRet = OC_EH_OK;
OCEntityHandlerResponse response = { 0, 0, OC_EH_ERROR, 0, 0, { },{ 0 }, false };
OCEntityHandlerResponse response =
{ 0, 0, OC_EH_ERROR, 0, 0,
{ },
{ 0 }, false };
OCRepPayload* payload = NULL;
if (entityHandlerRequest && (flag & OC_REQUEST_FLAG))
{
if (OC_REST_GET == entityHandlerRequest->method)
......@@ -305,7 +299,9 @@ OCEntityHandlerResult OCEntityHandlerCb(OCEntityHandlerFlag flag,
{
OIC_LOG(INFO, ES_RH_TAG, "Received PUT request");
if (gProvResource.handle != NULL && entityHandlerRequest->resource == gProvResource.handle)
//PUT request will be handled in the internal implementation
if (gProvResource.handle != NULL
&& entityHandlerRequest->resource == gProvResource.handle)
{
ehRet = ProcessPutRequest(entityHandlerRequest, &payload);
}
......@@ -317,9 +313,17 @@ OCEntityHandlerResult OCEntityHandlerCb(OCEntityHandlerFlag flag,
}
else if (OC_REST_POST == entityHandlerRequest->method)
{
// TODO: As of now, POST request will be not received.
OIC_LOG(INFO, ES_RH_TAG, "Received OC_REST_POST from client");
//ehRet = ProcessPostRequest (entityHandlerRequest, payload, sizeof(payload) - 1);
if (gProvResource.handle != NULL
&& entityHandlerRequest->resource == gProvResource.handle)
{
ehRet = ProcessPostRequest(entityHandlerRequest, &payload);
}
else
{
OIC_LOG(ERROR, ES_RH_TAG, "Cannot process put");
ehRet = OC_EH_ERROR;
}
}
if (ehRet == OC_EH_OK)
......@@ -332,8 +336,8 @@ OCEntityHandlerResult OCEntityHandlerCb(OCEntityHandlerFlag flag,
response.payload = (OCPayload*) (payload);
response.numSendVendorSpecificHeaderOptions = 0;
memset(response.sendVendorSpecificHeaderOptions, 0,
sizeof response.sendVendorSpecificHeaderOptions);
memset(response.resourceUri, 0, sizeof response.resourceUri);
sizeof(response.sendVendorSpecificHeaderOptions));
memset(response.resourceUri, 0, sizeof(response.resourceUri));
// Indicate that response is NOT in a persistent buffer
response.persistentBufferFlag = 0;
......@@ -346,12 +350,6 @@ OCEntityHandlerResult OCEntityHandlerCb(OCEntityHandlerFlag flag,
}
}
if (g_flag == 1)
{
gNetworkInfoProvEventCb(ES_RECVTRIGGEROFPROVRES);
g_flag = 0;
}
return ehRet;
}
......
......@@ -66,6 +66,9 @@ using namespace std;
*/
#define ES_PS_NEED_PROVISIONING 1
#define ES_PS_PROVISIONING_COMPLETED 2
#define ES_PS_TRIGGER_INIT_VALUE 0
#define ES_PS_TRIGGER_CONNECTION 1
/**
* Device Roles defined for each device type used in easy setup
......
......@@ -18,9 +18,8 @@
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#ifndef __PROVISIONING_HANDLER_H_
#define __PROVISIONING_HANDLER_H_
#ifndef __ES_PROVISIONING_HANDLER_H_
#define __ES_PROVISIONING_HANDLER_H_
#include "octypes.h"
......@@ -33,11 +32,6 @@
//-----------------------------------------------------------------------------
#define EASY_SETUP_DEFAULT_CONTEXT_VALUE 0x99
//-----------------------------------------------------------------------------
// Typedefs
//-----------------------------------------------------------------------------
/**
* List of methods that can be inititated from the client
*/
......@@ -45,41 +39,48 @@ OCStackResult InitProvisioningHandler();
OCStackResult TerminateProvisioningHandler();
void *listeningFunc(void *);
OCStackResult GetProvisioningStatus(OCQualityOfService qos, const char *query,
const OCDevAddr *destination);
OCStackResult StartProvisioningProcess(const ProvConfig *netInfo,
WiFiOnboadingConnection *onboardConn, OCProvisioningStatusCB provisioningStatusCallback,
char *findResQuery);
void StopProvisioningProcess();
/**
* Internal worker functions.
*/
OCStackResult TriggerNetworkConnection(OCQualityOfService qos, const char *query,
const char *resUri, OCDevAddr *destination, int /*pauseBeforeStart*/);
OCStackApplicationResult TriggerNetworkConnectionResponse(void *ctx, OCDoHandle handle,
OCClientResponse *clientResponse);
OCStackApplicationResult ProvisionEnrolleeResponse(void *ctx, OCDoHandle handle,
OCClientResponse *clientResponse);
OCClientResponse *clientResponse);
OCStackResult ProvisionEnrollee(OCQualityOfService qos, const char *query, const char *resUri,
OCDevAddr *destination, int pauseBeforeStart);
OCDevAddr *destination, int pauseBeforeStart);
OCStackApplicationResult GetProvisioningStatusResponse(void *ctx, OCDoHandle handle,
OCClientResponse *clientResponse);
OCClientResponse *clientResponse);
OCStackResult InvokeOCDoResource(const char *query, OCMethod method, const OCDevAddr *dest,
OCQualityOfService qos, OCClientResponseHandler cb,
OCRepPayload *payload,
OCHeaderOption *options, uint8_t numOptions);
OCStackResult GetProvisioningStatus(OCQualityOfService qos, const char *query,
const OCDevAddr *destination);
OCStackResult StartProvisioningProcess(const ProvConfig *netInfo,WiFiOnboadingConnection *onboardConn,
OCProvisioningStatusCB provisioningStatusCallback,
char *findResQuery);
void StopProvisioningProcess();
OCQualityOfService qos, OCClientResponseHandler cb, OCRepPayload *payload,
OCHeaderOption *options, uint8_t numOptions);
OCStackApplicationResult FindProvisioningResourceResponse(void *ctx, OCDoHandle handle,
OCClientResponse *clientResponse);
OCClientResponse *clientResponse);
void *FindProvisioningResource(void *data);
//Invoke Provisioning Status Callback
ProvisioningInfo *PrepareProvisioingStatusCB(OCClientResponse *clientResponse,
ProvStatus provStatus);
ProvStatus provStatus);
/**
* Internal Util functions.
*/
void LogProvisioningResponse(OCRepPayloadValue * val);
bool ConfigEnrolleeObject(const ProvConfig *netInfo, WiFiOnboadingConnection *onboardConn);
......@@ -90,12 +91,14 @@ void SuccessCallback(OCClientResponse * clientResponse);
void ErrorCallback(ProvStatus status);
bool ValidateEnrolleResponse(OCClientResponse * clientResponse);
bool ValidateEnrolleeResponse(OCClientResponse * clientResponse);
bool ValidateFinddResourceResponse(OCClientResponse * clientResponse);
bool ValidateFindResourceResponse(OCClientResponse * clientResponse);
bool ValidateEnrolleeBasicResponse(OCClientResponse * clientResponse);
ProvisioningInfo *GetCallbackObjectOnSuccess(OCClientResponse *clientResponse,
ProvStatus provStatus);
ProvStatus provStatus);
ProvisioningInfo *GetCallbackObjectOnError(ProvStatus status);
......@@ -107,11 +110,10 @@ bool SetProgress(OCProvisioningStatusCB provisioningStatusCallback);
bool InProgress();
bool ValidateEasySetupParams(const ProvConfig *netInfo,WiFiOnboadingConnection *onboardConn,
OCProvisioningStatusCB provisioningStatusCallback);
bool ValidateEasySetupParams(const ProvConfig *netInfo, WiFiOnboadingConnection *onboardConn,
OCProvisioningStatusCB provisioningStatusCallback);
bool IsSetupStopped();
#endif
#endif //__ES_PROVISIONING_HANDLER_H_
......@@ -29,28 +29,26 @@
#include "provisioning.h"
//-----------------------------------------------------------------------------
// Defines
//-----------------------------------------------------------------------------
#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif
OCStackResult InitProvProcess();
OCStackResult InitProvProcess();
OCStackResult ResetProvProcess();
OCStackResult RegisterCallback(
OCProvisioningStatusCB provisioningStatusCallback);
OCStackResult ResetProvProcess();
void UnRegisterCallback();
OCStackResult RegisterCallback(OCProvisioningStatusCB provisioningStatusCallback);
OCStackResult StartProvisioning(const ProvConfig *netInfo, WiFiOnboadingConnection *onboardConn);
void UnRegisterCallback();
OCStackResult StopProvisioning(OCConnectivityType connectivityType);
OCStackResult StartProvisioning(const ProvConfig *netInfo,
WiFiOnboadingConnection *onboardConn);
OCStackResult StopProvisioning(OCConnectivityType connectivityType);
#ifdef __cplusplus
}
#endif
......
This diff is collapsed.
......@@ -28,50 +28,57 @@
#include "provisioningapi.h"
#include "oic_string.h"
#define ES_PROV_ADAP_TAG "ES_PROVISIONING_ADAPTER"
//Use ipv4addr for both InitDiscovery and InitDeviceDiscovery
char ipv4addr[IPV4_ADDR_SIZE] = {0};
char ipv4addr[IPV4_ADDR_SIZE] =
{ 0 };
#ifdef REMOTE_ARDUINO_ENROLEE
//Arduino Enrollee needs mediator application provide IP and port55555 which is specific
// to Arduino WiFi enrollee
static const char * UNICAST_PROVISIONING_QUERY = "coap://%s:%d/oic/res?rt=oic.r.prov";
//Arduino Enrollee needs mediator application provide IP and port55555 which is specific
// to Arduino WiFi enrollee
static const char * UNICAST_PROVISIONING_QUERY = "coap://%s:%d/oic/res?rt=oic.r.prov";
#else
static const char * UNICAST_PROVISIONING_QUERY = "/oic/res?rt=oic.r.prov";
static const char * UNICAST_PROVISIONING_QUERY = "/oic/res?rt=oic.r.prov";
#endif
volatile static OCProvisioningStatusCB cbData = NULL;
OCStackResult InitProvProcess() {
OCStackResult InitProvProcess()
{
OCStackResult result = OC_STACK_ERROR;
if (InitProvisioningHandler() == OC_STACK_OK) {
if (InitProvisioningHandler() == OC_STACK_OK)
{
result = OC_STACK_OK;
OIC_LOG(DEBUG, ES_PROV_ADAP_TAG, "InitProvisioningHandler returned Success");
} else {
}
else
{
result = OC_STACK_ERROR;
OIC_LOG_V(ERROR, ES_PROV_ADAP_TAG, "InitProvisioningHandler returned error = %d",
result);
result);
}
return result;
}
OCStackResult ResetProvProcess() {
OCStackResult ResetProvProcess()
{
return TerminateProvisioningHandler();
}
OCStackResult RegisterCallback(OCProvisioningStatusCB provisioningStatusCallback) {
OCStackResult RegisterCallback(OCProvisioningStatusCB provisioningStatusCallback)
{
OCStackResult result = OC_STACK_OK;
if (provisioningStatusCallback != NULL) {
if (provisioningStatusCallback != NULL)
{
cbData = provisioningStatusCallback;
}
else {
else
{
result = OC_STACK_ERROR;
OIC_LOG(ERROR, ES_PROV_ADAP_TAG, "provisioningStatusCallback is NULL");
}
......@@ -79,17 +86,22 @@ OCStackResult RegisterCallback(OCProvisioningStatusCB provisioningStatusCallback
return result;
}
void UnRegisterCallback() {
if (cbData) {
void UnRegisterCallback()
{
if (cbData)
{
cbData = NULL;
}
}
OCStackResult StartProvisioning(const ProvConfig *provConfig, WiFiOnboadingConnection *onboardConn) {
OCStackResult StartProvisioning(const ProvConfig *provConfig, WiFiOnboadingConnection *onboardConn)
{
char findQuery[64] = {0};
char findQuery[64] =
{ 0 };
if(provConfig == NULL || onboardConn == NULL){
if (provConfig == NULL || onboardConn == NULL)
{
return OC_STACK_ERROR;
}
......@@ -97,15 +109,16 @@ OCStackResult StartProvisioning(const ProvConfig *provConfig, WiFiOnboadingConne
//Arduino Enrollee needs mediator application provide IP and port55555 which is specific
// to Arduino WiFi enrollee
snprintf(findQuery, sizeof(findQuery) - 1, UNICAST_PROVISIONING_QUERY,
onboardConn->ipAddress, IP_PORT);
onboardConn->ipAddress, IP_PORT);
#else
OICStrcpy(findQuery, sizeof(findQuery)-1, UNICAST_PROVISIONING_QUERY);
OICStrcpy(findQuery, sizeof(findQuery) - 1, UNICAST_PROVISIONING_QUERY);
#endif
return StartProvisioningProcess(provConfig, onboardConn, cbData, findQuery);
}
OCStackResult StopProvisioning(OCConnectivityType /*connectivityType*/) {
OCStackResult StopProvisioning(OCConnectivityType /*connectivityType*/)
{
OCStackResult result = OC_STACK_OK;
StopProvisioningProcess();
......
......@@ -36,56 +36,129 @@
// External includes
#include "logger.h"
#include "oic_string.h"
#define ES_WIFI_PROV_TAG "ES_WIFI_PROVISIONING"
static const char * UNICAST_PROV_STATUS_QUERY = "coap://%s:%d%s";
OCStackApplicationResult GetProvisioningStatusResponse(void* /*ctx*/,
OCDoHandle /*handle*/,
OCClientResponse *clientResponse) {
OCStackApplicationResult ProvisionEnrolleeResponse(void* /*ctx*/, OCDoHandle /*handle*/,
OCClientResponse *clientResponse)
{