[TIZEN] Tizen console application support for enrollee
authorSandipan Patra <sandipan.p@samsung.com>
Fri, 29 Jan 2016 12:48:22 +0000 (18:18 +0530)
committerMadan Lanka <lanka.madan@samsung.com>
Fri, 5 Feb 2016 15:47:55 +0000 (15:47 +0000)
and SoftAp stubs API added for Tizen enrollee.

Change-Id: I7b524017e62cd82c8aa9db94279c0f2f7175272d
Signed-off-by: Sandipan Patra <sandipan.p@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/4887
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
32 files changed:
gbsbuild.sh
service/SConscript
service/easy-setup/SConscript
service/easy-setup/sampleapp/SConscript
service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/SConscript [new file with mode: 0644]
service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/SConstruct [new file with mode: 0644]
service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/com.oic.es.sample.manifest [new file with mode: 0644]
service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/com.oic.es.sample.xml [new file with mode: 0644]
service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/enrollee_wifi.cpp [new file with mode: 0644]
service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/packaging/com.oic.es.sample.spec [new file with mode: 0644]
service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/scons/SConscript [new file with mode: 0644]
service/easy-setup/sampleapp/enrollee/tizen-sdb/README.txt [new file with mode: 0644]
service/easy-setup/sampleapp/enrollee/tizen/Enrolleesample/edc_resource/re_client_control.edc [new file with mode: 0644]
service/easy-setup/sampleapp/enrollee/tizen/Enrolleesample/inc/enrollee_wifi.h [new file with mode: 0644]
service/easy-setup/sampleapp/enrollee/tizen/Enrolleesample/res/ui_controls.edc [new file with mode: 0644]
service/easy-setup/sampleapp/enrollee/tizen/Enrolleesample/shared/res/resampleapp.png [new file with mode: 0644]
service/easy-setup/sampleapp/enrollee/tizen/Enrolleesample/src/enrollee_wifi.cpp [new file with mode: 0644]
service/easy-setup/sampleapp/enrollee/tizen/Enrolleesample/tizen-manifest.xml [new file with mode: 0644]
service/easy-setup/sdk/common/escommon.h
service/easy-setup/sdk/enrollee/api/easysetup.h
service/easy-setup/sdk/enrollee/inc/onboarding.h [new file with mode: 0644]
service/easy-setup/sdk/enrollee/inc/resourceHandler.h
service/easy-setup/sdk/enrollee/inc/softap.h [new file with mode: 0644]
service/easy-setup/sdk/enrollee/src/easysetup.cpp
service/easy-setup/sdk/enrollee/src/onboarding.cpp [new file with mode: 0644]
service/easy-setup/sdk/enrollee/src/resourceHandler.cpp
service/easy-setup/sdk/enrollee/src/softap.cpp [new file with mode: 0644]
service/easy-setup/sdk/enrollee/tizen/wifi/networkHandler.cpp
service/easy-setup/sdk/enrollee/tizen/wifi/networkHandler.h
service/easy-setup/sdk/enrollee/tizen/wifi/softapnative.cpp [new file with mode: 0644]
service/easy-setup/sdk/enrollee/tizen/wifi/softapnative.h [new file with mode: 0644]
tools/tizen/iotivity.spec

