From: Madan Lanka Date: Wed, 10 Jun 2015 06:55:28 +0000 (-0400) Subject: Added initial prototype implementation of Android Multi-PHY Easy Setup X-Git-Tag: 1.2.0+RC1~597^2^2~64 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4c2a6185549f7b8ed68e5a57c9a45b1ceeb05019;p=platform%2Fupstream%2Fiotivity.git Added initial prototype implementation of Android Multi-PHY Easy Setup The source code provides reference prototype implementation of Easy Setup Mediator for Android platform. The implementation can be used to provision any Enrollee over Wi-Fi network. The implementation follows the design mentioned in the following wiki page https://wiki.iotivity.org/multi-phy_easy_setup More information about Multi-PHY easy setup can be found at the following page https://workspace.openinterconnect.org/apps/org/workgroup/oswg/document.php?document_id=2201 Change-Id: I809b5703800e7d95ead5ac08f6c4b2a04b570e91 Signed-off-by: Madan Lanka Reviewed-on: https://gerrit.iotivity.org/gerrit/1211 Reviewed-by: Uze Choi Tested-by: Uze Choi --- diff --git a/resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c b/resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c index a4103eb..bd03d34 100644 --- a/resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c +++ b/resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c @@ -479,7 +479,12 @@ CAResult_t CAIPInitializeNetworkMonitor(const ca_thread_pool_t threadPool) VERIFY_NON_NULL(threadPool, IP_MONITOR_TAG, "threadPool is null"); - CAResult_t ret = CAIPJniInit(); + CAResult_t ret = CA_STATUS_FAILED; + + //TODO: Have to fix the JNI load issue for CA using direct csdk APIs instead OCPlatform Java API + // and remove the EASY_SETUP_CA_INIT +#ifndef EASY_SETUP_CA_INIT + ret = CAIPJniInit(); if (CA_STATUS_OK != ret) { OIC_LOG(ERROR, IP_MONITOR_TAG, "Initialization failed"); @@ -499,6 +504,7 @@ CAResult_t CAIPInitializeNetworkMonitor(const ca_thread_pool_t threadPool) OIC_LOG(ERROR, IP_MONITOR_TAG, "unable to create CaIpInterface instance"); return ret; } +#endif ret = CAInitializeNetworkMonitorMutexes(); diff --git a/service/SConscript b/service/SConscript index 92d7f0e..71d8d2e 100644 --- a/service/SConscript +++ b/service/SConscript @@ -26,22 +26,20 @@ Import('env') target_os = env.get('TARGET_OS') -if target_os not in ['arduino','darwin']: +#if target_os not in ['arduino','darwin']: # Build things manager project - SConscript('things-manager/SConscript') + #SConscript('things-manager/SConscript') # Build soft sensor manager project - SConscript('soft-sensor-manager/SConscript') + #SConscript('soft-sensor-manager/SConscript') # Build protocol plugin project # protocol-plugin use 'inotify', this feature isn't support by MAC OSX - if target_os not in ['darwin', 'ios', 'android']: - SConscript('protocol-plugin/SConscript') + #if target_os not in ['darwin', 'ios', 'android']: + # SConscript('protocol-plugin/SConscript') # Build notification manager project - SConscript('notification-manager/SConscript') -#else: -# SConscript('notification-manager/SampleApp/arduino/SConscript') - -if target_os == 'arduino': - SConscript('easy-setup/SConscript') \ No newline at end of file + #SConscript('notification-manager/SConscript') + +if target_os in ['arduino','android', 'linux']: + SConscript('easy-setup/SConscript') \ No newline at end of file diff --git a/service/easy-setup/SConscript b/service/easy-setup/SConscript index 945b93c..b434f0a 100644 --- a/service/easy-setup/SConscript +++ b/service/easy-setup/SConscript @@ -21,15 +21,20 @@ ## # easy-setup project build script ## + import os + Import('env') -# Add third party libraries -lib_env = env.Clone() -#SConscript(env.get('SRC_DIR') + '/service/third_party_libs.scons', exports = 'lib_env') +env.AppendUnique(CPPDEFINES = ['EASY_SETUP_CA_INIT']) -easy_setup_env = lib_env.Clone() +easy_setup_env = env.Clone() target_os = env.get('TARGET_OS') + +lib_env = env.Clone() +if target_os == 'android': + SConscript(env.get('SRC_DIR') + '/service/third_party_libs.scons', exports = 'lib_env') + ###################################################################### # Build flags ###################################################################### @@ -40,12 +45,21 @@ if target_os not in ['windows', 'winrt']: if target_os not in ['android', 'arduino']: easy_setup_env.AppendUnique(CXXFLAGS = ['-pthread']) -if target_os == 'android': - easy_setup_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions']) - easy_setup_env.PrependUnique(LIBS = ['oc', 'octbstack', 'gnustl_shared']) +if target_os in ['android', 'linux']: + easy_setup_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')]) + easy_setup_env.AppendUnique(RPATH = [env.get('BUILD_DIR')]) + easy_setup_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions']) + if target_os not in ['linux', 'arduino']: + easy_setup_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'connectivity_abstraction', 'gnustl_shared']) + else: + easy_setup_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'pthread', 'connectivity_abstraction']) + + if not env.get('RELEASE'): + easy_setup_env.AppendUnique(LIBS = ['log']) + if target_os == 'arduino': - easy_setup_env.AppendUnique(CPPPATH = [ + easy_setup_env.AppendUnique(CPPPATH = [ '../../resource/oc_logger/include', '../../resource/csdk/logger/include', '../../resource/csdk/stack/include', @@ -53,26 +67,42 @@ if target_os == 'arduino': 'sdk/arduino/wifi/inc', 'sdk/arduino/wifi/src' ]) +if target_os in ['android','linux']: + easy_setup_env.PrependUnique(CPPPATH = [ + env.get('SRC_DIR') + '/resource/csdk/ocmalloc/include', + env.get('SRC_DIR') + '/resource/csdk/connectivity/common/inc', + env.get('SRC_DIR') + '/resource/csdk/connectivity/api', + env.get('SRC_DIR') + '/resource/csdk/stack/include', + env.get('SRC_DIR') + '/resource/csdk/logger/include', + env.get('SRC_DIR') + '/resource/csdk/security/include', + env.get('SRC_DIR') + '/extlibs/cjson' + ]) + ###################################################################### # Source files and Targets ###################################################################### -#if target_os == 'arduino': - es_src = env.Glob('sdk/src/*.cpp') - es_src += env.Glob('sdk/arduino/wifi/src/*.cpp') - es_sdk_static = easy_setup_env.StaticLibrary('ESSDKLibrary', es_src) - easy_setup_env.InstallTarget(es_sdk_static, 'libESSDK') +if target_os == 'arduino': + es_sdk_static = easy_setup_env.StaticLibrary('ESSDKLibrary', + ['sdk/src/easysetup.cpp', + 'sdk/src/resourceHandler.cpp', + 'sdk/arduino/wifi/src/networkHandler.cpp']) + easy_setup_env.InstallTarget(es_sdk_static, 'libESSDK') + if target_os == 'android': - es_src = env.Glob('sdk/src/*.cpp') - es_src += env.Glob('sdk/android/wifi/src/*.cpp') - es_sdk_static = easy_setup_env.StaticLibrary('ESLib', es_src) - es_sdk_shared = easy_setup_env.SharedLibrary('ESLib', es_src) - easy_setup_env.InstallTarget([es_sdk_static, es_sdk_shared], 'libESSDK') - -# Build JNI layer -#if target_os == 'android': -# SConscript(os.path.join('sdk', 'java', 'jni', 'SConscript')) + es_sdk_shared = easy_setup_env.SharedLibrary('libESSDK', + ['sdk/src/easysetupmgr.cpp', + 'sdk/src/camutex_pthreads.c', + 'sdk/src/provisioninghandler.cpp']) + easy_setup_env.InstallTarget(es_sdk_shared, 'libESSDK') + +if target_os == 'linux': + es_sdk_shared = easy_setup_env.SharedLibrary('ESSDKLibrary', + ['sdk/src/easysetupmgr.cpp', + 'sdk/src/camutex_pthreads.c', + 'sdk/src/provisioninghandler.cpp']) + easy_setup_env.InstallTarget(es_sdk_shared, 'libESSDK') #Go to build sample apps SConscript('sampleapp/SConscript') diff --git a/service/easy-setup/sampleapp/SConscript b/service/easy-setup/sampleapp/SConscript index a00282c..13c1c3a 100644 --- a/service/easy-setup/sampleapp/SConscript +++ b/service/easy-setup/sampleapp/SConscript @@ -26,7 +26,7 @@ Import('env') # Add third party libraries lib_env = env.Clone() -#SConscript(env.get('SRC_DIR') + '/service/third_party_libs.scons', 'lib_env') + sample_env = lib_env.Clone() target_os = env.get('TARGET_OS') @@ -41,3 +41,6 @@ if target_os == 'arduino' : # Build linux sample app SConscript('arduino/thinserver/SConscript') +if target_os == 'linux' : + # Build linux sample app + SConscript('linux/richclient/SConscript') diff --git a/service/easy-setup/sampleapp/android/.gitignore b/service/easy-setup/sampleapp/android/.gitignore new file mode 100644 index 0000000..6451fc5 --- /dev/null +++ b/service/easy-setup/sampleapp/android/.gitignore @@ -0,0 +1,50 @@ +#built application files +*.apk +*.ap_ + +# files for the dex VM +*.dex + +# Java class files +*.class + +# generated files +bin/ +gen/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Windows thumbnail db +Thumbs.db + +# OSX files +.DS_Store + +# Eclipse project files +.classpath +.project + +#Android Studio & Gradle +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build/* +/base/build/* +/base/obj/* +/base/libs/* +/sample/* + +#Some older projects +/*/out +/*/*/build +/*/*/production +*.iws +*.ipr +*~ +*.swp \ No newline at end of file diff --git a/service/easy-setup/sampleapp/android/EasySetup/.classpath b/service/easy-setup/sampleapp/android/EasySetup/.classpath new file mode 100644 index 0000000..c30d6df --- /dev/null +++ b/service/easy-setup/sampleapp/android/EasySetup/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/service/easy-setup/sampleapp/android/EasySetup/.project b/service/easy-setup/sampleapp/android/EasySetup/.project new file mode 100644 index 0000000..5e22258 --- /dev/null +++ b/service/easy-setup/sampleapp/android/EasySetup/.project @@ -0,0 +1,33 @@ + + + EasySetup + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/service/easy-setup/sampleapp/android/EasySetup/AndroidManifest.xml b/service/easy-setup/sampleapp/android/EasySetup/AndroidManifest.xml new file mode 100644 index 0000000..bce0044 --- /dev/null +++ b/service/easy-setup/sampleapp/android/EasySetup/AndroidManifest.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/service/easy-setup/sampleapp/android/EasySetup/project.properties b/service/easy-setup/sampleapp/android/EasySetup/project.properties new file mode 100644 index 0000000..4630921 --- /dev/null +++ b/service/easy-setup/sampleapp/android/EasySetup/project.properties @@ -0,0 +1,15 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system edit +# "ant.properties", and override values to adapt the script to your +# project structure. +# +# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): +#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt + +# Project target. +target=android-21 +android.library.reference.1=../../../sdk/android/EasySetupCore diff --git a/service/easy-setup/sampleapp/android/EasySetup/res/drawable-hdpi/background.png b/service/easy-setup/sampleapp/android/EasySetup/res/drawable-hdpi/background.png new file mode 100644 index 0000000..561cce8 Binary files /dev/null and b/service/easy-setup/sampleapp/android/EasySetup/res/drawable-hdpi/background.png differ diff --git a/service/easy-setup/sampleapp/android/EasySetup/res/drawable-hdpi/cancel.png b/service/easy-setup/sampleapp/android/EasySetup/res/drawable-hdpi/cancel.png new file mode 100644 index 0000000..da342e5 Binary files /dev/null and b/service/easy-setup/sampleapp/android/EasySetup/res/drawable-hdpi/cancel.png differ diff --git a/service/easy-setup/sampleapp/android/EasySetup/res/drawable-hdpi/ic_launcher.png b/service/easy-setup/sampleapp/android/EasySetup/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 0000000..288b665 Binary files /dev/null and b/service/easy-setup/sampleapp/android/EasySetup/res/drawable-hdpi/ic_launcher.png differ diff --git a/service/easy-setup/sampleapp/android/EasySetup/res/drawable-hdpi/icon.png b/service/easy-setup/sampleapp/android/EasySetup/res/drawable-hdpi/icon.png new file mode 100644 index 0000000..24a8af2 Binary files /dev/null and b/service/easy-setup/sampleapp/android/EasySetup/res/drawable-hdpi/icon.png differ diff --git a/service/easy-setup/sampleapp/android/EasySetup/res/layout/activity_main.xml b/service/easy-setup/sampleapp/android/EasySetup/res/layout/activity_main.xml new file mode 100644 index 0000000..2f7737e --- /dev/null +++ b/service/easy-setup/sampleapp/android/EasySetup/res/layout/activity_main.xml @@ -0,0 +1,71 @@ + + +