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 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
24 * This file has methods for on-boarding the Enrollee device.
25 * This will contain template methods that will have core business logic & negotiation algorithm
26 * on various on-boarding methods.
29 #include "easysetup.h"
31 #include "onboarding.h"
34 #include "resourcehandler.h"
37 * @var ES_ENROLLEE_TAG
38 * @brief Logging tag for module name.
40 #define ES_ENROLLEE_TAG "ES_SOFTAP"
43 * It will return true on-boarding type is soft AP
45 bool ESSoftapOnboarding()
47 // TODO: To be changed based on user config. Current version, hardcoded to SoftAp onboarding
52 * It will return true on-boarding type is BLE
54 bool ESBleOnboarding()
56 //BLE onboarding is not supported with current version.
61 * It will do onboarding based on the user's configuration.
63 bool ESOnboard(const char * ssid, const char* passwd, NetworkEventCallback cb)
65 OIC_LOG(DEBUG, ES_ENROLLEE_TAG, "ESOnboard IN");
67 if (ESSoftapOnboarding())
69 if (ESSoftapAtEnrollee())
71 OIC_LOG(DEBUG, ES_ENROLLEE_TAG, "Create SoftAp at enrollee");
72 ESCreateSoftap(ssid, passwd, cb);
76 OIC_LOG(DEBUG, ES_ENROLLEE_TAG, "Connecting to Mediator SoftAp");
77 ConnectToWiFiNetwork(ssid, passwd, cb);
81 else if (ESBleOnboarding())
83 OIC_LOG(ERROR, ES_ENROLLEE_TAG, "ESOnboard::Ble onboarding is not supported");
90 OIC_LOG(ERROR, ES_ENROLLEE_TAG, "ESOnboard::Invalid onboarding option");