index d9ab246..e7dc27c 100755 (executable)
@@ -44,7 +44,8 @@ cp ./SConstruct ./tmp
 # copy dependency RPMs and conf files for tizen build
 cp ./tools/tizen/*.rpm ./tmp
 cp ./tools/tizen/.gbs.conf ./tmp
-
+cp ./tools/tizen/*.rpm $sourcedir/tmp/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample
+cp ./tools/tizen/.gbs.conf ./tmp/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample
 cp -R $sourcedir/iotivity.pc.in $sourcedir/tmp
 
 cd $sourcedir/tmp
@@ -71,6 +72,28 @@ else
    exit 1
 fi
 
+cd service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample
+echo `pwd`
+
+if [ ! -d .git ]; then
+      git init ./
+      git config user.email "you@example.com"
+      git config user.name "Your Name"
+      git add ./
+      git commit -m "Initial commit"
+fi
+
+echo "Calling sample gbs build command"
+gbscommand="gbs build -A armv7l -B ~/GBS-ROOT --include-all --repository ./ --define 'TARGET_TRANSPORT IP' --define 'SECURED 0' --define 'RELEASE 0' --define 'LOGGING True' --define 'ROUTING EP' --define 'TARGET_ENROLLEE tizen
+'"
+echo $gbscommand
+if eval $gbscommand; then
+   echo "Sample build is successful"
+else
+   echo "Sample build is failed. "
+   exit 1
+fi
+
 cd $sourcedir
 rm -rf $sourcedir/tmp
 
index 3a35a4a..dea7af0 100755 (executable)
@@ -49,7 +49,6 @@ if target_os not in ['arduino','darwin']:
         SConscript('resource-directory/SConscript')
 
 # Build EasySetup module
-if target_os in ['arduino','android', 'linux']:
+if target_os in ['arduino', 'android', 'linux','tizen']:
     SConscript('easy-setup/SConscript')
 
-       
index 5be6fda..fc474a1 100755 (executable)
@@ -141,6 +141,7 @@ if target_os == 'tizen':
 if target_os == 'arduino':
        es_sdk_static = easy_setup_env.StaticLibrary('ESSDKLibrary',
                                        ['sdk/enrollee/src/easysetup.cpp',
+                                       'sdk/enrollee/src/onboarding.cpp',
                                        'sdk/enrollee/src/resourceHandler.cpp',
                                        'sdk/enrollee/arduino/wifi/networkHandler.cpp'])
        easy_setup_env.InstallTarget(es_sdk_static, 'libESSDK')
@@ -153,11 +154,14 @@ if target_os == 'android':
        easy_setup_env.InstallTarget(es_sdk_shared, 'libESSDK')
 
 if target_os == 'tizen':
-       es_sdk_shared = easy_setup_env.SharedLibrary('ESSDKLibrary',
-                                       ['sdk/enrollee/src/easysetup.cpp',
-                                       'sdk/enrollee/src/resourceHandler.cpp',
-                                       'sdk/enrollee/tizen/wifi/networkHandler.cpp'])
-       easy_setup_env.InstallTarget(es_sdk_shared, 'libESSDK')
+        es_sdk_shared = easy_setup_env.SharedLibrary('ESSDKLibrary',
+                                        ['sdk/enrollee/src/easysetup.cpp',
+                                        'sdk/enrollee/src/onboarding.cpp',
+                                        'sdk/enrollee/src/softap.cpp',
+                                        'sdk/enrollee/src/resourceHandler.cpp',
+                                        'sdk/enrollee/tizen/wifi/networkHandler.cpp',
+                                        'sdk/enrollee/tizen/wifi/softapnative.cpp'])
+        easy_setup_env.InstallTarget(es_sdk_shared, 'libESSDK')
 
 print"easysetup_path %s" % easysetup_path
 
index 95b780a..db2fcf8 100644 (file)
@@ -38,7 +38,7 @@ target_os = env.get('TARGET_OS')
 # Source files and Targets
 ######################################################################
 if target_os == 'arduino' :
-       # Build linux sample app
+       # Build arduino sample app
        SConscript('enrollee/arduino/SConscript')
 
 if target_os == 'linux' :
diff --git a/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/SConscript b/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/SConscript
new file mode 100644 (file)
index 0000000..0cd8288
--- /dev/null
@@ -0,0 +1,219 @@
+##########################################################################
+#
+# 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.
+#
+##########################################################################
+
+##
+# This script includes generic build options:
+#    release/debug, target os, target arch, cross toolchain, build environment etc
+##
+import os
+import platform
+
+print "Inside the Config SConscript"
+# Map of host os and allowed target os (host: allowed target os)
+host_target_map = {
+        'linux': ['linux', 'android', 'arduino', 'yocto', 'tizen'],
+        'windows': ['windows', 'winrt', 'android', 'arduino', 'tizen'],
+        'darwin': ['darwin', 'ios', 'android', 'arduino'],
+        }
+
+# Map of os and allowed archs (os: allowed archs)
+os_arch_map = {
+        'linux': ['x86', 'x86_64', 'arm', 'arm64'],
+        'android': ['x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'armeabi-v7a-hard', 'arm64-v8a'],
+        'windows': ['x86', 'amd64', 'arm'],
+        'winrt': ['arm'],
+        'darwin': ['i386', 'x86_64'],
+        'ios': ['i386', 'x86_64', 'armv7', 'armv7s', 'arm64'],
+        'arduino': ['avr', 'arm'],
+                'yocto': ['x86', 'x86_64'],
+        'tizen': ['armv7'],
+        }
+
+host = platform.system().lower()
+
+if not host_target_map.has_key(host):
+    print "\nError: Current system (%s) isn't supported\n" % host
+    Exit(1)
+
+######################################################################
+# Get build options (the optins from command line)
+######################################################################
+target_os = ARGUMENTS.get('TARGET_OS', host).lower() # target os
+
+if target_os not in host_target_map[host]:
+    print "\nError: Unknown target os: %s (Allow values: %s)\n" % (target_os, host_target_map[host])
+    Exit(1)
+
+default_arch = platform.machine()
+if default_arch not in os_arch_map[target_os]:
+    default_arch = os_arch_map[target_os][0].lower()
+
+target_arch = ARGUMENTS.get('TARGET_ARCH', default_arch) # target arch
+
+######################################################################
+# Common build options (release, target os, target arch)
+######################################################################
+help_vars = Variables()
+help_vars.Add(BoolVariable('RELEASE', 'Build for release?', True)) # set to 'no', 'false' or 0 for debug
+help_vars.Add(EnumVariable('TARGET_OS', 'Target platform', host, host_target_map[host]))
+help_vars.Add(ListVariable('TARGET_TRANSPORT', 'Target transport', 'ALL', ['ALL', 'IP', 'BT', 'BLE']))
+help_vars.Add(EnumVariable('TARGET_ARCH', 'Target architecture', default_arch, os_arch_map[target_os]))
+help_vars.Add(EnumVariable('SECURED', 'Build with DTLS', '0', allowed_values=('0', '1')))
+help_vars.Add(EnumVariable('ROUTING', 'Enable routing', 'EP', allowed_values=('GW', 'EP')))
+
+######################################################################
+# Platform(build target) specific options: SDK/NDK & toolchain
+######################################################################
+targets_support_cc = ['tizen']
+
+if target_os in targets_support_cc:
+    # Set cross compile toolchain
+    help_vars.Add('TC_PREFIX', "Toolchain prefix (Generally only be required for cross-compiling)", os.environ.get('TC_PREFIX'))
+    help_vars.Add(PathVariable('TC_PATH',
+            'Toolchain path (Generally only be required for cross-compiling)',
+            os.environ.get('TC_PATH')))
+
+if target_os in ['android', 'arduino']: # Android/Arduino always uses GNU compiler regardless of the host
+    env = Environment(variables = help_vars,
+            tools = ['gnulink', 'gcc', 'g++', 'ar', 'as']
+            )
+else:
+    env = Environment(variables = help_vars, TARGET_ARCH = target_arch, TARGET_OS = target_os)
+
+Help(help_vars.GenerateHelpText(env))
+
+tc_set_msg = '''
+************************************ Warning **********************************
+*   Enviornment variable TC_PREFIX/TC_PATH is set. It will change the default *
+* toolchain, if it isn't what you expect you should unset it, otherwise it may*
+* cause inexplicable errors.                                                  *
+*******************************************************************************
+'''
+
+if target_os in targets_support_cc:
+    prefix = env.get('TC_PREFIX')
+    tc_path = env.get('TC_PATH')
+    if prefix:
+        env.Replace(CC = prefix + 'gcc')
+        env.Replace(CXX = prefix + 'g++')
+        env.Replace(AR = prefix + 'ar')
+        env.Replace(AS = prefix + 'as')
+        env.Replace(LINK = prefix + 'ld')
+        env.Replace(RANLIB = prefix + 'ranlib')
+
+    if tc_path:
+        env.PrependENVPath('PATH', tc_path)
+        sys_root = os.path.abspath(tc_path + '/../')
+        env.AppendUnique(CCFLAGS = ['--sysroot=' + sys_root])
+        env.AppendUnique(LINKFLAGS = ['--sysroot=' + sys_root])
+
+    if prefix or tc_path:
+        print tc_set_msg
+
+# Ensure scons be able to change its working directory
+env.SConscriptChdir(1)
+
+# Set the source directory and build directory
+#   Source directory: 'dir'
+#   Build directory: 'dir'/out/<target_os>/<target_arch>/<release or debug>/
+#
+# You can get the directory as following:
+#   env.get('SRC_DIR')
+#   env.get('BUILD_DIR')
+
+def __set_dir(env, dir):
+    if not os.path.exists(dir + '/SConstruct'):
+        print '''
+*************************************** Error *********************************
+* The directory(%s) seems isn't a source code directory, no SConstruct file is
+* found. *
+*******************************************************************************
+''' % dir
+        Exit(1)
+
+    if env.get('RELEASE'):
+        build_dir = dir + '/out/' + target_os + '/' + target_arch + '/release/'
+    else:
+        build_dir = dir + '/out/' + target_os + '/' + target_arch + '/debug/'
+    env.VariantDir(build_dir, dir, duplicate=0)
+
+    env.Replace(BUILD_DIR = build_dir)
+    env.Replace(SRC_DIR = dir)
+
+def __src_to_obj(env, src, home = ''):
+    obj = env.get('BUILD_DIR') + src.replace(home, '')
+    if env.get('OBJSUFFIX'):
+        obj += env.get('OBJSUFFIX')
+    return env.Object(obj, src)
+
+def __install(ienv, targets, name):
+    i_n = ienv.Install(env.get('BUILD_DIR'), targets)
+    Alias(name, i_n)
+    env.AppendUnique(TS = [name])
+
+def __append_target(ienv, target):
+    env.AppendUnique(TS = [target])
+
+def __print_targets(env):
+    Help('''
+===============================================================================
+Targets:\n    ''')
+    for t in env.get('TS'):
+        Help(t + ' ')
+    Help('''
+\nDefault all targets will be built. You can specify the target to build:
+
+    $ scons [options] [target]
+===============================================================================
+''')
+
+env.AddMethod(__set_dir, 'SetDir')
+env.AddMethod(__print_targets, 'PrintTargets')
+env.AddMethod(__src_to_obj, 'SrcToObj')
+env.AddMethod(__append_target, 'AppendTarget')
+env.AddMethod(__install, 'InstallTarget')
+env.SetDir(env.GetLaunchDir())
+env['ROOT_DIR']=env.GetLaunchDir()
+
+env.AppendUnique(CPPDEFINES = ['TB_LOG'])
+if env.get('ROUTING') == 'GW':
+    env.AppendUnique(CPPDEFINES = ['ROUTING_GATEWAY'])
+elif env.get('ROUTING') == 'EP':
+    env.AppendUnique(CPPDEFINES = ['ROUTING_EP'])
+env.AppendUnique(CPPDEFINES = ['__TIZEN__'])
+
+Export('env')
+
+######################################################################
+# continue with the regular build process. Load config of target os
+######################################################################
+env.SConscript(target_os + '/SConscript')
+
+# Delete the temp files of configuration
+if env.GetOption('clean'):
+    dir = env.get('SRC_DIR')
+
+    if os.path.exists(dir + '/config.log'):
+        Execute(Delete(dir + '/config.log'))
+        Execute(Delete(dir + '/.sconsign.dblite'))
+        Execute(Delete(dir + '/.sconf_temp'))
+
+Return('env')
+
diff --git a/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/SConstruct b/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/SConstruct
new file mode 100644 (file)
index 0000000..bc860fb
--- /dev/null
@@ -0,0 +1,23 @@
+##
+# The main build script
+#
+##
+
+# Load common build config
+# Load common build config
+SConscript('SConscript')
+
+Import('env')
+
+target_os = env.get('TARGET_OS')
+transport = env.get('TARGET_TRANSPORT')
+
+print "Given Transport is %s" % transport
+print "Given OS is %s" % target_os
+print "Secured %s" % env.get('SECURED')
+
+if target_os == 'tizen':
+        SConscript('scons/SConscript')
+else:
+       print "Given platform is not supported"
+
diff --git a/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/com.oic.es.sample.manifest b/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/com.oic.es.sample.manifest
new file mode 100644 (file)
index 0000000..b37c690
--- /dev/null
@@ -0,0 +1,26 @@
+<manifest>
+       <define>
+         <domain name="essample" />
+         <permit>
+               <smack permit="system::use_internet" type="rwx"/>
+         </permit>
+         <request>
+                <smack request="system::use_internet" type="rwx"/>
+                <smack request="bt-service" type="rwx"/>
+               <smack request="sap" type="rwx"/>
+                <smack request="bt-service::spp" type="rwx"/>
+                <smack request="bt-service::gap" type="rwx"/>
+                <smack request="bt-service::admin" type="rwx"/>
+                <smack request="bt-service::manager" type="rwx"/>
+                <smack request="bt-service::public" type="rwx"/>
+                 <smack request="bt-service::platform" type="rwx"/>
+         </request>
+       </define>
+       <assign>
+               <filesystem path="/opt/apps/com.oic.es.sample/bin/sample" exec_label="sample" />
+       </assign>
+       <request>
+               <domain name="essample" />
+       </request>
+</manifest>
+
diff --git a/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/com.oic.es.sample.xml b/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/com.oic.es.sample.xml
new file mode 100644 (file)
index 0000000..fcf94d6
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns="http://tizen.org/ns/packages" package="com.oic.es.sample" version="0.1.12" install-location="internal-only">
+       <label>essample</label>
+       <author email="oic" href="www.iotivity.org">OIC</author>
+       <description>essample</description>
+       <ui-application appid="com.oic.es.sample" exec="/usr/apps/com.oic.es.sample/bin/sample" nodisplay="false" multiple="false" type="capp" taskmanage="true">
+               <icon>com.oic.es.sample.png</icon>
+               <label>essample</label>
+               <label xml:lang="en-us">essample</label>
+               <label xml:lang="nl-nl">essample</label>
+       </ui-application>
+       <privileges>
+               <privilege>http://tizen.org/privilege/socket</privilege>
+       </privileges>
+
+</manifest>
+
diff --git a/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/enrollee_wifi.cpp b/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/enrollee_wifi.cpp
new file mode 100644 (file)
index 0000000..365ac1a
--- /dev/null
@@ -0,0 +1,189 @@
+//******************************************************************
+//
+// 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 <string.h>
+#include <iostream>
+#include <pthread.h>
+
+#define TAG "TS"
+
+using namespace std;
+
+void *listeningFunc(void*);
+
+/**
+ * @var ssid
+ * @brief Target SSID of the Soft Access point to which the device has to connect
+ */
+static char ssid[] = "EasySetup123";
+
+/**
+ * @var passwd
+ * @brief Password of the Soft Access point to which the device has to connect
+ */
+static char passwd[] = "EasySetup123";
+
+void PrintMenu()
+{
+    cout<<"============"<<endl;
+    cout<<"S: start easy setup"<<endl;
+    cout<<"P: start provisioning resources"<<endl;
+    cout<<"T: terminate"<<endl;
+    cout<<"Q: quit"<<endl;
+    cout<<"============"<<endl;
+}
+
+void EventCallbackInApp(ESResult esResult, EnrolleeState enrolleeState)
+{
+    cout<<"Easy setup event callback"<<endl;
+
+    if(esResult == ES_OK)
+    {
+        if(enrolleeState == ES_ON_BOARDED_STATE)
+        {
+            cout<<"Device is successfully OnBoared on Adhoc network"<<endl;
+        }
+        else if (enrolleeState == ES_PROVISIONED_STATE)
+        {
+            cout<<"Device is provisioned with target network's credentials"<<endl;
+        }
+        else if (enrolleeState == ES_ON_BOARDED_TARGET_NETWORK_STATE)
+        {
+            cout<<"Device is onboarded/connected with target network"<<endl;
+        }
+        else
+        {
+            cout<<"Wrong state !! Easy setup is failed at Enrollee state = "<<enrolleeState<<endl;
+        }
+    }
+    else
+    {
+        cout<<"Easy stup is failed at Enrollee state = "<<enrolleeState<<endl;
+    }
+
+    PrintMenu();
+}
+
+
+void StartEasySetup()
+{
+    cout<<"StartEasySetup and onboarding started.."<<endl;
+
+    if(InitEasySetup(CT_ADAPTER_IP, ssid, passwd, EventCallbackInApp) == ES_ERROR)
+    {
+        cout<<"StartEasySetup and onboarding Fail!!"<<endl;
+        return;
+    }
+
+    pthread_t thread_handle;
+    if (pthread_create(&thread_handle, NULL, listeningFunc, NULL))
+    {
+        cout<<"Thread creation failed"<<endl;
+    }
+}
+
+void StartProvisioning()
+{
+    cout<<"Starting Enrollee Provisioning"<<endl;
+
+    if(InitProvisioning()== ES_ERROR)
+    {
+        cout<<"Init Provisioning Failed"<<endl;
+        return;
+    }
+    cout<<"InitProvisioning:Success"<<endl;
+}
+
+void StopEasySetup()
+{
+    cout<<"StopEasySetup IN"<<endl;
+    if(TerminateEasySetup()== ES_ERROR)
+    {
+        cout<<"return value is: ES_ERROR"<<endl;
+        return;
+    }
+    cout<<"StopEasySetup OUT"<<endl;
+}
+
+int main()
+{
+    cout<<"#########################"<<endl;
+    cout<<"EasySetup Enrollee SAMPLE"<<endl;
+    cout<<"#########################"<<endl;
+    PrintMenu();
+    char option;
+
+    while(true)
+    {
+        cin>>option;
+        switch (option)
+        {
+            case 'H': // help
+            case 'h':
+                PrintMenu();
+                break;
+
+            case 'Q': // quit
+            case 'q':
+                cout<<"quit";
+                break;
+
+            case 'S': // start easy setup
+            case 's':
+                StartEasySetup();
+                break;
+
+            case 'P': // start provisioning
+            case 'p':
+                StartProvisioning();
+                break;
+
+            case 'T': // stop easy setup
+            case 't':
+                StopEasySetup();
+                break;
+
+            default:
+                cout<<"wrong option"<<endl;
+                break;
+        }
+        if(option=='Q') break;
+    }
+    return 0;
+}
+
+void *listeningFunc(void*)
+{
+    OCStackResult result;
+
+    while (true)
+    {
+        result = OCProcess();
+        if (result != OC_STACK_OK)
+        {
+           cout<<"OCStack stop error";
+        }
+    }
+    return NULL;
+}
+
diff --git a/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/packaging/com.oic.es.sample.spec b/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/packaging/com.oic.es.sample.spec
new file mode 100644 (file)
index 0000000..e9d34f0
--- /dev/null
@@ -0,0 +1,52 @@
+%define PREFIX /usr/apps/com.oic.es.sample
+%define ROOTDIR  %{_builddir}/%{name}-%{version}
+
+Name: com-oic-es-sample
+Version:    0.1
+Release:    1
+Summary: Tizen adapter interfacesample application
+URL: http://slp-source.sec.samsung.net
+Source: %{name}-%{version}.tar.gz
+License: Apache-2.0
+Group: Applications/OICSample
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: boost-devel
+BuildRequires: boost-thread
+BuildRequires: boost-system
+BuildRequires: boost-filesystem
+BuildRequires: pkgconfig(capi-network-wifi)
+BuildRequires: pkgconfig(capi-network-bluetooth)
+BuildRequires: scons
+BuildRequires: iotivity
+BuildRequires: iotivity-devel
+BuildRequires: iotivity-service
+
+
+%description
+EasySetup Sample application
+
+%prep
+%setup -q
+
+%build
+
+scons TARGET_OS=tizen LOGGING=True TARGET_TRANSPORT=%{TARGET_TRANSPORT} SECURED=%{SECURED} RELEASE=%{RELEASE} ROUTING=%{ROUTING}
+
+%install
+
+mkdir -p %{buildroot}%{_datadir}/packages
+mkdir -p %{buildroot}/%{_sysconfdir}/smack/accesses2.d
+mkdir -p %{buildroot}/usr/apps/com.oic.es.sample/bin/
+mkdir -p %{buildroot}/usr/apps/com.oic.es.sample/bin/internal
+
+cp -rf %{ROOTDIR}/com.oic.es.sample.xml %{buildroot}/%{_datadir}/packages
+cp -rf %{ROOTDIR}/scons/enrollee_wifi %{buildroot}/usr/apps/com.oic.es.sample/bin/
+
+%files
+%manifest com.oic.es.sample.manifest
+%defattr(-,root,root,-)
+/usr/apps/com.oic.es.sample/bin/enrollee_wifi
+/%{_datadir}/packages/com.oic.es.sample.xml
+
+
diff --git a/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/scons/SConscript b/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/scons/SConscript
new file mode 100644 (file)
index 0000000..385476d
--- /dev/null
@@ -0,0 +1,51 @@
+#******************************************************************
+#
+# Copyright 2014 Intel Mobile Communications GmbH 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.
+#
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+Import('env')
+
+target_os = env.get('TARGET_OS')
+transport = env.get('TARGET_TRANSPORT')
+secured = env.get('SECURED')
+routing = env.get('ROUTING')
+OIC_LIB = 'oic'
+root_dir = env.get('ROOT_DIR')
+build_dir = env.get('BUILD_DIR')
+sample_dir = build_dir
+
+env.AppendUnique(CPPFLAGS = ['-std=c++0x', '-fPIC', '-D__TIZEN__','-DWITH_POSIX', '-Wall', '-DSLP_SDK_LOG', '-g','-D_GNU_SOURCE','-DTIZEN_DEBUG_ENABLE', '-DTB_LOG','`pkg-config', '--cflags', '--libs','dlog','capi-network-wifi',
+                               'gobject-2.0','glib-2.0`'])
+
+env.AppendUnique(CPPDEFINES = ['TB_LOG', 'ESWIFI'])
+
+env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
+
+if routing == 'GW':
+       env.AppendUnique(CPPDEFINES = ['ROUTING_GATEWAY'])
+elif routing == 'EP':
+       env.AppendUnique(CPPDEFINES = ['ROUTING_EP'])
+env.Append(LIBS=['octbstack','connectivity_abstraction','coap', 'ESSDKLibrary','pthread'])
+
+if secured == '1':
+       env.PrependUnique(CPPPATH = [root_dir + '/external/inc/'])
+       env.AppendUnique(CPPDEFINES = ['__WITH_DTLS__'])
+       env.Append(LIBS=['-ltinydtls'])
+
+env.Program('enrollee_wifi', [sample_dir + 'enrollee_wifi.cpp'])
+
diff --git a/service/easy-setup/sampleapp/enrollee/tizen-sdb/README.txt b/service/easy-setup/sampleapp/enrollee/tizen-sdb/README.txt
new file mode 100644 (file)
index 0000000..a7935da
--- /dev/null
@@ -0,0 +1,54 @@
+/******************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************/
+
+Build Procedure
+===============
+
+1) If you are building first time, then delete GBS-ROOT folder from home directory.
+   Note: Default build server URL for Tizen is set in gbs configuration file @ iotivity/tools/tizen/.gbs.conf.
+         If needed, same can be modified as per appropriate target.
+2) Go to "iotivity/" folder.
+3) Execute following command(s) to start build based on transport selection required :
+
+sh gbsbuild.sh
+Note :- Upon successful execution of above command(s) RI library and sample applications will be
+        generated at path "~/GBS-ROOT/local/repos/<target>/armv7l/RPMS".
+
+Procedure to Execute Sample App:
+================================
+    1) Copy the generated rpms(iotivity-1.0.0-0.armv7l.rpm,iotivity-devel-1.0.0-0.armv7l.rpm,iotivity-service-1.0.0-0.armv7l.rpm,com-oic-es-sample-0.1-1.armv7l.rpm) to Tizen Device
+       (say /opt/usr/media/xxx/)
+    2) sdb shell
+    3) su
+    4) cd /opt/usr/media/xxx/
+    5) change-booting-mode.sh --update
+
+    6) Install the rpms using the following commands:
+        a) rpm -Uvh iotivity-1.0.0-0.armv7l.rpm --force --nodeps
+        a) rpm -Uvh iotivity-devel-1.0.0-0.armv7l.rpm --force --nodeps
+        a) rpm -Uvh iotivity-service-1.0.0-0.armv7l.rpm --force --nodeps
+        b) rpm -Uvh com-oic-es-sample-0.1-1.armv7l.rpm --force --nodeps
+    7) For IP transport, apply net-config smack rules using below command:
+        a) chsmack -a "net-config" /usr/apps/com.oic.es.sample/bin/*
+        b) chsmack -e "net-config" /usr/apps/com.oic.es.sample/bin/*
+    7) RPM will be installed in "/usr/apps/"
+       Execute the sample app by below commands
+        i) cd /usr/apps/com.oic.es.sample/bin
+            a) ./enrollee_wifi 
diff --git a/service/easy-setup/sampleapp/enrollee/tizen/Enrolleesample/edc_resource/re_client_control.edc b/service/easy-setup/sampleapp/enrollee/tizen/Enrolleesample/edc_resource/re_client_control.edc
new file mode 100644 (file)
index 0000000..8146661
--- /dev/null
@@ -0,0 +1,148 @@
+/******************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************/
+
+#define POPUP_CONTENT_DEFAULT_PADDING_LEFT_MIN_INC 15
+#define POPUP_EDITFIELD_LAYOUT_MINMAX_HEIGHT_INC 96
+
+group
+{
+    name: "group_layout";
+    parts
+    {
+        part
+        {
+            name: "button1";
+            type: SWALLOW;
+            scale: 1;
+            description
+            {
+                rel1.relative: 0.01 0.01;
+                rel2.relative: 0.5 0.09;
+            }
+        }
+        part
+        {
+            name: "button2";
+            type: SWALLOW;
+            scale: 1;
+            description
+            {
+                rel1.relative: 0.51 0.01;
+                rel2.relative: 1.0 0.09;
+            }
+        }
+        part
+        {
+            name: "list";
+            type: SWALLOW;
+            scale: 1;
+            description
+            {
+                rel1.relative: 0.01 0.1;
+                rel2.relative: 0.99 0.7;
+            }
+        }
+        part
+        {
+            name: "log_bg";
+            type: RECT;
+            scale: 1;
+            description
+            {
+                state: "default" 0.0;
+                rel1.relative: 0.01 0.71;
+                rel2.relative: 0.98 1.0;
+                color: 220 220 220 255;
+            }
+        }
+        part
+        {
+            name: "log";
+            type: SWALLOW;
+            scale: 1;
+            description
+            {
+                rel1.to: "log_bg";
+                rel2.to: "log_bg";
+            }
+        }
+    }
+}
+
+group
+{
+    name: "popup_datetime_text";
+    parts
+    {
+        part
+        {
+            name: "pad_l";
+            type: SPACER;
+            scale: 1;
+            description
+            {
+                state: "default" 0.0;
+                min: POPUP_CONTENT_DEFAULT_PADDING_LEFT_MIN_INC 0;
+                fixed: 1 0;
+                rel1.relative: 0.0 0.0;
+                rel2.relative: 0.0 1.0;
+                align: 0.0 0.0;
+            }
+        }
+        part
+        {
+            name: "pad_r";
+            type: SPACER;
+            scale: 1;
+            description
+            {
+                state: "default" 0.0;
+                min: POPUP_CONTENT_DEFAULT_PADDING_LEFT_MIN_INC 0;
+                fixed: 1 0;
+                rel1.relative: 1.0 0.0;
+                rel2.relative: 1.0 1.0;
+                align: 1.0 0.0;
+            }
+        }
+        part
+        {
+            name: "elm.swallow.content";
+            type: SWALLOW;
+            scale: 1;
+            description
+            {
+                state: "default" 0.0;
+                min: 0 POPUP_EDITFIELD_LAYOUT_MINMAX_HEIGHT_INC;
+                max: -1 POPUP_EDITFIELD_LAYOUT_MINMAX_HEIGHT_INC;
+                align: 0.5 0.5;
+                rel1
+                {
+                    relative: 1.0 0.0;
+                    to_x: "pad_l";
+                }
+                rel2
+                {
+                    relative: 0.0 1.0;
+                    to_x: "pad_r";
+                }
+            }
+        }
+    }
+}
diff --git a/service/easy-setup/sampleapp/enrollee/tizen/Enrolleesample/inc/enrollee_wifi.h b/service/easy-setup/sampleapp/enrollee/tizen/Enrolleesample/inc/enrollee_wifi.h
new file mode 100644 (file)
index 0000000..a89b4f0
--- /dev/null
@@ -0,0 +1,57 @@
+/******************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************/
+
+#ifndef RECLIENTMAIN_H__
+#define RECLIENTMAIN_H__
+
+#include <app.h>
+#include <Elementary.h>
+#include <system_settings.h>
+#include <efl_extension.h>
+#include <dlog.h>
+
+#include "OCPlatform.h"
+#include "OCApi.h"
+
+#include "easysetup.h"
+#include "wifi.h"
+#include "escommon.h"
+using namespace OC;
+
+#ifdef  LOG_TAG
+#undef  LOG_TAG
+#endif
+#define LOG_TAG "TIZEN ES"
+
+#if !defined(PACKAGE)
+#define PACKAGE "org.tizen.esenrolleesample"
+#endif
+
+#define ELM_DEMO_EDJ "opt/usr/apps/org.tizen.esenrolleesample/res/ui_controls.edj"
+
+void StartEnrollee(void *data, Evas_Object *obj, void *event_info);
+void *listeningFunc(void*);
+static char ssid[] = "EasySetup123";
+static char passwd[] = "EasySetup123";
+static bool g_OnBoardingSucceeded = false;
+static bool g_ProvisioningSucceeded = false;
+
+static bool g_isInitialized = false;
+#endif // RECLIENTMAIN_H__
diff --git a/service/easy-setup/sampleapp/enrollee/tizen/Enrolleesample/res/ui_controls.edc b/service/easy-setup/sampleapp/enrollee/tizen/Enrolleesample/res/ui_controls.edc
new file mode 100644 (file)
index 0000000..7e85384
--- /dev/null
@@ -0,0 +1,25 @@
+/******************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************/
+
+collections
+{
+    base_scale: 1.8;
+    #include "../edc_resource/re_client_control.edc"
+}
\ No newline at end of file
diff --git a/service/easy-setup/sampleapp/enrollee/tizen/Enrolleesample/shared/res/resampleapp.png b/service/easy-setup/sampleapp/enrollee/tizen/Enrolleesample/shared/res/resampleapp.png
new file mode 100644 (file)
index 0000000..9765b1b
Binary files /dev/null and b/service/easy-setup/sampleapp/enrollee/tizen/Enrolleesample/shared/res/resampleapp.png differ
diff --git a/service/easy-setup/sampleapp/enrollee/tizen/Enrolleesample/src/enrollee_wifi.cpp b/service/easy-setup/sampleapp/enrollee/tizen/Enrolleesample/src/enrollee_wifi.cpp
new file mode 100644 (file)
index 0000000..e8739c6
--- /dev/null
@@ -0,0 +1,254 @@
+/******************************************************************
+ *
+ * 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 "enrollee_wifi.h"
+#include <pthread.h>
+#include "logger.h"
+#include <iostream>
+
+using namespace std;
+
+static Evas_Object *log_entry = NULL;
+static Evas_Object *list = NULL;
+static Evas_Object *naviframe = NULL;
+
+/**
+ * Function to update the log in UI
+ */
+void *updateGroupLog(void *data)
+{
+    string *log = (string *) data;
+    *log = *log + "<br>";
+    // Show the log
+    elm_entry_entry_append(log_entry, (*log).c_str());
+    elm_entry_cursor_end_set(log_entry);
+    return NULL;
+}
+
+/**
+ * EventCallback function implementation
+ * This callback to be used for Enrollee status change
+ */
+void EventCallbackInApp(ESResult esResult, EnrolleeState enrolleeState)
+{
+    string logmessage = "callback!!! in app";
+    OC_LOG(INFO,LOG_TAG,"callback!!! in app");
+
+    if (esResult == ES_OK)
+    {
+        if (!g_OnBoardingSucceeded)
+        {
+            OC_LOG(INFO,LOG_TAG,"Device is successfully OnBoarded");
+            logmessage += "Device is successfully OnBoarded";
+            g_OnBoardingSucceeded = true;
+        }
+        else if (g_OnBoardingSucceeded & enrolleeState == ES_ON_BOARDED_STATE)
+        {
+            OC_LOG(INFO,LOG_TAG,"Device is successfully OnBoared with SoftAP");
+            logmessage += "Device is successfully OnBoared with SoftAP";
+            g_ProvisioningSucceeded = true;
+        }
+
+        else if (enrolleeState == ES_PROVISIONED_STATE)
+        {
+            OC_LOG(INFO,LOG_TAG,"Device is provisioned");
+            logmessage += "Device is provisioned";
+            g_ProvisioningSucceeded = true;
+        }
+
+    }
+    else if (esResult == ES_ERROR)
+    {
+        if (g_OnBoardingSucceeded)
+        {
+            OC_LOG_V(ERROR,LOG_TAG,
+                        "Failure in Provisioning.Current Enrollee State: %d", enrolleeState);
+            logmessage += "Failure in Provisioning\n";
+            g_OnBoardingSucceeded = false;
+        }
+        else if (g_ProvisioningSucceeded)
+        {
+            OC_LOG_V(ERROR,LOG_TAG,
+                "Failure in connect to target network.Current Enrollee State: %d", enrolleeState);
+            logmessage += "Failure in connect to target network\n";
+            g_ProvisioningSucceeded = false;
+        }
+    }
+    ecore_main_loop_thread_safe_call_sync((void * (*)(void *))updateGroupLog, &logmessage);
+}
+
+/**
+ * List_selected_cb callback
+ */
+static void list_selected_cb(void *data, Evas_Object *obj, void *event_info)
+{
+    Elm_Object_Item *it = (Elm_Object_Item *) event_info;
+    elm_list_item_selected_set(it, EINA_FALSE);
+}
+
+/**
+ * This function initializes easysetup and does onboarding
+ */
+static void init_easysetup(void *data, Evas_Object *obj, void *event_info)
+{
+    string logmessage = "Init Easysetup\n";
+    if (InitEasySetup(CT_ADAPTER_IP, ssid, passwd, EventCallbackInApp) == ES_ERROR)
+    {
+        OC_LOG(ERROR,LOG_TAG,"OnBoarding Failed");
+        logmessage = logmessage + "OnBoarding Failed. Connect to " + ssid + " pasword= " + passwd;
+        ecore_main_loop_thread_safe_call_sync((void * (*)(void *))updateGroupLog, &logmessage);
+        return;
+
+    }
+    g_isInitialized = true;
+    OC_LOG_V(ERROR,LOG_TAGLOG_TAG, "OnBoarding succeeded. Successfully connected to ssid : %s",
+            ssid);
+    logmessage = logmessage + "OnBoarding succeeded. Successfully connected to ssid:" + ssid;
+    ecore_main_loop_thread_safe_call_sync((void * (*)(void *))updateGroupLog, &logmessage);
+}
+
+/**
+ * Initialises and Creates provisioning resource
+ */
+void StartProvisioning(void *data, Evas_Object *obj, void *event_info)
+{
+    OC_LOG(INFO,LOG_TAG"StartProvisioning");
+    string logmessage = "StartProvisioning\n";
+
+    if (InitProvisioning() == ES_ERROR)
+    {
+        OC_LOG(ERROR,LOG_TAG,"Init Provisioning Failed");
+        logmessage += "Init Provisioning Failed\n";
+        return;
+    }
+
+    pthread_t thread_handle;
+    if (pthread_create(&thread_handle, NULL, listeningFunc, NULL))
+    {
+        OC_LOG(ERROR,LOG_TAG,"Thread creation failed");
+    }
+    ecore_main_loop_thread_safe_call_sync((void * (*)(void *))updateGroupLog, &logmessage);
+}
+
+/**
+ * Thread to execute OCProcess in a loop
+ */
+void *listeningFunc(void*)
+{
+    OCStackResult result;
+    while (true)
+    {
+        result = OCProcess();
+        if (result != OC_STACK_OK)
+        {
+            OC_LOG(ERROR,LOG_TAG,"OCStack stop error");
+        }
+
+        // To minimize CPU utilization we may wish to do this with sleep
+        sleep(1);
+    }
+    return NULL;
+}
+
+/**
+ * naviframe_pop_cb callback impl
+ */
+static Eina_Bool naviframe_pop_cb(void *data, Elm_Object_Item *it)
+{
+    if (NULL != log_entry)
+    {
+        evas_object_del(log_entry);
+        log_entry = NULL;
+    }
+    if (NULL != list)
+    {
+        evas_object_del(list);
+        list = NULL;
+    }
+    return EINA_TRUE;
+}
+
+/**
+ * Client callback: client_cb impl
+ */
+void client_cb(void *data)
+{
+    Evas_Object *layout;
+    Evas_Object *scroller;
+    Evas_Object *nf = (Evas_Object *) data;
+    Evas_Object *button1;
+    Evas_Object *button2;
+    Elm_Object_Item *nf_it;
+
+    naviframe = nf;
+
+    // Scroller
+    scroller = elm_scroller_add(nf);
+    elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_TRUE);
+    elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
+
+    // Layout
+    layout = elm_layout_add(nf);
+    elm_layout_file_set(layout, ELM_DEMO_EDJ, "group_layout");
+    evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+    elm_object_content_set(scroller, layout);
+
+    // Start Discovery Button
+    button1 = elm_button_add(layout);
+    elm_object_part_content_set(layout, "button1", button1);
+    elm_object_text_set(button1, "Init Easysetup");
+    evas_object_smart_callback_add(button1, "clicked", init_easysetup, NULL);
+
+    // Cancel Discovery Button
+    button2 = elm_button_add(layout);
+    elm_object_part_content_set(layout, "button2", button2);
+    elm_object_text_set(button2, "start Provisioning");
+    evas_object_smart_callback_add(button2, "clicked", StartProvisioning, NULL);
+
+    // List
+    list = elm_list_add(layout);
+    elm_list_mode_set(list, ELM_LIST_COMPRESS);
+    evas_object_smart_callback_add(list, "selected", list_selected_cb, NULL);
+    elm_object_part_content_set(layout, "list", list);
+    elm_list_go(list);
+
+    // log_entry - textarea for log
+    log_entry = elm_entry_add(layout);
+    elm_entry_scrollable_set(log_entry, EINA_TRUE);
+    elm_entry_editable_set(log_entry, EINA_FALSE);
+    elm_object_part_text_set(log_entry, "elm.guide",
+            "Logs will be updated here!!!<br>Please connect to network :Easysetup before starting!!");
+    evas_object_size_hint_weight_set(log_entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+    evas_object_size_hint_align_set(log_entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
+    elm_object_part_content_set(layout, "log", log_entry);
+
+    nf_it = elm_naviframe_item_push(nf, "EasySetup-Enrollee", NULL, NULL, scroller, NULL);
+    elm_naviframe_item_pop_cb_set(nf_it, naviframe_pop_cb, NULL);
+}
+
+/**
+ * Starting Enrollee
+ */
+void StartEnrollee(void *data, Evas_Object *obj, void *event_info)
+{
+    client_cb(data);
+}
+
diff --git a/service/easy-setup/sampleapp/enrollee/tizen/Enrolleesample/tizen-manifest.xml b/service/easy-setup/sampleapp/enrollee/tizen/Enrolleesample/tizen-manifest.xml
new file mode 100644 (file)
index 0000000..05bfb47
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<manifest xmlns="http://tizen.org/ns/packages" api-version="2.3" package="org.tizen.esenrolleesample" version="1.0.0">
+    <profile name="mobile"/>
+    <ui-application appid="org.tizen.esenrolleesample" exec="esenrolleesample" multiple="false" nodisplay="false" taskmanage="true" type="capp">
+        <label>esenrolleesample</label>
+        <icon>resampleapp.png</icon>
+    </ui-application>
+    <privileges>
+        <privilege>http://tizen.org/privilege/network.get</privilege>
+        <privilege>http://tizen.org/privilege/systemsettings</privilege>
+        <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
+        <privilege>http://tizen.org/privilege/network.set</privilege>
+        <privilege>http://tizen.org/privilege/bluetooth</privilege>
+        <privilege>http://tizen.org/privilege/internet</privilege>
+        <privilege>http://tizen.org/privilege/power</privilege>
+        <privilege>http://tizen.org/privilege/network.profile</privilege>
+        <privilege>http://tizen.org/privilege/wifidirect</privilege>
+    </privileges>
+    <feature name="http://tizen.org/feature/network.wifi">true</feature>
+</manifest>
index 520990a..24963b5 100755 (executable)
 #include "octypes.h"
 
 // Defines
-#define OIC_STRING_MAX_VALUE 100
-#define IPV4_ADDR_SIZE 16
-#define IP_PORT 55555
-#define NET_WIFI_SSID_SIZE 100
-#define NET_WIFI_PWD_SIZE 100
+#define OIC_STRING_MAX_VALUE    100
+#define IPV4_ADDR_SIZE          16
+#define IP_PORT                 55555
+#define NET_WIFI_SSID_SIZE      100
+#define NET_WIFI_PWD_SIZE       100
 
 /**
  * @brief Mac address length for BT port
 /**
  * @brief Defines for Provisioning status accepted values
  */
-#define ES_PS_NEED_PROVISIONING 1
-#define ES_PS_PROVISIONING_COMPLETED 2
+#define ES_PS_NEED_PROVISIONING         1
+#define ES_PS_PROVISIONING_COMPLETED    2
 
+/**
+* Device Roles defined for each device type used in easy setup
+*/
 typedef enum
 {
+    ENROLLEE,
+    MEDIATOR,
+    ENROLLER,
+} DeviceRole;
 
+/**
+* On-boarding connection to create Adhoc network.
+*/
+typedef enum
+{
+    SOFTAP,
+    BLE,
+} OBConnection;
+
+typedef enum
+{
     ES_ERROR = -1,
     ES_OK = 0,
     ES_NETWORKFOUND = 1,
@@ -77,58 +95,62 @@ typedef enum
 typedef enum
 {
     /**
-        * Default state of the device
-        */
+     * Default state of the device
+     */
     ES_INIT_STATE,
 
     /**
-        * Device will move to this state once the on boarding begins
-        */
+     * Device will move to this state once the on boarding begins
+     */
     ES_ON_BOARDING_STATE,
 
     /**
-        * Device will move to this state after successful on-boarding of the device
-        */
+     * Device will move to this state after successful on-boarding of the device
+     */
     ES_ON_BOARDED_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
+     */
     ES_PROVISIONING_STATE,
 
     /**
-        * Easy setup process is successful.
-        */
+     * Easy setup process is successful.
+     */
     ES_PROVISIONED_STATE,
 
     /**
-        * 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
-        */
+     * 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
+     */
     ES_OWNERSHIP_TRANSFERRING_STATE,
 
     /**
-        * This state is arbitrary one, any time device can come into this state
-        * Device will move to this state if the ownership transfer is completed
-        */
+     * This state is arbitrary one, any time device can come into this state
+     * Device will move to this state if the ownership transfer is completed
+     */
     ES_OWNERSHIP_TRANSFERRED_STATE,
 
     /**
-        * 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
-        */
+     * 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
+     */
     ES_FACTORY_RESET_STATE,
-}EnrolleeState;
-
 
+    /**
+     * Enrollee moves to this state after connecting to target network
+     */
+    ES_ON_BOARDED_TARGET_NETWORK_STATE,
+}EnrolleeState;
 
 /**
  * Provisioning Device Status
  */
-typedef struct {
-    /// Address of remote server
+typedef struct
+{
+    // Address of remote server
     OCDevAddr * addr;
-    /// Indicates adaptor type on which the response was received
+    // Indicates adaptor type on which the response was received
     OCConnectivityType connType;
 } EasySetupDeviceInfo;
 
@@ -143,12 +165,11 @@ typedef enum
     DEVICE_NOT_OWNED
 } EasySetupState, ProvStatus;
 
-
-
 /**
  * Response from queries to remote servers.
  */
-typedef struct {
+typedef struct
+{
     // EasySetup Status
     EasySetupState provStatus;
     // EasySetup Device Info
index e3b0adc..12c6324 100644 (file)
@@ -27,7 +27,6 @@
 #ifndef EASYSETUP_ENROLLEE_H__
 #define EASYSETUP_ENROLLEE_H__
 
-#include "Arduino.h"
 #include "escommon.h"
 
 #ifdef __cplusplus
diff --git a/service/easy-setup/sdk/enrollee/inc/onboarding.h b/service/easy-setup/sdk/enrollee/inc/onboarding.h
new file mode 100644 (file)
index 0000000..7822413
--- /dev/null
@@ -0,0 +1,51 @@
+//******************************************************************
+//
+// 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.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+#ifndef EASYSETUP_ENROLLEE_ONBOARDING_H__
+#define EASYSETUP_ENROLLEE_ONBOARDING_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif // __cplusplus:$
+
+#include "networkHandler.h"
+
+/**
+ * It will on-board the Enrollee device. This is a template method that has
+ * core business logic & negotiation algorithm on various on-boarding methods.
+ */
+bool ESOnboard(const char * ssid, const char* passwd, NetworkEventCallback cb);
+
+/**
+ * It will return true on-boarding type is soft AP.
+ */
+bool ESSoftapOnboarding(); 
+
+/**
+ * It will return true on-boarding type is BLE.
+ */
+bool ESBleOnboarding();
+
+#ifdef __cplusplus
+}
+#endif // __cplusplus
+
+
+#endif /* EASYSETUP_ENROLLEE_ONBOARDING_H__ */
index 6d24877..1dead62 100644 (file)
@@ -19,7 +19,6 @@
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
 // Do not remove the include below
-#include "Arduino.h"
 
 #include <string.h>
 #include "logger.h"
diff --git a/service/easy-setup/sdk/enrollee/inc/softap.h b/service/easy-setup/sdk/enrollee/inc/softap.h
new file mode 100644 (file)
index 0000000..57efb35
--- /dev/null
@@ -0,0 +1,69 @@
+//******************************************************************
+//
+// 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.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+#ifndef EASYSETUP_ENROLLEE_SOFTAP_H__
+#define EASYSETUP_ENROLLEE_SOFTAP_H__
+
+#include "escommon.h"
+#include "networkHandler.h"
+
+//#ifdef __cplusplus
+//extern "C" {
+//#endif // __cplusplus
+
+/**
+ * @file
+ *
+ * This file contains the configuration for SoftAP
+ */
+
+/**
+ * It will return true if the Soft AP is created at Enrollee device
+ */
+bool ESSoftapAtEnrollee();
+
+
+/**
+ * It will return true if the Soft AP is created at Mediator device
+ */
+
+bool ESSoftapAtMediator();
+
+/**
+ * It will return Device which is creating Soft AP ;  Devices are identified by their role
+ * i.e. Enrollee or Mediator.
+ */
+DeviceRole ESSoftapHost();
+
+/**
+ * Handle Soft AP creation
+ */
+void ESCreateSoftap(const char * ssid, const char* passwd, NetworkEventCallback cb);
+
+
+//#ifdef __cplusplus
+//}
+//#endif // __cplusplus
+
+
+#endif /* EASYSETUP_ENROLLEE_SOFTAP_H__ */
+
+
+
index 9855710..eb4dd31 100644 (file)
@@ -25,7 +25,8 @@
  */
 
 #include "easysetup.h"
-
+#include "softap.h"
+#include "onboarding.h"
 #include "logger.h"
 #include "resourceHandler.h"
 
@@ -52,147 +53,119 @@ static char *targetSsid;
 static char *targetPass;
 
 /**
- * @var g_cbForEnrolleeStatus
+ * @var gEnrolleeStatusCb
  * @brief Fucntion pointer holding the callback for intimation of EasySetup Enrollee status callback
  */
-static EventCallback g_cbForEnrolleeStatus = NULL;
+static EventCallback gEnrolleeStatusCb = NULL;
 
 //-----------------------------------------------------------------------------
 // Private internal function prototypes
 //-----------------------------------------------------------------------------
+void OnboardingCallback(ESResult esResult);
+void ProvisioningCallback(ESResult esResult);
+void OnboardingCallbackTargetNet(ESResult esResult);
+bool validateParam(OCConnectivityType networkType, const char *ssid, const char *passwd,
+              EventCallback cb);
 
-void EventCallbackInOnboarding(ESResult esResult);
-void EventCallbackInProvisioning(ESResult esResult);
-void EventCallbackAfterProvisioning(ESResult esResult);
 
-void EventCallbackInOnboarding(ESResult esResult)
+void OnboardingCallback(ESResult esResult)
 {
-    if (g_cbForEnrolleeStatus != NULL){
-        OC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Calling the application with esResult = %d", esResult);
-        if(esResult == ES_OK){
-            OC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Calling the application with enrolleestate = %d",
-                                                ES_ON_BOARDED_STATE);
-            g_cbForEnrolleeStatus(esResult, ES_ON_BOARDED_STATE);
+        OC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "OnboardingCallback with  result = %d", esResult);
+        if(esResult == ES_OK)
+        {
+            gEnrolleeStatusCb(esResult, ES_ON_BOARDED_STATE);
         }
-        else{
-            OC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Calling the application with enrolleestate = %d",
-                                                ES_INIT_STATE);
-            g_cbForEnrolleeStatus(esResult, ES_INIT_STATE);
+        else
+        {
+            OC_LOG_V(DEBUG, ES_ENROLLEE_TAG, 
+                        "Onboarding is failed callback result is = %d", esResult);
+            gEnrolleeStatusCb(esResult, ES_INIT_STATE);
         }
-    }
-    else{
-        OC_LOG(ERROR, ES_ENROLLEE_TAG, "g_cbForEnrolleeStatus is NULL");
-    }
 }
 
-void EventCallbackInProvisioning(ESResult esResult)
+void ProvisioningCallback(ESResult esResult)
 {
+    OC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "ProvisioningCallback with  result = %d", esResult);
     ESResult res = ES_OK;
-
     if (esResult == ES_RECVTRIGGEROFPROVRES)
     {
         targetSsid = (char *) malloc(MAXSSIDLEN);
         targetPass = (char *) malloc(MAXNETCREDLEN);
 
-        if(TerminateEasySetup() != OC_STACK_OK)
-        {
-            OC_LOG(ERROR, ES_ENROLLEE_TAG, "Terminating stack failed");
-            return;
-        }
-
         GetTargetNetworkInfoFromProvResource(targetSsid, targetPass);
+        gEnrolleeStatusCb(ES_OK, ES_PROVISIONED_STATE);
+        OC_LOG(DEBUG, ES_ENROLLEE_TAG, "Connecting with target network");
 
-        res = ConnectToWiFiNetwork(targetSsid, targetPass, EventCallbackAfterProvisioning);
-
-        if (g_cbForEnrolleeStatus != NULL)
-        {
-            if(res == ES_NETWORKCONNECTED){
-                OC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Calling the application with enrolleestate = %d",
-                                                    ES_PROVISIONED_STATE);
-                g_cbForEnrolleeStatus(ES_OK, ES_PROVISIONED_STATE);
-            }
-            else{
-                OC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Calling the application with enrolleestate = %d",
-                                                    ES_PROVISIONING_STATE);
-                g_cbForEnrolleeStatus(ES_OK, ES_PROVISIONING_STATE);
-            }
-
-        }
+        // Connecting/onboarding to target network
+        ConnectToWiFiNetwork(targetSsid, targetPass, OnboardingCallbackTargetNet);
+    }
+    else
+    {
+       OC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Provisioning is failed callback result is = %d", esResult);
+       // Resetting Enrollee to ONBOARDED_STATE as Enrollee is alreday onboarded in previous step
+       gEnrolleeStatusCb(ES_OK, ES_ON_BOARDED_STATE);
     }
 }
 
