1 //******************************************************************
\r
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
\r
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
\r
7 // Licensed under the Apache License, Version 2.0 (the "License");
\r
8 // you may not use this file except in compliance with the License.
\r
9 // You may obtain a copy of the License at
\r
11 // http://www.apache.org/licenses/LICENSE-2.0
\r
13 // Unless required by applicable law or agreed to in writing, software
\r
14 // distributed under the License is distributed on an "AS IS" BASIS,
\r
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 // See the License for the specific language governing permissions and
\r
17 // limitations under the License.
\r
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
\r
21 #ifndef REMOTE_ENROLLEE_RESOURCE_H_
\r
22 #define REMOTE_ENROLLEE_RESOURCE_H_
\r
27 #include "escommon.h"
\r
38 class EnrolleeSecurity;
\r
41 * This class contains the resource discovery methods.
\r
43 * @see RemoteEnrolleeResource
\r
45 class RemoteEnrolleeResource
\r
47 friend class EnrolleeSecurity;
\r
50 typedef std::shared_ptr< RemoteEnrolleeResource > Ptr;
\r
52 typedef std::function< void(std::shared_ptr< ProvisioningStatus >) > ProvStatusCb;
\r
55 * RemoteEnrolleeResource constructor
\r
57 * @param enrolleeNWProvInfo Provisioning information for the Enrollee
\r
59 * @throw ESBadRequestException is thrown if the parameters are invalid
\r
61 RemoteEnrolleeResource(EnrolleeNWProvInfo enrolleeNWProvInfo);
\r
63 ~RemoteEnrolleeResource() = default;
\r
66 * Register provisioning status handler.
\r
68 * @param callback Callback to get Provisioning status.
\r
70 * @throws InvalidParameterException If callback is an empty function or null.
\r
71 * @throws ESBadRequestException If registration is already completed.
\r
73 * @see ProvisioningStatus
\r
75 void registerProvStatusCallback (ProvStatusCb provStatusCb);
\r
78 * Construct Remote OIC resource using the enrollee host and connectivity information
\r
79 * provided in the constructor of RemoteEnrolleeResource.
\r
81 * @throws InvalidParameterException If the provided information is invalid.
\r
82 * @throws ESBadRequestException If resource is already constructed.
\r
84 * @see ProvisioningStatus
\r
86 ESResult constructResourceObject();
\r
89 * Function for provisioning of Remote Enrollee resource using the information provided.
\r
91 * @throws InvalidParameterException If cb is empty.
\r
93 void provisionEnrollee();
\r
96 * Function for unprovisioning of Remote Enrollee and bring to unprovisioned state
\r
98 * @throws ESBadRequestException If device is not provisioned already.
\r
100 void unprovisionEnrollee();
\r
105 std::shared_ptr< OC::OCResource > m_ocResource;
\r
106 std::mutex m_mutex;
\r
107 ProvStatusCb m_provStatusCb;
\r
108 EnrolleeNWProvInfo m_enrolleeNWProvInfo;
\r
109 bool m_discoveryResponse;
\r
111 void getProvStatusResponse(const HeaderOptions& headerOptions, const OCRepresentation& rep,
\r
114 void checkProvInformationCb(const HeaderOptions& headerOptions, const OCRepresentation& rep,
\r
117 ESResult ESDiscoveryTimeout(unsigned short waittime);
\r
119 void onDeviceDiscovered(std::shared_ptr<OC::OCResource> resource);
\r