<data android:mimeType="text/plain" />
</intent-filter>
</activity>
- <activity
- android:name=".BLEActivity"
- >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
</application>
</manifest>
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
package org.iotivity.service.easysetup.core;
-public class BleConnection implements ConnectionInterface {
+public class BleConnection implements OnBoardingConnection {
private boolean mIsConnected;
private String mServiceUUID;
*/\r
\r
public void finish() {\r
+\r
//Native Api call to reset OIC stack\r
if(mProvisionEnrolleeInstance != null)\r
{\r
* @param enrolleedevice Device to be enrolled in network\r
*/\r
public synchronized void stopSetup(EnrolleeDevice enrolleedevice) {\r
- enrolleedevice.stopOnBoardingProcess();\r
- mEnrolleeDeviceList.remove(enrolleedevice);\r
-\r
- //Native Api call to stop on-going enrolling process for the enrolling device\r
- EasySetupManager.getInstance().stopEnrolleeProvisioning(enrolleedevice.mOnBoardingConfig.getConnType().getValue());\r
+ if(enrolleedevice.mState == EnrolleeState.DEVICE_ON_BOARDING_STATE) {\r
+ if(mEnrolleeDeviceList.contains(enrolleedevice)) {\r
+ Log.i(TAG, "stopOnBoardingProcess for enrolleedevice");\r
+ enrolleedevice.stopOnBoardingProcess();\r
+ mEnrolleeDeviceList.remove(enrolleedevice);\r
+ }\r
+ }\r
+ else if(enrolleedevice.mState == EnrolleeState.DEVICE_PROVISIONING_STATE)\r
+ {\r
+ if(mEnrolleeDeviceList.contains(enrolleedevice)) {\r
+ Log.i(TAG, "stopOnBoardingProcess for enrolleedevice");\r
+ enrolleedevice.stopOnBoardingProcess();\r
+\r
+ Log.i(TAG, "stopEnrolleeProvisioning for enrolleedevice");\r
+ //Native Api call to stop on-going enrolling process for the enrolling device\r
+ EasySetupManager.getInstance().stopEnrolleeProvisioning(enrolleedevice\r
+ .mOnBoardingConfig.getConnType().getValue());\r
+ mEnrolleeDeviceList.remove(enrolleedevice);\r
+ }\r
+ }\r
}\r
\r
public synchronized void getEnrolleeDevice(OnBoardingConfig connType) {\r
\r
@Override\r
public void onFinished(EnrolleeDevice enrolledevice) {\r
- //if(mEnrolleeDeviceList.contains(enrolledevice)) {\r
- Log.i(TAG, "onFinished() is received " + enrolledevice.isSetupSuccessful());\r
- mCallback.onFinished(enrolledevice);\r
- // }\r
+ if(mEnrolleeDeviceList.contains(enrolledevice)) {\r
+ Log.i(TAG, "onFinished() is received " + enrolledevice.isSetupSuccessful());\r
+ mCallback.onFinished(enrolledevice);\r
+ mEnrolleeDeviceList.remove(enrolledevice);\r
+ }\r
}\r
\r
}\r
import android.util.Log;
import org.iotivity.service.easysetup.core.BleConnection;
-import org.iotivity.service.easysetup.core.ConnectionInterface;
+import org.iotivity.service.easysetup.core.OnBoardingConnection;
import org.iotivity.service.easysetup.core.EnrolleeDevice;
import org.iotivity.service.easysetup.core.EnrolleeState;
import org.iotivity.service.easysetup.core.OnBoardingConfig;
}
@Override
- protected void startProvisioningProcess(ConnectionInterface conn) {
+ protected void startProvisioningProcess(OnBoardingConnection conn) {
Log.i("start provisioning BLE", mProvConfig.getConnType() + "");
\r
@Override\r
public void deviceOnBoardingStatus(EnrolleeInfo enrolleStatus) {\r
+ myTimer.cancel();\r
Log.d("ESSoftAPOnBoarding", "Entered");\r
if (mState == EnrolleeState.DEVICE_ON_BOARDING_STATE) {\r
Log.d("ESSoftAPOnBoarding", "Device in OnBoarding State");\r
+++ /dev/null
-/**\r
- * ***************************************************************\r
- * <p>\r
- * Copyright 2015 Samsung Electronics All Rights Reserved.\r
- * <p>\r
- * <p>\r
- * <p>\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * <p>\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * <p>\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * <p>\r
- * ****************************************************************\r
- */\r
-package org.iotivity.service.easysetup.mediator;\r
-\r
-import android.content.Context;\r
-import android.net.wifi.WifiConfiguration;\r
-\r
-\r
-import org.iotivity.service.easysetup.mediator.ip.WiFiSoftAPManager;\r
-\r
-public class OnBoardEnrollee {\r
- WiFiSoftAPManager wifiSoftAPManager;\r
- IOnBoardingStatus deviceScanListener;\r
-\r
- /**\r
- * Constructor for OnBoardEnrollee. Constructs a new OnBoardEnrollee.\r
- */\r
- public OnBoardEnrollee(Context context) {\r
- wifiSoftAPManager = new WiFiSoftAPManager(context);\r
- }\r
-\r
- public void registerOnBoardingStatusHandler(\r
- IOnBoardingStatus deviceScanListener) {\r
- this.deviceScanListener = deviceScanListener;\r
- }\r
-\r
- public void startDeviceScan() {\r
- wifiSoftAPManager.getClientList(this.deviceScanListener, 300);\r
- }\r
-\r
- public void enableWiFiAP(WifiConfiguration netConfig, boolean enabled) {\r
- wifiSoftAPManager.setWifiApEnabled(netConfig, true);\r
- }\r
-\r
- public void disableWiFiAP() {\r
- wifiSoftAPManager.setWifiApEnabled(null, false);\r
- }\r
-}\r
* If the device entry is found in the device, as application is already notified it will
* continue
*/
- private synchronized boolean CheckForDeviceEntryAndNotify(String ipAddr,
+ private boolean CheckForDeviceEntryAndNotify(String ipAddr,
String macAddr, boolean isReachable) {
final EnrolleeInfo result = new EnrolleeInfo();
boolean deviceAddedToList = false;
if (appNotification.size() > 0) {
for (EnrolleeOnBoardingInfo ipDeviceOnBoardingNotification : appNotification) {
- EnrolleeOnBoardingInfo ipEnrolleeDevice = (EnrolleeOnBoardingInfo) ipDeviceOnBoardingNotification;
+ EnrolleeOnBoardingInfo ipEnrolleeDevice = (EnrolleeOnBoardingInfo)
+ ipDeviceOnBoardingNotification;
boolean macAddressComparison = ipEnrolleeDevice.getHWAddr().equalsIgnoreCase(
macAddr) ? true : false;
.remove(ipDeviceOnBoardingNotification);
if (isReachable) {
appNotification
- .add(new EnrolleeOnBoardingInfo(ipAddr, macAddr, "", isReachable,
+ .add(new EnrolleeOnBoardingInfo(ipAddr, macAddr, "",
+ isReachable,
false, true));
- } else {
- appNotification
- .add(new EnrolleeOnBoardingInfo(ipAddr, macAddr, "", isReachable,
- true, false));
+ } else {
+ //This case will happen during the transition from connected to
+ // disconneted. This case need not be notified to application.
+ // Notifying this state will cause failure of OnBoarding
}
-
NotifyApplication(result);
return true;
}
appNotification
.add(new EnrolleeOnBoardingInfo(ipAddr, macAddr, "", isReachable, false,
true));
- } else {
- appNotification
- .add(new EnrolleeOnBoardingInfo(ipAddr, macAddr, "", isReachable, true,
- false));
- }
- result.setIpAddr(ipAddr);
- result.setHWAddr(macAddr);
- result.setReachable(isReachable);
+ result.setIpAddr(ipAddr);
+ result.setHWAddr(macAddr);
+ result.setReachable(isReachable);
- NotifyApplication(result);
+ NotifyApplication(result);
+ } else {
+ //This case will happen for the first time device is listed, but reachability
+ // is false. This case need not be notified to application. Notifying this
+ // state will cause failure of OnBoarding
+ }
return true;
}
} else {
appNotification
.add(new EnrolleeOnBoardingInfo(ipAddr, macAddr, "", isReachable, false,
true));
+ result.setIpAddr(ipAddr);
+ result.setHWAddr(macAddr);
+ result.setReachable(isReachable);
+
+ NotifyApplication(result);
} else {
- appNotification
- .add(new EnrolleeOnBoardingInfo(ipAddr, macAddr, "", isReachable, true,
- false));
+ //This case will happen for the first time device is listed, but
+ // reachability is false. This case need not be notified to
+ // application. Notifying this state will cause failure of OnBoarding
}
- result.setIpAddr(ipAddr);
- result.setHWAddr(macAddr);
- result.setReachable(isReachable);
-
- NotifyApplication(result);
return true;
}
return false;
* @param finishListener Interface called when the scan method finishes
* @param reachableTimeout Reachable Timeout in miliseconds
*/
- public void getClientList(IOnBoardingStatus finishListener, final int reachableTimeout) {
+ public synchronized void getClientList(IOnBoardingStatus finishListener, final int
+ reachableTimeout) {
this.finishListener = finishListener;
+ //Clearing the scan list for providing u
+ appNotification.clear();
Runnable runnable = new Runnable() {
public void run() {
Log.i(TAG, "Scanning enrolling device in the network" );
};
mainHandler.post(myRunnable);
*/
- Log.i(TAG, "Scanning is finished with result, IP : " + result.getIpAddr() + "Notifying to Application");
+ Log.i(TAG, "Scanning is finished with result, IP : " + result.getIpAddr() + "Notifying " +
+ "to Application");
finishListener.deviceOnBoardingStatus(result);
}
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#include "provisioninghandler.h"
+
+//Standard includes
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>
+
+//EasySetup include files
#include "ocpayload.h"
-#include "provisioninghandler.h"
#include "common.h"
-// External includes
+// External includes
#include "camutex.h"
#include "cathreadpool.h"
#include "logger.h"