-void EventCallbackAfterProvisioning(ESResult esResult)
+void OnboardingCallbackTargetNet(ESResult esResult)
 {
-    if (g_cbForEnrolleeStatus != NULL){
-        if(esResult == ES_OK){
-            OC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Calling the application with enrolleestate = %d",
-                                                   ES_PROVISIONED_STATE);
-            g_cbForEnrolleeStatus(esResult, ES_PROVISIONED_STATE);
-        }
-        else{
-            OC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Calling the application with enrolleestate = %d",
-                                                   ES_PROVISIONING_STATE);
-            g_cbForEnrolleeStatus(esResult, ES_PROVISIONING_STATE);
-        }
+    OC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "OnboardingCallback on target network with result = %d",
+                                                                                        esResult);
+    if(esResult == ES_OK)
+    {
+        gEnrolleeStatusCb(esResult, ES_ON_BOARDED_TARGET_NETWORK_STATE);
     }
-    else{
-        OC_LOG(ERROR, ES_ENROLLEE_TAG, "g_cbForEnrolleeStatus is NULL");
+    else
+    {
+        OC_LOG_V(DEBUG, ES_ENROLLEE_TAG,
+                    "Onboarding is failed on target network and callback result is = %d", esResult);
+        // Resetting Enrollee state to the ES_PROVISIONED_STATE
+        // as device is already being provisioned with target network creds.
+        gEnrolleeStatusCb(esResult, ES_PROVISIONED_STATE);
     }
 }
 
