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_H_
22 #define REMOTE_ENROLLEE_H_
24 #include "ESRichCommon.h"
30 class RemoteEnrolleeResource;
31 class EnrolleeSecurity;
34 * This class represents Remote Enrollee device instance.
35 * It will provide APIs for Mediator to perform operations to enable the Enrollee device
36 * to connect to the Enroller.
42 * RemoteEnrollee constructor
44 * @param enrolleeNWProvInfo Provisioning information for the Enrollee
46 * @throw ESBadRequestException is thrown if the parameters are invalid
48 RemoteEnrollee(const ProvConfig& enrolleeNWProvInfo, const WiFiOnboadingConnection& connection) ;
50 ~RemoteEnrollee() = default;
52 typedef std::shared_ptr< RemoteEnrollee > shared_ptr;
55 * Callback definition to be invoked when EasySetup status is changed.
56 * The same callback will be invoked when there is an error in the
59 * @see registerResourceHandler
62 typedef std::function< void(std::shared_ptr< EasySetupStatus >) >
67 * Register Security status and other information callback handlers.
69 * @param secProvisioningDbCb Callback to be invoked when the stack expects a
70 * path for the provisioning db.
71 * @param securityPinCb Callback to get security pin during pin based ownership transfer.
73 * @throws InvalidParameterException If callback is an empty function or null.
74 * @throws ESBadRequestException If registration is already completed.
76 * @see SecProvisioningResult
78 ESResult registerSecurityCallbackHandler(SecurityPinCb securityPinCb,
79 SecProvisioningDbPathCb secProvisioningDbPathCb);
80 #endif //__WITH_DTLS__
83 * Register EasySetup status handler.
85 * @param callback Callback to get EasySetup status.
86 * @param secProvisioningDbCB Callback to be invoked when the stack expects a
87 * path for the provisioning db.
89 * @throws InvalidParameterException If callback is an empty function or null.
90 * @throws ESBadRequestException If registration is already completed.
92 * @see EasySetupStatus
94 void registerEasySetupStatusHandler(EasySetupStatusCB callback);
97 * Start provisioning of target Enrollers information to the Enrollee.
99 * @throws ESBadRequestException If RemoteEnrollee device not created prior to this call.
101 * @see RemoteEnrollee
103 void startProvisioning();
106 * Stop provisioning process that is currently in progress.
108 * @throws BadRequestException If provisioning is not in progress.
110 void stopProvisioning();
113 * Check if the Enrollee device provisioned.
115 bool isEnrolleeProvisioned();
118 * Get the Provisioning information provided for the current Enrollee.
120 * @return ProvConfig Provisioning information provided for the current Enrollee.
122 ProvConfig getProvConfig ();
125 * Get the Onboarding connection information between Mediator and Enrollee.
127 * @return WiFiOnboadingConnection information between Mediator and Enrollee.
130 WiFiOnboadingConnection getOnboardConn();
133 std::shared_ptr< RemoteEnrolleeResource > m_remoteResource;
134 EasySetupStatusCB m_easySetupStatusCb;
135 EnrolleeSecStatusCb m_enrolleeSecStatusCb;
136 SecurityPinCb m_securityPinCb;
137 SecProvisioningDbPathCb m_secProvisioningDbPathCb;
138 ProvConfig m_ProvConfig;
139 WiFiOnboadingConnection m_wifiOnboardingconn;
141 std::shared_ptr< EnrolleeSecurity > m_enrolleeSecurity;
142 CurrentESState m_currentESState;
145 void provisioningStatusHandler (std::shared_ptr< ProvisioningStatus > provStatus);
146 void easySetupSecurityStatusCallback(
147 std::shared_ptr< SecProvisioningResult > secProvisioningResult);
152 #endif //REMOTE_ENROLLEE_H_