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 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #ifndef REMOTE_ENROLLEE_RESOURCE_H_
22 #define REMOTE_ENROLLEE_RESOURCE_H_
27 #include "ESRichCommon.h"
38 class EnrolleeSecurity;
41 * This class contains the resource discovery methods.
43 * @see RemoteEnrolleeResource
45 class RemoteEnrolleeResource
47 friend class EnrolleeSecurity;
50 typedef std::shared_ptr< RemoteEnrolleeResource > Ptr;
52 typedef std::function< void(std::shared_ptr< ProvisioningStatus >) > ProvStatusCb;
55 * RemoteEnrolleeResource constructor
57 * @param enrolleeNWProvInfo Provisioning information for the Enrollee
59 * @throw ESBadRequestException is thrown if the parameters are invalid
61 RemoteEnrolleeResource(const ProvConfig &enrolleeNWProvInfo,
62 const WiFiOnboadingConnection &onboardingconn);
64 ~RemoteEnrolleeResource() = default;
67 * Register provisioning status handler.
69 * @param callback Callback to get Provisioning status.
71 * @throws InvalidParameterException If callback is an empty function or null.
72 * @throws ESBadRequestException If registration is already completed.
74 * @see ProvisioningStatus
76 void registerProvStatusCallback (ProvStatusCb provStatusCb);
79 * Construct Remote OIC resource using the enrollee host and connectivity information
80 * provided in the constructor of RemoteEnrolleeResource.
82 * @throws InvalidParameterException If the provided information is invalid.
83 * @throws ESBadRequestException If resource is already constructed.
85 * @see ProvisioningStatus
87 ESResult constructResourceObject();
90 * Function for provisioning of Remote Enrollee resource using the information provided.
92 * @throws InvalidParameterException If cb is empty.
94 void provisionEnrollee();
97 * Function for unprovisioning of Remote Enrollee and bring to unprovisioned state
99 * @throws ESBadRequestException If device is not provisioned already.
101 void unprovisionEnrollee();
106 std::shared_ptr< OC::OCResource > m_ocResource;
108 ProvStatusCb m_provStatusCb;
109 ProvConfig m_ProvConfig;
110 WiFiOnboadingConnection m_wifiOnboardingconn;
111 bool m_discoveryResponse;
113 void getProvStatusResponse(const HeaderOptions& headerOptions, const OCRepresentation& rep,
116 void checkProvInformationCb(const HeaderOptions& headerOptions, const OCRepresentation& rep,
119 ESResult ESDiscoveryTimeout(unsigned short waittime);
121 void onDeviceDiscovered(std::shared_ptr<OC::OCResource> resource);
123 void triggerNetworkConnection();
125 void triggerNetworkConnectionCb(
126 const HeaderOptions& headerOptions, const OCRepresentation& rep,