-ESResult FindNetworkForOnboarding(OCConnectivityType networkType,
-                                           const char *ssid,
-                                           const char *passwd,
-                                           EventCallback cb)
+static FILE* server_fopen(const char* /*path*/, const char *mode)
 {
-    if (!ssid || !passwd)
+    OC_LOG_V(INFO,ES_ENROLLEE_TAG,"oic_svr_db_server open %s",mode);
+    FILE *file= fopen("/opt/usr/media/Images/oic_svr_db_server.json", mode);
+    if(file==NULL)
     {
-        return ES_ERROR;
-    }
-
-    if (networkType == CT_ADAPTER_IP)
-    {
-        if (g_cbForEnrolleeStatus == NULL)
-        {
-            g_cbForEnrolleeStatus = cb;
-        }
-
-        if(ConnectToWiFiNetwork(ssid, passwd, EventCallbackInOnboarding) != ES_NETWORKCONNECTED)
-        {
-            OC_LOG(ERROR, ES_ENROLLEE_TAG, "ConnectToWiFiNetwork Failed");
-            cb(ES_ERROR, ES_ON_BOARDING_STATE);
-            return ES_ERROR;
-        }
-        else{
-            OC_LOG(INFO, ES_ENROLLEE_TAG, "ConnectToWiFiNetwork Success");
-            cb(ES_OK, ES_ON_BOARDED_STATE);
-            return ES_OK;
-        }
+        OC_LOG(ERROR,ES_ENROLLEE_TAG,"oic_svr_db_server failed");
     }
-    return ES_ERROR;
+    return file;
 }
 
