62a462c746408f8dfb47baab070267a84e790f78
[platform/upstream/iotivity.git] / service / easy-setup / sdk / mediator / inc / provisioninghandler.h
1 //******************************************************************
2 //
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
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
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
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.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21
22 #ifndef __PROVISIONING_HANDLER_H_
23 #define __PROVISIONING_HANDLER_H_
24
25 #include "octypes.h"
26
27 #include "logger.h"
28 #include "ocstack.h"
29 #include "common.h"
30
31 //-----------------------------------------------------------------------------
32 // Defines
33 //-----------------------------------------------------------------------------
34 #define TAG "provisioninghandler"
35 #define DEFAULT_CONTEXT_VALUE 0x99
36 #ifndef MAX_LENGTH_IPv4_ADDR
37 #define MAX_LENGTH_IPv4_ADDR 16
38 #endif
39
40 //-----------------------------------------------------------------------------
41 // Typedefs
42 //-----------------------------------------------------------------------------
43
44 /**
45  * List of methods that can be inititated from the client
46  */
47 OCStackResult InitProvisioningHandler();
48
49 OCStackResult TerminateProvisioningHandler();
50
51 void listeningFunc(void*);
52
53 OCStackApplicationResult ProvisionEnrolleeResponse(void* ctx, OCDoHandle handle,
54         OCClientResponse * clientResponse);
55
56 OCStackResult ProvisionEnrollee(OCQualityOfService qos, const char* query, const char* resUri,OCDevAddr *destination);
57
58 OCStackApplicationResult GetProvisioningStatusResponse(void* ctx, OCDoHandle handle,
59         OCClientResponse * clientResponse);
60
61 OCStackResult InvokeOCDoResource(const char* query, OCMethod method, const OCDevAddr *dest,
62         OCQualityOfService qos, OCClientResponseHandler cb, OCRepPayload* payload,
63         OCHeaderOption * options, uint8_t numOptions);
64
65 OCStackResult GetProvisioningStatus(OCQualityOfService qos, const char* query,
66         const OCDevAddr*destination);
67
68 OCStackResult StartProvisioningProcess(const EnrolleeNWProvInfo_t *netInfo,
69         OCProvisioningStatusCB provisioningStatusCallback);
70
71 void StopProvisioningProcess();
72
73 OCStackApplicationResult SubscribeProvPresenceCallback(void* ctx, OCDoHandle handle,
74         OCClientResponse* clientResponse);
75
76 OCStackResult SubscribeProvPresence(OCQualityOfService qos, const char* requestURI);
77
78 OCStackApplicationResult FindProvisioningResourceResponse(void* ctx, OCDoHandle handle,
79         OCClientResponse * clientResponse);
80
81 void FindProvisioningResource(void *data);
82
83 //Invoke Provisioning Status Callback
84 ProvisioningInfo* PrepareProvisioingStatusCB(OCClientResponse * clientResponse,
85         ProvStatus provStatus);
86
87
88 void LogProvisioningResponse(OCRepPayloadValue* val);
89
90 bool ConfigEnrolleeObject(const EnrolleeNWProvInfo_t *netInfo);
91
92 bool ClearMemory();
93
94 void SuccessCallback(OCClientResponse * clientResponse);
95
96 void ErrorCallback(ProvStatus status);
97
98 bool ValidateEnrolleResponse(OCClientResponse * clientResponse);
99
100 bool ValidateFinddResourceResponse(OCClientResponse * clientResponse);
101
102 ProvisioningInfo* GetCallbackObjectOnSuccess(OCClientResponse * clientResponse,
103         ProvStatus provStatus);
104
105 ProvisioningInfo* GetCallbackObjectOnError(ProvStatus status);
106
107 ProvisioningInfo* CreateCallBackObject();
108
109 bool ResetProgress();
110
111 bool SetProgress(OCProvisioningStatusCB provisioningStatusCallback);
112
113 bool InProgress();
114
115 bool ValidateEasySetupParams(const EnrolleeNWProvInfo_t *netInfo,
116         OCProvisioningStatusCB provisioningStatusCallback);
117
118
119 #endif
120