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 will have methods for on-boarding the Enrollee device.
25 * This will contain template methods that has will have core business logic & negotiation algorithm on various on-boarding methods.
28 #include "easysetup.h"
30 #include "onboarding.h"
33 #include "resourcehandler.h"
36 * @var ES_ENROLLEE_TAG
37 * @brief Logging tag for module name.
39 #define ES_ENROLLEE_TAG "ES_SOFTAP"
42 * It will return true on-boarding type is soft AP
44 bool ESSoftapOnboarding()
46 // TODO: To be changed based on user config. Current version, hardcoded to SoftAp onboarding
51 * It will return true on-boarding type is BLE
53 bool ESBleOnboarding()
55 //BLE onboarding is not supported with current version.
60 * It will do onboarding based on the user's configuration.
62 bool ESOnboard(const char * ssid, const char* passwd, NetworkEventCallback cb)
64 OC_LOG(DEBUG, ES_ENROLLEE_TAG, "ESOnboard IN");
66 if (ESSoftapOnboarding())
68 #ifndef ARDUINO //SoftAp at Arduino is not supported
69 if (ESSoftapAtEnrollee())
71 OC_LOG(DEBUG, ES_ENROLLEE_TAG, "Create softap at enrollee");
72 ESCreateSoftap(ssid, passwd, cb);
77 OC_LOG(DEBUG, ES_ENROLLEE_TAG, "Connecting to SoftAp");
78 ConnectToWiFiNetwork(ssid, passwd, cb);
82 else if (ESBleOnboarding())
84 OC_LOG(ERROR, ES_ENROLLEE_TAG, "ESOnboard::Ble onboarding is not supported");
91 OC_LOG(ERROR, ES_ENROLLEE_TAG, "ESOnboard::Invalid onboarding option");