-
-ESResult InitEasySetup(OCConnectivityType networkType, const char *ssid, const char *passwd,
-              EventCallback cb)
+ESResult InitEasySetup(OCConnectivityType networkType, const char *ssid,
+                            const char *passwd, EventCallback cb)
 {
-    if(FindNetworkForOnboarding(networkType, ssid, passwd, cb) != ES_OK)
+    OC_LOG(INFO, ES_ENROLLEE_TAG, "InitEasySetup IN");
+    if(!validateParam(networkType,ssid,passwd,cb))
     {
-        OC_LOG(ERROR, ES_ENROLLEE_TAG, "OnBoarding Failed");
+        OC_LOG(ERROR, ES_ENROLLEE_TAG,
+                            "InitEasySetup::Stopping Easy setup due to invalid parameters");
         return ES_ERROR;
     }
 
-    // Initialize the OC Stack in Server mode
-    if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK)
+    //Init callback
+    gEnrolleeStatusCb = cb;
+
+    // TODO : This onboarding state has to be set by lower layer, as they better
+    // knows when actually on-boarding started.
+    cb(ES_ERROR,ES_ON_BOARDING_STATE);
+
+    OC_LOG(INFO, ES_ENROLLEE_TAG, "received callback");
+    OC_LOG(INFO, ES_ENROLLEE_TAG, "onboarding now..");
+
+    if(!ESOnboard(ssid, passwd, OnboardingCallback))
     {
-        OC_LOG(ERROR, ES_ENROLLEE_TAG, "OCStack init error");
+        OC_LOG(ERROR, ES_ENROLLEE_TAG, "InitEasySetup::On-boarding failed");
+        cb(ES_ERROR, ES_INIT_STATE);
         return ES_ERROR;
     }
