Enrollee support for BLE
authorVinil Jain <vinil.gj@samsung.com>
Wed, 16 Sep 2015 14:11:31 +0000 (19:41 +0530)
committerMadan Lanka <lanka.madan@samsung.com>
Fri, 18 Sep 2015 09:32:12 +0000 (09:32 +0000)
-New sampleapp and easysetup.cpp for BLE
-Mediator changes to pass enrollee le address

Change-Id: I3953d37fd9c1ed5579c25603590e39c2f92435ea
Signed-off-by: Vinil Jain <vinil.gj@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2597
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
17 files changed:
service/easy-setup/SConscript
service/easy-setup/sampleapp/android/EasySetup/app/src/main/AndroidManifest.xml
service/easy-setup/sampleapp/android/EasySetup/app/src/main/java/org/iotivity/service/easysetup/BLEActivity.java
service/easy-setup/sampleapp/android/EasySetup/app/src/main/java/org/iotivity/service/easysetup/OnBoardingSelect.java [new file with mode: 0644]
service/easy-setup/sampleapp/android/EasySetup/app/src/main/res/layout/activity_ble.xml [new file with mode: 0644]
service/easy-setup/sampleapp/android/EasySetup/app/src/main/res/layout/activity_on_boarding_select.xml [new file with mode: 0644]
service/easy-setup/sampleapp/android/EasySetup/app/src/main/res/menu/menu_ble.xml [new file with mode: 0644]
service/easy-setup/sampleapp/arduino/thinserver/SConscript
service/easy-setup/sampleapp/arduino/thinserver/thinserverble.cpp [new file with mode: 0644]
service/easy-setup/sdk/enrollee/arduino/ble/networkHandler.h [new file with mode: 0644]
service/easy-setup/sdk/enrollee/common/inc/easysetup.h
service/easy-setup/sdk/enrollee/common/inc/resourceHandler.h
service/easy-setup/sdk/enrollee/common/src/easysetupble.cpp [new file with mode: 0644]
service/easy-setup/sdk/enrollee/common/src/resourceHandler.cpp
service/easy-setup/sdk/mediator/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/impl/EnrolleeDeviceBLEOnBoarding.java
service/easy-setup/sdk/mediator/android/jni/jni_easy_setup.cpp
service/easy-setup/sdk/mediator/src/provisioninghandler_ble.cpp [moved from service/easy-setup/sdk/mediator/src/provisioninghandlerBLE.cpp with 99% similarity]

index 36096c2..bf983e2 100644 (file)
@@ -26,9 +26,12 @@ import os
 
 Import('env')
 
+transport = env.get('TARGET_TRANSPORT')
+
 env.AppendUnique(CPPDEFINES = ['EASY_SETUP_CA_INIT'])
 
 easy_setup_env = env.Clone()
+#
 target_os = env.get('TARGET_OS')
 
 lib_env = env.Clone()
@@ -55,17 +58,27 @@ if target_os in ['android', 'linux']:
                        easy_setup_env.AppendUnique(LIBS = ['log'])
        else:
                easy_setup_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'pthread', 'connectivity_abstraction'])
-
 if target_os == 'arduino':
