Imported Upstream version 1.0.1
[platform/upstream/iotivity.git] / service / easy-setup / sdk / mediator / inc / provisioning.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 "escommon.h"
30
31 //-----------------------------------------------------------------------------
32 // Defines
33 //-----------------------------------------------------------------------------
34 #define EASY_SETUP_DEFAULT_CONTEXT_VALUE 0x99
35
36
37 //-----------------------------------------------------------------------------
38 // Typedefs
39 //-----------------------------------------------------------------------------
40
41 /**
42  * List of methods that can be inititated from the client
43  */
44 OCStackResult InitProvisioningHandler();
45
46 OCStackResult TerminateProvisioningHandler();
47
48 void *listeningFunc(void *);
49
50 OCStackApplicationResult ProvisionEnrolleeResponse(void *ctx, OCDoHandle handle,
51                                                    OCClientResponse *clientResponse);
52
53 OCStackResult ProvisionEnrollee(OCQualityOfService qos, const char *query, const char *resUri,
54                                 OCDevAddr *destination, int pauseBeforeStart);
55
56 OCStackApplicationResult GetProvisioningStatusResponse(void *ctx, OCDoHandle handle,
57                                                        OCClientResponse *clientResponse);
58
59 OCStackResult InvokeOCDoResource(const char *query, OCMethod method, const OCDevAddr *dest,
60                                  OCQualityOfService qos, OCClientResponseHandler cb,
61                                  OCRepPayload *payload,
62                                  OCHeaderOption *options, uint8_t numOptions);
63
64 OCStackResult GetProvisioningStatus(OCQualityOfService qos, const char *query,
65                                     const OCDevAddr *destination);
66
67 OCStackResult StartProvisioningProcess(const EnrolleeNWProvInfo_t *netInfo,
68                                        OCProvisioningStatusCB provisioningStatusCallback,
69                                        char *findResQuery);
70
71 void StopProvisioningProcess();
72
73 OCStackApplicationResult FindProvisioningResourceResponse(void *ctx, OCDoHandle handle,
74                                                           OCClientResponse *clientResponse);
75
76 void *FindProvisioningResource(void *data);
77
78 //Invoke Provisioning Status Callback
79 ProvisioningInfo *PrepareProvisioingStatusCB(OCClientResponse *clientResponse,
80                                              ProvStatus provStatus);
81
82
83 void LogProvisioningResponse(OCRepPayloadValue * val);
84
85 bool ConfigEnrolleeObject(const EnrolleeNWProvInfo_t *netInfo);
86
87 bool ClearMemory();
88
89 void SuccessCallback(OCClientResponse * clientResponse);
90
91 void ErrorCallback(ProvStatus status);
92
93 bool ValidateEnrolleResponse(OCClientResponse * clientResponse);
94
95 bool ValidateFinddResourceResponse(OCClientResponse * clientResponse);
96
97 ProvisioningInfo *GetCallbackObjectOnSuccess(OCClientResponse *clientResponse,
98                                              ProvStatus provStatus);
99
100 ProvisioningInfo *GetCallbackObjectOnError(ProvStatus status);
101
102 ProvisioningInfo *CreateCallBackObject();
103
104 bool ResetProgress();
105
106 bool SetProgress(OCProvisioningStatusCB provisioningStatusCallback);
107
108 bool InProgress();
109
110 bool ValidateEasySetupParams(const EnrolleeNWProvInfo_t *netInfo,
111                              OCProvisioningStatusCB provisioningStatusCallback);
112
113 bool IsSetupStopped();
114
115
116 #endif
117