-    else
-    {
-        OC_LOG(DEBUG, ES_ENROLLEE_TAG, "OCStack init success");
-        return ES_OK;
-    }
+
+    OC_LOG(INFO, ES_ENROLLEE_TAG, "InitEasySetup OUT");
+    return ES_OK;
 }
 
 ESResult TerminateEasySetup()
@@ -211,18 +184,41 @@ ESResult TerminateEasySetup()
 
 ESResult InitProvisioning()
 {
+    OC_LOG(INFO, ES_ENROLLEE_TAG, "InitProvisioning <<IN>>");
+
+   // Initialize the OC Stack in Server mode
+    if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK)
+    {
+        OC_LOG(ERROR, ES_ENROLLEE_TAG, "OCStack init error");
+        return ES_ERROR;
+    }
+
     if (CreateProvisioningResource() != OC_STACK_OK)
     {
+        OC_LOG(ERROR, ES_ENROLLEE_TAG, "CreateProvisioningResource error");
         return ES_ERROR;
     }
 
     if (CreateNetworkResource() != OC_STACK_OK)
     {
+        OC_LOG(ERROR, ES_ENROLLEE_TAG, "CreateNetworkResource error");
         return ES_ERROR;
     }
 
-    RegisterResourceEventCallBack(EventCallbackInProvisioning);
+    RegisterResourceEventCallBack(ProvisioningCallback);
 
+    OC_LOG(INFO, ES_ENROLLEE_TAG, "InitProvisioning OUT");
     return ES_RESOURCECREATED;
 }
 
+bool validateParam(OCConnectivityType networkType, const char *ssid, const char *passwd,
+              EventCallback cb)
+{
+    if (!ssid || !passwd || !cb)
+    {
+        OC_LOG(ERROR, ES_ENROLLEE_TAG, "validateParam - Invalid parameters");
+        return false;
+    }
+    return true;
+}
+
diff --git a/service/easy-setup/sdk/enrollee/src/onboarding.cpp b/service/easy-setup/sdk/enrollee/src/onboarding.cpp
new file mode 100644 (file)
index 0000000..be7a4ff
--- /dev/null
@@ -0,0 +1,93 @@
+//******************************************************************
+//
+// 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.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+/**
+ * @file
+ *
+ * This file will have methods for on-boarding the Enrollee device. 
+ * This will contain template methods that has will have core business logic & negotiation algorithm on various on-boarding methods.  
+ */
+
+#include "easysetup.h"
+#include "softap.h"
+#include "onboarding.h"
+
+#include "logger.h"
+#include "resourceHandler.h"
+
+/**
+ * @var ES_ENROLLEE_TAG
+ * @brief Logging tag for module name.
+ */
+#define ES_ENROLLEE_TAG "ES_SOFTAP"
+
+/**
+ * It will return true on-boarding type is soft AP
+ */
+bool ESSoftapOnboarding()
+{
+    // TODO: To be changed based on user config. Current version, hardcoded to SoftAp onboarding
+    return true;
+}
+
+/**
+ * It will return true on-boarding type is BLE
+ */
+bool ESBleOnboarding()
+{
+    //BLE onboarding is not supported with current version.
+    return false;
+}
+
+/**
+ * It will do onboarding based on the user's configuration.
+ */
+bool ESOnboard(const char * ssid, const char* passwd, NetworkEventCallback cb)
+{
+    OC_LOG(DEBUG, ES_ENROLLEE_TAG, "ESOnboard IN");
+
+    if (ESSoftapOnboarding())
+    {
+        if (ESSoftapAtEnrollee())
+        {
+            OC_LOG(DEBUG, ES_ENROLLEE_TAG, "Create softap at enrollee");
+            ESCreateSoftap(ssid, passwd, cb);
+        }
+        else
+        {
+            OC_LOG(DEBUG, ES_ENROLLEE_TAG, "Connecting to SoftAp");
+            ConnectToWiFiNetwork(ssid, passwd, cb);
+        }
+        return true;
+    }
+    else if (ESBleOnboarding())
+    {
+        OC_LOG(ERROR, ES_ENROLLEE_TAG, "ESOnboard::Ble onboarding is not supported");
+        // TODO:
+        return false;
+    }
+    else
+    {
+        // TODO:
+        OC_LOG(ERROR, ES_ENROLLEE_TAG, "ESOnboard::Invalid onboarding option");
+        return false;
+    }
+}
+
index f066367..33dbfdb 100755 (executable)
@@ -21,7 +21,6 @@
 #include "resourceHandler.h"
 #include "ocpayload.h"
 