-       easy_setup_env.AppendUnique(CPPPATH = [
+       if 'BLE' in transport:
+               easy_setup_env.AppendUnique(CPPPATH = [
                                       '../../resource/oc_logger/include',
                                       '../../resource/csdk/logger/include',
                                       '../../resource/csdk/stack/include',
                                       '../../extlibs/cjson',
-                                      'sdk/enrollee/arduino/wifi',
-                                      'sdk/enrollee/common/src',
+                                          'sdk/enrollee/arduino/ble',
+                                          'sdk/enrollee/common/src',
                                       'sdk/enrollee/common/inc'])
-
+               easy_setup_env.AppendUnique(CPPDEFINES = ['TB_LOG', 'ESBLE'])                      
+       else:
+               easy_setup_env.AppendUnique(CPPPATH = [
+                                      '../../resource/oc_logger/include',
+                                      '../../resource/csdk/logger/include',
+                                      '../../resource/csdk/stack/include',
+                                      '../../extlibs/cjson',
+                                          'sdk/enrollee/arduino/wifi',
+                                          'sdk/enrollee/common/src',
+                                      'sdk/enrollee/common/inc'])
+               easy_setup_env.AppendUnique(CPPDEFINES = ['TB_LOG', 'ESWIFI'])
 if target_os in ['android','linux']:                                      
        easy_setup_env.PrependUnique(CPPPATH = [
                env.get('SRC_DIR') + '/resource/c_common/oic_malloc/include',           
@@ -83,18 +96,28 @@ if target_os in ['android','linux']:
 ######################################################################
 
 if target_os == 'arduino':
-       es_sdk_static = easy_setup_env.StaticLibrary('ESSDKLibrary',
-                                       ['sdk/enrollee/common/src/easysetup.cpp',
-                                       'sdk/enrollee/common/src/resourceHandler.cpp',
-                                       'sdk/enrollee/arduino/wifi/networkHandler.cpp'])
+       if 'BLE' in transport:
+               es_sdk_static = easy_setup_env.StaticLibrary('ESSDKLibrary',
+                                               ['sdk/enrollee/common/src/easysetupble.cpp',
+                                               'sdk/enrollee/common/src/resourceHandler.cpp'])
+       else:
+               es_sdk_static = easy_setup_env.StaticLibrary('ESSDKLibrary',
+                                               ['sdk/enrollee/common/src/easysetup.cpp',
+                                               'sdk/enrollee/common/src/resourceHandler.cpp',
+                                               'sdk/enrollee/arduino/wifi/networkHandler.cpp'])
        easy_setup_env.InstallTarget(es_sdk_static, 'libESSDK')
 
-
 if target_os == 'android':
-       es_sdk_shared = easy_setup_env.StaticLibrary('libESSDK',
-                                       ['sdk/mediator/src/easysetupmgr.cpp',
-                                       'sdk/mediator/src/camutex_pthreads.c',
-                                       'sdk/mediator/src/provisioninghandler.cpp'])
+       if 'BLE' in transport:
+               es_sdk_shared = easy_setup_env.StaticLibrary('libESSDK',
+                                               ['sdk/mediator/src/easysetupmgr.cpp',
+                                               'sdk/mediator/src/camutex_pthreads.c',
+                                               'sdk/mediator/src/provisioninghandler_ble.cpp'])
+       else :
+               es_sdk_shared = easy_setup_env.StaticLibrary('libESSDK',
+                                               ['sdk/mediator/src/easysetupmgr.cpp',
+                                               'sdk/mediator/src/camutex_pthreads.c',
+                                               'sdk/mediator/src/provisioninghandler.cpp'])
        easy_setup_env.InstallTarget(es_sdk_shared, 'libESSDK')
 
 if target_os == 'linux':
index 8c52513..68e32ce 100755 (executable)
@@ -2,10 +2,14 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="org.iotivity.service.easysetup"
     android:versionCode="1"
-    android:versionName="1.0" >
-    <uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>
-    <uses-permission android:name="android.permission.BLUETOOTH"/>
-    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
+    android:versionName="1.0">
+
+    <uses-feature
+        android:name="android.hardware.bluetooth_le"
+        android:required="true" />
+
+    <uses-permission android:name="android.permission.BLUETOOTH" />
+    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
     <uses-permission android:name="android.permission.INTERNET" />
     <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
     <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
         android:allowBackup="true"
         android:icon="@drawable/ic_launcher"
         android:label="@string/app_name"
-        android:theme="@style/AppTheme" >
+        android:theme="@style/AppTheme">
         <activity
             android:name=".MainActivity"
-            android:label="@string/app_name" >
+            android:label="@string/app_name">
 
             <intent-filter>
                 <action android:name="android.intent.action.SEND" />
                 <data android:mimeType="text/plain" />
             </intent-filter>
         </activity>
+
+        <activity android:name=".BLEActivity" />
+        <activity android:name=".OnBoardingSelect">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
     </application>
 
 </manifest>
index abf3157..4ccbb42 100644 (file)
@@ -88,14 +88,14 @@ public class BLEActivity extends Activity {
     }
 
     public WiFiProvConfig getEnrollerWifiConfig() {
+        // SET the wifi credentials here
         mWiFiProvConfig = new WiFiProvConfig("linksysy", "12345678");
         return mWiFiProvConfig;
     }
 
     public BLEOnBoardingConfig getOnBoardingWifiConfig() {
-        //TODO : Check proper configuration
+        // Set the uuid of the OIC device here
         bleOnBoardingConfig = new BLEOnBoardingConfig();
-
         bleOnBoardingConfig.setUuid("ade3d529-c784-4f63-a987-eb69f70ee816");
 
         return bleOnBoardingConfig;
@@ -113,7 +113,8 @@ public class BLEActivity extends Activity {
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
         // User chose not to enable Bluetooth.
         if (requestCode == REQUEST_ENABLE_BT && resultCode == Activity.RESULT_CANCELED) {
-            Log.e("error enablg bluetooth", resultCode + "");
+            Log.e("error bluetooth", "Bluetooth not enabled..Try again");
+            Toast.makeText(BLEActivity.this, "Bluetooth not enabled..Try again", Toast.LENGTH_SHORT).show();
             finish();
             return;
         } else try {
@@ -142,15 +143,16 @@ public class BLEActivity extends Activity {
 
     public void start() {
         //This function starts the bluetooth adpater so that the easysetup can start scanning for BLE devices
-        //IF bluetooth is directly enabled it will directly start the setup of enrollee devices
         final BluetoothManager bluetoothManager =
                 (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
         BluetoothAdapter mBluetoothAdapter = bluetoothManager.getAdapter();
 
         if (!mBluetoothAdapter.isEnabled()) {
+            //Bluetooth is disabled, enable it
             Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
             startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
         } else try {
+            //IF bluetooth is directly enabled it will directly start the setup of enrollee devices
             mEasySetupService.startSetup(mDevice);
         } catch (IOException e) {
             e.printStackTrace();
diff --git a/service/easy-setup/sampleapp/android/EasySetup/app/src/main/java/org/iotivity/service/easysetup/OnBoardingSelect.java b/service/easy-setup/sampleapp/android/EasySetup/app/src/main/java/org/iotivity/service/easysetup/OnBoardingSelect.java
new file mode 100644 (file)
index 0000000..66d6542
--- /dev/null
@@ -0,0 +1,45 @@
+package org.iotivity.service.easysetup;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.RadioButton;
+import android.widget.Toast;
+
+public class OnBoardingSelect extends Activity {
+
+    RadioButton radio_wifi, radio_ble;
+    Button button_continue;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_on_boarding_select);
+
+        radio_wifi = (RadioButton) findViewById(R.id.radioWifi);
+        radio_ble = (RadioButton) findViewById(R.id.radioBle);
+        button_continue = (Button) findViewById(R.id.button_continue);
+
+        button_continue.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                Intent intent;
+                if (radio_wifi.isChecked())
+                    intent = new Intent(OnBoardingSelect.this, MainActivity.class);
+                else if (radio_ble.isChecked())
+                    intent = new Intent(OnBoardingSelect.this, BLEActivity.class);
+                else {
+
+                    Toast.makeText(OnBoardingSelect.this, "Please Select OnBoarding method " +
+                            "before Continuing", Toast.LENGTH_SHORT).show();
+                    return;
+                }
+                startActivity(intent);
+            }
+        });
+    }
+
+
+}
diff --git a/service/easy-setup/sampleapp/android/EasySetup/app/src/main/res/layout/activity_ble.xml b/service/easy-setup/sampleapp/android/EasySetup/app/src/main/res/layout/activity_ble.xml
new file mode 100644 (file)
index 0000000..3244e46
--- /dev/null
@@ -0,0 +1,18 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@drawable/background"
+    android:paddingBottom="@dimen/activity_vertical_margin"
+    android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:paddingTop="@dimen/activity_vertical_margin"
+    tools:context="org.iotivity.service.easysetup.BLEActivity">
+
+    <TextView
+        android:id="@+id/textView_ble"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/hello_world" />
+
+</RelativeLayout>
diff --git a/service/easy-setup/sampleapp/android/EasySetup/app/src/main/res/layout/activity_on_boarding_select.xml b/service/easy-setup/sampleapp/android/EasySetup/app/src/main/res/layout/activity_on_boarding_select.xml
new file mode 100644 (file)
index 0000000..8fc9018
--- /dev/null
@@ -0,0 +1,43 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@drawable/background"
+    android:paddingBottom="@dimen/activity_vertical_margin"
+    android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:paddingTop="@dimen/activity_vertical_margin"
+    tools:context="org.iotivity.service.easysetup.OnBoardingSelect">
+
+    <RadioGroup
+        android:id="@+id/radiotype"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_centerHorizontal="true"
+        android:layout_marginTop="75dp">
+
+        <RadioButton
+            android:id="@+id/radioWifi"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:checked="true"
+            android:text="Soft AP/WIFI" />
+
+        <RadioButton
+            android:id="@+id/radioBle"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="BLE" />
+
+    </RadioGroup>
+
+    <Button
+        android:id="@+id/button_continue"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_centerHorizontal="true"
+        android:layout_centerVertical="true"
+        android:text="Continue" />
+
+
+</RelativeLayout>
diff --git a/service/easy-setup/sampleapp/android/EasySetup/app/src/main/res/menu/menu_ble.xml b/service/easy-setup/sampleapp/android/EasySetup/app/src/main/res/menu/menu_ble.xml
new file mode 100644 (file)
index 0000000..eb6d83e
--- /dev/null
@@ -0,0 +1,9 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    tools:context="org.iotivity.service.easysetup.BLEActivity">
+    <item
+        android:id="@+id/action_settings"
+        android:orderInCategory="100"
+        android:showAsAction="never"
+        android:title="@string/action_settings" />
+</menu>
index fca7b3d..3b93a5b 100644 (file)
 Import('env')
 
 thinserver_env = env.Clone()
+transport = thinserver_env.get('TARGET_TRANSPORT')
+
 ######################################################################
 # Build flags
 ######################################################################
-thinserver_env.PrependUnique(CPPPATH = [
+if 'BLE' in transport:
+       thinserver_env.PrependUnique(CPPPATH = [
+                '../../../../../resource/oc_logger/include',
+               '../../../../../resource/csdk/logger/include',
+                '../../../../../resource/csdk/stack/include',
+               '../../../../../extlibs/cjson',
+               '../../../sdk/common',
+               '../../../sdk/enrollee/arduino/ble',
+               '../../../sdk/enrollee/common/inc',
+               '../../../sdk/enrollee/common/src'
+               ])
+       thinserver_env.AppendUnique(CPPDEFINES = ['TB_LOG', 'ESBLE'])   
+else : 
+       thinserver_env.PrependUnique(CPPPATH = [
                 '../../../../../resource/oc_logger/include',
                '../../../../../resource/csdk/logger/include',
                 '../../../../../resource/csdk/stack/include',
@@ -34,13 +49,15 @@ thinserver_env.PrependUnique(CPPPATH = [
                '../../../sdk/enrollee/common/inc',
                '../../../sdk/enrollee/common/src'
                ])
-
+       thinserver_env.AppendUnique(CPPDEFINES = ['TB_LOG', 'ESWIFI'])
+       
 thinserver_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-thinserver_env.AppendUnique(CPPDEFINES = ['TB_LOG', 'ARDUINOWIFI'])
 
 thinserver_env.PrependUnique(LIBS = ['octbstack','ocsrm','connectivity_abstraction','coap', 'ESSDKLibrary'])
-
-thinserver = thinserver_env.Program('thinserver', 'thinserver.cpp')
+if 'BLE' in transport:
+       thinserver = thinserver_env.Program('thinserver', 'thinserverble.cpp')
+else :
+       thinserver = thinserver_env.Program('thinserver', 'thinserver.cpp')
 env.CreateBin('thinserver')
 
 i_thinserver = thinserver_env.Install(env.get('BUILD_DIR'), thinserver)
diff --git a/service/easy-setup/sampleapp/arduino/thinserver/thinserverble.cpp b/service/easy-setup/sampleapp/arduino/thinserver/thinserverble.cpp
new file mode 100644 (file)
index 0000000..75481fb
--- /dev/null
@@ -0,0 +1,91 @@
+//******************************************************************
+//
+// 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
+//
+// 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.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+// Do not remove the include below
+#include "Arduino.h"
+#include "logger.h"
+#include <string.h>
+#include "easysetup.h"
+
+const char *getResult(OCStackResult result);
+
+PROGMEM const char TAG[] = "ThinServer";
+
+void EventCallbackInApp(ESResult eventFlag)
+{
+    Serial.println("callback!!! in app");
+}
+
+// On Arduino Atmel boards with Harvard memory architecture, the stack grows
+// downwards from the top and the heap grows upwards. This method will print
+// the distance(in terms of bytes) between those two.
+// See here for more details :
+// http://www.atmel.com/webdoc/AVRLibcReferenceManual/malloc_1malloc_intro.html
+void PrintArduinoMemoryStats()
+{
+#ifdef ARDUINO_AVR_MEGA2560
+    //This var is declared in avr-libc/stdlib/malloc.c
+    //It keeps the largest address not allocated for heap
+    extern char *__brkval;
+    //address of tmp gives us the current stack boundry
+    int tmp;
+    OC_LOG_V(INFO, TAG, "Stack: %u         Heap: %u", (unsigned int)&tmp, (unsigned int)__brkval);
+    OC_LOG_V(INFO, TAG, "Unallocated Memory between heap and stack: %u",
+            ((unsigned int)&tmp - (unsigned int)__brkval));
+#endif
+}
+//The setup function is called once at startup of the sketch
+void setup()
+{
+    // Add your initialization code here
+    // Note : This will initialize Serial port on Arduino at 115200 bauds
+    OC_LOG_INIT();
+    OC_LOG(DEBUG, TAG, PCF("OCServer is starting..."));
+
+    if (InitEasySetup(ES_BLE, EventCallbackInApp) == ES_ERROR)
+    {
+        OC_LOG(ERROR, TAG, "EasySetup Init Failed");
+        return;
+    }
+
+    if (InitProvisioning(EventCallbackInApp) == ES_ERROR)
+    {
+        OC_LOG(ERROR, TAG, "Init Provisioning Failed");
+        return;
+    }
+}
+
+// The loop function is called in an endless loop
+void loop()
+{
+    // This artificial delay is kept here to avoid endless spinning
+    // of Arduino microcontroller. Modify it as per specific application needs.
+    delay(2000);
+
+    // This call displays the amount of free SRAM available on Arduino
+    PrintArduinoMemoryStats();
+
+    // Give CPU cycles to OCStack to perform send/recv and other OCStack stuff
+    if (OCProcess() != OC_STACK_OK)
+    {
+        OC_LOG(ERROR, TAG, PCF("OCStack process error"));
+        return;
+    }
+}
diff --git a/service/easy-setup/sdk/enrollee/arduino/ble/networkHandler.h b/service/easy-setup/sdk/enrollee/arduino/ble/networkHandler.h
new file mode 100644 (file)
index 0000000..db02a42
--- /dev/null
@@ -0,0 +1,50 @@
+//******************************************************************
+//
+// Copyright 2014 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
+//
+// 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.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+// Do not remove the include below
+#include "Arduino.h"
+
+#include "logger.h"
+#include "ocstack.h"
+#include <string.h>
+
+#include "common.h"
+
+#ifndef ES_NETWORK_HANDLER_H_
+#define ES_NETWORK_HANDLER_H_
+
+#define MAXSSIDLEN 33
+#define MAXNETCREDLEN 20
+#define MAXNUMTYPE 5
+#define MAXADDRLEN 15
+
+typedef void (*NetworkEventCallback)(ESResult);
+
+enum NetworkType
+{
+    ES_WIFI = 1, ES_BT = 2, ES_BLE = 3, ES_ZIGBEE = 4, ES_ETH = 5
+};
+typedef struct NETWORKINFO
+{
+    NetworkType type;
+    byte mac[6];
+} NetworkInfo;
+
+#endif
index db332cb..116c930 100755 (executable)
 
 typedef void (*EventCallback)(ESResult);
 
-ESResult InitEasySetup(NetworkType networkType, const char *ssid, const char *passwd,
-              EventCallback cb);
+#ifdef ESWIFI
+ESResult InitEasySetup(NetworkType networkType, const char *ssid, const char *passwd,EventCallback cb);
+#endif
+
+#ifdef ESBLE
+ESResult InitEasySetup(NetworkType networkType,EventCallback cb);
+#endif
+
 ESResult InitProvisioning(EventCallback cb);
 ESResult TerminateEasySetup();
 
index 13d0ee1..e64c2f5 100755 (executable)
@@ -55,7 +55,12 @@ typedef struct NETRESOURCE
 } NetResource;
 
 OCStackResult CreateProvisioningResource();
+
+//created only for in case of wifi
+#ifdef ESWIFI
 OCStackResult CreateNetworkResource();
+#endif
+
 void GetTargetNetworkInfoFromProvResource(char *, char *);
 void RegisterResourceEventCallBack(ResourceEventCallback);
 
diff --git a/service/easy-setup/sdk/enrollee/common/src/easysetupble.cpp b/service/easy-setup/sdk/enrollee/common/src/easysetupble.cpp
new file mode 100644 (file)
index 0000000..4fcd952
--- /dev/null
@@ -0,0 +1,143 @@
+//******************************************************************
+//
+// 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
+//
+// 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.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+#include "easysetup.h"
+#include "logger.h"
+#include "resourceHandler.h"
+
+#define TAG "ES"
+
+int g_eventflag = 0;
+int g_cnt = 0;
+char *targetSsid;
+char *targetPass;
+
+EventCallback g_cbForProvisioning = NULL;
+EventCallback g_cbForOnboarding = NULL;
+
+void EventCallbackInOnboarding(ESResult event);
+void EventCallbackInProvisioning(ESResult event);
+void EventCallbackAfterProvisioning(ESResult event);
+
+void EventCallbackInOnboarding(ESResult event)
+{
+    if (event == ES_NETWORKFOUND || event == ES_NETWORKCONNECTED)
+    {
+        if (g_cbForOnboarding != NULL)
+        {
+            g_cbForOnboarding(event);
+        }
+    }
+}
+
+void EventCallbackInProvisioning(ESResult event)
+{
+    ESResult res = ES_OK;
+
+    if (event == ES_RECVTRIGGEROFPROVRES)
+    {
+        targetSsid = (char *) malloc(MAXSSIDLEN);
+        targetPass = (char *) malloc(MAXNETCREDLEN);
+
+        if (TerminateEasySetup() != OC_STACK_OK)
+        {
+            OC_LOG(ERROR, TAG, "Terminating stack failed");
+            return;
+        }
+
+        GetTargetNetworkInfoFromProvResource(targetSsid, targetPass);
+
+        OC_LOG(INFO, TAG, targetSsid);
+        OC_LOG(INFO, TAG, targetPass);
+        OC_LOG(INFO, TAG, "Device Provisioned");
+
+        // cannot connect to target network, as currently arduino supports only one transport at a time
+        //res = ConnectToWiFiNetwork(targetSsid, targetPass, EventCallbackAfterProvisioning);
+
+        if (g_cbForProvisioning != NULL)
+        {
+            g_cbForProvisioning(res);
+        }
+    }
+}
+
+void EventCallbackAfterProvisioning(ESResult event)
+{
+    if (event == ES_NETWORKFOUND || event == ES_NETWORKCONNECTED)
+    {
+        if (g_cbForProvisioning != NULL)
+        {
+            g_cbForProvisioning(event);
+        }
+    }
+}
+
+ESResult InitEasySetup(NetworkType networkType, EventCallback cb)
+{
+
+    // Initialize the OC Stack in Server mode
+    //if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK)
+    if (OCInit1(OC_SERVER, OC_DEFAULT_FLAGS, OC_DEFAULT_FLAGS) != OC_STACK_OK)
+    {
+        OC_LOG(ERROR, TAG, "OCStack init error");
+        return ES_ERROR;
+    }
+    else
+    {
+        OC_LOG(DEBUG, TAG, "OCStack init success");
+        return ES_OK;
+    }
+}
+
+ESResult TerminateEasySetup()
+{
+    if (OCStop() != OC_STACK_OK)
+    {
+        OC_LOG(ERROR, TAG, "OCStack stop failed");
+        return ES_ERROR;
+    }
+    else
+    {
+        OC_LOG(ERROR, TAG, "OCStack stop success");
+        return ES_OK;
+    }
+}
+
+ESResult InitProvisioning(EventCallback cb)
+{
+    if (cb == NULL)
+    {
+        return ES_ERROR;
+    }
+    else
+    {
+        g_cbForProvisioning = cb;
+    }
+
+    if (CreateProvisioningResource() != OC_STACK_OK)
+    {
+        return ES_ERROR;
+    }
+
+    RegisterResourceEventCallBack( EventCallbackInProvisioning);
+
+    return ES_RESOURCECREATED;
+}
+
index bafdf66..0f4305f 100755 (executable)
@@ -27,16 +27,12 @@ ProvResource g_prov;
 NetResource g_net;
 
 OCEntityHandlerResult OCEntityHandlerCb(OCEntityHandlerFlag flag,
-                                              OCEntityHandlerRequest *ehRequest,
-                                              void *callback);
+        OCEntityHandlerRequest *ehRequest, void *callback);
 const char *getResult(OCStackResult result);
 
-OCEntityHandlerResult ProcessGetRequest(OCEntityHandlerRequest *ehRequest,
-                                               OCRepPayload** payload);
-OCEntityHandlerResult ProcessPutRequest(OCEntityHandlerRequest *ehRequest,
-                                               OCRepPayload** payload);
-OCEntityHandlerResult ProcessPostRequest(OCEntityHandlerRequest *ehRequest,
-                                               OCRepPayload** payload);
+OCEntityHandlerResult ProcessGetRequest(OCEntityHandlerRequest *ehRequest, OCRepPayload** payload);
+OCEntityHandlerResult ProcessPutRequest(OCEntityHandlerRequest *ehRequest, OCRepPayload** payload);
+OCEntityHandlerResult ProcessPostRequest(OCEntityHandlerRequest *ehRequest, OCRepPayload** payload);
 OCRepPayload* constructResponse(OCEntityHandlerRequest *ehRequest);
 
 int g_flag = 0;
@@ -65,13 +61,13 @@ OCStackResult CreateProvisioningResource()
     sprintf(g_prov.cd, "Unknown");
 
     OCStackResult res = OCCreateResource(&g_prov.handle, "oic.prov", OC_RSRVD_INTERFACE_DEFAULT,
-            OC_RSRVD_ES_URI_PROV, OCEntityHandlerCb,NULL, OC_DISCOVERABLE | OC_OBSERVABLE);
+            OC_RSRVD_ES_URI_PROV, OCEntityHandlerCb, NULL, OC_DISCOVERABLE | OC_OBSERVABLE);
 
     OC_LOG_V(INFO, TAG, "Created Prov resource with result: %s", getResult(res));
 
     return res;
 }
-
+#ifdef ESWIFI
 OCStackResult CreateNetworkResource()
 {
     NetworkInfo netInfo;
@@ -101,24 +97,23 @@ OCStackResult CreateNetworkResource()
 
     return res;
 }
-
-OCEntityHandlerResult ProcessGetRequest(OCEntityHandlerRequest *ehRequest,
-                                                OCRepPayload **payload)
+#endif
+OCEntityHandlerResult ProcessGetRequest(OCEntityHandlerRequest *ehRequest, OCRepPayload **payload)
 {
     OCEntityHandlerResult ehResult = OC_EH_ERROR;
-    if(!ehRequest)
+    if (!ehRequest)
     {
         OC_LOG(ERROR, TAG, "Request is Null");
         return ehResult;
     }
-    if(ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION)
+    if (ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION)
     {
         OC_LOG(ERROR, TAG, "Incoming payload not a representation");
         return ehResult;
     }
 
     OCRepPayload *getResp = constructResponse(ehRequest);
-    if(!getResp)
+    if (!getResp)
     {
         OC_LOG(ERROR, TAG, "constructResponse failed");
         return OC_EH_ERROR;
@@ -130,32 +125,31 @@ OCEntityHandlerResult ProcessGetRequest(OCEntityHandlerRequest *ehRequest,
     return ehResult;
 }
 
-OCEntityHandlerResult ProcessPutRequest (OCEntityHandlerRequest *ehRequest,
-                                                OCRepPayload** payload)
+OCEntityHandlerResult ProcessPutRequest(OCEntityHandlerRequest *ehRequest, OCRepPayload** payload)
 {
 
-    OCEntityHandlerResult ehResult=OC_EH_ERROR;
-    if(ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION)
+    OCEntityHandlerResult ehResult = OC_EH_ERROR;
+    if (ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION)
     {
         OC_LOG(ERROR, TAG, "Incoming payload not a representation");
         return ehResult;
     }
 
-    OCRepPayload* input = (OCRepPayload*)(ehRequest->payload);
-    if(!input)
+    OCRepPayload* input = (OCRepPayload*) (ehRequest->payload);
+    if (!input)
     {
         OC_LOG(ERROR, TAG, "Failed to parse");
         return ehResult;
     }
 
     char* tnn;
-    if(OCRepPayloadGetPropString(input,OC_RSRVD_ES_TNN, &tnn))
+    if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_TNN, &tnn))
     {
         sprintf(g_prov.tnn, "%s", tnn);
     }
 
     char* cd;
-    if(OCRepPayloadGetPropString(input, OC_RSRVD_ES_CD, &cd))
+    if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_CD, &cd))
     {
         sprintf(g_prov.cd, "%s", cd);
     }
@@ -163,7 +157,7 @@ OCEntityHandlerResult ProcessPutRequest (OCEntityHandlerRequest *ehRequest,
     g_flag = 1;
 
     OCRepPayload *getResp = constructResponse(ehRequest);
-    if(!getResp)
+    if (!getResp)
     {
         OC_LOG(ERROR, TAG, "constructResponse failed");
         return OC_EH_ERROR;
@@ -172,35 +166,31 @@ OCEntityHandlerResult ProcessPutRequest (OCEntityHandlerRequest *ehRequest,
     *payload = getResp;
     ehResult = OC_EH_OK;
 
-
-
     return ehResult;
 }
 
-
-OCEntityHandlerResult ProcessPostRequest(OCEntityHandlerRequest *ehRequest,
-                                                OCRepPayload** payload)
+OCEntityHandlerResult ProcessPostRequest(OCEntityHandlerRequest *ehRequest, OCRepPayload** payload)
 {
     OCEntityHandlerResult ehResult = OC_EH_ERROR;
-    if(!ehRequest)
+    if (!ehRequest)
     {
         OC_LOG(ERROR, TAG, "Request is Null");
         return ehResult;
     }
-    if(ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION)
+    if (ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION)
     {
         OC_LOG(ERROR, TAG, "Incoming payload not a representation");
         return ehResult;
     }
 
-    OCRepPayload* input = (OCRepPayload*)(ehRequest->payload);
-    if(!input)
+    OCRepPayload* input = (OCRepPayload*) (ehRequest->payload);
+    if (!input)
     {
         OC_LOG(ERROR, TAG, "Failed to parse");
         return ehResult;
     }
     char* tr;
-    if(OCRepPayloadGetPropString(input, OC_RSRVD_ES_TR, &tr))
+    if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_TR, &tr))
     {
 
         // Triggering
@@ -215,7 +205,7 @@ OCEntityHandlerResult ProcessPostRequest(OCEntityHandlerRequest *ehRequest,
 OCRepPayload* constructResponse(OCEntityHandlerRequest *ehRequest)
 {
     OCRepPayload* payload = OCRepPayloadCreate();
-    if(!payload)
+    if (!payload)
     {
         OC_LOG(ERROR, TAG, "Failed to allocate Payload");
         return NULL;
@@ -223,11 +213,11 @@ OCRepPayload* constructResponse(OCEntityHandlerRequest *ehRequest)
 
     if (ehRequest->resource == g_prov.handle)
     {
-        OCRepPayloadSetUri(payload,OC_RSRVD_ES_URI_PROV);
-        OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_PS,g_prov.ps);
+        OCRepPayloadSetUri(payload, OC_RSRVD_ES_URI_PROV);
+        OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_PS, g_prov.ps);
         OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_TNT, g_prov.tnt);
-        OCRepPayloadSetPropString(payload,OC_RSRVD_ES_TNN, g_prov.tnn);
-        OCRepPayloadSetPropString(payload,OC_RSRVD_ES_CD, g_prov.cd);
+        OCRepPayloadSetPropString(payload, OC_RSRVD_ES_TNN, g_prov.tnn);
+        OCRepPayloadSetPropString(payload, OC_RSRVD_ES_CD, g_prov.cd);
     }
     else if (ehRequest->requestHandle == g_net.handle)
     {
@@ -241,9 +231,9 @@ OCRepPayload* constructResponse(OCEntityHandlerRequest *ehRequest)
 // This is the entity handler for the registered resource.
 // This is invoked by OCStack whenever it recevies a request for this resource.
 OCEntityHandlerResult OCEntityHandlerCb(OCEntityHandlerFlag flag,
-        OCEntityHandlerRequest* entityHandlerRequest,void *callback)
+        OCEntityHandlerRequest* entityHandlerRequest, void *callback)
 {
-    (void)callback;
+    (void) callback;
     OCEntityHandlerResult ehRet = OC_EH_OK;
     OCEntityHandlerResponse response =
     { 0 };
@@ -282,7 +272,7 @@ OCEntityHandlerResult OCEntityHandlerCb(OCEntityHandlerFlag flag,
             response.resourceHandle = entityHandlerRequest->resource;
             response.ehResult = ehRet;
             //response uses OCPaylod while all get,put methodes use OCRepPayload
-            response.payload = (OCPayload*)(payload);
+            response.payload = (OCPayload*) (payload);
             response.numSendVendorSpecificHeaderOptions = 0;
             memset(response.sendVendorSpecificHeaderOptions, 0,
                     sizeof response.sendVendorSpecificHeaderOptions);
@@ -312,40 +302,40 @@ const char *getResult(OCStackResult result)
 {
     switch (result)
     {
-    case OC_STACK_OK:
-        return "OC_STACK_OK";
-    case OC_STACK_INVALID_URI:
-        return "OC_STACK_INVALID_URI";
-    case OC_STACK_INVALID_QUERY:
-        return "OC_STACK_INVALID_QUERY";
-    case OC_STACK_INVALID_IP:
-        return "OC_STACK_INVALID_IP";
-    case OC_STACK_INVALID_PORT:
-        return "OC_STACK_INVALID_PORT";
-    case OC_STACK_INVALID_CALLBACK:
-        return "OC_STACK_INVALID_CALLBACK";
-    case OC_STACK_INVALID_METHOD:
-        return "OC_STACK_INVALID_METHOD";
-    case OC_STACK_NO_MEMORY:
-        return "OC_STACK_NO_MEMORY";
-    case OC_STACK_COMM_ERROR:
-        return "OC_STACK_COMM_ERROR";
-    case OC_STACK_INVALID_PARAM:
-        return "OC_STACK_INVALID_PARAM";
-    case OC_STACK_NOTIMPL:
-        return "OC_STACK_NOTIMPL";
-    case OC_STACK_NO_RESOURCE:
-        return "OC_STACK_NO_RESOURCE";
-    case OC_STACK_RESOURCE_ERROR:
-        return "OC_STACK_RESOURCE_ERROR";
-    case OC_STACK_SLOW_RESOURCE:
-        return "OC_STACK_SLOW_RESOURCE";
-    case OC_STACK_NO_OBSERVERS:
-        return "OC_STACK_NO_OBSERVERS";
-    case OC_STACK_ERROR:
-        return "OC_STACK_ERROR";
-    default:
-        return "UNKNOWN";
+        case OC_STACK_OK:
+            return "OC_STACK_OK";
+        case OC_STACK_INVALID_URI:
+            return "OC_STACK_INVALID_URI";
+        case OC_STACK_INVALID_QUERY:
+            return "OC_STACK_INVALID_QUERY";
+        case OC_STACK_INVALID_IP:
+            return "OC_STACK_INVALID_IP";
+        case OC_STACK_INVALID_PORT:
+            return "OC_STACK_INVALID_PORT";
+        case OC_STACK_INVALID_CALLBACK:
+            return "OC_STACK_INVALID_CALLBACK";
+        case OC_STACK_INVALID_METHOD:
+            return "OC_STACK_INVALID_METHOD";
+        case OC_STACK_NO_MEMORY:
+            return "OC_STACK_NO_MEMORY";
+        case OC_STACK_COMM_ERROR:
+            return "OC_STACK_COMM_ERROR";
+        case OC_STACK_INVALID_PARAM:
+            return "OC_STACK_INVALID_PARAM";
+        case OC_STACK_NOTIMPL:
+            return "OC_STACK_NOTIMPL";
+        case OC_STACK_NO_RESOURCE:
+            return "OC_STACK_NO_RESOURCE";
+        case OC_STACK_RESOURCE_ERROR:
+            return "OC_STACK_RESOURCE_ERROR";
+        case OC_STACK_SLOW_RESOURCE:
+            return "OC_STACK_SLOW_RESOURCE";
+        case OC_STACK_NO_OBSERVERS:
+            return "OC_STACK_NO_OBSERVERS";
+        case OC_STACK_ERROR:
+            return "OC_STACK_ERROR";
+        default:
+            return "UNKNOWN";
     }
 }
 
index 1e74def..c7a339d 100755 (executable)
@@ -22,8 +22,9 @@ package org.iotivity.service.easysetup.impl;
 import android.content.Context;
 import android.util.Log;
 
+import org.iotivity.base.OcConnectivityType;
 import org.iotivity.service.easysetup.core.BleConnection;
-import org.iotivity.service.easysetup.core.OnBoardingConnection;
+import org.iotivity.service.easysetup.core.ConnectionInterface;
 import org.iotivity.service.easysetup.core.EnrolleeDevice;
 import org.iotivity.service.easysetup.core.EnrolleeState;
 import org.iotivity.service.easysetup.core.OnBoardingConfig;
@@ -81,7 +82,8 @@ public class EnrolleeDeviceBLEOnBoarding extends EnrolleeDevice {
         }
     };
 
-    protected EnrolleeDeviceBLEOnBoarding(Context context, OnBoardingConfig onBoardingConfig, ProvisioningConfig provConfig) {
+    protected EnrolleeDeviceBLEOnBoarding(Context context, OnBoardingConfig onBoardingConfig,
+                                          ProvisioningConfig provConfig) {
         super(onBoardingConfig, provConfig);
         mContext = context;
         bleManager = new BLEManager(mContext, (BLEOnBoardingConfig) onBoardingConfig);
@@ -110,36 +112,33 @@ public class EnrolleeDeviceBLEOnBoarding extends EnrolleeDevice {
     }
 
     @Override
-    protected void startProvisioningProcess(OnBoardingConnection conn) {
+    protected void startProvisioningProcess(ConnectionInterface conn) {
 
         Log.i("start provisioning BLE", mProvConfig.getConnType() + "");
 
-        //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;
-                    mProvisioningCallback.onFinished(EnrolleeDeviceBLEOnBoarding.this);
-                }
-            });
-
-            BleConnection connection = (BleConnection) conn;
-            WiFiProvConfig wifiProvConfig = (WiFiProvConfig) mProvConfig;
-            if (mContext == null)
-                Log.d("BLE context is null", "");
-            else Log.d("BLE context is not null", "");
-            easySetupManagerNativeInstance = EasySetupManager.getInstance();
-
-
-            easySetupManagerNativeInstance.setApplicationContext(mContext);
-            easySetupManagerNativeInstance.initEasySetup();
-            Log.d("init", "successful");
-            easySetupManagerNativeInstance.provisionEnrollee(connection.getMacaddress(), wifiProvConfig.getSsId(), wifiProvConfig.getPassword(), 0);
+        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;
+                mProvisioningCallback.onFinished(EnrolleeDeviceBLEOnBoarding.this);
+            }
+        });
+
+        BleConnection connection = (BleConnection) conn;
+        WiFiProvConfig wifiProvConfig = (WiFiProvConfig) mProvConfig;
+        easySetupManagerNativeInstance = EasySetupManager.getInstance();
+        easySetupManagerNativeInstance.setApplicationContext(mContext);
+        easySetupManagerNativeInstance.initEasySetup();
+        Log.d("init", "successful");
+        OcConnectivityType ocConnectivityType = OcConnectivityType.CT_ADAPTER_GATT_BTLE;
+        easySetupManagerNativeInstance.provisionEnrollee(connection.getMacaddress(),
+                wifiProvConfig.getSsId(),
+                wifiProvConfig.getPassword(),
+                ocConnectivityType.getValue());
 
-        }
 
     }
 }
\ No newline at end of file
index 46b5564..3444218 100644 (file)
 #include "jni_easy_setup_jvm.h"\r
 #include "easysetupmgr.h"\r
 \r
-void JNIProvisioningStatusCallback(ProvisioningInfo *provInfo) {\r
+void JNIProvisioningStatusCallback(ProvisioningInfo *provInfo)\r
+{\r
     JNIEnv *env = EasySetupJVM::getEnv();\r
-    if (env == NULL) {\r
+    if (env == NULL)\r
+    {\r
         LOGE("JNIProvisioningStatusCallback : Getting JNIEnv failed");\r
         return;\r
     }\r
 \r
     // Get EasySetupHandler class reference\r
-    jclass easysetupCallbacks = GetJClass(\r
-            EASY_SETUP_SERVICE_CALLBACK_NATIVE_API_CLASS_PATH);\r
-    if (NULL == easysetupCallbacks) {\r
-        LOGE(\r
-                "JNIProvisioningStatusCallback : GetJClass easysetupCallbacks failed");\r
+    jclass easysetupCallbacks = GetJClass(EASY_SETUP_SERVICE_CALLBACK_NATIVE_API_CLASS_PATH);\r
+    if (NULL == easysetupCallbacks)\r
+    {\r
+        LOGE("JNIProvisioningStatusCallback : GetJClass easysetupCallbacks failed");\r
         EasySetupJVM::releaseEnv();\r
         return;\r
     }\r
 \r
     // Get the easysetupCallback class instance\r
-    jobject jobjectCallback = GetJObjectInstance(\r
-            EASY_SETUP_SERVICE_CALLBACK_NATIVE_API_CLASS_PATH);\r
-    if (NULL == jobjectCallback) {\r
-        LOGE("getInstance( %s) failed!",\r
-                EASY_SETUP_SERVICE_CALLBACK_NATIVE_API_CLASS_PATH);\r
+    jobject jobjectCallback = GetJObjectInstance(EASY_SETUP_SERVICE_CALLBACK_NATIVE_API_CLASS_PATH);\r
+    if (NULL == jobjectCallback)\r
+    {\r
+        LOGE("getInstance( %s) failed!", EASY_SETUP_SERVICE_CALLBACK_NATIVE_API_CLASS_PATH);\r
         EasySetupJVM::releaseEnv();\r
         return;\r
     }\r
 \r
     // Get onResourceCallback method reference\r
-    jmethodID method_id = env->GetMethodID(easysetupCallbacks,\r
-            "ProvisioningStatusCallBack",\r
+    jmethodID method_id = env->GetMethodID(easysetupCallbacks, "ProvisioningStatusCallBack",\r
             METHOD_PROVISIONING_STATUS_INTEGER_CALLBACK);\r
-    if (NULL == method_id) {\r
-        LOGE(\r
-                "JNIProvisioningStatusCallback: onResourceCallback : GetMethodID failed");\r
+    if (NULL == method_id)\r
+    {\r
+        LOGE("JNIProvisioningStatusCallback: onResourceCallback : GetMethodID failed");\r
         EasySetupJVM::releaseEnv();\r
         return;\r
     }\r
 \r
-    if ((env)->ExceptionCheck()) {\r
+    if ((env)->ExceptionCheck())\r
+    {\r
         LOGE("JNIProvisioningStatusCallback : ExceptionCheck failed");\r
         EasySetupJVM::releaseEnv();\r
         return;\r
     }\r
 \r
-    if (NULL == method_id) {\r
+    if (NULL == method_id)\r
+    {\r
         LOGI("JNI method_id is NULL");\r
-    } else {\r
+    }\r
+    else\r
+    {\r
         LOGI("JNI method_id is VALID");\r
 \r
         jint result;\r
-        if (provInfo->provStatus == DEVICE_PROVISIONED) {\r
+        if (provInfo->provStatus == DEVICE_PROVISIONED)\r
+        {\r
             result = 0;\r
-        } else {\r
+        }\r
+        else\r
+        {\r
             result = -1;\r
         }\r
 \r
@@ -98,12 +104,11 @@ JNIEXPORT void JNICALL JNITerminateEasySetup(JNIEnv *env, jobject thisObj)
     TerminateEasySetupManager();\r
 }\r
 \r
-\r
 JNIEXPORT void JNICALL JNIProvisionEnrollee(JNIEnv *env, jobject thisObj,\r
-                                                    jstring jIPAddress,\r
-                                                    jstring jNetSSID,\r
-                                                    jstring jNetPWD,\r
-                                                    jint jConnectivityType)\r
+        jstring jIPAddress,\r
+        jstring jNetSSID,\r
+        jstring jNetPWD,\r
+        jint jConnectivityType)\r
 {\r
     LOGI("JNI JNIProvisionEnrollee: Enter");\r
 \r
@@ -138,12 +143,20 @@ JNIEXPORT void JNICALL JNIProvisionEnrollee(JNIEnv *env, jobject thisObj,
     LOGI("JNI JNIProvisionEnrollee : netPWD is : %s",netPWD);\r
 \r
     OCConnectivityType connecitivityType;\r
-    EnrolleeNWProvInfo_t netInfo = {0};\r
+    EnrolleeNWProvInfo_t netInfo =\r
+    {   0};\r
 \r
     strncpy(netInfo.netAddressInfo.WIFI.ipAddress, ipAddress, IPV4_ADDR_SIZE);\r
     strncpy(netInfo.netAddressInfo.WIFI.ssid, netSSID, NET_WIFI_SSID_SIZE);\r
     strncpy(netInfo.netAddressInfo.WIFI.pwd, netPWD, NET_WIFI_PWD_SIZE);\r
     netInfo.connType = (OCConnectivityType)jConnectivityType;\r
+\r
+    if(netInfo.connType==CT_ADAPTER_GATT_BTLE)\r
+    {\r
+        strncpy(netInfo.netAddressInfo.LE.leMacAddress,ipAddress,NET_MACADDR_SIZE);\r
+        LOGI("MAC set=%s",netInfo.netAddressInfo.LE.leMacAddress);\r
+\r
+    }\r
     netInfo.isSecured = true;\r
 \r
     ProvisionEnrollee(&netInfo);\r
@@ -152,7 +165,7 @@ JNIEXPORT void JNICALL JNIProvisionEnrollee(JNIEnv *env, jobject thisObj,
 }\r
 \r
 JNIEXPORT void JNICALL JNIStopEnrolleeProvisioning(JNIEnv *env, jobject thisObj,\r
-                                                    jint jConnectivityType)\r
+        jint jConnectivityType)\r
 {\r
     LOGI("JNI Stop Easy Setup: Entering");\r
 \r
@@ -168,4 +181,3 @@ JNIEXPORT void JNICALL JNIStopEnrolleeProvisioning(JNIEnv *env, jobject thisObj,
     return;\r
 }\r
 \r
-\r
@@ -416,7 +416,8 @@ OCStackApplicationResult FindProvisioningResourceResponse(void* ctx, OCDoHandle
     devaddress->adapter = OC_ADAPTER_GATT_BTLE;
 
     if (strcmp(netProvInfo->netAddressInfo.WIFI.ipAddress, clientResponse->devAddr.addr))
-        OIC_LOG(INFO, TAG, "equal");
+        OIC_LOG_V(INFO, TAG, "unequal %s %s", netProvInfo->netAddressInfo.WIFI.ipAddress,
+                clientResponse->devAddr.addr);
     else
         OIC_LOG_V(INFO, TAG, "unequal %s %s", netProvInfo->netAddressInfo.WIFI.ipAddress,
                 clientResponse->devAddr.addr);
@@ -761,7 +762,7 @@ bool ConfigEnrolleeObject(const EnrolleeNWProvInfo_t *netInfo)
             netProvInfo->netAddressInfo.WIFI.pwd);
 
     OIC_LOG_V(DEBUG, TAG, "Network Provisioning Info. MAC ADDRESS = %s",
-            netProvInfo->netAddressInfo.WIFI.ipAddress);
+            netInfo->netAddressInfo.LE.leMacAddress);
 
     return true;