1 //******************************************************************
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
22 #ifndef __PROVISIONING_HANDLER_H_
23 #define __PROVISIONING_HANDLER_H_
31 //-----------------------------------------------------------------------------
33 //-----------------------------------------------------------------------------
34 #define TAG "provisioninghandler"
35 #define DEFAULT_CONTEXT_VALUE 0x99
36 #ifndef MAX_LENGTH_IPv4_ADDR
37 #define MAX_LENGTH_IPv4_ADDR 16
40 //-----------------------------------------------------------------------------
42 //-----------------------------------------------------------------------------
45 * List of methods that can be inititated from the client
47 OCStackResult InitProvisioningHandler();
49 OCStackResult TerminateProvisioningHandler();
51 void listeningFunc(void*);
53 OCStackApplicationResult ProvisionEnrolleeResponse(void* ctx, OCDoHandle handle,
54 OCClientResponse * clientResponse);
56 OCStackResult ProvisionEnrollee(OCQualityOfService qos, const char* query, const char* resUri,OCDevAddr *destination);
58 OCStackApplicationResult GetProvisioningStatusResponse(void* ctx, OCDoHandle handle,
59 OCClientResponse * clientResponse);
61 OCStackResult InvokeOCDoResource(const char* query, OCMethod method, const OCDevAddr *dest,
62 OCQualityOfService qos, OCClientResponseHandler cb, OCRepPayload* payload,
63 OCHeaderOption * options, uint8_t numOptions);
65 OCStackResult GetProvisioningStatus(OCQualityOfService qos, const char* query,
66 const OCDevAddr*destination);
68 OCStackResult StartProvisioningProcess(const EnrolleeNWProvInfo_t *netInfo,
69 OCProvisioningStatusCB provisioningStatusCallback);
71 void StopProvisioningProcess();
73 OCStackApplicationResult SubscribeProvPresenceCallback(void* ctx, OCDoHandle handle,
74 OCClientResponse* clientResponse);
76 OCStackResult SubscribeProvPresence(OCQualityOfService qos, const char* requestURI);
78 OCStackApplicationResult FindProvisioningResourceResponse(void* ctx, OCDoHandle handle,
79 OCClientResponse * clientResponse);
81 void FindProvisioningResource(void *data);
83 //Invoke Provisioning Status Callback
84 ProvisioningInfo* PrepareProvisioingStatusCB(OCClientResponse * clientResponse,
85 ProvStatus provStatus);
88 void LogProvisioningResponse(OCRepPayloadValue* val);
90 bool ConfigEnrolleeObject(const EnrolleeNWProvInfo_t *netInfo);
94 void SuccessCallback(OCClientResponse * clientResponse);
96 void ErrorCallback(ProvStatus status);
98 bool ValidateEnrolleResponse(OCClientResponse * clientResponse);
100 bool ValidateFinddResourceResponse(OCClientResponse * clientResponse);
102 ProvisioningInfo* GetCallbackObjectOnSuccess(OCClientResponse * clientResponse,
103 ProvStatus provStatus);
105 ProvisioningInfo* GetCallbackObjectOnError(ProvStatus status);
107 ProvisioningInfo* CreateCallBackObject();
109 bool ResetProgress();
111 bool SetProgress(OCProvisioningStatusCB provisioningStatusCallback);
115 bool ValidateEasySetupParams(const EnrolleeNWProvInfo_t *netInfo,
116 OCProvisioningStatusCB provisioningStatusCallback);