From 40019a2e68acb556b583e4a899446a678d7e99d3 Mon Sep 17 00:00:00 2001
From: Hemant Mahsky
Date: Wed, 9 Sep 2015 00:06:50 +0530
Subject: [PATCH] JavaDoc comments and code formatting
- Updated Java doc comments for EasySetup SDK APIs
- Performed code formatting using Android style
Signed-off-by: Hemant Mahsky
Change-Id: Ibdce574d460110de2e965817163561375a0669e9
Reviewed-on: https://gerrit.iotivity.org/gerrit/2410
Tested-by: jenkins-iotivity
Reviewed-by: Madan Lanka
---
.../iotivity/service/easysetup/MainActivity.java | 224 ++-------------------
.../easysetup/core/ConnectionInterface.java | 0
.../service/easysetup/core/EasySetupService.java | 55 +++--
.../service/easysetup/core/EasySetupStatus.java | 24 ++-
.../service/easysetup/core/EnrolleeDevice.java | 78 ++++++-
.../service/easysetup/core/EnrolleeSetupError.java | 9 +
.../service/easysetup/core/EnrolleeState.java | 40 ++--
.../service/easysetup/core/IpConnection.java | 4 +-
.../service/easysetup/core/OnBoardingCallback.java | 2 +-
.../service/easysetup/core/OnBoardingConfig.java | 20 +-
.../easysetup/core/ProvisioningCallback.java | 2 +-
.../service/easysetup/core/ProvisioningConfig.java | 19 +-
.../easysetup/impl/EnrolleeDeviceFactory.java | 27 ++-
.../impl/EnrolleeDeviceWiFiOnboarding.java | 69 +++----
.../easysetup/impl/WiFiOnBoardingConfig.java | 25 ++-
.../service/easysetup/impl/WiFiProvConfig.java | 6 +-
.../mediator/EasySetupCallbackHandler.java | 26 +--
.../easysetup/mediator/EasySetupManager.java | 28 +--
.../service/easysetup/mediator/EnrolleeInfo.java | 28 +--
.../easysetup/mediator/EnrolleeOnBoardingInfo.java | 32 +--
.../easysetup/mediator/IOnBoardingStatus.java | 22 +-
.../easysetup/mediator/IProvisioningListener.java | 22 +-
.../easysetup/mediator/OnBoardEnrollee.java | 23 ++-
.../easysetup/mediator/ProvisionEnrollee.java | 8 +-
.../easysetup/mediator/ip/WiFiSoftAPManager.java | 51 +++--
25 files changed, 423 insertions(+), 421 deletions(-)
mode change 100755 => 100644 service/easy-setup/sampleapp/android/EasySetup/app/src/main/java/org/iotivity/service/easysetup/MainActivity.java
mode change 100755 => 100644 service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/ConnectionInterface.java
mode change 100755 => 100644 service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/EasySetupStatus.java
mode change 100755 => 100644 service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/EnrolleeDevice.java
mode change 100755 => 100644 service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/EnrolleeSetupError.java
mode change 100755 => 100644 service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/EnrolleeState.java
mode change 100755 => 100644 service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/IpConnection.java
mode change 100755 => 100644 service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/OnBoardingCallback.java
mode change 100755 => 100644 service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/OnBoardingConfig.java
mode change 100755 => 100644 service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/ProvisioningCallback.java
mode change 100755 => 100644 service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/ProvisioningConfig.java
mode change 100755 => 100644 service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/impl/EnrolleeDeviceFactory.java
mode change 100755 => 100644 service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/impl/EnrolleeDeviceWiFiOnboarding.java
mode change 100755 => 100644 service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/impl/WiFiOnBoardingConfig.java
mode change 100755 => 100644 service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/impl/WiFiProvConfig.java
mode change 100755 => 100644 service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/IOnBoardingStatus.java
mode change 100755 => 100644 service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/ProvisionEnrollee.java
mode change 100755 => 100644 service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/ip/WiFiSoftAPManager.java
diff --git a/service/easy-setup/sampleapp/android/EasySetup/app/src/main/java/org/iotivity/service/easysetup/MainActivity.java b/service/easy-setup/sampleapp/android/EasySetup/app/src/main/java/org/iotivity/service/easysetup/MainActivity.java
old mode 100755
new mode 100644
index 75c67c5..69b81e0
--- a/service/easy-setup/sampleapp/android/EasySetup/app/src/main/java/org/iotivity/service/easysetup/MainActivity.java
+++ b/service/easy-setup/sampleapp/android/EasySetup/app/src/main/java/org/iotivity/service/easysetup/MainActivity.java
@@ -27,77 +27,21 @@ import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends Activity {
- TextView textView1;
+ TextView textView1;
- static final int REQUEST_IMAGE_CAPTURE = 1;
- ImageView imageView;
+ static final int REQUEST_IMAGE_CAPTURE = 1;
+ ImageView imageView;
ProvisionEnrollee provisionEnrolleInstance;
- /****Start new API implementation */
+ /**
+ * Objects to be instantiated by the programmer
+ */
WiFiProvConfig mWiFiProvConfig;
WiFiOnBoardingConfig mWiFiOnBoardingConfig;
- EasySetupService mEasySetupService ;
+ EasySetupService mEasySetupService;
EnrolleeDeviceFactory mDeviceFactory;
EnrolleeDevice mDevice;
- /* IOnBoardingStatus deviceScanListener = new IOnBoardingStatus() {
-
- @Override
- public void deviceOnBoardingStatus(EnrolleeInfo enrolleStatus) {
- // TODO Auto-generated method stub
- // TODO Auto-generated method stub
- if (enrolleStatus != null && enrolleStatus.getIpAddr() != null) {
- String finalResult = "Easy Connect : ";
-
- if (enrolleStatus.isReachable()) {
- finalResult = "Device OnBoarded" + "["
- + enrolleStatus.getIpAddr() + "]";
-
-
- * easySetupInstance.StartEasySetup(enrolleStatus.getIpAddr()) ;
- * easySetupCount++; Log.i("EasyConnect",
- * "easy Setup Count-"+easySetupCount); Log.i("EasyConnect",
- * "IP Address-"+enrolleStatus.getIpAddr());
-
- connectedDevice = enrolleStatus;
- } else {
- finalResult = "Device Removed" + "["
- + enrolleStatus.getIpAddr() + "]";
- }
-
- textView1.setText("");
- textView1.append("Clients: \n");
- textView1.append("####################\n");
- textView1.append("IP Address : " + enrolleStatus.getIpAddr()
- + "\n");
- textView1.append("Device : " + enrolleStatus.getDevice() + "\n");
- textView1.append("HW Address : " + enrolleStatus.getHWAddr()
- + "\n");
- textView1.append("Is OnBoarded : " + enrolleStatus.isReachable()
- + "\n");
-
- Toast.makeText(getApplicationContext(), finalResult,
- Toast.LENGTH_LONG).show();
-
-
- * myTimer2 = new Timer(); myTimer2.schedule(new TimerTask() {
- *
- * @Override public void run() {
- * easySetupInstance.StartEasySetup(enrolleStatus.getIpAddr());
- * easySetupCount++; Log.i("EasyConnect",
- * "easy Setup Count-"+easySetupCount); Log.i("EasyConnect",
- * "IP Address-"+enrolleStatus.getIpAddr()); }
- *
- * }, 0, 10000);
-
- }
- }
- };
- */
-
-
- /* End new API implementation*/
-
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -105,50 +49,17 @@ public class MainActivity extends Activity {
textView1 = (TextView) findViewById(R.id.textView1);
- // OnBoarding Process
- // onBoardingHandlerInstance = new OnBoardEnrollee(this);
-
- //onBoardingHandlerInstance.registerOnBoardingStatusHandler(this);
-
// Provisioning Process
provisionEnrolleInstance = new ProvisionEnrollee(this);
- // provisionEnrolleInstance.registerProvisioningHandler(this);
-
- /* // Get intent, action and MIME type
- Intent intent = getIntent();
- String action = intent.getAction();
- String type = intent.getType();
-
- if (Intent.ACTION_SEND.equals(action) && type != null) {
- if ("text/plain".equals(type)) {
- handleSendText(intent); // Handle text being sent
- }
- } else {
- // Handle other intents, such as being started from the home screen
- }
- addListenerForStartAP();
- addListenerForStopAP();
- addListenerOnProvisioning();
-
- myTimer2 = new Timer();
- myTimer2.schedule(new TimerTask() {
- @Override
- public void run() {
- //onBoardingHandlerInstance.startDeviceScan();
- mWifiSoftAPManager.getClientList(false, deviceScanListener);
- }
-
- }, 0, 2000);*/
-
-
- /* Start new API implementation */
+ /* Invocation of APIs using the Easy Setup SDK APIs */
+ /* Create Easy Setup Service instance*/
mEasySetupService = EasySetupService.getInstance(getApplicationContext(), new EasySetupStatus() {
@Override
public void onFinished(EnrolleeDevice enrolledevice) {
- final String msg = enrolledevice.isSetupSuccessful()? "Device configured successfully" : "Device configuration failed" ;
+ final String msg = enrolledevice.isSetupSuccessful() ? "Device configured successfully" : "Device configuration failed";
runOnUiThread(new Runnable() {
@Override
public void run() {
@@ -169,25 +80,26 @@ public class MainActivity extends Activity {
});
+ /* Create EnrolleeDevice Factory instance*/
mDeviceFactory = EnrolleeDeviceFactory.newInstance(getApplicationContext());
+ /* Create a device using Factory instance*/
mDevice = mDeviceFactory.newEnrolleeDevice(getOnBoardingWifiConfig(), getEnrollerWifiConfig());
addListenerForStartAP();
addListenerForStopAP();
-
- /* End new API implementation */
-
}
public WiFiProvConfig getEnrollerWifiConfig() {
+ /* Provide the credentials for the Mediator Soft AP to be connected by Enrollee*/
mWiFiProvConfig = new WiFiProvConfig("EasySetup123", "EasySetup123");
return mWiFiProvConfig;
}
public WiFiOnBoardingConfig getOnBoardingWifiConfig() {
- //TODO : Check proper configuration
mWiFiOnBoardingConfig = new WiFiOnBoardingConfig();
+
+ /* Provide the target credentials to be provisioned to the Enrollee by Mediator*/
mWiFiOnBoardingConfig.setSSId("EasySetup123");
mWiFiOnBoardingConfig.setSharedKey("EasySetup123");
mWiFiOnBoardingConfig.setAuthAlgo(WifiConfiguration.AuthAlgorithm.OPEN);
@@ -199,94 +111,8 @@ public class MainActivity extends Activity {
public void onDestroy() {
super.onDestroy();
provisionEnrolleInstance.stopEnrolleeProvisioning(0);
- //onBoardingHandlerInstance.disableWiFiAP();
- // mWifiSoftAPManager.setWifiApEnabled(null, false);
-
- //finish();
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- menu.add(0, 0, 0, "Get Clients");
- menu.add(0, 1, 0, "Start AP");
- menu.add(0, 2, 0, "Stop AP");
- menu.add(0, 3, 0, "Provision");
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.main, menu);
- return true;
}
-/* @Override
- public void onFinishProvisioning(final int statuscode) {
- // TODO Auto-generated method stub
- try {
- // code runs in a thread
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- // TODO Auto-generated method stub
- Toast toast = null;
- if (statuscode == 0) {
- toast = Toast.makeText(getApplicationContext(),
- connectedDevice.getIpAddr()
- + " - is Provisioned",
- Toast.LENGTH_LONG);
- Log.i("EasyConnect", "Provisioned statuscode-"
- + statuscode);
- } else {
- toast = Toast.makeText(getApplicationContext(),
- connectedDevice.getIpAddr()
- + " - is NOT Provisioned",
- Toast.LENGTH_LONG);
- Log.i("EasyConnect", "Not Provisioned statuscode-"
- + statuscode);
- }
-
- toast.show();
- }
- });
- } catch (final Exception ex) {
- Log.i("---", "Exception in thread");
- }
- }*/
-
-/* void handleSendText(Intent intent) {
- String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
- if (sharedText != null) {
-
- WifiConfiguration netConfig = new WifiConfiguration();
- netConfig.SSID = "DLNA_LISMORE1";
- netConfig.allowedAuthAlgorithms
- .set(WifiConfiguration.AuthAlgorithm.OPEN);
- netConfig.allowedKeyManagement
- .set(WifiConfiguration.KeyMgmt.WPA_PSK);
- netConfig.preSharedKey = "dlna@010203";
-
- mWifiSoftAPManager.setWifiApEnabled((WifiConfiguration)getOnBoardingWifiConfig().getConfig(), true);
-
- Toast.makeText(getApplicationContext(),
- "QR Code Captured. Starting Wi-Fi Access Point!",
- Toast.LENGTH_LONG).show();
-
- myTimer = new Timer();
- myTimer.schedule(new TimerTask() {
- @Override
- public void run() {
- scan();
- scanCount++;
- Log.i("EasyConnect", "Scan Count -" + scanCount);
- }
-
- }, 0, 5000);
- }
- }*/
-
-/* private void scan() {
- //onBoardingHandlerInstance.registerOnBoardingStatusHandler(this);
- mWifiSoftAPManager.getClientList(false, deviceScanListener);
- //onBoardingHandlerInstance.startDeviceScan();
- }*/
-
public void addListenerForStartAP() {
Button button = (Button) findViewById(R.id.button1);
@@ -314,24 +140,6 @@ public class MainActivity extends Activity {
});
}
-/* public void addListenerOnProvisioning() {
- Button button = (Button) findViewById(R.id.button2);
-
- button.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View arg0) {
- provisionEnrolleInstance.provisionEnrollee(
- connectedDevice.getIpAddr(), "NewAccessPoint",
- "NewAccessPoint", 0);
- easySetupCount++;
- Log.i("EasyConnect", "easy Setup Count-" + easySetupCount);
- Log.i("EasyConnect",
- "IP Address-" + connectedDevice.getIpAddr());
- }
- });
-
- }*/
-
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
@@ -340,6 +148,4 @@ public class MainActivity extends Activity {
imageView.setImageBitmap(imageBitmap);
}
}
-
-
}
diff --git a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/ConnectionInterface.java b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/ConnectionInterface.java
old mode 100755
new mode 100644
diff --git a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/EasySetupService.java b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/EasySetupService.java
index a07b54f..837b784 100644
--- a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/EasySetupService.java
+++ b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/EasySetupService.java
@@ -8,13 +8,19 @@ import org.iotivity.service.easysetup.impl.EnrolleeDeviceFactory;
import java.io.IOException;
import java.util.ArrayList;
+/**
+ * This is facade class, a single point of contact for Application.
+ * It contains set of APIs to do easy setup of the enrolling device.
+ * ON-BOARDING - This is a step to establish connectivity between the device & Mediator device.
+ * PROVISION - This is a step where the netowork's detail & credentials are given to the enrolling device.
+ */
public class EasySetupService {
- private static EasySetupService sInstance ;
+ private static EasySetupService sInstance;
private final EasySetupStatus mCallback;
- private ArrayListmEnrolleeDeviceList;
+ private ArrayList mEnrolleeDeviceList;
private final ProvisioningCallback mProvisioningCallback;
@@ -26,26 +32,38 @@ public class EasySetupService {
private EasySetupService(EasySetupStatus callback) {
mCallback = callback;
mProvisioningCallback = new ProvisioningCallbackImpl(mCallback);
- mEnrolleeDeviceList = new ArrayList ();
+ mEnrolleeDeviceList = new ArrayList();
mContext = null;
mDeviceFactory = null;
}
- // TODO : Implement singleton method
+ /**
+ * Gives a singleton instance of Easy setup service.
+ *
+ * @param callback Application needs to provide this callback to receive the status of of easy setup process.
+ */
+
public synchronized static EasySetupService getInstance(Context context, EasySetupStatus callback) {
- if(sInstance == null) {
+ if (sInstance == null) {
sInstance = new EasySetupService(callback);
mContext = context;
}
- return sInstance ;
+ return sInstance;
}
- public synchronized void startSetup (final EnrolleeDevice enrolledevice) throws IOException{
+ /**
+ * Starts Easy setup process for the enrolling device.
+ *
+ * @param enrolledevice Device to be enrolled in network
+ * @throws IOException Throws exception in case of any connection error.
+ */
+
+ public synchronized void startSetup(final EnrolleeDevice enrolledevice) throws IOException {
mEnrolleeDeviceList.add(enrolledevice);
// Starts the provisioning directly if the device is already on boarded on the network.
- if(enrolledevice.onBoarded()) {
+ if (enrolledevice.onBoarded()) {
enrolledevice.startProvisioning(mProvisioningCallback);
return;
}
@@ -54,7 +72,7 @@ public class EasySetupService {
@Override
public void onFinished(ConnectionInterface connection) {
- if(connection.isConnected()) {
+ if (connection.isConnected()) {
try {
Thread.sleep(15000);//Sleep for allowing thin device to start the services
} catch (InterruptedException e) {
@@ -64,7 +82,7 @@ public class EasySetupService {
// Start provisioning here
enrolledevice.setConnection(connection);
enrolledevice.startProvisioning(mProvisioningCallback);
- }else{
+ } else {
enrolledevice.mState = EnrolleeState.DEVICE_PROVISIONING_FAILED_STATE;
mProvisioningCallback.onFinished(enrolledevice);
}
@@ -75,27 +93,32 @@ public class EasySetupService {
}
- public synchronized void stopSetup (EnrolleeDevice enrolledevice) {
+ /**
+ * Stops on-going Easy setup process for enrolling device.
+ *
+ * @param enrolledevice Device to be enrolled in network
+ */
+ public synchronized void stopSetup(EnrolleeDevice enrolledevice) {
enrolledevice.stopOnBoardingProcess();
mEnrolleeDeviceList.remove(enrolledevice);
}
- public synchronized void getEnrolleeDevice (OnBoardingConfig connType) {
+ public synchronized void getEnrolleeDevice(OnBoardingConfig connType) {
mDeviceFactory = EnrolleeDeviceFactory.newInstance(mContext);
}
class ProvisioningCallbackImpl extends ProvisioningCallback {
- private final EasySetupStatus mCallback ;
+ private final EasySetupStatus mCallback;
- ProvisioningCallbackImpl (EasySetupStatus callback) {
- mCallback = callback;
+ ProvisioningCallbackImpl(EasySetupStatus callback) {
+ mCallback = callback;
}
@Override
public void onFinished(EnrolleeDevice enrolledevice) {
//if(mEnrolleeDeviceList.contains(enrolledevice)) {
- mCallback.onFinished(enrolledevice);
+ mCallback.onFinished(enrolledevice);
//}
}
diff --git a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/EasySetupStatus.java b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/EasySetupStatus.java
old mode 100755
new mode 100644
index f77db29..4ec7712
--- a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/EasySetupStatus.java
+++ b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/EasySetupStatus.java
@@ -1,8 +1,28 @@
package org.iotivity.service.easysetup.core;
+/**
+ * This interface facilitates Application to get progress & result of Easy setup
+ * process Easy setup process.
+ */
public interface EasySetupStatus {
- public void onFinished(EnrolleeDevice enrolledevice);
- public void onProgress(EnrolleeState state);
+ /**
+ * This method is called back when easy setup process is finished. Easy
+ * setup process status can read from the APIs given in Enrollee class.This
+ * method is called on worker thread, UI operations to be executed on main /
+ * Ui Thread.
+ *
+ * @param enrolledevice Device to be enrolled in network through Easy setup process
+ */
+ public void onFinished(EnrolleeDevice enrolledevice);
+
+ /**
+ * This method is called back to give intermediate progress on the easy
+ * setup process This method is called on worker thread, UI operations to be
+ * executed on main / Ui Thread.
+ *
+ * @param state Gives state of the device changed during easy setup process
+ */
+ public void onProgress(EnrolleeState state);
}
diff --git a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/EnrolleeDevice.java b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/EnrolleeDevice.java
old mode 100755
new mode 100644
index 9962b59..e7577d1
--- a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/EnrolleeDevice.java
+++ b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/EnrolleeDevice.java
@@ -1,60 +1,118 @@
package org.iotivity.service.easysetup.core;
+/**
+ * This is an abstract class represents the device being provisioned into the network. The device being enrolled or provisioned into the network is called Enrollee.
+ * Application has to extend this class and provide implementation of abstract methods according to the ON-BOARDING & PROVISION connectivity i.e. WiFi, BLE, BT etc. the device is having.
+ */
+
public abstract class EnrolleeDevice {
protected EnrolleeState mState;
private EnrolleeSetupError mError;
- protected ConnectionInterface mConnection;
+ protected ConnectionInterface mConnection;
protected final ProvisioningConfig mProvConfig;
protected final OnBoardingConfig mOnBoardingConfig;
protected OnBoardingCallback mOnBoardingCallback;
protected ProvisioningCallback mProvisioningCallback;
+ /**
+ * @param onBoardingConfig Contains details about the connectivity to be established between the Enrollee device & Mediator device in order to perform on-boarding
+ * @param provConfig Contains details about the network to which Enrollee device is going to connect.
+ */
protected EnrolleeDevice(OnBoardingConfig onBoardingConfig, ProvisioningConfig provConfig) {
mProvConfig = provConfig;
mOnBoardingConfig = onBoardingConfig;
}
-
- // Application can override this API to provide their own implementation for on boarding.
+ /**
+ * Application has to implement it according to the on boarding connectivity the device is having.
+ * This method will be called back during the easy setup process.
+ */
protected abstract void startOnBoardingProcess();
+
+ /**
+ * This method is called back during the easy setup process if Application cancels the setup.
+ * Easy setup service checks the state of device and calls this function accordingly.
+ * Application has to provide implementation for this method to cancel the on boarding step.
+ */
protected abstract void stopOnBoardingProcess();
+ /**
+ * Application has to implement it according to the type of the network device is going to connect or provisioned.
+ * This method will be called back once on-boarding of the device is successful.
+ *
+ * @param conn Contains detail about the network established between the Enrollee device & Mediator device. Its implementation vary according to the connectivity type.
+ */
protected abstract void startProvisioningProcess(ConnectionInterface conn);
+ /**
+ * Once on boarding is successful concrete Enrollee class would call this method and set the Connection.
+ *
+ * @param conn Connectivity between Enrollee device & Mediator device.
+ */
public void setConnection(ConnectionInterface conn) {
mConnection = conn;
}
- // Not accessible by the Application
- void startOnBoarding(OnBoardingCallback onBoardingCallback){
+
+ /**
+ * This method is called back by Easy setup service if on boarding needs to be done.
+ *
+ * @param onBoardingCallback This is called back once the on boarding is completed.
+ */
+ void startOnBoarding(OnBoardingCallback onBoardingCallback) {
mOnBoardingCallback = onBoardingCallback;
startOnBoardingProcess();
}
- // Not accessible by the Application
- void startProvisioning(ProvisioningCallback provisioningCallback){
+ /**
+ * This method is called back by Easy setup service once on boarding is successful
+ *
+ * @param provisioningCallback This is called back once the provisioning process is completed
+ */
+ void startProvisioning(ProvisioningCallback provisioningCallback) {
mProvisioningCallback = provisioningCallback;
startProvisioningProcess(mConnection);
}
+ /**
+ * This method is used to check easy setup status
+ *
+ * @return true if successful or false
+ */
- public boolean isSetupSuccessful(){
+ public boolean isSetupSuccessful() {
return (mState == EnrolleeState.DEVICE_PROVISIONING_SUCCESS_STATE) ? true : false;
}
+ /**
+ * Returns error occured during easy setup process
+ *
+ * @return True EnrolleeSetupError object
+ */
public EnrolleeSetupError getError() {
return mError;
}
+ /**
+ * Gives the state of the device being enrolled during the easy setup process.
+ *
+ * @return Returns EnrolleeState object
+ */
public EnrolleeState getState() {
return mState;
}
- public boolean onBoarded(){
- return ( mState == EnrolleeState.DEVICE_PROVISIONING_STATE ) ? true : false;
+ /**
+ * This method is used to know if the device is on boarded or not
+ *
+ * @return True if on-boarded successfully or False
+ */
+
+ public boolean onBoarded() {
+ return (mState == EnrolleeState.DEVICE_PROVISIONING_STATE) ? true : false;
}
}
diff --git a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/EnrolleeSetupError.java b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/EnrolleeSetupError.java
old mode 100755
new mode 100644
index 93b4b08..3a2ef4b
--- a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/EnrolleeSetupError.java
+++ b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/EnrolleeSetupError.java
@@ -1,6 +1,15 @@
package org.iotivity.service.easysetup.core;
+/**
+ * This class defines constants for Errors comes during Easy setup process
+ */
public enum EnrolleeSetupError {
+ /**
+ * Device setup successful
+ */
DEVICE_SETUP_SUCCESSFUL,
+ /**
+ * Device setup failed
+ */
DEVICE_SETUP_FAILED,
}
diff --git a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/EnrolleeState.java b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/EnrolleeState.java
old mode 100755
new mode 100644
index b20f5f2..cb74de6
--- a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/EnrolleeState.java
+++ b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/EnrolleeState.java
@@ -2,33 +2,47 @@ package org.iotivity.service.easysetup.core;
/**
- *
- * The device being enrolled into the network will fall into any of the below mentioned states
- *
+ * It defines various states of the Enrollee device during easy setup process
*/
public enum EnrolleeState {
- // Device will be there in this state by default
+ /**
+ * Default state of the device
+ */
+ DEVICE_INIT_STATE,
+
+ /**
+ * Device will move to this state after successful on-boarding of the device
+ */
DEVICE_ON_BOARDING_STATE,
- // Device will move to this state once the on boarding is done
+ /**
+ * Device will move to this state once the on boarding is done
+ */
DEVICE_PROVISIONING_STATE,
- // Device will move to this state after successful provisioning into the network
+ /**
+ * Easy setup process is successful.
+ */
DEVICE_PROVISIONING_SUCCESS_STATE,
- // Device is not able to provisioned
+ /**
+ * Device is not able to provisioned.
+ * Easy setup process failed to enrolled the device in the network
+ */
DEVICE_PROVISIONING_FAILED_STATE,
- // The below state is arbitrary one, any time device can come into this state
- //Device will move to this state if the ownership transfer initiated by the Application
+ /**
+ * This state is arbitrary one, any time device can come into this state
+ * Device will move to this state if the ownership transfer initiated by the Application
+ */
DEVICE_OWNERSHIP_TRANSFER_STATE,
- // The below state is arbitrary one, any time device can come into this state
- // Device will move to this state once the Application factory reset the device
+ /**
+ * This state is arbitrary one, any time device can come into this state
+ * Device will move to this state once the Application factory reset the device
+ */
DEVICE_FACTORY_RESET_STATE,
-
-
}
diff --git a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/IpConnection.java b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/IpConnection.java
old mode 100755
new mode 100644
index 480bbac..6140ca9
--- a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/IpConnection.java
+++ b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/IpConnection.java
@@ -1,11 +1,11 @@
package org.iotivity.service.easysetup.core;
-public class IpConnection implements ConnectionInterface{
+public class IpConnection implements ConnectionInterface {
private boolean mIsConnected;
private String mIp;
- public void setConnectivity(boolean connected){
+ public void setConnectivity(boolean connected) {
mIsConnected = connected;
}
diff --git a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/OnBoardingCallback.java b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/OnBoardingCallback.java
old mode 100755
new mode 100644
index cf9fc76..f7314de
--- a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/OnBoardingCallback.java
+++ b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/OnBoardingCallback.java
@@ -1,5 +1,5 @@
package org.iotivity.service.easysetup.core;
public abstract class OnBoardingCallback {
- public abstract void onFinished(ConnectionInterface connection) ;
+ public abstract void onFinished(ConnectionInterface connection);
}
diff --git a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/OnBoardingConfig.java b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/OnBoardingConfig.java
old mode 100755
new mode 100644
index e6279ee..b8f96ba
--- a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/OnBoardingConfig.java
+++ b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/OnBoardingConfig.java
@@ -1,16 +1,32 @@
package org.iotivity.service.easysetup.core;
+/**
+ * It contains configuration details about the connectivity type between the Enrollee device & Mediator device in order to perform on-boarding.
+ */
public interface OnBoardingConfig {
+ /**
+ * It provides constants for connectivity types used for on-boarding Enrollee device
+ */
public static enum ConnType {
WiFi,
BLE,
}
+ /**
+ * Gives configuration object specific to the on-boarding connectivity of the enrolling device.
+ *
+ * @return instance object of configuration according to connectivity type
+ */
public Object getConfig();
+
+ /**
+ * Gives connectivity type of on-boarding device
+ *
+ * @return on-boarding connectivity type
+ */
public ConnType getConnType();
- public ConnectionInterface getConnection();
- public void setConnection(ConnectionInterface conn);
+
}
diff --git a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/ProvisioningCallback.java b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/ProvisioningCallback.java
old mode 100755
new mode 100644
index 2a8847f..d8ddb58
--- a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/ProvisioningCallback.java
+++ b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/ProvisioningCallback.java
@@ -1,5 +1,5 @@
package org.iotivity.service.easysetup.core;
public abstract class ProvisioningCallback {
- public abstract void onFinished(EnrolleeDevice enrolledevice) ;
+ public abstract void onFinished(EnrolleeDevice enrolledevice);
}
diff --git a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/ProvisioningConfig.java b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/ProvisioningConfig.java
old mode 100755
new mode 100644
index 8cb52d1..6792cc6
--- a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/ProvisioningConfig.java
+++ b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/core/ProvisioningConfig.java
@@ -1,14 +1,31 @@
package org.iotivity.service.easysetup.core;
-
+/**
+ * It contains configuration details about the the target network where Enrollee device is going to be enrolled.
+ */
public interface ProvisioningConfig {
+ /**
+ * It provides constants for connectivity types of target network
+ */
public static enum ConnType {
WiFi,
BT
}
+ /**
+ * Gives the instance of the configuration object created according to the connectivity type of target network.
+ *
+ * @return instance object of configuration according to connectivity type of target network
+ */
Object getConfig();
+
+
+ /**
+ * Gives connectivity type of target network
+ *
+ * @return Connectivity type of target network
+ */
ConnType getConnType();
}
diff --git a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/impl/EnrolleeDeviceFactory.java b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/impl/EnrolleeDeviceFactory.java
old mode 100755
new mode 100644
index 8f6b78e..145e2ea
--- a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/impl/EnrolleeDeviceFactory.java
+++ b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/impl/EnrolleeDeviceFactory.java
@@ -6,25 +6,42 @@ import org.iotivity.service.easysetup.core.ProvisioningConfig;
import android.content.Context;
+/**
+ * This a factory class provides the native implementation of the various Enrollee devices.
+ * Application can make use of Enrollee factory if it does not want to create its own Enrollee devices.
+ */
public class EnrolleeDeviceFactory {
Context mContext;
+ /**
+ * This method create & returns instance of EnrolleeDeviceFactory
+ *
+ * @param context This is Android Application context
+ */
public static EnrolleeDeviceFactory newInstance(Context context) {
return new EnrolleeDeviceFactory(context);
}
- private EnrolleeDeviceFactory (Context context) {
+ private EnrolleeDeviceFactory(Context context) {
mContext = context;
}
- public EnrolleeDevice newEnrolleeDevice(OnBoardingConfig onboardingConfig, ProvisioningConfig provConfig){
+ /**
+ * This method create & returns instance of Enrollee device of supported configuration
+ *
+ * @param onboardingConfig Contains details about the connectivity to be established between the Enrollee device & Mediator device in order to perform on-boarding
+ * @param provConfig Contains details about the network to which Enrollee device is going to connect.
+ * @return Instance of the Enrollee device created natively.
+ */
+
+ public EnrolleeDevice newEnrolleeDevice(OnBoardingConfig onboardingConfig, ProvisioningConfig provConfig) {
EnrolleeDevice enrolleeDevice;
- if (onboardingConfig.getConnType()== OnBoardingConfig.ConnType.WiFi) {
- enrolleeDevice = new EnrolleeDeviceWiFiOnboarding(mContext, onboardingConfig, provConfig);
- }else {
+ if (onboardingConfig.getConnType() == OnBoardingConfig.ConnType.WiFi) {
+ enrolleeDevice = new EnrolleeDeviceWiFiOnboarding(mContext, onboardingConfig, provConfig);
+ } else {
throw new IllegalArgumentException("OnBoarding configuration is not supported");
}
diff --git a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/impl/EnrolleeDeviceWiFiOnboarding.java b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/impl/EnrolleeDeviceWiFiOnboarding.java
old mode 100755
new mode 100644
index cf22da2..db57a77
--- a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/impl/EnrolleeDeviceWiFiOnboarding.java
+++ b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/impl/EnrolleeDeviceWiFiOnboarding.java
@@ -22,27 +22,30 @@ import android.net.wifi.WifiConfiguration;
import android.util.Log;
import android.widget.Toast;
-public class EnrolleeDeviceWiFiOnboarding extends EnrolleeDevice {
+/**
+ * This is a ready to use class for Enrollee device having Soft AP as on-boarding connectivity.
+ */
+public class EnrolleeDeviceWiFiOnboarding extends EnrolleeDevice {
public static final String TAG = EnrolleeDeviceWiFiOnboarding.class.getName();
- final Context mContext;
+ final Context mContext;
final WiFiSoftAPManager mWifiSoftAPManager;
- EnrolleeInfo connectedDevice;
- private EasySetupManager easySetupManagerNativeInstance ;
+ EnrolleeInfo connectedDevice;
+ private EasySetupManager easySetupManagerNativeInstance;
ProvisionEnrollee provisionEnrolleInstance;
IOnBoardingStatus deviceScanListener = new IOnBoardingStatus() {
- @Override
- public void deviceOnBoardingStatus(EnrolleeInfo enrolleStatus) {
- Log.d("ESSoftAPOnBoarding", "Entered");
- if (enrolleStatus != null && enrolleStatus.getIpAddr() != null) {
- String finalResult = "Easy Connect : ";
+ @Override
+ public void deviceOnBoardingStatus(EnrolleeInfo enrolleStatus) {
+ Log.d("ESSoftAPOnBoarding", "Entered");
+ if (enrolleStatus != null && enrolleStatus.getIpAddr() != null) {
+ String finalResult = "Easy Connect : ";
- if (enrolleStatus.isReachable()) {
- finalResult = "Device OnBoarded" + "["
- + enrolleStatus.getIpAddr() + "]";
+ if (enrolleStatus.isReachable()) {
+ finalResult = "Device OnBoarded" + "["
+ + enrolleStatus.getIpAddr() + "]";
/*
* easySetupInstance.StartEasySetup(enrolleStatus.getIpAddr()) ;
@@ -50,15 +53,15 @@ public class EnrolleeDeviceWiFiOnboarding extends EnrolleeDevice {
* "easy Setup Count-"+easySetupCount); Log.i("EasyConnect",
* "IP Address-"+enrolleStatus.getIpAddr());
*/
- connectedDevice = enrolleStatus;
- IpConnection conn = new IpConnection();
- conn.setConnectivity(true);
- conn.setIp(connectedDevice.getIpAddr());
- Log.d("ESSoftAPOnBoarding", "Entered");
- mOnBoardingCallback.onFinished(conn);
- return;
+ connectedDevice = enrolleStatus;
+ IpConnection conn = new IpConnection();
+ conn.setConnectivity(true);
+ conn.setIp(connectedDevice.getIpAddr());
+ Log.d("ESSoftAPOnBoarding", "Entered");
+ mOnBoardingCallback.onFinished(conn);
+ return;
- }
+ }
/* textView1.setText("");
textView1.append("Clients: \n");
@@ -75,12 +78,12 @@ public class EnrolleeDeviceWiFiOnboarding extends EnrolleeDevice {
Toast.LENGTH_LONG).show();*/
- }
-
- IpConnection conn = new IpConnection();
- conn.setConnectivity(false);
- mOnBoardingCallback.onFinished(conn);
}
+
+ IpConnection conn = new IpConnection();
+ conn.setConnectivity(false);
+ mOnBoardingCallback.onFinished(conn);
+ }
};
@@ -101,12 +104,12 @@ public class EnrolleeDeviceWiFiOnboarding extends EnrolleeDevice {
Log.i(TAG, "Starging on boarding process");
//1. Create Soft AP
- boolean status = mWifiSoftAPManager.setWifiApEnabled((WifiConfiguration)mOnBoardingConfig.getConfig(), true);
+ boolean status = mWifiSoftAPManager.setWifiApEnabled((WifiConfiguration) mOnBoardingConfig.getConfig(), true);
Log.i(TAG, "Soft AP is created with status " + status);
- Timer myTimer;
+ Timer myTimer;
myTimer = new Timer();
myTimer.schedule(new TimerTask() {
@Override
@@ -118,7 +121,6 @@ public class EnrolleeDeviceWiFiOnboarding extends EnrolleeDevice {
}, 0, 5000);
-
}
protected void stopOnBoardingProcess() {
@@ -130,27 +132,26 @@ public class EnrolleeDeviceWiFiOnboarding extends EnrolleeDevice {
@Override
protected void startProvisioningProcess(ConnectionInterface conn) {
- if(mProvConfig.getConnType() == ProvisioningConfig.ConnType.WiFi) {
+ if (mProvConfig.getConnType() == ProvisioningConfig.ConnType.WiFi) {
provisionEnrolleInstance = new ProvisionEnrollee(mContext);
provisionEnrolleInstance.registerProvisioningHandler(new IProvisioningListener() {
@Override
public void onFinishProvisioning(int statuscode) {
- mState = ( statuscode == 0) ? EnrolleeState.DEVICE_PROVISIONING_SUCCESS_STATE : EnrolleeState.DEVICE_PROVISIONING_FAILED_STATE;
+ mState = (statuscode == 0) ? EnrolleeState.DEVICE_PROVISIONING_SUCCESS_STATE : EnrolleeState.DEVICE_PROVISIONING_FAILED_STATE;
mProvisioningCallback.onFinished(EnrolleeDeviceWiFiOnboarding.this);
}
});
- IpConnection connection = (IpConnection)conn;
- WiFiProvConfig wifiProvConfig = (WiFiProvConfig)mProvConfig;
+ IpConnection connection = (IpConnection) conn;
+ WiFiProvConfig wifiProvConfig = (WiFiProvConfig) mProvConfig;
easySetupManagerNativeInstance = EasySetupManager.getInstance();
easySetupManagerNativeInstance.initEasySetup();
- easySetupManagerNativeInstance.provisionEnrollee(connection .getIp(), wifiProvConfig.getSsId(), wifiProvConfig.getPassword(), 0 /*In base code '0' is hard coded*/);
+ easySetupManagerNativeInstance.provisionEnrollee(connection.getIp(), wifiProvConfig.getSsId(), wifiProvConfig.getPassword(), 0 /*In base code '0' is hard coded*/);
}
}
-
}
diff --git a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/impl/WiFiOnBoardingConfig.java b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/impl/WiFiOnBoardingConfig.java
old mode 100755
new mode 100644
index ed450b6..1bf863d
--- a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/impl/WiFiOnBoardingConfig.java
+++ b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/impl/WiFiOnBoardingConfig.java
@@ -6,7 +6,12 @@ import org.iotivity.service.easysetup.core.OnBoardingConfig;
import android.net.wifi.WifiConfiguration;
-public class WiFiOnBoardingConfig implements OnBoardingConfig{
+/**
+ * This class contains on boarding configuration information for Soft AP on boarding connectivity.
+ * It implements OnBoardingConfig interface & provide implementation for WiFi Soft AP connectivity.
+ */
+
+public class WiFiOnBoardingConfig implements OnBoardingConfig {
private final WifiConfiguration config = new WifiConfiguration();
private final ConnType mConnType = OnBoardingConfig.ConnType.WiFi;
@@ -40,16 +45,16 @@ public class WiFiOnBoardingConfig implements OnBoardingConfig{
return mConnType;
}
- @Override
- public ConnectionInterface getConnection() {
- // TODO Auto-generated method stub
- return mConnection;
- }
+/* @Override
+ public OnBoardingConnection getConnection() {
+ // TODO Auto-generated method stub
+ return mConnection;
+ }
- @Override
- public void setConnection(ConnectionInterface conn) {
- mConnection = (IpConnection)conn;
- }
+ @Override
+ public void setConnection(OnBoardingConnection conn) {
+ mConnection = (IpConnection)conn;
+ }*/
}
diff --git a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/impl/WiFiProvConfig.java b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/impl/WiFiProvConfig.java
old mode 100755
new mode 100644
index 723dcbc..f2c8ab0
--- a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/impl/WiFiProvConfig.java
+++ b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/impl/WiFiProvConfig.java
@@ -5,7 +5,11 @@ import org.iotivity.service.easysetup.mediator.EnrolleeInfo;
import android.net.wifi.WifiConfiguration;
-public class WiFiProvConfig implements ProvisioningConfig{
+/**
+ * This class contains on provisioning configuration information for for target network.
+ * It implements ProvisioningConfig interface and provide configuration object specific to WiFi target network
+ */
+public class WiFiProvConfig implements ProvisioningConfig {
private final ConnType mConnType = ProvisioningConfig.ConnType.WiFi;
diff --git a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EasySetupCallbackHandler.java b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EasySetupCallbackHandler.java
index 1b61069..3c93be1 100644
--- a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EasySetupCallbackHandler.java
+++ b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EasySetupCallbackHandler.java
@@ -1,29 +1,31 @@
-/******************************************************************
- *
+/**
+ * ***************************************************************
+ *
* Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
+ *
+ *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
- ******************************************************************/
+ *
+ * ****************************************************************
+ */
package org.iotivity.service.easysetup.mediator;
import android.util.Log;
public class EasySetupCallbackHandler {
- private static final String TAG = "ESCallbackHandler";
- ProvisionEnrollee provisioningListener;
+ private static final String TAG = "ESCallbackHandler";
+ ProvisionEnrollee provisioningListener;
private static EasySetupCallbackHandler easySetupCallbackHandlerObj;
diff --git a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EasySetupManager.java b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EasySetupManager.java
index 0319f79..dcb99e4 100644
--- a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EasySetupManager.java
+++ b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EasySetupManager.java
@@ -1,22 +1,24 @@
-/******************************************************************
- *
+/**
+ * ***************************************************************
+ *
* Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
+ *
+ *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
- ******************************************************************/
+ *
+ * ****************************************************************
+ */
package org.iotivity.service.easysetup.mediator;
import android.content.Context;
@@ -32,14 +34,14 @@ public class EasySetupManager {
// second parameter for PerformEasySetup
// instead of integer
private native void ProvisionEnrollee(String ipAddress, String netSSID,
- String netPWD, int connectivityType);
+ String netPWD, int connectivityType);
private native void StopEnrolleeProvisioning(int connectivityType);
public static native void initialize(Context context);
private static EasySetupManager easySetupManagerInterfaceObj = null;
- private Context appContext = null;
+ private Context appContext = null;
static {
// Load Easy Setup JNI interface
@@ -80,7 +82,7 @@ public class EasySetupManager {
}
public void provisionEnrollee(String ipAddress, String netSSID,
- String netPWD, int connectivityType) {
+ String netPWD, int connectivityType) {
ProvisionEnrollee(ipAddress, netSSID, netPWD, connectivityType);
}
diff --git a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EnrolleeInfo.java b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EnrolleeInfo.java
index a00758e..db3b737 100644
--- a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EnrolleeInfo.java
+++ b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EnrolleeInfo.java
@@ -1,30 +1,32 @@
-/******************************************************************
- *
+/**
+ * ***************************************************************
+ *
* Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
+ *
+ *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
- ******************************************************************/
+ *
+ * ****************************************************************
+ */
package org.iotivity.service.easysetup.mediator;
public class EnrolleeInfo {
- private String IpAddr;
- private String HWAddr;
- private String Device;
+ private String IpAddr;
+ private String HWAddr;
+ private String Device;
private boolean isReachable;
public String getIpAddr() {
diff --git a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EnrolleeOnBoardingInfo.java b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EnrolleeOnBoardingInfo.java
index 161b7fb..1abf5f4 100644
--- a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EnrolleeOnBoardingInfo.java
+++ b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EnrolleeOnBoardingInfo.java
@@ -1,36 +1,38 @@
-/******************************************************************
- *
+/**
+ * ***************************************************************
+ *
* Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
+ *
+ *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
- ******************************************************************/
+ *
+ * ****************************************************************
+ */
package org.iotivity.service.easysetup.mediator;
public class EnrolleeOnBoardingInfo {
- private String IpAddr;
- private String HWAddr;
- private String Device;
+ private String IpAddr;
+ private String HWAddr;
+ private String Device;
private boolean isReachable;
private boolean isAdditionNotified;
private boolean isRemovalNotified;
public EnrolleeOnBoardingInfo(String ipAddr, String hWAddr, String device,
- boolean isReachable, boolean isRemovalNotified,
- boolean isAdditionNotified) {
+ boolean isReachable, boolean isRemovalNotified,
+ boolean isAdditionNotified) {
this.IpAddr = ipAddr;
this.HWAddr = hWAddr;
this.Device = device;
diff --git a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/IOnBoardingStatus.java b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/IOnBoardingStatus.java
old mode 100755
new mode 100644
index 403721d..23cec64
--- a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/IOnBoardingStatus.java
+++ b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/IOnBoardingStatus.java
@@ -1,22 +1,24 @@
-/******************************************************************
- *
+/**
+ * ***************************************************************
+ *
* Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
+ *
+ *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
- ******************************************************************/
+ *
+ * ****************************************************************
+ */
package org.iotivity.service.easysetup.mediator;
import java.util.ArrayList;
diff --git a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/IProvisioningListener.java b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/IProvisioningListener.java
index a178401..8106382 100644
--- a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/IProvisioningListener.java
+++ b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/IProvisioningListener.java
@@ -1,22 +1,24 @@
-/******************************************************************
- *
+/**
+ * ***************************************************************
+ *
* Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
+ *
+ *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
- ******************************************************************/
+ *
+ * ****************************************************************
+ */
package org.iotivity.service.easysetup.mediator;
public interface IProvisioningListener {
diff --git a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/OnBoardEnrollee.java b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/OnBoardEnrollee.java
index 0add977..3bffc96 100644
--- a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/OnBoardEnrollee.java
+++ b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/OnBoardEnrollee.java
@@ -1,26 +1,29 @@
-/******************************************************************
- *
+/**
+ * ***************************************************************
+ *
* Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
+ *
+ *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
- ******************************************************************/
+ *
+ * ****************************************************************
+ */
package org.iotivity.service.easysetup.mediator;
import android.content.Context;
import android.net.wifi.WifiConfiguration;
+
import org.iotivity.service.easysetup.mediator.ip.WiFiSoftAPManager;
import android.widget.Toast;
diff --git a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/ProvisionEnrollee.java b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/ProvisionEnrollee.java
old mode 100755
new mode 100644
index ce68f53..79dd916
--- a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/ProvisionEnrollee.java
+++ b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/ProvisionEnrollee.java
@@ -4,9 +4,9 @@ import android.content.Context;
import android.util.Log;
public class ProvisionEnrollee {
- private static final String TAG = "ProvisionEnrollee";
- private Context appContext = null;
- private EasySetupManager easySetupManagerNativeInstance = null;
+ private static final String TAG = "ProvisionEnrollee";
+ private Context appContext = null;
+ private EasySetupManager easySetupManagerNativeInstance = null;
private IProvisioningListener provisioningListener;
/**
@@ -25,7 +25,7 @@ public class ProvisionEnrollee {
}
public void provisionEnrollee(String ipAddress, String netSSID,
- String netPWD, int connectivityType) {
+ String netPWD, int connectivityType) {
easySetupManagerNativeInstance.provisionEnrollee(ipAddress, netSSID,
netPWD, connectivityType);
}
diff --git a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/ip/WiFiSoftAPManager.java b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/ip/WiFiSoftAPManager.java
old mode 100755
new mode 100644
index beeb705..3aef566
--- a/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/ip/WiFiSoftAPManager.java
+++ b/service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/ip/WiFiSoftAPManager.java
@@ -1,22 +1,24 @@
-/******************************************************************
- *
+/**
+ * ***************************************************************
+ *
* Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
+ *
+ *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
- ******************************************************************/
+ *
+ * ****************************************************************
+ */
package org.iotivity.service.easysetup.mediator.ip;
import java.io.BufferedReader;
@@ -46,11 +48,11 @@ import org.iotivity.service.easysetup.mediator.IOnBoardingStatus;
*
*/
public class WiFiSoftAPManager {
- private final WifiManager mWifiManager;
- private Context context;
+ private final WifiManager mWifiManager;
+ private Context context;
static ArrayList appNotification =
- new ArrayList();
- IOnBoardingStatus finishListener = null;
+ new ArrayList();
+ IOnBoardingStatus finishListener = null;
public enum WIFI_AP_STATE {
WIFI_AP_STATE_DISABLING,
@@ -69,13 +71,10 @@ public class WiFiSoftAPManager {
/*
* Utility API to check the validity of the MAC Address read from the ARP cache
*/
- private boolean CheckIfValidMacAddress(String macAddr)
- {
- if(macAddr.matches("..:..:..:..:..:.."))
- {
+ private boolean CheckIfValidMacAddress(String macAddr) {
+ if (macAddr.matches("..:..:..:..:..:..")) {
return true;
- }
- else {
+ } else {
return false;
}
}
@@ -88,16 +87,15 @@ public class WiFiSoftAPManager {
* continue
*/
private synchronized boolean CheckForDeviceEntryAndNotify(String ipAddr,
- String macAddr, boolean isReachable)
- {
+ 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;
+ macAddr) ? true : false;
if (macAddressComparison) {
deviceAddedToList = true;
@@ -183,7 +181,7 @@ public class WiFiSoftAPManager {
* @return {@code true} if the operation succeeds, {@code false} otherwise
*/
public boolean setWifiApEnabled(WifiConfiguration wifiConfig,
- boolean enabled) {
+ boolean enabled) {
try {
// Stopping Wi-Fi mode
if (enabled) {
@@ -300,8 +298,7 @@ public class WiFiSoftAPManager {
// API returns true is there is a notification to the application.
// API returns false if there is no entry or if device is
// already notified
- if(CheckForDeviceEntryAndNotify(ipAddr, macAddr, isReachable))
- {
+ if (CheckForDeviceEntryAndNotify(ipAddr, macAddr, isReachable)) {
break;
}
}
--
2.7.4