-#include "oic_string.h"
 
 /**
  * @var ES_RH_TAG
 //-----------------------------------------------------------------------------
 
 /**
- * @var g_prov
+ * @var gProvResource
  * @brief Structure for holding the Provisioning status and target information required to connect to the target network
  */
-static ProvResource g_prov;
+static ProvResource gProvResource;
 
 /**
- * @var g_net
+ * @var gNetResource
  * @brief Structure forr holding the Provisioning status of network information
  */
-static NetResource g_net;
+static NetResource gNetResource;
 
 //-----------------------------------------------------------------------------
 // Private internal function prototypes
 //-----------------------------------------------------------------------------
 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,
@@ -62,36 +60,36 @@ OCRepPayload* constructResponse(OCEntityHandlerRequest *ehRequest);
 
 static int g_flag = 0;
 
-ResourceEventCallback g_cbForResEvent = NULL;
+ResourceEventCallback gNetworkInfoProvEventCb = NULL;
 
 void RegisterResourceEventCallBack(ResourceEventCallback cb)
 {
-    g_cbForResEvent = cb;
+    gNetworkInfoProvEventCb = cb;
 }
 
 void GetTargetNetworkInfoFromProvResource(char *name, char *pass)
 {
     if (name != NULL && pass != NULL)
     {
-        sprintf(name, "%s", g_prov.tnn);
-        sprintf(pass, "%s", g_prov.cd);
+        sprintf(name, "%s", gProvResource.tnn);
+        sprintf(pass, "%s", gProvResource.cd);
     }
 }
 
 OCStackResult CreateProvisioningResource()
 {
-    g_prov.ps = 1; // need to provisioning
-    g_prov.tnt = CT_ADAPTER_IP;
-    sprintf(g_prov.tnn, "Unknown");
-    sprintf(g_prov.cd, "Unknown");
-
-    OCStackResult res = OCCreateResource(&g_prov.handle, "oic.r.prov", OC_RSRVD_INTERFACE_DEFAULT,
-            OC_RSRVD_ES_URI_PROV, OCEntityHandlerCb, NULL, OC_DISCOVERABLE | OC_OBSERVABLE);
-
+    gProvResource.ps = 1; // need to do provisioning
+    gProvResource.tnt = CT_ADAPTER_IP;
+    sprintf(gProvResource.tnn, "Unknown");
+    sprintf(gProvResource.cd, "Unknown");
+
+    OCStackResult res = OCCreateResource(&gProvResource.handle, "oic.r.prov", OC_RSRVD_INTERFACE_DEFAULT,
+                                                OC_RSRVD_ES_URI_PROV, OCEntityHandlerCb, NULL,
+                                                OC_DISCOVERABLE | OC_OBSERVABLE);
     OC_LOG_V(INFO, ES_RH_TAG, "Created Prov resource with result: %s", getResult(res));
-
     return res;
 }
+
 #ifdef ESWIFI
 OCStackResult CreateNetworkResource()
 {
@@ -107,17 +105,22 @@ OCStackResult CreateNetworkResource()
         return OC_STACK_ERROR;
     }
 
-    g_net.cnt = (int) netInfo.type;
-    g_net.ant[0] = (int) CT_ADAPTER_IP;
-    sprintf(g_net.ipaddr, "%d.%d.%d.%d", netInfo.ipaddr[0], netInfo.ipaddr[1], netInfo.ipaddr[2],
-            netInfo.ipaddr[3]);
-    sprintf(g_net.cnn, "%s", netInfo.ssid);
+    gNetResource.cnt = (int) netInfo.type;
+    gNetResource.ant[0] = (int) CT_ADAPTER_IP;
 
-    OC_LOG_V(INFO, ES_RH_TAG, "SSID: %s", g_net.cnn);
-    OC_LOG_V(INFO, ES_RH_TAG, "IP Address: %s", g_net.ipaddr);
+    if(netInfo.ipaddr != NULL)
+    {
+        sprintf(gNetResource.ipaddr, "%d.%d.%d.%d", netInfo.ipaddr[0], netInfo.ipaddr[1],
+                                            netInfo.ipaddr[2], netInfo.ipaddr[3]);
+    }
+    sprintf(gNetResource.cnn, "%s", netInfo.ssid);
 
-    OCStackResult res = OCCreateResource(&g_net.handle, "oic.r.net", OC_RSRVD_INTERFACE_DEFAULT,
+    OC_LOG_V(INFO, ES_RH_TAG, "SSID: %s", gNetResource.cnn);
+    OC_LOG_V(INFO, ES_RH_TAG, "IP Address: %s", gNetResource.ipaddr);
+
+    OCStackResult res = OCCreateResource(&gNetResource.handle, "oic.r.net", OC_RSRVD_INTERFACE_DEFAULT,
             OC_RSRVD_ES_URI_NET, OCEntityHandlerCb,NULL, OC_DISCOVERABLE | OC_OBSERVABLE);
+
     OC_LOG_V(INFO, ES_RH_TAG, "Created Net resource with result: %s", getResult(res));
 
     return res;
@@ -154,7 +157,7 @@ OCEntityHandlerResult ProcessGetRequest(OCEntityHandlerRequest *ehRequest,
 OCEntityHandlerResult ProcessPutRequest(OCEntityHandlerRequest *ehRequest,
                                                OCRepPayload** payload)
 {
-
+    OC_LOG(INFO, ES_RH_TAG, "ProcessPutRequest enter");
     OCEntityHandlerResult ehResult = OC_EH_ERROR;
     if (ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION)
     {
@@ -169,50 +172,21 @@ OCEntityHandlerResult ProcessPutRequest(OCEntityHandlerRequest *ehRequest,
         return ehResult;
     }
 
-    //TODO : ES_PS_PROVISIONING_COMPLETED state indicates that already provisioning is completed.
-    // A new request for provisioning means overriding existing network provisioning information.
-    // Metadata to indicate that it is override is needed. The metadata can be a new attribute
-    // should be added to the /oic/prov resource indicating to override the existing network
-    // information.
-    if (g_prov.ps == ES_PS_PROVISIONING_COMPLETED)
-    {
-        OC_LOG(DEBUG, ES_RH_TAG, "Provisioning already completed. "
-                "This a request to override the existing the network provisioning information");
-    }
-
-    // PUT request is appropriate for provisioning information to the enrollee.
-    // When an enrollee receives the put request, the entire resource information should
-    // be overwritten.
-    sprintf(g_prov.tnn, "%s", "");
-    sprintf(g_prov.cd, "%s", "");
-
     char* tnn;
     if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_TNN, &tnn))
     {
-        sprintf(g_prov.tnn, "%s", tnn);
-    }
-    else
-    {
-        OC_LOG (ERROR, ES_RH_TAG, "value is not available");
+        sprintf(gProvResource.tnn, "%s", tnn);
+        OC_LOG(INFO, ES_RH_TAG, "got ssid");
     }
 
-    OC_LOG_V(INFO, ES_RH_TAG, "g_prov.tnn %s", g_prov.tnn);
-
     char* cd;
     if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_CD, &cd))
     {
-        sprintf(g_prov.cd, "%s", cd);
-    }
-    else
-    {
-        OC_LOG (ERROR, ES_RH_TAG, "value is not available");
+        sprintf(gProvResource.cd, "%s", cd);
+        OC_LOG(INFO, ES_RH_TAG, "got password");
     }
-
-    OC_LOG_V(INFO, ES_RH_TAG, "g_prov.cd %s", g_prov.cd);
-
-    g_prov.ps = 2;
-    OC_LOG_V(INFO, ES_RH_TAG, "g_prov.ps %d", g_prov.ps);
-
+    gProvResource.ps = 2;
+    OC_LOG_V(INFO, ES_RH_TAG, "gProvResource.ps %d", gProvResource.ps);
     g_flag = 1;
 
     OCRepPayload *getResp = constructResponse(ehRequest);
@@ -255,7 +229,6 @@ OCEntityHandlerResult ProcessPostRequest(OCEntityHandlerRequest *ehRequest,
         // Triggering
         ehResult = OC_EH_OK;
     }
-
     g_flag = 1;
 
     return ehResult;
@@ -270,32 +243,34 @@ OCRepPayload* constructResponse(OCEntityHandlerRequest *ehRequest)
         return NULL;
     }
 
-    if (ehRequest->resource == g_prov.handle)
+    if (ehRequest->resource == gProvResource.handle)
     {
+        OC_LOG(INFO, ES_RH_TAG, "constructResponse prov res");
         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);
+        OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_PS, gProvResource.ps);
+        OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_TNT, gProvResource.tnt);
+        OCRepPayloadSetPropString(payload, OC_RSRVD_ES_TNN, gProvResource.tnn);
+        OCRepPayloadSetPropString(payload, OC_RSRVD_ES_CD, gProvResource.cd);
     }
-    else if (ehRequest->requestHandle == g_net.handle)
+    else if (ehRequest->requestHandle == gNetResource.handle)
     {
 
         OCRepPayloadSetUri(payload, OC_RSRVD_ES_URI_NET);
-        OCRepPayloadSetPropInt(payload, "ant", g_net.ant[0]);
+        OCRepPayloadSetPropInt(payload, "ant", gNetResource.ant[0]);
     }
     return payload;
 }
 
-// This is the entity handler for the registered resource.
-// This is invoked by OCStack whenever it recevies a request for this resource.
+/**
+ * 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)
 {
     (void) callback;
     OCEntityHandlerResult ehRet = OC_EH_OK;
-    OCEntityHandlerResponse response =
-    { 0 };
+    OCEntityHandlerResponse response = { 0 };
     OCRepPayload* payload = NULL;
     if (entityHandlerRequest && (flag & OC_REQUEST_FLAG))
     {
@@ -308,12 +283,13 @@ OCEntityHandlerResult OCEntityHandlerCb(OCEntityHandlerFlag flag,
         {
             OC_LOG(INFO, ES_RH_TAG, "Received PUT request");
 
-            if (g_prov.handle != NULL && entityHandlerRequest->resource == g_prov.handle)
+            if (gProvResource.handle != NULL && entityHandlerRequest->resource == gProvResource.handle)
             {
                 ehRet = ProcessPutRequest(entityHandlerRequest, &payload);
             }
             else
             {
+                OC_LOG(ERROR, ES_RH_TAG, "Cannot process put");
                 ehRet = OC_EH_ERROR;
             }
         }
@@ -350,7 +326,7 @@ OCEntityHandlerResult OCEntityHandlerCb(OCEntityHandlerFlag flag,
 
     if (g_flag == 1)
     {
-        g_cbForResEvent(ES_RECVTRIGGEROFPROVRES);
+        gNetworkInfoProvEventCb(ES_RECVTRIGGEROFPROVRES);
         g_flag = 0;
     }
 
diff --git a/service/easy-setup/sdk/enrollee/src/softap.cpp b/service/easy-setup/sdk/enrollee/src/softap.cpp
new file mode 100644 (file)
index 0000000..3d0075c
--- /dev/null
@@ -0,0 +1,83 @@
+//      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.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+/**
+ * These are adapter APIs will make caller modules agnostic to platform.
+ */
+
+#include "softapnative.h"
+#include "easysetup.h"
+#include "softap.h"
+#include "networkHandler.h"
+
+void ESCreateSoftapCallback(int result, const char *ip, const char* mac_addr,
+                                                            const char* device_name );
+
+NetworkEventCallback gCallback;
+
+/**
+ * It will return Device which is creating Soft AP ;  Devices are identified by their role.
+ * i.e.Enrollee or Mediator.
+ */
+DeviceRole ESSoftapHost()
+{
+    // TODO: To implement
+    return ENROLLEE;
+}
+
+/**
+ * It will return true if the Soft AP is created at Enrollee device
+ */
+bool ESSoftapAtEnrollee()
+{
+    return ( ESSoftapHost() == ENROLLEE) ? true : false;
+}
+
+/**
+ * It will return true if the Soft AP is created at Mediator device
+ */
+bool ESSoftapAtMediator()
+{
+    return (ESSoftapHost() == MEDIATOR) ? true : false;
+}
+
+
+/**
+ * This API will map result returned from the native to the caller.
+ * Callback API's signature needs to be modified under build switch according
+ * to the underline platform.
+ */
+void ESCreateSoftapCallback(int result, const char *ip, const char* mac_addr,
+                                                                const char* device_name)
+{
+    if(SOFTAP_SUCCESS ==  result) //on Success
+    {
+        gCallback(ES_OK);
+    }
+    else //on Failure
+    {
+        gCallback(ES_ERROR);
+    }
+}
+
+/**
+ * This API will create the softap at enrollee
+ */
+void ESCreateSoftap(const char * ssid, const char* passwd, NetworkEventCallback cb)
+{
+    gCallback = cb;
+
+    // TODO: To be implemented
+    // Create Soft AP through native APIs -- start
+    // native API call by and pass ESCreateSoftapCallback() as callback
+    ESCreateSoftapNative(ssid, passwd,ESCreateSoftapCallback);
+    // Create Soft AP through native APIs -- end
+}
+
index 17bf30e..12cc031 100644 (file)
  ******************************************************************/
 
 #include <wifi.h>
-#include "logger.h"
 #include <unistd.h>
+
 #include "logger.h"
+#include "easysetup.h"
 #include "networkHandler.h"
-#define LOG_TAG "Tizen ES"
 
-const char *g_ssid;
-const char *g_pass;
-char *g_ipaddress;
-bool is_connected = false;
-wifi_ap_h connected_wifi;
-NetworkEventCallback g_cb;
-static void activate_wifi();
+#define LOG_TAG "TIZEN ES"
+
+const char *gSsid = "DLNA_LISMORE1";
+const char *gPass = "dlna@010203";
+char *gIpAddress;
+wifi_ap_h connectedWifi;
+NetworkEventCallback gNetworkEventCb;
+static void ESActivateWifi();
 
 static const char*
 print_state(wifi_connection_state_e state)
@@ -52,10 +53,9 @@ print_state(wifi_connection_state_e state)
 void __wifi_connected_cb(wifi_error_e error_code, void *user_data)
 {
     OC_LOG(INFO,LOG_TAG,"#### __connected ");
-    is_connected = true;
-    wifi_ap_get_ip_address(connected_wifi, WIFI_ADDRESS_FAMILY_IPV4, &g_ipaddress);
-    OC_LOG_V(INFO,LOG_TAG,"#### __connected, Ipaddress=%s", g_ipaddress);
-    g_cb(ES_OK);
+    wifi_ap_get_ip_address(connectedWifi, WIFI_ADDRESS_FAMILY_IPV4, &gIpAddress);
+    OC_LOG_V(INFO,LOG_TAG,"#### __connected, Ipaddress=%s", gIpAddress);
+    gNetworkEventCb(ES_OK);
 
 }
 
@@ -83,11 +83,11 @@ bool __wifi_found_ap_cb(wifi_ap_h ap, void *user_data)
     }
     OC_LOG_V(INFO,LOG_TAG,"#### AP name : %s, state : %s", ap_name, print_state(state));
 
-    if (strcmp(ap_name, g_ssid) == 0)
+    if (strcmp(ap_name, gSsid) == 0)
     {
         OC_LOG(INFO,LOG_TAG,"#### network found");
-        wifi_ap_set_passphrase(ap, g_pass);
-        connected_wifi = ap;
+        wifi_ap_set_passphrase(ap, gPass);
+        connectedWifi = ap;
         error_code = wifi_connect(ap, __wifi_connected_cb, NULL);
         OC_LOG_V(INFO,LOG_TAG,"Code=%d", error_code);
     }
@@ -115,7 +115,7 @@ static void __wifi_activated_cb(wifi_error_e result, void *user_data)
     wifi_scan(__scan_request_cb, NULL);
 
 }
-static void activate_wifi()
+static void ESActivateWifi()
 {
     int error_code;
     error_code = wifi_initialize();
@@ -140,23 +140,17 @@ static void activate_wifi()
 
 static void start()
 {
-
     OC_LOG(INFO, LOG_TAG, "START");
-    activate_wifi();
+    ESActivateWifi();
 }
 
-ESResult ConnectToWiFiNetwork(const char *ssid, const char *pass, NetworkEventCallback cb)
+void ConnectToWiFiNetwork(const char *ssid, const char *pass, NetworkEventCallback cb)
 {
     OC_LOG_V(INFO, LOG_TAG, "ConnectToWiFiNetwork %s %s",ssid,pass);
-    g_pass = pass;
-    g_ssid = ssid;
-    g_cb = cb;
+    gPass = pass;
+    gSsid = ssid;
+    gNetworkEventCb = cb;
     start();
-    //sleep(5000);
-    //if (is_connected)
-    return ES_NETWORKCONNECTED;
-    //else
-    //return ES_NETWORKNOTCONNECTED;
 }
 
 ESResult getCurrentNetworkInfo(OCConnectivityType targetType, NetworkInfo *info)
@@ -164,10 +158,10 @@ ESResult getCurrentNetworkInfo(OCConnectivityType targetType, NetworkInfo *info)
     if (targetType == CT_ADAPTER_IP)
     {
         info->type = CT_ADAPTER_IP;
-        info->ipaddr = g_ipaddress;
-        if (strlen(g_ssid) <= MAXSSIDLEN)
+        info->ipaddr = gIpAddress;
+        if (strlen(gSsid) <= MAXSSIDLEN)
         {
-            strcpy(info->ssid, g_ssid);
+            strcpy(info->ssid, gSsid);
             return ES_OK;
         }
         else
index 39f3153..43c68cd 100644 (file)
@@ -29,6 +29,7 @@
 
 
 #include <string.h>
+#include "easysetup.h"
 #include "logger.h"
 #include "escommon.h"
 
@@ -55,7 +56,7 @@ typedef struct
     //byte mac[6];
 } NetworkInfo;
 
-ESResult ConnectToWiFiNetwork(const char *ssid, const char *pass, NetworkEventCallback);
+void ConnectToWiFiNetwork(const char *ssid, const char *pass, NetworkEventCallback);
 ESResult getCurrentNetworkInfo(OCConnectivityType targetType, NetworkInfo *info);
 
 #endif
diff --git a/service/easy-setup/sdk/enrollee/tizen/wifi/softapnative.cpp b/service/easy-setup/sdk/enrollee/tizen/wifi/softapnative.cpp
new file mode 100644 (file)
index 0000000..d6861a0
--- /dev/null
@@ -0,0 +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
+//
+// 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 "softapnative.h"
+
+/**
+ * This API will create the Soft AP at Enrollee device. 
+ */
+void ESCreateSoftapNative(const char * ssid, const char* passwd, SoftAPCallbackNative cb)
+{
+    const char *ip, *macaddr, *devicename;
+
+    // Soft is created successfully. This callback may be send from other cascaded callbacks
+    cb(SOFTAP_SUCCESS, ip, macaddr, devicename);
+
+    // TODO: Use below code to indicate failed on-boarding / softap creation
+    // Soft creation is failed. This callback may be send from other cascaded callbacks 
+    //cb(SOFTAP_FAILED, nullptr,nullptr,nullptr);
+}
+
diff --git a/service/easy-setup/sdk/enrollee/tizen/wifi/softapnative.h b/service/easy-setup/sdk/enrollee/tizen/wifi/softapnative.h
new file mode 100644 (file)
index 0000000..35c3773
--- /dev/null
@@ -0,0 +1,53 @@
+//******************************************************************
+//
+// 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.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+/**
+ * @file
+ *
+ * This file contains the API declaration for creating & configuration for SoftAP 
+ */
+
+#ifndef EASYSETUP_ENROLLEE_SOFTAP_H__
+#define EASYSETUP_ENROLLEE_SOFTAP_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif // __cplusplus
+
+
+#define SOFTAP_SUCCESS  1
+#define SOFTAP_FAILED   0
+
+
+//This callback signagure may get changed as per the native implementation.
+typedef void (*SoftAPCallbackNative)(int result, const char *ip, const char* mac_addr,
+                                                                        const char*device_name);
+
+void ESCreateSoftapNative(const char * ssid, const char* passwd, SoftAPCallbackNative cb);
+
+#ifdef __cplusplus
+}
+#endif // __cplusplus
+
+
+#endif /* EASYSETUP_ENROLLEE_SOFTAP_H__ */
+
+
+
index 6c6fc22..7584cb2 100755 (executable)
@@ -1,5 +1,5 @@
 Name: iotivity
-Version: 0.9.2
+Version: 1.0.0
 Release: 0
 Summary: IoTivity Base Stack & IoTivity Services
 Group: System Environment/Libraries
@@ -8,7 +8,7 @@ URL: https://www.iotivity.org/
 Source0: %{name}-%{version}.tar.bz2
 Source1001: %{name}.manifest
 Source1002: %{name}-test.manifest
-BuildRequires: gettext, expat-devel
+BuildRequires: gettext
 BuildRequires: python, libcurl-devel
 BuildRequires: scons
 BuildRequires: openssl-devel
@@ -134,6 +134,12 @@ cp resource/csdk/ocrandom/include/*.h %{buildroot}%{_includedir}
 cp -r resource/oc_logger/include/* %{buildroot}%{_includedir}
 cp resource/include/*.h %{buildroot}%{_includedir}
 
+cp resource/c_common/*.h %{buildroot}%{_includedir}
+
+cp service/things-manager/sdk/inc/*.h %{buildroot}%{_includedir}
+cp service/easy-setup/sdk/common/*.h %{buildroot}%{_includedir}
+cp service/easy-setup/sdk/enrollee/api/*.h %{buildroot}%{_includedir}
+
 cp service/things-manager/sdk/inc/*.h %{buildroot}%{_includedir}
 
 %post -p /sbin/ldconfig
@@ -162,6 +168,7 @@ cp service/things-manager/sdk/inc/*.h %{buildroot}%{_includedir}
 %{_libdir}/librcs_common.so
 %{_libdir}/librcs_container.so
 %{_libdir}/librcs_server.so
+%{_libdir}/libESSDKLibrary.so
 
 %files test
 %manifest %{name}-test.manifest