From ac8ffa40df98b2238be21c4bc3703cfa45e7871d Mon Sep 17 00:00:00 2001 From: Tim Kourt Date: Fri, 15 May 2015 13:16:29 -0700 Subject: [PATCH] Android Base API merge to master Introduced support for automated Jenkins build for android Change-Id: Ide54185a0e75ee8c75b3616beb5f935810220203 Signed-off-by: Erich Keane Signed-off-by: Rahul Rahul Signed-off-by: Tim Kourt Reviewed-on: https://gerrit.iotivity.org/gerrit/894 Tested-by: jenkins-iotivity --- .gitignore | 4 + SConstruct | 4 + android/Base/app/build.gradle | 60 - android/Base/app/jni/ocheaderoption-jni.cpp | 44 - android/Base/app/jni/ocplatform-jni.cpp | 124 -- android/Base/app/jni/ocrepresentation-jni.cpp | 101 -- android/Base/app/jni/ocresource-jni.cpp | 445 ------ android/Base/app/jni/ocstack-jni.cpp | 134 -- android/Base/app/jni/ocstack-jni.h | 101 -- android/Base/app/jni/platformcfg-jni.cpp | 80 - .../java/org/iotivity/base/ApplicationTest.java | 33 - android/Base/app/src/main/AndroidManifest.xml | 11 - .../org/iotivity/base/AbstractDeleteCallback.java | 25 - .../org/iotivity/base/AbstractFindCallback.java | 26 - .../org/iotivity/base/AbstractGetCallback.java | 27 - .../org/iotivity/base/AbstractObserveCallback.java | 27 - .../org/iotivity/base/AbstractPostCallback.java | 27 - .../org/iotivity/base/AbstractPutCallback.java | 7 - .../iotivity/base/AbstractSubscriberCallback.java | 25 - .../main/java/org/iotivity/base/EntityHandler.java | 25 - .../java/org/iotivity/base/OCHeaderOption.java | 36 - .../main/java/org/iotivity/base/OCPlatform.java | 32 - .../java/org/iotivity/base/OCRepresentation.java | 49 - .../main/java/org/iotivity/base/OCResource.java | 60 - .../java/org/iotivity/base/OCResourceRequest.java | 24 - .../java/org/iotivity/base/OCResourceResponse.java | 24 - .../main/java/org/iotivity/base/OCStackResult.java | 54 - .../main/java/org/iotivity/base/ObserveType.java | 26 - .../java/org/iotivity/base/PlatformConfig.java | 68 - android/Base/app/src/main/res/values/strings.xml | 3 - android/Base/gradle.properties | 18 - android/Base/settings.gradle | 1 - android/BuildInstructionsForAndroidAPI.txt | 45 + android/SimpleClient/app/build.gradle | 40 - android/SimpleClient/app/proguard-rules.pro | 17 - .../org/iotivity/simpleclient/ApplicationTest.java | 33 - .../org/iotivity/simpleclient/FoundResource.java | 72 - .../main/java/org/iotivity/simpleclient/OnGet.java | 58 - .../java/org/iotivity/simpleclient/OnObserve.java | 75 - .../java/org/iotivity/simpleclient/OnPost.java | 77 - .../java/org/iotivity/simpleclient/OnPost2.java | 75 - .../main/java/org/iotivity/simpleclient/OnPut.java | 59 - .../org/iotivity/simpleclient/SimpleClient.java | 151 -- .../org/iotivity/simpleclient/SimpleToast.java | 44 - .../src/main/res/layout/activity_simple_client.xml | 16 - .../app/src/main/res/menu/simple_client.xml | 8 - android/SimpleClient/build.gradle | 19 - android/SimpleClient/gradle.properties | 18 - android/SimpleClient/settings.gradle | 1 - android/android_api/.gitignore | 10 + android/android_api/SConscript | 48 + android/android_api/android_api.iml | 19 + android/android_api/base/.gitignore | 5 + android/android_api/base/base.iml | 91 ++ android/android_api/base/build.gradle | 115 ++ android/android_api/base/jni/Android.mk | 78 + android/android_api/base/jni/Application.mk | 2 + android/android_api/base/jni/JniCaInterface.c | 60 + android/android_api/base/jni/JniCaInterface.h | 44 + android/android_api/base/jni/JniEntityHandler.cpp | 111 ++ android/android_api/base/jni/JniEntityHandler.h | 39 + .../android_api/base/jni/JniListenerManager.cpp | 103 ++ android/android_api/base/jni/JniListenerManager.h | 125 ++ android/android_api/base/jni/JniOcPlatform.cpp | 1591 ++++++++++++++++++++ android/android_api/base/jni/JniOcPlatform.h | 264 ++++ .../android_api/base/jni/JniOcPresenceHandle.cpp | 73 + android/android_api/base/jni/JniOcPresenceHandle.h | 65 + .../android_api/base/jni/JniOcRepresentation.cpp | 1040 +++++++++++++ android/android_api/base/jni/JniOcRepresentation.h | 769 ++++++++++ .../android_api/base/jni/JniOcRequestHandle.cpp | 63 + android/android_api/base/jni/JniOcRequestHandle.h | 58 + android/android_api/base/jni/JniOcResource.cpp | 1520 +++++++++++++++++++ android/android_api/base/jni/JniOcResource.h | 359 +++++ .../android_api/base/jni/JniOcResourceHandle.cpp | 66 + android/android_api/base/jni/JniOcResourceHandle.h | 56 + .../base/jni/JniOcResourceIdentifier.cpp | 89 ++ .../android_api/base/jni/JniOcResourceIdentifier.h | 65 + .../android_api/base/jni/JniOcResourceRequest.cpp | 321 ++++ .../android_api/base/jni/JniOcResourceRequest.h | 158 ++ .../android_api/base/jni/JniOcResourceResponse.cpp | 320 ++++ .../android_api/base/jni/JniOcResourceResponse.h | 144 ++ android/android_api/base/jni/JniOcStack.cpp | 449 ++++++ android/android_api/base/jni/JniOcStack.h | 169 +++ .../android_api/base/jni/JniOnDeleteListener.cpp | 121 ++ android/android_api/base/jni/JniOnDeleteListener.h | 45 + .../base/jni/JniOnDeviceInfoListener.cpp | 113 ++ .../android_api/base/jni/JniOnDeviceInfoListener.h | 42 + android/android_api/base/jni/JniOnGetListener.cpp | 144 ++ android/android_api/base/jni/JniOnGetListener.h | 43 + .../android_api/base/jni/JniOnObserveListener.cpp | 147 ++ .../android_api/base/jni/JniOnObserveListener.h | 44 + android/android_api/base/jni/JniOnPostListener.cpp | 143 ++ android/android_api/base/jni/JniOnPostListener.h | 45 + .../android_api/base/jni/JniOnPresenceListener.cpp | 133 ++ .../android_api/base/jni/JniOnPresenceListener.h | 43 + android/android_api/base/jni/JniOnPutListener.cpp | 144 ++ android/android_api/base/jni/JniOnPutListener.h | 45 + .../base/jni/JniOnResourceFoundListener.cpp | 118 ++ .../base/jni/JniOnResourceFoundListener.h | 43 + android/android_api/base/jni/JniUtils.cpp | 193 +++ android/android_api/base/jni/JniUtils.h | 230 +++ .../app => android_api/base}/proguard-rules.pro | 34 +- .../base/src/androidTest/AndroidManifest.xml | 35 + .../org/iotivity/base/OcRepresentationTest.java | 593 ++++++++ .../java/org/iotivity/base/SmokeTest.java | 1563 +++++++++++++++++++ .../android_api/base/src/main/AndroidManifest.xml | 35 + .../org/iotivity/base/EntityHandlerResult.java | 42 + .../src/main/java/org/iotivity/base/ErrorCode.java | 95 ++ .../src/main/java/org/iotivity/base/ModeType.java | 39 + .../java/org/iotivity/base/ObservationInfo.java | 55 + .../main/java/org/iotivity/base/ObserveAction.java | 47 + .../main/java/org/iotivity/base/ObserveType.java | 38 + .../java/org/iotivity/base/OcConnectivityType.java | 52 + .../main/java/org/iotivity/base/OcDeviceInfo.java | 177 +++ .../main/java/org/iotivity/base/OcException.java | 58 + .../java/org/iotivity/base/OcHeaderOption.java | 70 + .../main/java/org/iotivity/base/OcPlatform.java | 777 ++++++++++ .../java/org/iotivity/base/OcPlatformStatus.java | 39 + .../java/org/iotivity/base/OcPresenceHandle.java | 41 + .../java/org/iotivity/base/OcPresenceStatus.java | 50 + .../java/org/iotivity/base/OcRepresentation.java | 358 +++++ .../java/org/iotivity/base/OcRequestHandle.java | 41 + .../main/java/org/iotivity/base/OcResource.java | 575 +++++++ .../java/org/iotivity/base/OcResourceHandle.java | 41 + .../org/iotivity/base/OcResourceIdentifier.java | 51 + .../java/org/iotivity/base/OcResourceRequest.java | 135 ++ .../java/org/iotivity/base/OcResourceResponse.java | 139 ++ .../java/org/iotivity/base/PlatformConfig.java | 88 ++ .../java/org/iotivity/base/QualityOfService.java | 42 + .../java/org/iotivity/base/RequestHandlerFlag.java | 61 + .../main/java/org/iotivity/base/RequestType.java | 48 + .../java/org/iotivity/base/ResourceProperty.java | 41 + .../main/java/org/iotivity/base/ServiceType.java | 38 + .../src/main/java/org/iotivity/ca/CaInterface.java | 34 + .../main/java/org/iotivity/ca/CaIpInterface.java | 70 + .../main/java/org/iotivity/ca/CaWiFiInterface.java | 72 + android/android_api/build.gradle | 41 + android/android_api/gradle.properties | 40 + .../android_api/gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 49896 bytes .../gradle/wrapper/gradle-wrapper.properties | 28 + android/{Base => android_api}/gradlew | 328 ++-- android/{SimpleClient => android_api}/gradlew.bat | 0 android/android_api/settings.gradle | 23 + android/{Base => examples}/build.gradle | 38 +- android/examples/examples.iml | 19 + android/examples/fridgeclient/.gitignore | 1 + android/examples/fridgeclient/build.gradle | 26 + android/examples/fridgeclient/fridgeclient.iml | 95 ++ .../fridgeclient/src/main/AndroidManifest.xml | 22 + .../base/examples/fridgeclient/FridgeClient.java | 362 +++++ .../examples/fridgeclient/StringConstants.java | 33 + .../src/main/res/drawable-hdpi/ic_launcher.png | Bin .../src/main/res/drawable-mdpi/ic_launcher.png | Bin .../src/main/res/drawable-xhdpi/ic_launcher.png | Bin .../src/main/res/drawable-xxhdpi/ic_launcher.png | Bin .../src/main/res/layout/activity_fridge_client.xml | 18 + .../src/main/res/menu/menu_fridge_client.xml | 6 + .../src/main/res/values-w820dp/dimens.xml | 12 +- .../fridgeclient}/src/main/res/values/dimens.xml | 10 +- .../fridgeclient}/src/main/res/values/strings.xml | 16 +- .../fridgeclient}/src/main/res/values/styles.xml | 16 +- android/examples/fridgeserver/.gitignore | 1 + android/examples/fridgeserver/build.gradle | 26 + android/examples/fridgeserver/fridgeserver.iml | 95 ++ .../fridgeserver/src/main/AndroidManifest.xml | 24 + .../base/examples/fridgeserver/DeviceResource.java | 189 +++ .../base/examples/fridgeserver/DoorResource.java | 178 +++ .../base/examples/fridgeserver/FridgeServer.java | 145 ++ .../base/examples/fridgeserver/LightResource.java | 164 ++ .../base/examples/fridgeserver/Refrigerator.java | 57 + .../base/examples/fridgeserver/Resource.java | 41 + .../examples/fridgeserver/StringConstants.java | 37 + .../src/main/res/drawable-hdpi/ic_launcher.png | Bin .../src/main/res/drawable-mdpi/ic_launcher.png | Bin .../src/main/res/drawable-xhdpi/ic_launcher.png | Bin .../src/main/res/drawable-xxhdpi/ic_launcher.png | Bin .../src/main/res/layout/activity_fridge_server.xml | 18 + .../src/main/res/menu/menu_fridge_server.xml | 6 + .../src/main/res/values-w820dp/dimens.xml | 6 + .../fridgeserver/src/main/res/values/dimens.xml | 5 + .../fridgeserver/src/main/res/values/strings.xml | 8 + .../fridgeserver}/src/main/res/values/styles.xml | 16 +- android/examples/gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 49896 bytes .../gradle/wrapper/gradle-wrapper.properties | 6 + android/{SimpleClient => examples}/gradlew | 328 ++-- android/{Base => examples}/gradlew.bat | 0 android/examples/message/.gitignore | 3 + android/examples/message/build.gradle | 24 + android/examples/message/message.iml | 94 ++ .../examples/message/src/main/AndroidManifest.xml | 9 + .../org/examples/message/IMessageLogger.java | 27 + android/examples/settings.gradle | 1 + android/examples/simpleclient/.gitignore | 1 + android/examples/simpleclient/build.gradle | 25 + android/examples/simpleclient/simpleclient.iml | 95 ++ .../simpleclient}/src/main/AndroidManifest.xml | 47 +- .../iotivity/base/examples/simpleclient/Light.java | 65 + .../base/examples/simpleclient/SimpleClient.java | 443 ++++++ .../examples/simpleclient/StringConstants.java | 17 + .../src/main/res/drawable-hdpi/ic_launcher.png | Bin 0 -> 9397 bytes .../src/main/res/drawable-mdpi/ic_launcher.png | Bin 0 -> 5237 bytes .../src/main/res/drawable-xhdpi/ic_launcher.png | Bin 0 -> 14383 bytes .../src/main/res/drawable-xxhdpi/ic_launcher.png | Bin 0 -> 19388 bytes .../src/main/res/layout/activity_main.xml | 18 + .../simpleclient/src/main/res/menu/menu_main.xml | 6 + .../src/main/res/values-w820dp/dimens.xml | 6 + .../simpleclient/src/main/res/values/dimens.xml | 5 + .../simpleclient/src/main/res/values/strings.xml | 8 + .../simpleclient/src/main/res/values/styles.xml | 8 + android/examples/simpleserver/.gitignore | 1 + android/examples/simpleserver/build.gradle | 27 + android/examples/simpleserver/simpleserver.iml | 95 ++ .../simpleserver/src/main/AndroidManifest.xml | 24 + .../base/examples/simpleserver/LightRepThread.java | 86 ++ .../base/examples/simpleserver/LightResource.java | 308 ++++ .../base/examples/simpleserver/SimpleServer.java | 145 ++ .../examples/simpleserver/StringConstants.java | 21 + .../src/main/res/drawable-hdpi/ic_launcher.png | Bin 0 -> 9397 bytes .../src/main/res/drawable-mdpi/ic_launcher.png | Bin 0 -> 5237 bytes .../src/main/res/drawable-xhdpi/ic_launcher.png | Bin 0 -> 14383 bytes .../src/main/res/drawable-xxhdpi/ic_launcher.png | Bin 0 -> 19388 bytes .../src/main/res/layout/activity_main.xml | 31 + .../simpleserver/src/main/res/menu/menu_main.xml | 6 + .../src/main/res/values-w820dp/dimens.xml | 6 + .../simpleserver/src/main/res/values/dimens.xml | 5 + .../simpleserver/src/main/res/values/strings.xml | 8 + .../simpleserver/src/main/res/values/styles.xml | 8 + auto_build.sh | 27 +- build_common/android/SConscript | 64 +- extlibs/android/gradle/SConscript | 29 + extlibs/android/ndk/SConscript | 37 + extlibs/android/sdk/SConscript | 58 + extlibs/boost/SConscript | 2 +- resource/SConscript | 2 +- resource/csdk/connectivity/build/How_To_Build.txt | 17 +- resource/csdk/connectivity/build/SConscript | 1 - resource/csdk/connectivity/build/android/Makefile | 19 + .../csdk/connectivity/build/android/README.txt | 0 .../csdk/connectivity/build/android/SConscript | 0 .../csdk/connectivity/build/android/jni/Android.mk | 0 .../connectivity/build/android/jni/Application.mk | 0 .../build/arduino/Arduino_Setup_README.txt | 0 resource/csdk/connectivity/build/arduino/Makefile | 75 + .../csdk/connectivity/build/arduino/README.txt | 0 .../csdk/connectivity/build/arduino/SConscript | 0 .../csdk/connectivity/build/arduino/arduino.scons | 1 + .../build/arduino/arduinomega.properties | 0 resource/csdk/connectivity/build/arduino/build.sh | 0 .../connectivity/build/arduino/local.properties | 0 resource/csdk/connectivity/build/common.mk | 60 + resource/csdk/connectivity/build/linux/SConscript | 0 resource/csdk/connectivity/build/tizen/Makefile | 65 + resource/csdk/connectivity/build/tizen/SConscript | 241 +++ resource/csdk/connectivity/build/tizen/SConstruct | 0 .../connectivity/build/tizen/com.oic.ca.manifest | 0 .../csdk/connectivity/build/tizen/com.oic.ca.pc | 0 resource/csdk/connectivity/build/tizen/gbsbuild.sh | 30 +- .../build/tizen/packaging/com.oic.ca.spec | 9 +- .../csdk/connectivity/build/tizen/scons/SConscript | 9 +- .../csdk/connectivity/lib/libcoap-4.1.1/SConscript | 5 +- .../android/sample_service/jni/Application.mk | 2 +- .../src/org/iotivity/ca/CaIpInterface.java | 70 + .../src/ip_adapter/android/caipnwmonitor.c | 31 +- .../android/org_iotivity_ca_CaIpInterface.h | 29 + .../android/org_iotivity_jar_caipinterface.h | 30 - .../csdk/stack/samples/linux/secure/SConscript | 2 +- resource/examples/SConscript | 2 +- resource/include/OCRepresentation.h | 23 + resource/oc_logger/SConscript | 2 +- resource/oc_logger/examples/SConscript | 2 +- resource/src/SConscript | 2 +- 271 files changed, 20612 insertions(+), 3023 deletions(-) delete mode 100644 android/Base/app/build.gradle delete mode 100644 android/Base/app/jni/ocheaderoption-jni.cpp delete mode 100644 android/Base/app/jni/ocplatform-jni.cpp delete mode 100644 android/Base/app/jni/ocrepresentation-jni.cpp delete mode 100644 android/Base/app/jni/ocresource-jni.cpp delete mode 100644 android/Base/app/jni/ocstack-jni.cpp delete mode 100644 android/Base/app/jni/ocstack-jni.h delete mode 100644 android/Base/app/jni/platformcfg-jni.cpp delete mode 100644 android/Base/app/src/androidTest/java/org/iotivity/base/ApplicationTest.java delete mode 100644 android/Base/app/src/main/AndroidManifest.xml delete mode 100644 android/Base/app/src/main/java/org/iotivity/base/AbstractDeleteCallback.java delete mode 100644 android/Base/app/src/main/java/org/iotivity/base/AbstractFindCallback.java delete mode 100644 android/Base/app/src/main/java/org/iotivity/base/AbstractGetCallback.java delete mode 100644 android/Base/app/src/main/java/org/iotivity/base/AbstractObserveCallback.java delete mode 100644 android/Base/app/src/main/java/org/iotivity/base/AbstractPostCallback.java delete mode 100644 android/Base/app/src/main/java/org/iotivity/base/AbstractPutCallback.java delete mode 100644 android/Base/app/src/main/java/org/iotivity/base/AbstractSubscriberCallback.java delete mode 100644 android/Base/app/src/main/java/org/iotivity/base/EntityHandler.java delete mode 100644 android/Base/app/src/main/java/org/iotivity/base/OCHeaderOption.java delete mode 100644 android/Base/app/src/main/java/org/iotivity/base/OCPlatform.java delete mode 100644 android/Base/app/src/main/java/org/iotivity/base/OCRepresentation.java delete mode 100644 android/Base/app/src/main/java/org/iotivity/base/OCResource.java delete mode 100644 android/Base/app/src/main/java/org/iotivity/base/OCResourceRequest.java delete mode 100644 android/Base/app/src/main/java/org/iotivity/base/OCResourceResponse.java delete mode 100644 android/Base/app/src/main/java/org/iotivity/base/OCStackResult.java delete mode 100644 android/Base/app/src/main/java/org/iotivity/base/ObserveType.java delete mode 100644 android/Base/app/src/main/java/org/iotivity/base/PlatformConfig.java delete mode 100644 android/Base/app/src/main/res/values/strings.xml delete mode 100644 android/Base/gradle.properties delete mode 100644 android/Base/settings.gradle create mode 100644 android/BuildInstructionsForAndroidAPI.txt delete mode 100644 android/SimpleClient/app/build.gradle delete mode 100644 android/SimpleClient/app/proguard-rules.pro delete mode 100644 android/SimpleClient/app/src/androidTest/java/org/iotivity/simpleclient/ApplicationTest.java delete mode 100644 android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/FoundResource.java delete mode 100644 android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/OnGet.java delete mode 100644 android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/OnObserve.java delete mode 100644 android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/OnPost.java delete mode 100644 android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/OnPost2.java delete mode 100644 android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/OnPut.java delete mode 100644 android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/SimpleClient.java delete mode 100644 android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/SimpleToast.java delete mode 100644 android/SimpleClient/app/src/main/res/layout/activity_simple_client.xml delete mode 100644 android/SimpleClient/app/src/main/res/menu/simple_client.xml delete mode 100644 android/SimpleClient/build.gradle delete mode 100644 android/SimpleClient/gradle.properties delete mode 100644 android/SimpleClient/settings.gradle create mode 100755 android/android_api/.gitignore create mode 100755 android/android_api/SConscript create mode 100755 android/android_api/android_api.iml create mode 100755 android/android_api/base/.gitignore create mode 100755 android/android_api/base/base.iml create mode 100755 android/android_api/base/build.gradle create mode 100755 android/android_api/base/jni/Android.mk create mode 100755 android/android_api/base/jni/Application.mk create mode 100644 android/android_api/base/jni/JniCaInterface.c create mode 100644 android/android_api/base/jni/JniCaInterface.h create mode 100644 android/android_api/base/jni/JniEntityHandler.cpp create mode 100644 android/android_api/base/jni/JniEntityHandler.h create mode 100644 android/android_api/base/jni/JniListenerManager.cpp create mode 100644 android/android_api/base/jni/JniListenerManager.h create mode 100644 android/android_api/base/jni/JniOcPlatform.cpp create mode 100644 android/android_api/base/jni/JniOcPlatform.h create mode 100644 android/android_api/base/jni/JniOcPresenceHandle.cpp create mode 100644 android/android_api/base/jni/JniOcPresenceHandle.h create mode 100644 android/android_api/base/jni/JniOcRepresentation.cpp create mode 100644 android/android_api/base/jni/JniOcRepresentation.h create mode 100644 android/android_api/base/jni/JniOcRequestHandle.cpp create mode 100644 android/android_api/base/jni/JniOcRequestHandle.h create mode 100644 android/android_api/base/jni/JniOcResource.cpp create mode 100644 android/android_api/base/jni/JniOcResource.h create mode 100644 android/android_api/base/jni/JniOcResourceHandle.cpp create mode 100644 android/android_api/base/jni/JniOcResourceHandle.h create mode 100644 android/android_api/base/jni/JniOcResourceIdentifier.cpp create mode 100644 android/android_api/base/jni/JniOcResourceIdentifier.h create mode 100644 android/android_api/base/jni/JniOcResourceRequest.cpp create mode 100644 android/android_api/base/jni/JniOcResourceRequest.h create mode 100644 android/android_api/base/jni/JniOcResourceResponse.cpp create mode 100644 android/android_api/base/jni/JniOcResourceResponse.h create mode 100644 android/android_api/base/jni/JniOcStack.cpp create mode 100644 android/android_api/base/jni/JniOcStack.h create mode 100644 android/android_api/base/jni/JniOnDeleteListener.cpp create mode 100644 android/android_api/base/jni/JniOnDeleteListener.h create mode 100644 android/android_api/base/jni/JniOnDeviceInfoListener.cpp create mode 100644 android/android_api/base/jni/JniOnDeviceInfoListener.h create mode 100644 android/android_api/base/jni/JniOnGetListener.cpp create mode 100644 android/android_api/base/jni/JniOnGetListener.h create mode 100644 android/android_api/base/jni/JniOnObserveListener.cpp create mode 100644 android/android_api/base/jni/JniOnObserveListener.h create mode 100644 android/android_api/base/jni/JniOnPostListener.cpp create mode 100644 android/android_api/base/jni/JniOnPostListener.h create mode 100644 android/android_api/base/jni/JniOnPresenceListener.cpp create mode 100644 android/android_api/base/jni/JniOnPresenceListener.h create mode 100644 android/android_api/base/jni/JniOnPutListener.cpp create mode 100644 android/android_api/base/jni/JniOnPutListener.h create mode 100644 android/android_api/base/jni/JniOnResourceFoundListener.cpp create mode 100644 android/android_api/base/jni/JniOnResourceFoundListener.h create mode 100644 android/android_api/base/jni/JniUtils.cpp create mode 100644 android/android_api/base/jni/JniUtils.h rename android/{Base/app => android_api/base}/proguard-rules.pro (86%) mode change 100644 => 100755 create mode 100755 android/android_api/base/src/androidTest/AndroidManifest.xml create mode 100755 android/android_api/base/src/androidTest/java/org/iotivity/base/OcRepresentationTest.java create mode 100755 android/android_api/base/src/androidTest/java/org/iotivity/base/SmokeTest.java create mode 100755 android/android_api/base/src/main/AndroidManifest.xml create mode 100755 android/android_api/base/src/main/java/org/iotivity/base/EntityHandlerResult.java create mode 100755 android/android_api/base/src/main/java/org/iotivity/base/ErrorCode.java create mode 100755 android/android_api/base/src/main/java/org/iotivity/base/ModeType.java create mode 100755 android/android_api/base/src/main/java/org/iotivity/base/ObservationInfo.java create mode 100755 android/android_api/base/src/main/java/org/iotivity/base/ObserveAction.java create mode 100755 android/android_api/base/src/main/java/org/iotivity/base/ObserveType.java create mode 100755 android/android_api/base/src/main/java/org/iotivity/base/OcConnectivityType.java create mode 100755 android/android_api/base/src/main/java/org/iotivity/base/OcDeviceInfo.java create mode 100755 android/android_api/base/src/main/java/org/iotivity/base/OcException.java create mode 100755 android/android_api/base/src/main/java/org/iotivity/base/OcHeaderOption.java create mode 100755 android/android_api/base/src/main/java/org/iotivity/base/OcPlatform.java create mode 100755 android/android_api/base/src/main/java/org/iotivity/base/OcPlatformStatus.java create mode 100755 android/android_api/base/src/main/java/org/iotivity/base/OcPresenceHandle.java create mode 100755 android/android_api/base/src/main/java/org/iotivity/base/OcPresenceStatus.java create mode 100755 android/android_api/base/src/main/java/org/iotivity/base/OcRepresentation.java create mode 100755 android/android_api/base/src/main/java/org/iotivity/base/OcRequestHandle.java create mode 100755 android/android_api/base/src/main/java/org/iotivity/base/OcResource.java create mode 100755 android/android_api/base/src/main/java/org/iotivity/base/OcResourceHandle.java create mode 100755 android/android_api/base/src/main/java/org/iotivity/base/OcResourceIdentifier.java create mode 100755 android/android_api/base/src/main/java/org/iotivity/base/OcResourceRequest.java create mode 100755 android/android_api/base/src/main/java/org/iotivity/base/OcResourceResponse.java create mode 100755 android/android_api/base/src/main/java/org/iotivity/base/PlatformConfig.java create mode 100755 android/android_api/base/src/main/java/org/iotivity/base/QualityOfService.java create mode 100755 android/android_api/base/src/main/java/org/iotivity/base/RequestHandlerFlag.java create mode 100755 android/android_api/base/src/main/java/org/iotivity/base/RequestType.java create mode 100755 android/android_api/base/src/main/java/org/iotivity/base/ResourceProperty.java create mode 100755 android/android_api/base/src/main/java/org/iotivity/base/ServiceType.java create mode 100755 android/android_api/base/src/main/java/org/iotivity/ca/CaInterface.java create mode 100755 android/android_api/base/src/main/java/org/iotivity/ca/CaIpInterface.java create mode 100755 android/android_api/base/src/main/java/org/iotivity/ca/CaWiFiInterface.java create mode 100755 android/android_api/build.gradle create mode 100755 android/android_api/gradle.properties create mode 100755 android/android_api/gradle/wrapper/gradle-wrapper.jar create mode 100755 android/android_api/gradle/wrapper/gradle-wrapper.properties rename android/{Base => android_api}/gradlew (96%) rename android/{SimpleClient => android_api}/gradlew.bat (100%) mode change 100644 => 100755 create mode 100755 android/android_api/settings.gradle rename android/{Base => examples}/build.gradle (83%) mode change 100644 => 100755 create mode 100755 android/examples/examples.iml create mode 100755 android/examples/fridgeclient/.gitignore create mode 100755 android/examples/fridgeclient/build.gradle create mode 100755 android/examples/fridgeclient/fridgeclient.iml create mode 100755 android/examples/fridgeclient/src/main/AndroidManifest.xml create mode 100755 android/examples/fridgeclient/src/main/java/org/iotivity/base/examples/fridgeclient/FridgeClient.java create mode 100755 android/examples/fridgeclient/src/main/java/org/iotivity/base/examples/fridgeclient/StringConstants.java rename android/{SimpleClient/app => examples/fridgeclient}/src/main/res/drawable-hdpi/ic_launcher.png (100%) mode change 100644 => 100755 rename android/{SimpleClient/app => examples/fridgeclient}/src/main/res/drawable-mdpi/ic_launcher.png (100%) mode change 100644 => 100755 rename android/{SimpleClient/app => examples/fridgeclient}/src/main/res/drawable-xhdpi/ic_launcher.png (100%) mode change 100644 => 100755 rename android/{SimpleClient/app => examples/fridgeclient}/src/main/res/drawable-xxhdpi/ic_launcher.png (100%) mode change 100644 => 100755 create mode 100755 android/examples/fridgeclient/src/main/res/layout/activity_fridge_client.xml create mode 100755 android/examples/fridgeclient/src/main/res/menu/menu_fridge_client.xml rename android/{SimpleClient/app => examples/fridgeclient}/src/main/res/values-w820dp/dimens.xml (98%) mode change 100644 => 100755 rename android/{SimpleClient/app => examples/fridgeclient}/src/main/res/values/dimens.xml (97%) mode change 100644 => 100755 rename android/{SimpleClient/app => examples/fridgeclient}/src/main/res/values/strings.xml (74%) mode change 100644 => 100755 rename android/{Base/app => examples/fridgeclient}/src/main/res/values/styles.xml (59%) mode change 100644 => 100755 create mode 100755 android/examples/fridgeserver/.gitignore create mode 100755 android/examples/fridgeserver/build.gradle create mode 100755 android/examples/fridgeserver/fridgeserver.iml create mode 100755 android/examples/fridgeserver/src/main/AndroidManifest.xml create mode 100755 android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DeviceResource.java create mode 100755 android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DoorResource.java create mode 100755 android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/FridgeServer.java create mode 100755 android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/LightResource.java create mode 100755 android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Refrigerator.java create mode 100755 android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Resource.java create mode 100755 android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/StringConstants.java rename android/{Base/app => examples/fridgeserver}/src/main/res/drawable-hdpi/ic_launcher.png (100%) mode change 100644 => 100755 rename android/{Base/app => examples/fridgeserver}/src/main/res/drawable-mdpi/ic_launcher.png (100%) mode change 100644 => 100755 rename android/{Base/app => examples/fridgeserver}/src/main/res/drawable-xhdpi/ic_launcher.png (100%) mode change 100644 => 100755 rename android/{Base/app => examples/fridgeserver}/src/main/res/drawable-xxhdpi/ic_launcher.png (100%) mode change 100644 => 100755 create mode 100755 android/examples/fridgeserver/src/main/res/layout/activity_fridge_server.xml create mode 100755 android/examples/fridgeserver/src/main/res/menu/menu_fridge_server.xml create mode 100755 android/examples/fridgeserver/src/main/res/values-w820dp/dimens.xml create mode 100755 android/examples/fridgeserver/src/main/res/values/dimens.xml create mode 100755 android/examples/fridgeserver/src/main/res/values/strings.xml rename android/{SimpleClient/app => examples/fridgeserver}/src/main/res/values/styles.xml (59%) mode change 100644 => 100755 create mode 100755 android/examples/gradle/wrapper/gradle-wrapper.jar create mode 100755 android/examples/gradle/wrapper/gradle-wrapper.properties rename android/{SimpleClient => examples}/gradlew (96%) rename android/{Base => examples}/gradlew.bat (100%) mode change 100644 => 100755 create mode 100755 android/examples/message/.gitignore create mode 100755 android/examples/message/build.gradle create mode 100755 android/examples/message/message.iml create mode 100755 android/examples/message/src/main/AndroidManifest.xml create mode 100755 android/examples/message/src/main/java/base/iotivity/org/examples/message/IMessageLogger.java create mode 100755 android/examples/settings.gradle create mode 100755 android/examples/simpleclient/.gitignore create mode 100755 android/examples/simpleclient/build.gradle create mode 100755 android/examples/simpleclient/simpleclient.iml rename android/{SimpleClient/app => examples/simpleclient}/src/main/AndroidManifest.xml (76%) mode change 100644 => 100755 create mode 100755 android/examples/simpleclient/src/main/java/org/iotivity/base/examples/simpleclient/Light.java create mode 100755 android/examples/simpleclient/src/main/java/org/iotivity/base/examples/simpleclient/SimpleClient.java create mode 100755 android/examples/simpleclient/src/main/java/org/iotivity/base/examples/simpleclient/StringConstants.java create mode 100755 android/examples/simpleclient/src/main/res/drawable-hdpi/ic_launcher.png create mode 100755 android/examples/simpleclient/src/main/res/drawable-mdpi/ic_launcher.png create mode 100755 android/examples/simpleclient/src/main/res/drawable-xhdpi/ic_launcher.png create mode 100755 android/examples/simpleclient/src/main/res/drawable-xxhdpi/ic_launcher.png create mode 100755 android/examples/simpleclient/src/main/res/layout/activity_main.xml create mode 100755 android/examples/simpleclient/src/main/res/menu/menu_main.xml create mode 100755 android/examples/simpleclient/src/main/res/values-w820dp/dimens.xml create mode 100755 android/examples/simpleclient/src/main/res/values/dimens.xml create mode 100755 android/examples/simpleclient/src/main/res/values/strings.xml create mode 100755 android/examples/simpleclient/src/main/res/values/styles.xml create mode 100755 android/examples/simpleserver/.gitignore create mode 100755 android/examples/simpleserver/build.gradle create mode 100755 android/examples/simpleserver/simpleserver.iml create mode 100755 android/examples/simpleserver/src/main/AndroidManifest.xml create mode 100755 android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/LightRepThread.java create mode 100755 android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/LightResource.java create mode 100755 android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/SimpleServer.java create mode 100755 android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/StringConstants.java create mode 100755 android/examples/simpleserver/src/main/res/drawable-hdpi/ic_launcher.png create mode 100755 android/examples/simpleserver/src/main/res/drawable-mdpi/ic_launcher.png create mode 100755 android/examples/simpleserver/src/main/res/drawable-xhdpi/ic_launcher.png create mode 100755 android/examples/simpleserver/src/main/res/drawable-xxhdpi/ic_launcher.png create mode 100755 android/examples/simpleserver/src/main/res/layout/activity_main.xml create mode 100755 android/examples/simpleserver/src/main/res/menu/menu_main.xml create mode 100755 android/examples/simpleserver/src/main/res/values-w820dp/dimens.xml create mode 100755 android/examples/simpleserver/src/main/res/values/dimens.xml create mode 100755 android/examples/simpleserver/src/main/res/values/strings.xml create mode 100755 android/examples/simpleserver/src/main/res/values/styles.xml create mode 100644 extlibs/android/gradle/SConscript create mode 100644 extlibs/android/ndk/SConscript create mode 100644 extlibs/android/sdk/SConscript mode change 100644 => 100755 resource/csdk/connectivity/build/How_To_Build.txt mode change 100644 => 100755 resource/csdk/connectivity/build/SConscript create mode 100755 resource/csdk/connectivity/build/android/Makefile mode change 100644 => 100755 resource/csdk/connectivity/build/android/README.txt mode change 100644 => 100755 resource/csdk/connectivity/build/android/SConscript mode change 100644 => 100755 resource/csdk/connectivity/build/android/jni/Android.mk mode change 100644 => 100755 resource/csdk/connectivity/build/android/jni/Application.mk mode change 100644 => 100755 resource/csdk/connectivity/build/arduino/Arduino_Setup_README.txt create mode 100755 resource/csdk/connectivity/build/arduino/Makefile mode change 100644 => 100755 resource/csdk/connectivity/build/arduino/README.txt mode change 100644 => 100755 resource/csdk/connectivity/build/arduino/SConscript mode change 100644 => 100755 resource/csdk/connectivity/build/arduino/arduino.scons mode change 100644 => 100755 resource/csdk/connectivity/build/arduino/arduinomega.properties mode change 100644 => 100755 resource/csdk/connectivity/build/arduino/build.sh mode change 100644 => 100755 resource/csdk/connectivity/build/arduino/local.properties create mode 100755 resource/csdk/connectivity/build/common.mk mode change 100644 => 100755 resource/csdk/connectivity/build/linux/SConscript create mode 100755 resource/csdk/connectivity/build/tizen/Makefile create mode 100755 resource/csdk/connectivity/build/tizen/SConscript mode change 100644 => 100755 resource/csdk/connectivity/build/tizen/SConstruct mode change 100644 => 100755 resource/csdk/connectivity/build/tizen/com.oic.ca.manifest mode change 100644 => 100755 resource/csdk/connectivity/build/tizen/com.oic.ca.pc mode change 100644 => 100755 resource/csdk/connectivity/build/tizen/gbsbuild.sh mode change 100644 => 100755 resource/csdk/connectivity/build/tizen/packaging/com.oic.ca.spec mode change 100644 => 100755 resource/csdk/connectivity/build/tizen/scons/SConscript create mode 100644 resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/ca/CaIpInterface.java create mode 100644 resource/csdk/connectivity/src/ip_adapter/android/org_iotivity_ca_CaIpInterface.h delete mode 100644 resource/csdk/connectivity/src/ip_adapter/android/org_iotivity_jar_caipinterface.h diff --git a/.gitignore b/.gitignore index d242a39..e34025b 100644 --- a/.gitignore +++ b/.gitignore @@ -84,6 +84,10 @@ extlibs/master.zip extlibs/cereal/cereal extlibs/expat/expat* extlibs/cereal +extlibs/android/gradle/gradle-2.2.1 +extlibs/android/ndk/android-ndk-r10d +extlibs/android/sdk/android-sdk_r24.2 +extlibs/boost/boost_1_58_0 *.tgz *.zip extlibs/arduino/arduino-1.5.8 diff --git a/SConstruct b/SConstruct index 2ea9acb..eeaa86a 100644 --- a/SConstruct +++ b/SConstruct @@ -33,6 +33,10 @@ Import('env') target_os = env.get('TARGET_OS') if target_os == 'arduino': SConscript('arduino.scons') + +if target_os == 'android': + SConscript('android/android_api/SConscript') + # By default, src_dir is current dir, the build_dir is: # ./out//// # diff --git a/android/Base/app/build.gradle b/android/Base/app/build.gradle deleted file mode 100644 index 31d66bb..0000000 --- a/android/Base/app/build.gradle +++ /dev/null @@ -1,60 +0,0 @@ -apply plugin: 'com.android.library' - -android { - compileSdkVersion 19 - buildToolsVersion "19.1.0" - - defaultConfig { - applicationId "org.iotivity.base" - minSdkVersion 19 - targetSdkVersion 19 - versionCode 1 - versionName "1.0" - } - buildTypes { - release { - runProguard false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } -} - -dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) -} - - -////////////// -// NDK Support -////////////// -// If using this, Android studio will fail run the following to set the environment variable for android studio: -// launchctl setenv ANDROID_NDK_HOME /Users/boos_patrick/Development/Android/android-ndk-r8e -// otherwise remove the dependsOn part and run ./gradlew buildNative from the command line -task copyNativeLibs(type: Copy, dependsOn: 'buildNative') { - dependsOn 'buildNative' - from(new File('libs')) { include '**/*.so' } - into new File(buildDir, 'native-libs') -} - -tasks.withType(Compile) { compileTask -> compileTask.dependsOn copyNativeLibs } - -clean.dependsOn 'cleanCopyNativeLibs' - -tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask -> - pkgTask.jniFolders = new HashSet() - pkgTask.jniFolders.add(new File(buildDir, 'native-libs')) -} - -task buildNative(type: Exec) { - if (System.env.ANDROID_NDK_HOME != null) { - def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build') - commandLine ndkBuild - } else { - doLast { - println '##################' - println 'Skipping NDK build' - println 'Reason: ANDROID_NDK_HOME not set.' - println '##################' - } - } -} diff --git a/android/Base/app/jni/ocheaderoption-jni.cpp b/android/Base/app/jni/ocheaderoption-jni.cpp deleted file mode 100644 index 7dcd320..0000000 --- a/android/Base/app/jni/ocheaderoption-jni.cpp +++ /dev/null @@ -1,44 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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 "ocstack-jni.h" - -static const char* TAG = "OCHEADEROPTION-JNI"; - -JNIEXPORT jint JNICALL getOptionID(JNIEnv *env, jobject jobj) -{ - OC::HeaderOption::OCHeaderOption *option = getHandle(env, jobj); - return option->getOptionID(); -} - -JNIEXPORT jstring JNICALL getOptionData(JNIEnv *env, jobject jobj) -{ - OC::HeaderOption::OCHeaderOption *option = getHandle(env, jobj); - std::string data = option->getOptionData(); - return env->NewStringUTF(data.c_str()); -} - -JNIEXPORT jlong JNICALL OCHeaderOptionConstructor(JNIEnv *env, jobject jobj, jint joption, jstring jdata) -{ - OC::HeaderOption::OCHeaderOption *option = new OC::HeaderOption::OCHeaderOption(joption, env->GetStringUTFChars(jdata, 0)); - jlong instptr = reinterpret_cast(option); - return instptr; -} - diff --git a/android/Base/app/jni/ocplatform-jni.cpp b/android/Base/app/jni/ocplatform-jni.cpp deleted file mode 100644 index a69ac2d..0000000 --- a/android/Base/app/jni/ocplatform-jni.cpp +++ /dev/null @@ -1,124 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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 "ocstack-jni.h" - -static const char* TAG = "OCPLATFORM-JNI"; - -JNIEXPORT void JNICALL configure(JNIEnv *env, jobject obj, jobject jcfg) -{ - OC::PlatformConfig *cfg = getHandle(env, jcfg); - - __android_log_print(ANDROID_LOG_INFO, TAG, "service : %d\n", (int) cfg->serviceType); - __android_log_print(ANDROID_LOG_INFO, TAG, "mode : %d\n", (int) cfg->mode); - __android_log_print(ANDROID_LOG_INFO, TAG, "IP : %s\n", (cfg->ipAddress).c_str()); - __android_log_print(ANDROID_LOG_INFO, TAG, "port : %d\n", cfg->port); - __android_log_print(ANDROID_LOG_INFO, TAG, "QOS : %d\n", (int) cfg->QoS); - - OC::OCPlatform::Configure(*cfg); -} - - -JNIEXPORT jint JNICALL findResource(JNIEnv* env, jobject obj, jstring jhost, jstring juri, jobject found) -{ - string host = env->GetStringUTFChars(jhost,0); - string uri = env->GetStringUTFChars(juri,0); - - JNICallBackContext *callbackContext; - string key = uri + "/FIND"; - std:map::iterator iter = gJNICallBackContextList.find(key); - if(iter == gJNICallBackContextList.end()) { - gJNICallBackContextList[key] = new JNICallBackContext(env->NewGlobalRef(found)); - callbackContext = gJNICallBackContextList[key]; - __android_log_print(ANDROID_LOG_INFO, TAG, "Adding %s to gJNICallBackContextList", key.c_str()); - } - else - callbackContext = iter->second; - - __android_log_print(ANDROID_LOG_ERROR, TAG, "Calling oic base findresource()\n"); - try { - OC::OCPlatform::findResource(host, uri, - [callbackContext](std::shared_ptr resource) - { - JNIEnv * env; - - // Attach to JavaVM - // double check it's all ok - int getEnvStat = g_JavaVM->GetEnv((void **)&env, JNI_VERSION_1_6); - if (getEnvStat == JNI_EDETACHED) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "GetEnv: not attached"); - if (g_JavaVM->AttachCurrentThread(&env, NULL) != 0) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "Failed to attach"); - } - else - __android_log_print(ANDROID_LOG_INFO, TAG, "Attached OK"); - } else if (getEnvStat == JNI_OK) { - // - } else if (getEnvStat == JNI_EVERSION) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "GetEnv: version not supported"); - } - - // save the C++ resource ptr now - jmethodID resource_constructor = env->GetMethodID(g_ocresource_clazz, "", "(J)V"); - - callbackContext->m_resource = resource; - jobject jresource = env->NewObject(g_ocresource_clazz, resource_constructor, \ - (jlong) reinterpret_cast(&callbackContext->m_resource)); - - if(jresource == NULL) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "cannot create OCResource class"); - return; - } - - jclass clazz = env->GetObjectClass(callbackContext->m_callBackFunction); - if (clazz == NULL) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "Failed to find class"); - } - - // Find Callback function - jmethodID mid = env->GetMethodID(clazz, "Callback", \ - "(Lorg/iotivity/base/OCResource;)V"); - if(mid == NULL) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "FoundResource.Callback() is not defined in JAVA"); - return; - } - - __android_log_print(ANDROID_LOG_INFO, TAG, "calling JAVA FindCallback"); - try { - env->CallVoidMethod(callbackContext->m_callBackFunction, mid, jresource); - } catch(OC::OCException& e) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "callbackContext() exception : %s", e.reason(e).c_str()); - } - - __android_log_print(ANDROID_LOG_INFO, TAG, "fineResourceCB detach"); - env->DeleteLocalRef(jresource); - g_JavaVM->DetachCurrentThread(); - - } - ); - } - catch(OC::OCException& e) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "FindCB() exception : %s", e.reason(e).c_str()); - } - __android_log_print(ANDROID_LOG_ERROR, TAG, "Called oic base findresource()\n"); - - return 0; -} - diff --git a/android/Base/app/jni/ocrepresentation-jni.cpp b/android/Base/app/jni/ocrepresentation-jni.cpp deleted file mode 100644 index d7c894d..0000000 --- a/android/Base/app/jni/ocrepresentation-jni.cpp +++ /dev/null @@ -1,101 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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 "ocstack-jni.h" - -static const char* TAG = "OCREPRESENTATION-JNI"; - -JNIEXPORT jlong JNICALL OCRepresentationConstructor(JNIEnv *env, jobject jobj) -{ - OC::OCRepresentation *rep = new OC::OCRepresentation(); - jlong instptr = reinterpret_cast(rep); - return instptr; -} - -JNIEXPORT jstring JNICALL getUri(JNIEnv *env, jobject jobj) -{ - OC::OCRepresentation *rep = getHandle(env, jobj); - string uri = rep->getUri(); - __android_log_print(ANDROID_LOG_INFO, TAG, "getUri() URI : %s", uri.c_str()); - return env->NewStringUTF(uri.c_str()); -} - -JNIEXPORT jint JNICALL getValueInt(JNIEnv *env, jobject jobj, jstring jstr) -{ - OC::OCRepresentation *rep = getHandle(env, jobj); - string str = env->GetStringUTFChars(jstr,0); - int val; - rep->getValue(str, val); - __android_log_print(ANDROID_LOG_INFO, TAG, "getValueInt() : %d", val); - return((jint) val); -} - - -JNIEXPORT jboolean JNICALL getValueBool(JNIEnv *env, jobject jobj, jstring jstr) -{ - OC::OCRepresentation *rep = getHandle(env, jobj); - string str = env->GetStringUTFChars(jstr,0); - bool val; - rep->getValue(str, val); - __android_log_print(ANDROID_LOG_INFO, TAG, "getValueBool() : %d", val); - return((jboolean) val); -} - -JNIEXPORT jstring JNICALL getValueString(JNIEnv *env, jobject jobj, jstring jstr) -{ - OC::OCRepresentation *rep = getHandle(env, jobj); - string str = env->GetStringUTFChars(jstr,0); - string get_val; - rep->getValue(str, get_val); - - __android_log_print(ANDROID_LOG_INFO, TAG, "getValueString() : %s", get_val.c_str()); - return env->NewStringUTF(get_val.c_str()); -} - -JNIEXPORT void JNICALL setValueInt(JNIEnv *env, jobject jobj, jstring jstr, jint jval) -{ - OC::OCRepresentation *rep = getHandle(env, jobj); - string str = env->GetStringUTFChars(jstr,0); - rep->setValue(str, jval); -} - -JNIEXPORT void JNICALL setValueBool(JNIEnv *env, jobject jobj, jstring jstr, jboolean jval) -{ - OC::OCRepresentation *rep = getHandle(env, jobj); - string str = env->GetStringUTFChars(jstr,0); - rep->setValue(str, (bool) jval); -} - -JNIEXPORT void JNICALL setValueString(JNIEnv *env, jobject jobj, jstring jstr, jstring jval) -{ - OC::OCRepresentation *rep = getHandle(env, jobj); - string str = env->GetStringUTFChars(jstr,0); - string val = env->GetStringUTFChars(jval,0); - - rep->setValue(str, val); -} - -JNIEXPORT jboolean JNICALL hasAttribute(JNIEnv *env, jobject jobj, jstring jstr) -{ - OC::OCRepresentation *rep = getHandle(env, jobj); - string str = env->GetStringUTFChars(jstr,0); - - return rep->hasAttribute(str); -} diff --git a/android/Base/app/jni/ocresource-jni.cpp b/android/Base/app/jni/ocresource-jni.cpp deleted file mode 100644 index 95c2c39..0000000 --- a/android/Base/app/jni/ocresource-jni.cpp +++ /dev/null @@ -1,445 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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 "ocstack-jni.h" - -static const char* TAG = "OCRESOURCE-JNI"; - -JNIEXPORT jobject JNICALL jniOicGet(JNIEnv *env, jobject jobj, jobject jattributeHandler) -{ - - std::shared_ptr *resource = getHandle>(env, jobj); - __android_log_print(ANDROID_LOG_ERROR, TAG, "get() resource = %p\n", resource); - - JNICallBackContext *callbackContext; - string key = (*resource)->uri() + "/GET"; - std:map::iterator iter = gJNICallBackContextList.find(key); - if(iter == gJNICallBackContextList.end()) { - gJNICallBackContextList[key] = new JNICallBackContext(*resource, env->NewGlobalRef(jattributeHandler)); - callbackContext = gJNICallBackContextList[key]; - __android_log_print(ANDROID_LOG_INFO, TAG, "Adding %s to gJNICallBackContextList", key.c_str()); - } - else { - iter->second->m_callBackFunction = env->NewGlobalRef(jattributeHandler); - callbackContext = iter->second; - } - - OC::QueryParamsMap test; - __android_log_print(ANDROID_LOG_ERROR, TAG, "calling oic base get()\n"); - - (*resource)->get(test, - [callbackContext](const OC::HeaderOptions& headerOptions, const OC::OCRepresentation& rep, const int eCode) - { - JNIEnv * env; - - // Attach to JavaVM - // double check it's all ok - int getEnvStat = g_JavaVM->GetEnv((void **)&env, JNI_VERSION_1_6); - if (getEnvStat == JNI_EDETACHED) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "GetEnv: not attached"); - if (g_JavaVM->AttachCurrentThread(&env, NULL) != 0) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "Failed to attach"); - } - else - __android_log_print(ANDROID_LOG_INFO, TAG, "Attached OK"); - } else if (getEnvStat == JNI_OK) { - // - } else if (getEnvStat == JNI_EVERSION) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "GetEnv: version not supported"); - } - - // save C++ ocheaderoption ptr now - jmethodID option_constructor = env->GetMethodID(g_ocheaderoption_clazz, "", "(J)V"); - int size = headerOptions.size(); - jobjectArray joptions = env->NewObjectArray(size, g_ocheaderoption_clazz, 0); - for (int n=0; nNewObject(g_ocheaderoption_clazz, option_constructor, \ - (jlong) reinterpret_cast(&headerOptions[n])); - - __android_log_print(ANDROID_LOG_ERROR, TAG, "jelem : %llu", (jlong) reinterpret_cast(&headerOptions[n])); - - env->SetObjectArrayElement(joptions, n, jelem); - env->DeleteLocalRef(jelem); - } - - // save C++ ocrepresentation ptr now - jmethodID representation_constructor = env->GetMethodID(g_ocrepresentation_clazz, "", "(J)V"); - jobject jrepresentation = env->NewObject(g_ocrepresentation_clazz, representation_constructor, \ - (jlong) reinterpret_cast(&rep)); - if(jrepresentation == NULL) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "cannot create OCRepresentation class"); - return; - } - - jclass cb_clazz = env->GetObjectClass(callbackContext->m_callBackFunction); - if (cb_clazz == NULL) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "Failed to find class"); - } - - // Find Callback function - jmethodID cb_mid = env->GetMethodID(cb_clazz, "Callback", \ - "([Lorg/iotivity/base/OCHeaderOption;Lorg/iotivity/base/OCRepresentation;I)V"); - if(cb_mid == NULL) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "onGet.Callback() is not defined in JAVA"); - return; - } - - __android_log_print(ANDROID_LOG_INFO, TAG, "calling JAVA GetCallback"); - env->CallVoidMethod(callbackContext->m_callBackFunction, cb_mid, joptions, jrepresentation, eCode); - - __android_log_print(ANDROID_LOG_INFO, TAG, "getCB detach"); - g_JavaVM->DetachCurrentThread(); - - } - ); - return NULL; - -} - -JNIEXPORT jobject JNICALL jniOicPut(JNIEnv *env, jobject jobj, jobject jocrepresentation, jobject jattributeHandler) -{ - std::shared_ptr *resource = getHandle>(env, jobj); - __android_log_print(ANDROID_LOG_ERROR, TAG, "put1() resource = %p\n", resource); - - JNICallBackContext *callbackContext; - string key = (*resource)->uri() + "/PUT"; - std:map::iterator iter = gJNICallBackContextList.find(key); - if(iter == gJNICallBackContextList.end()) { - gJNICallBackContextList[key] = new JNICallBackContext(*resource, env->NewGlobalRef(jattributeHandler)); - callbackContext = gJNICallBackContextList[key]; - __android_log_print(ANDROID_LOG_INFO, TAG, "Adding %s to gJNICallBackContextList", key.c_str()); - } - else { - iter->second->m_callBackFunction = env->NewGlobalRef(jattributeHandler); - callbackContext = iter->second; - } - - OC::OCRepresentation *rep = getHandle(env, jocrepresentation); - OC::QueryParamsMap test; - __android_log_print(ANDROID_LOG_ERROR, TAG, "calling oic base put()\n"); - - (*resource)->put(*rep, test, - [callbackContext](const OC::HeaderOptions& headerOptions, const OC::OCRepresentation& rep, const int eCode) - { - JNIEnv * env; - - // Attach to JavaVM - // double check it's all ok - int getEnvStat = g_JavaVM->GetEnv((void **)&env, JNI_VERSION_1_6); - if (getEnvStat == JNI_EDETACHED) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "GetEnv: not attached"); - if (g_JavaVM->AttachCurrentThread(&env, NULL) != 0) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "Failed to attach"); - } - else - __android_log_print(ANDROID_LOG_INFO, TAG, "Attached OK"); - } else if (getEnvStat == JNI_OK) { - // - } else if (getEnvStat == JNI_EVERSION) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "GetEnv: version not supported"); - } - - // save C++ ocheaderoption ptr now - jmethodID option_constructor = env->GetMethodID(g_ocheaderoption_clazz, "", "(J)V"); - int size = headerOptions.size(); - jobjectArray joptions = env->NewObjectArray(size, g_ocheaderoption_clazz, 0); - for (int n=0; nNewObject(g_ocheaderoption_clazz, option_constructor, \ - (jlong) reinterpret_cast(&headerOptions[n])); - - __android_log_print(ANDROID_LOG_ERROR, TAG, "jelem : %llu", (jlong) reinterpret_cast(&headerOptions[n])); - - env->SetObjectArrayElement(joptions, n, jelem); - env->DeleteLocalRef(jelem); - } - - // save C++ ocrepresentation ptr now - jmethodID representation_constructor = env->GetMethodID(g_ocrepresentation_clazz, "", "(J)V"); - jobject jrepresentation = env->NewObject(g_ocrepresentation_clazz, representation_constructor, \ - (jlong) reinterpret_cast(&rep)); - if(jrepresentation == NULL) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "cannot create OCRepresentation class"); - return; - } - - jclass cb_clazz = env->GetObjectClass(callbackContext->m_callBackFunction); - if (cb_clazz == NULL) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "Failed to find class"); - } - - // Find Callback function - jmethodID cb_mid = env->GetMethodID(cb_clazz, "Callback", \ - "([Lorg/iotivity/base/OCHeaderOption;Lorg/iotivity/base/OCRepresentation;I)V"); - if(cb_mid == NULL) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "onPut.Callback() is not defined in JAVA"); - return; - } - - __android_log_print(ANDROID_LOG_INFO, TAG, "calling JAVA PutCallback"); - env->CallVoidMethod(callbackContext->m_callBackFunction, cb_mid, joptions, jrepresentation, eCode); - - __android_log_print(ANDROID_LOG_INFO, TAG, "putCB detach"); - g_JavaVM->DetachCurrentThread(); - } - ); - return NULL; -} - -JNIEXPORT jobject JNICALL jniOicPost(JNIEnv *env, jobject jobj, jobject jocrepresentation, jobject jattributeHandler) -{ - std::shared_ptr *resource = getHandle>(env, jobj); - __android_log_print(ANDROID_LOG_ERROR, TAG, "post1() resource = %p\n", resource); - - JNICallBackContext *callbackContext; - string key = (*resource)->uri() + "/POST"; - std:map::iterator iter = gJNICallBackContextList.find(key); - if(iter == gJNICallBackContextList.end()) { - gJNICallBackContextList[key] = new JNICallBackContext(*resource, env->NewGlobalRef(jattributeHandler)); - callbackContext = gJNICallBackContextList[key]; - __android_log_print(ANDROID_LOG_INFO, TAG, "Adding %s to gJNICallBackContextList", key.c_str()); - } - else { - iter->second->m_callBackFunction = env->NewGlobalRef(jattributeHandler); - callbackContext = iter->second; - } - - OC::OCRepresentation *rep = getHandle(env, jocrepresentation); - OC::QueryParamsMap test; - __android_log_print(ANDROID_LOG_ERROR, TAG, "calling oic base post()\n"); - - (*resource)->post(*rep, test, - [callbackContext](const OC::HeaderOptions& headerOptions, const OC::OCRepresentation& rep, const int eCode) - { - JNIEnv * env; - - // Attach to JavaVM - // double check it's all ok - int getEnvStat = g_JavaVM->GetEnv((void **)&env, JNI_VERSION_1_6); - if (getEnvStat == JNI_EDETACHED) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "GetEnv: not attached"); - if (g_JavaVM->AttachCurrentThread(&env, NULL) != 0) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "Failed to attach"); - } - else - __android_log_print(ANDROID_LOG_INFO, TAG, "Attached OK"); - } else if (getEnvStat == JNI_OK) { - // - } else if (getEnvStat == JNI_EVERSION) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "GetEnv: version not supported"); - } - - // save C++ ocheaderoption ptr now - jmethodID option_constructor = env->GetMethodID(g_ocheaderoption_clazz, "", "(J)V"); - int size = headerOptions.size(); - jobjectArray joptions = env->NewObjectArray(size, g_ocheaderoption_clazz, 0); - for (int n=0; nNewObject(g_ocheaderoption_clazz, option_constructor, \ - (jlong) reinterpret_cast(&headerOptions[n])); - - __android_log_print(ANDROID_LOG_ERROR, TAG, "jelem : %llu", (jlong) reinterpret_cast(&headerOptions[n])); - - env->SetObjectArrayElement(joptions, n, jelem); - env->DeleteLocalRef(jelem); - } - - // save C++ ocrepresentation ptr now - jmethodID representation_constructor = env->GetMethodID(g_ocrepresentation_clazz, "", "(J)V"); - jobject jrepresentation = env->NewObject(g_ocrepresentation_clazz, representation_constructor, \ - (jlong) reinterpret_cast(&rep)); - if(jrepresentation == NULL) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "cannot create OCRepresentation class"); - return; - } - - jclass cb_clazz = env->GetObjectClass(callbackContext->m_callBackFunction); - if (cb_clazz == NULL) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "Failed to find class"); - } - - // Find Callback function - jmethodID cb_mid = env->GetMethodID(cb_clazz, "Callback", \ - "([Lorg/iotivity/base/OCHeaderOption;Lorg/iotivity/base/OCRepresentation;I)V"); - if(cb_mid == NULL) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "onPost.Callback() is not defined in JAVA"); - return; - } - - __android_log_print(ANDROID_LOG_INFO, TAG, "calling JAVA PostCallback"); - env->CallVoidMethod(callbackContext->m_callBackFunction, cb_mid, joptions, jrepresentation, eCode); - - __android_log_print(ANDROID_LOG_INFO, TAG, "postCB detach"); - g_JavaVM->DetachCurrentThread(); - - } - ); - return NULL; -} - -JNIEXPORT jobject JNICALL jniOicObserve(JNIEnv *env, jobject jobj, jint jobservetype, jobject jattributeHandler) -{ - std::shared_ptr *resource = getHandle>(env, jobj); - __android_log_print(ANDROID_LOG_ERROR, TAG, "observe1() resource = %p\n", resource); - - JNICallBackContext *callbackContext; - string key = (*resource)->uri() + "/OBSERVE"; - std:map::iterator iter = gJNICallBackContextList.find(key); - if(iter == gJNICallBackContextList.end()) { - gJNICallBackContextList[key] = new JNICallBackContext(*resource, env->NewGlobalRef(jattributeHandler)); - callbackContext = gJNICallBackContextList[key]; - __android_log_print(ANDROID_LOG_INFO, TAG, "Adding %s to gJNICallBackContextList", key.c_str()); - } - else { - iter->second->m_callBackFunction = env->NewGlobalRef(jattributeHandler); - callbackContext = iter->second; - } - - OC::QueryParamsMap test; - __android_log_print(ANDROID_LOG_ERROR, TAG, "calling oic base observe()\n"); - - (*resource)->observe((OC::ObserveType) jobservetype, test, - [callbackContext](const OC::HeaderOptions& headerOptions, const OC::OCRepresentation& rep, const int eCode, const int seqNum) - { - JNIEnv * env; - - // Attach to JavaVM - // double check it's all ok - int getEnvStat = g_JavaVM->GetEnv((void **)&env, JNI_VERSION_1_6); - if (getEnvStat == JNI_EDETACHED) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "GetEnv: not attached"); - if (g_JavaVM->AttachCurrentThread(&env, NULL) != 0) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "Failed to attach"); - } - else - __android_log_print(ANDROID_LOG_INFO, TAG, "Attached OK"); - } else if (getEnvStat == JNI_OK) { - // - } else if (getEnvStat == JNI_EVERSION) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "GetEnv: version not supported"); - } - - // save C++ ocheaderoption ptr now - jmethodID option_constructor = env->GetMethodID(g_ocheaderoption_clazz, "", "(J)V"); - int size = headerOptions.size(); - jobjectArray joptions = env->NewObjectArray(size, g_ocheaderoption_clazz, 0); - for (int n=0; nNewObject(g_ocheaderoption_clazz, option_constructor, \ - (jlong) reinterpret_cast(&headerOptions[n])); - - __android_log_print(ANDROID_LOG_ERROR, TAG, "jelem : %llu", (jlong) reinterpret_cast(&headerOptions[n])); - - env->SetObjectArrayElement(joptions, n, jelem); - env->DeleteLocalRef(jelem); - } - - // save C++ ocrepresentation ptr now - jmethodID representation_constructor = env->GetMethodID(g_ocrepresentation_clazz, "", "(J)V"); - jobject jrepresentation = env->NewObject(g_ocrepresentation_clazz, representation_constructor, \ - (jlong) reinterpret_cast(&rep)); - if(jrepresentation == NULL) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "cannot create OCRepresentation class"); - return; - } - - jclass cb_clazz = env->GetObjectClass(callbackContext->m_callBackFunction); - if (cb_clazz == NULL) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "Failed to find class"); - } - - // Find Callback function - jmethodID cb_mid = env->GetMethodID(cb_clazz, "Callback", \ - "([Lorg/iotivity/base/OCHeaderOption;Lorg/iotivity/base/OCRepresentation;II)V"); - if(cb_mid == NULL) { - __android_log_print(ANDROID_LOG_ERROR, TAG, "onObserve.Callback() is not defined in JAVA"); - return; - } - - __android_log_print(ANDROID_LOG_INFO, TAG, "calling JAVA ObserveCallback"); - env->CallVoidMethod(callbackContext->m_callBackFunction, cb_mid, joptions, jrepresentation, eCode, seqNum); - - __android_log_print(ANDROID_LOG_INFO, TAG, "observeCB detach"); - g_JavaVM->DetachCurrentThread(); - - } - ); - return NULL; -} - -JNIEXPORT jobject JNICALL jniOicCancelObserve(JNIEnv *env, jobject jobj) -{ - std::shared_ptr *resource = getHandle>(env, jobj); - __android_log_print(ANDROID_LOG_ERROR, TAG, "cancelObserve1() resource = %p\n", resource); - __android_log_print(ANDROID_LOG_ERROR, TAG, "calling oic base cancelObserve()\n"); - - (*resource)->cancelObserve(); - return NULL; -} - -JNIEXPORT jstring JNICALL uri(JNIEnv *env, jobject jobj) -{ - __android_log_print(ANDROID_LOG_ERROR, TAG, "uri()"); - std::shared_ptr *resource = getHandle>(env, jobj); - return env->NewStringUTF((*resource)->uri().c_str()); -} - -JNIEXPORT jstring JNICALL host(JNIEnv *env, jobject jobj) -{ - __android_log_print(ANDROID_LOG_ERROR, TAG, "host()"); - std::shared_ptr *resource = getHandle>(env, jobj); - return env->NewStringUTF((*resource)->host().c_str()); -} - -JNIEXPORT jobjectArray JNICALL getResourceTypes(JNIEnv *env, jobject jobj) -{ - __android_log_print(ANDROID_LOG_ERROR, TAG, "getResourceTypes()"); - std::shared_ptr *resource = getHandle>(env, jobj); - - std::vector resourceTypes = (*resource)->getResourceTypes(); - - int size = resourceTypes.size(); - jclass clazz = env->FindClass("java/lang/String"); - jobjectArray jresourceTypes = env->NewObjectArray(size, clazz, 0); - - for (int n=0; nNewStringUTF(resourceTypes[n].c_str()); - env->SetObjectArrayElement(jresourceTypes, n, jstr); - } - - return jresourceTypes; -} - -JNIEXPORT jobjectArray JNICALL getResourceInterfaces(JNIEnv *env, jobject jobj) -{ - __android_log_print(ANDROID_LOG_ERROR, TAG, "getResourceInterfaces()"); - std::shared_ptr *resource = getHandle>(env, jobj); - - std::vector resourceInterfaces = (*resource)->getResourceInterfaces(); - - int size = resourceInterfaces.size(); - jclass clazz = env->FindClass("java/lang/String"); - jobjectArray jresourceInterfaces = env->NewObjectArray(size, clazz, 0); - - for (int n=0; nNewStringUTF(resourceInterfaces[n].c_str()); - env->SetObjectArrayElement(jresourceInterfaces, n, jstr); - } - - return jresourceInterfaces; -} - diff --git a/android/Base/app/jni/ocstack-jni.cpp b/android/Base/app/jni/ocstack-jni.cpp deleted file mode 100644 index d9ae850..0000000 --- a/android/Base/app/jni/ocstack-jni.cpp +++ /dev/null @@ -1,134 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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 "ocstack-jni.h" - -// Global map to maintain callback functions and ocresource -// with key = URL + callback operation -// e.g. key = /a/light/GET -std::map gJNICallBackContextList; - -JavaVM* g_JavaVM = NULL; - -jclass g_ocplatform_clazz; -jclass g_ocresource_clazz; -jclass g_ocheaderoption_clazz; -jclass g_ocrepresentation_clazz; -jclass g_platformcfg_clazz; - -static const char* TAG = "OCSTACK-JNI"; - -static JNINativeMethod ocplatform_method_table[] = { - { "configure", "(Lorg/iotivity/base/PlatformConfig;)V", (void *) configure}, - { "findResource", "(Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/AbstractFindCallback;)I", (void *) findResource } -}; - -static int ocplatform_method_table_size = sizeof(ocplatform_method_table) / sizeof(ocplatform_method_table[0]); - -static JNINativeMethod platformconfig_method_table[] = { - { "createNativeInstance", "(IILjava/lang/String;II)J", (void *) createNativeInstance }, -}; - -static int platformconfig_method_table_size = sizeof(platformconfig_method_table) / sizeof(platformconfig_method_table[0]); - -static JNINativeMethod ocresource_method_table[] = { - { "get", "(Lorg/iotivity/base/AbstractGetCallback;)Lorg/iotivity/base/OCStackResult;", (void *) jniOicGet}, - - { "put", "(Lorg/iotivity/base/OCRepresentation;Lorg/iotivity/base/AbstractPutCallback;)Lorg/iotivity/base/OCStackResult;", (void *) jniOicPut}, - { "post", "(Lorg/iotivity/base/OCRepresentation;Lorg/iotivity/base/AbstractPostCallback;)Lorg/iotivity/base/OCStackResult;", (void *) jniOicPost}, - { "observe", "(ILorg/iotivity/base/AbstractObserveCallback;)Lorg/iotivity/base/OCStackResult;", (void *) jniOicObserve}, - { "cancelObserve", "()Lorg/iotivity/base/OCStackResult;", (void *) jniOicCancelObserve}, - { "uri", "()Ljava/lang/String;", (void *) uri}, - { "host", "()Ljava/lang/String;", (void *) host}, - { "getResourceTypes", "()[Ljava/lang/String;", (void *) getResourceTypes}, - { "getResourceInterfaces", "()[Ljava/lang/String;", (void *) getResourceInterfaces}, -}; - -static int ocresource_method_table_size = sizeof(ocresource_method_table) / sizeof(ocresource_method_table[0]); - -static JNINativeMethod ocheaderoption_method_table[] = { - { "getOptionID", "()I", (void *) getOptionID}, - { "getOptionData", "()Ljava/lang/String;", (void *) getOptionData}, - { "OCHeaderOptionConstructor", "(ILjava/lang/String;)J", (void *) OCHeaderOptionConstructor}, -}; - -static int ocheaderoption_method_table_size = sizeof(ocheaderoption_method_table) / sizeof(ocheaderoption_method_table[0]); - -static JNINativeMethod ocrepresentation_method_table[] = { - { "OCRepresentationConstructor", "()J", (void *) OCRepresentationConstructor}, - { "getUri", "()Ljava/lang/String;", (void *) getUri}, - { "getValueInt", "(Ljava/lang/String;)I", (void *) getValueInt}, - { "getValueBool", "(Ljava/lang/String;)Z", (void *) getValueBool}, - { "getValueString", "(Ljava/lang/String;)Ljava/lang/String;", (void *) getValueString}, - { "setValueInt", "(Ljava/lang/String;I)V", (void *) setValueInt}, - { "setValueBool", "(Ljava/lang/String;Z)V", (void *) setValueBool}, - { "setValueString", "(Ljava/lang/String;Ljava/lang/String;)V", (void *) setValueString}, - { "hasAttribute", "(Ljava/lang/String;)Z", (void *) hasAttribute}, -}; - -static int ocrepresentation_method_table_size = sizeof(ocrepresentation_method_table) / sizeof(ocrepresentation_method_table[0]); - -// JNI OnLoad -JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) -{ - JNIEnv* env; - - g_JavaVM = vm; - __android_log_print(ANDROID_LOG_ERROR, TAG, "g_JavaVM = %p\n", g_JavaVM); - - if (vm->GetEnv((void **) &env, JNI_VERSION_1_6) != JNI_OK) { - return JNI_ERR; - } else { - jint ret; - jclass clazz; - - clazz = env->FindClass("org/iotivity/base/OCPlatform"); - g_ocplatform_clazz = (jclass) env->NewGlobalRef(clazz); - env->DeleteLocalRef(clazz); - ret = env->RegisterNatives(g_ocplatform_clazz, ocplatform_method_table, ocplatform_method_table_size); - __android_log_print(ANDROID_LOG_ERROR, TAG, "load ocplatform = %d\n", ret); - - clazz = env->FindClass("org/iotivity/base/OCResource"); - g_ocresource_clazz = (jclass) env->NewGlobalRef(clazz); - env->DeleteLocalRef(clazz); - ret = env->RegisterNatives(g_ocresource_clazz, ocresource_method_table, ocresource_method_table_size); - __android_log_print(ANDROID_LOG_ERROR, TAG, "load ocresource = %d\n", ret); - - clazz = env->FindClass("org/iotivity/base/PlatformConfig"); - g_platformcfg_clazz = (jclass) env->NewGlobalRef(clazz); - env->DeleteLocalRef(clazz); - ret = env->RegisterNatives(g_platformcfg_clazz, platformconfig_method_table, platformconfig_method_table_size); - __android_log_print(ANDROID_LOG_ERROR, TAG, "load platformconfig = %d\n", ret); - - clazz = env->FindClass("org/iotivity/base/OCHeaderOption"); - g_ocheaderoption_clazz = (jclass) env->NewGlobalRef(clazz); - env->DeleteLocalRef(clazz); - ret = env->RegisterNatives(g_ocheaderoption_clazz, ocheaderoption_method_table, ocheaderoption_method_table_size); - __android_log_print(ANDROID_LOG_ERROR, TAG, "load ocheaderoption = %d\n", ret); - - clazz = env->FindClass("org/iotivity/base/OCRepresentation"); - g_ocrepresentation_clazz = (jclass) env->NewGlobalRef(clazz); - env->DeleteLocalRef(clazz); - ret = env->RegisterNatives(g_ocrepresentation_clazz, ocrepresentation_method_table, ocrepresentation_method_table_size); - __android_log_print(ANDROID_LOG_ERROR, TAG, "load ocrepresentation = %d\n", ret); - - return JNI_VERSION_1_6; - } -} diff --git a/android/Base/app/jni/ocstack-jni.h b/android/Base/app/jni/ocstack-jni.h deleted file mode 100644 index dd55aa4..0000000 --- a/android/Base/app/jni/ocstack-jni.h +++ /dev/null @@ -1,101 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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 _Included_org_iotivity_base_ocstack -#define _Included_org_iotivity_base_ocstack - -#include -#include -#include "OCApi.h" -#include "OCPlatform.h" - -class JNICallBackContext { - public: - - std::shared_ptr m_resource; - jobject m_callBackFunction; - - JNICallBackContext(jobject callback) { - m_resource = NULL; - m_callBackFunction = callback; - } - - JNICallBackContext(std::shared_ptr rsrc, - jobject callback) { - m_resource = rsrc; - m_callBackFunction = callback; - } -}; - -extern std::map gJNICallBackContextList; - -extern JavaVM* g_JavaVM; - -extern jclass g_ocplatform_clazz; -extern jclass g_ocresource_clazz; -extern jclass g_ocheaderoption_clazz; -extern jclass g_ocrepresentation_clazz; -extern jclass g_platformcfg_clazz; - -template -T *getHandle(JNIEnv *env, jobject obj) -{ - jclass cls = env->GetObjectClass(obj); - jfieldID fid = env->GetFieldID(cls, "nativeHandle", "J"); - jlong handle = env->GetLongField(obj, fid); - return reinterpret_cast(handle); -} - -// ocplatform-jni -extern JNIEXPORT void JNICALL configure(JNIEnv *env, jobject obj, jobject jcfg); -extern JNIEXPORT jint JNICALL findResource(JNIEnv* env, jobject obj, jstring jhost, jstring juri, jobject found); - -// platformcfg-jni -extern JNIEXPORT jlong JNICALL createNativeInstance - (JNIEnv *env, jobject obj, jint jServiceType, jint jModeType, jstring jIpAddress, jint port, jint jQOS); - -// ocheaderoption-jni -extern JNIEXPORT jint JNICALL getOptionID(JNIEnv *env, jobject jobj); -extern JNIEXPORT jstring JNICALL getOptionData(JNIEnv *env, jobject jobj); -extern JNIEXPORT jlong JNICALL OCHeaderOptionConstructor(JNIEnv *env, jobject jobj, jint joption, jstring jdata); - -// ocrepresentation-jni -extern JNIEXPORT jlong JNICALL OCRepresentationConstructor(JNIEnv *env, jobject jobj); -extern JNIEXPORT jstring JNICALL getUri(JNIEnv *env, jobject jobj); -extern JNIEXPORT jint JNICALL getValueInt(JNIEnv *env, jobject jobj, jstring jstr); -extern JNIEXPORT jboolean JNICALL getValueBool(JNIEnv *env, jobject jobj, jstring jstr); -extern JNIEXPORT jstring JNICALL getValueString(JNIEnv *env, jobject jobj, jstring jstr); -extern JNIEXPORT void JNICALL setValueInt(JNIEnv *env, jobject jobj, jstring jstr, jint jval); -extern JNIEXPORT void JNICALL setValueBool(JNIEnv *env, jobject jobj, jstring jstr, jboolean jval); -extern JNIEXPORT void JNICALL setValueString(JNIEnv *env, jobject jobj, jstring jstr, jstring jval); -extern JNIEXPORT jboolean JNICALL hasAttribute(JNIEnv *env, jobject jobj, jstring jstr); - -// ocresource-jni -extern JNIEXPORT jobject JNICALL jniOicGet(JNIEnv *env, jobject jobj, jobject jattributeHandler); -extern JNIEXPORT jobject JNICALL jniOicPut(JNIEnv *env, jobject jobj, jobject jocrepresentation, jobject jattributeHandler); -extern JNIEXPORT jobject JNICALL jniOicPost(JNIEnv *env, jobject jobj, jobject jocrepresentation, jobject jattributeHandler); -extern JNIEXPORT jobject JNICALL jniOicObserve(JNIEnv *env, jobject jobj, jint jobservetype, jobject jattributeHandler); -extern JNIEXPORT jobject JNICALL jniOicCancelObserve(JNIEnv *env, jobject jobj); -extern JNIEXPORT jstring JNICALL uri(JNIEnv *env, jobject jobj); -extern JNIEXPORT jstring JNICALL host(JNIEnv *env, jobject jobj); -extern JNIEXPORT jobjectArray JNICALL getResourceTypes(JNIEnv *env, jobject jobj); -extern JNIEXPORT jobjectArray JNICALL getResourceInterfaces(JNIEnv *env, jobject jobj); - -#endif diff --git a/android/Base/app/jni/platformcfg-jni.cpp b/android/Base/app/jni/platformcfg-jni.cpp deleted file mode 100644 index 73d40f9..0000000 --- a/android/Base/app/jni/platformcfg-jni.cpp +++ /dev/null @@ -1,80 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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 "ocstack-jni.h" - -static const char* TAG = "PLATFORMCFG-JNI"; - -OC::ServiceType getServiceType(int type) -{ - switch (type) { - case 0: - return OC::ServiceType::InProc; - case 1: - default: - return OC::ServiceType::OutOfProc; - }; -} - -OC::ModeType getModeType(int type) -{ - switch (type) { - case 0: - return OC::ModeType::Server; - case 1: - return OC::ModeType::Client; - case 2: - default: - return OC::ModeType::Both; - }; -} - -OC::QualityOfService getQOS(int type) -{ - switch (type) { - case 0: - return OC::QualityOfService::LowQos; - case 1: - return OC::QualityOfService::MidQos; - case 2: - return OC::QualityOfService::HighQos; - case 3: - default: - return OC::QualityOfService::NaQos; - }; -} - -OC::PlatformConfig *g_cfg; - -JNIEXPORT jlong JNICALL createNativeInstance - (JNIEnv *env, jobject obj, jint jServiceType, jint jModeType, jstring jIpAddress, jint port, jint jQOS) -{ - - g_cfg = new OC::PlatformConfig{getServiceType(jServiceType), - getModeType(jModeType), - env->GetStringUTFChars(jIpAddress, 0), - (uint16_t) port, - getQOS(jQOS) - }; - - - jlong instptr = reinterpret_cast(g_cfg); - return instptr; -} diff --git a/android/Base/app/src/androidTest/java/org/iotivity/base/ApplicationTest.java b/android/Base/app/src/androidTest/java/org/iotivity/base/ApplicationTest.java deleted file mode 100644 index ac4bdc3..0000000 --- a/android/Base/app/src/androidTest/java/org/iotivity/base/ApplicationTest.java +++ /dev/null @@ -1,33 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -package org.iotivity.base; - -import android.app.Application; -import android.test.ApplicationTestCase; - -/** - * Testing Fundamentals - */ -public class ApplicationTest extends ApplicationTestCase { - public ApplicationTest() { - super(Application.class); - } -} diff --git a/android/Base/app/src/main/AndroidManifest.xml b/android/Base/app/src/main/AndroidManifest.xml deleted file mode 100644 index 32cf1c1..0000000 --- a/android/Base/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - diff --git a/android/Base/app/src/main/java/org/iotivity/base/AbstractDeleteCallback.java b/android/Base/app/src/main/java/org/iotivity/base/AbstractDeleteCallback.java deleted file mode 100644 index d1c26b4..0000000 --- a/android/Base/app/src/main/java/org/iotivity/base/AbstractDeleteCallback.java +++ /dev/null @@ -1,25 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -package org.iotivity.base; - -public abstract class AbstractDeleteCallback { - public abstract void Callback(OCHeaderOption options, int a); -} diff --git a/android/Base/app/src/main/java/org/iotivity/base/AbstractFindCallback.java b/android/Base/app/src/main/java/org/iotivity/base/AbstractFindCallback.java deleted file mode 100644 index 132b1a8..0000000 --- a/android/Base/app/src/main/java/org/iotivity/base/AbstractFindCallback.java +++ /dev/null @@ -1,26 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -package org.iotivity.base; - -public abstract class AbstractFindCallback { - public abstract void Callback(OCResource resource); -// public OCResource ocresource = new OCResource(); -} diff --git a/android/Base/app/src/main/java/org/iotivity/base/AbstractGetCallback.java b/android/Base/app/src/main/java/org/iotivity/base/AbstractGetCallback.java deleted file mode 100644 index 6ba339b..0000000 --- a/android/Base/app/src/main/java/org/iotivity/base/AbstractGetCallback.java +++ /dev/null @@ -1,27 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -package org.iotivity.base; - -public abstract class AbstractGetCallback { - public abstract void Callback(OCHeaderOption[] options, OCRepresentation rep, int a); -// public OCHeaderOption[] ocoptions; -// public OCRepresentation ocrep = new OCRepresentation(); -} diff --git a/android/Base/app/src/main/java/org/iotivity/base/AbstractObserveCallback.java b/android/Base/app/src/main/java/org/iotivity/base/AbstractObserveCallback.java deleted file mode 100644 index 6c90561..0000000 --- a/android/Base/app/src/main/java/org/iotivity/base/AbstractObserveCallback.java +++ /dev/null @@ -1,27 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -package org.iotivity.base; - -public abstract class AbstractObserveCallback { - public abstract void Callback(OCHeaderOption[] options, OCRepresentation rep, int a, int b); -// public OCHeaderOption[] ocoptions; -// public OCRepresentation ocrep = new OCRepresentation(); -} diff --git a/android/Base/app/src/main/java/org/iotivity/base/AbstractPostCallback.java b/android/Base/app/src/main/java/org/iotivity/base/AbstractPostCallback.java deleted file mode 100644 index 20acbea..0000000 --- a/android/Base/app/src/main/java/org/iotivity/base/AbstractPostCallback.java +++ /dev/null @@ -1,27 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -package org.iotivity.base; - -public abstract class AbstractPostCallback { - public abstract void Callback(OCHeaderOption[] options, OCRepresentation rep, int a); -// public OCHeaderOption[] ocoptions; -// public OCRepresentation ocrep = new OCRepresentation(); -} diff --git a/android/Base/app/src/main/java/org/iotivity/base/AbstractPutCallback.java b/android/Base/app/src/main/java/org/iotivity/base/AbstractPutCallback.java deleted file mode 100644 index 46f2a19..0000000 --- a/android/Base/app/src/main/java/org/iotivity/base/AbstractPutCallback.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.iotivity.base; - -public abstract class AbstractPutCallback { - public abstract void Callback(OCHeaderOption[] options, OCRepresentation rep, int a); -// public OCHeaderOption[] ocoptions; -// public OCRepresentation ocrep = new OCRepresentation(); -} diff --git a/android/Base/app/src/main/java/org/iotivity/base/AbstractSubscriberCallback.java b/android/Base/app/src/main/java/org/iotivity/base/AbstractSubscriberCallback.java deleted file mode 100644 index 1f996cb..0000000 --- a/android/Base/app/src/main/java/org/iotivity/base/AbstractSubscriberCallback.java +++ /dev/null @@ -1,25 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -package org.iotivity.base; - -public abstract class AbstractSubscriberCallback { - public abstract void Callback(OCStackResult result, int a); -} diff --git a/android/Base/app/src/main/java/org/iotivity/base/EntityHandler.java b/android/Base/app/src/main/java/org/iotivity/base/EntityHandler.java deleted file mode 100644 index 779543c..0000000 --- a/android/Base/app/src/main/java/org/iotivity/base/EntityHandler.java +++ /dev/null @@ -1,25 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -package org.iotivity.base; - -public interface EntityHandler { - public abstract void Callback(OCResourceRequest request, OCResourceResponse response); -} diff --git a/android/Base/app/src/main/java/org/iotivity/base/OCHeaderOption.java b/android/Base/app/src/main/java/org/iotivity/base/OCHeaderOption.java deleted file mode 100644 index c169870..0000000 --- a/android/Base/app/src/main/java/org/iotivity/base/OCHeaderOption.java +++ /dev/null @@ -1,36 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -package org.iotivity.base; - -public class OCHeaderOption extends NativeInstance { - final private static String TAG = "OCHeaderOption"; - static { - System.loadLibrary("ocstack-jni"); - } - - public OCHeaderOption(long instPtr) { - super.nativeHandle = instPtr; - } - - public native int getOptionID(); - public native String getOptionData(); - public native long OCHeaderOptionConstructor(int optionID, String optionData); -} diff --git a/android/Base/app/src/main/java/org/iotivity/base/OCPlatform.java b/android/Base/app/src/main/java/org/iotivity/base/OCPlatform.java deleted file mode 100644 index e4424a6..0000000 --- a/android/Base/app/src/main/java/org/iotivity/base/OCPlatform.java +++ /dev/null @@ -1,32 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -package org.iotivity.base; - -public class OCPlatform { - final private static String TAG = "OCPlatform"; - static { - System.loadLibrary("ocstack-jni"); - } - - public static native void configure(PlatformConfig cfg); - public static native int findResource(String host, String Uri, AbstractFindCallback found); - -} diff --git a/android/Base/app/src/main/java/org/iotivity/base/OCRepresentation.java b/android/Base/app/src/main/java/org/iotivity/base/OCRepresentation.java deleted file mode 100644 index 06a2156..0000000 --- a/android/Base/app/src/main/java/org/iotivity/base/OCRepresentation.java +++ /dev/null @@ -1,49 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -package org.iotivity.base; - -public class OCRepresentation extends NativeInstance { - final private static String TAG = "OCRepresentation"; - static { - System.loadLibrary("ocstack-jni"); - } - - public OCRepresentation(long instPtr) { - super.nativeHandle = instPtr; - } - public OCRepresentation() { - super.nativeHandle = OCRepresentationConstructor(); - } - - public native long OCRepresentationConstructor(); - - public native int getValueInt(String str); - public native boolean getValueBool(String str); - public native String getValueString(String str); - - public native void setValueInt (String str, int val); - public native void setValueBool (String str, boolean val); - public native void setValueString (String str, String val); - - public native String getUri(); - - public native boolean hasAttribute(String str); -} diff --git a/android/Base/app/src/main/java/org/iotivity/base/OCResource.java b/android/Base/app/src/main/java/org/iotivity/base/OCResource.java deleted file mode 100644 index 7a7f6c8..0000000 --- a/android/Base/app/src/main/java/org/iotivity/base/OCResource.java +++ /dev/null @@ -1,60 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -package org.iotivity.base; - -public class OCResource extends NativeInstance { - final private static String TAG = "OCResource"; - static { - System.loadLibrary("ocstack-jni"); - } - - public native OCStackResult get(AbstractGetCallback attributeHandler); -// public native OCStackResult get(AbstractGetCallback attributeHandler, PlatformConfig.QualityOfService QoS); - - public native OCStackResult get(String resourceType, String resourceInterface, AbstractGetCallback attributeHandler); -// public native OCStackResult get(String resourceType, String resourceInterface, AbstractGetCallback attributeHandler, PlatformConfig.QualityOfService QoS); - - public native OCStackResult put(OCRepresentation rep, AbstractPutCallback attributeHandler); -// public native OCStackResult put(OCRepresentation rep, AbstractPutCallback attributeHandler, PlatformConfig.QualityOfService QoS); -// public native OCStackResult put(String resourceType, String resourceInterface, OCRepresentation rep, AbstractPutCallback attributeHandler); -// public native OCStackResult put(String resourceType, String resourceInterface, OCRepresentation rep, AbstractPutCallback attributeHandler, PlatformConfig.QualityOfService QoS); - - public native OCStackResult post(OCRepresentation rep, AbstractPostCallback attributeHandler); -// public native OCStackResult post(OCRepresentation rep, AbstractPostCallback attributeHandler, PlatformConfig.QualityOfService QoS); -// public native OCStackResult post(String resourceType, String resourceInterface, OCRepresentation rep, AbstractPostCallback attributeHandler); -// public native OCStackResult post(String resourceType, String resourceInterface, OCRepresentation rep, AbstractPostCallback attributeHandler, PlatformConfig.QualityOfService QoS); - - public native OCStackResult observe(int observeType, AbstractObserveCallback observerHandler); -// public native OCStackResult observe(int observeType, AbstractObserveCallback observerHandler, PlatformConfig.QualityOfService QoS); - - public native OCStackResult cancelObserve(); -// public native OCStackResult cancelObserve(PlatformConfig.QualityOfService QoS); - - public native String uri(); - public native String host(); - - public native String[] getResourceInterfaces(); - public native String[] getResourceTypes(); - - public OCResource(long instPtr) { - super.nativeHandle = instPtr; - } -} diff --git a/android/Base/app/src/main/java/org/iotivity/base/OCResourceRequest.java b/android/Base/app/src/main/java/org/iotivity/base/OCResourceRequest.java deleted file mode 100644 index 87c406e..0000000 --- a/android/Base/app/src/main/java/org/iotivity/base/OCResourceRequest.java +++ /dev/null @@ -1,24 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -package org.iotivity.base; - -public class OCResourceRequest { -} diff --git a/android/Base/app/src/main/java/org/iotivity/base/OCResourceResponse.java b/android/Base/app/src/main/java/org/iotivity/base/OCResourceResponse.java deleted file mode 100644 index 283d8de..0000000 --- a/android/Base/app/src/main/java/org/iotivity/base/OCResourceResponse.java +++ /dev/null @@ -1,24 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -package org.iotivity.base; - -public class OCResourceResponse { -} diff --git a/android/Base/app/src/main/java/org/iotivity/base/OCStackResult.java b/android/Base/app/src/main/java/org/iotivity/base/OCStackResult.java deleted file mode 100644 index 10440b6..0000000 --- a/android/Base/app/src/main/java/org/iotivity/base/OCStackResult.java +++ /dev/null @@ -1,54 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -package org.iotivity.base; - -public class OCStackResult { - /* Success status code - START HERE */ - static final public int OC_STACK_OK = 0; - static final public int OC_STACK_RESOURCE_CREATED = 1; - static final public int OC_STACK_RESOURCE_DELETED = 2; - /* Success status code - END HERE */ - /* Error status code - START HERE */ - static final public int OC_STACK_INVALID_URI = 3; - static final public int OC_STACK_INVALID_QUERY = 4; - static final public int OC_STACK_INVALID_IP = 5; - static final public int OC_STACK_INVALID_PORT = 6; - static final public int OC_STACK_INVALID_CALLBACK = 7; - static final public int OC_STACK_INVALID_METHOD = 8; - static final public int OC_STACK_INVALID_PARAM = 9; - static final public int OC_STACK_INVALID_OBSERVE_PARAM = 10; - static final public int OC_STACK_NO_MEMORY = 11; - static final public int OC_STACK_COMM_ERROR = 12; - static final public int OC_STACK_NOTIMPL = 13; - static final public int OC_STACK_NO_RESOURCE = 14; /* resource not found */ - static final public int OC_STACK_RESOURCE_ERROR = 15; /* ex: not supported method or interface */ - static final public int OC_STACK_SLOW_RESOURCE = 16; - static final public int OC_STACK_NO_OBSERVERS = 17; /* resource has no registered observers */ - static final public int OC_STACK_OBSERVER_NOT_FOUND = 18; - static final public int OC_STACK_OBSERVER_NOT_ADDED = 19; - static final public int OC_STACK_OBSERVER_NOT_REMOVED = 20; - static final public int OC_STACK_PRESENCE_STOPPED = 21; - static final public int OC_STACK_PRESENCE_DO_NOT_HANDLE = 22; - static final public int OC_STACK_INVALID_OPTION = 23; - static final public int OC_STACK_MALFORMED_RESPONSE = 24; /* the remote reply contained malformed data */ - static final public int OC_STACK_ERROR = 25; - /* Error status code - END HERE */ -} diff --git a/android/Base/app/src/main/java/org/iotivity/base/ObserveType.java b/android/Base/app/src/main/java/org/iotivity/base/ObserveType.java deleted file mode 100644 index f61c5d8..0000000 --- a/android/Base/app/src/main/java/org/iotivity/base/ObserveType.java +++ /dev/null @@ -1,26 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -package org.iotivity.base; - -public class ObserveType { - static final public int Observe = 0; - static final public int ObserveAll = 1; -} diff --git a/android/Base/app/src/main/java/org/iotivity/base/PlatformConfig.java b/android/Base/app/src/main/java/org/iotivity/base/PlatformConfig.java deleted file mode 100644 index 301cdde..0000000 --- a/android/Base/app/src/main/java/org/iotivity/base/PlatformConfig.java +++ /dev/null @@ -1,68 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -package org.iotivity.base; - -public class PlatformConfig extends NativeInstance -{ - final private static String TAG = "PlatformConfig"; - static { - System.loadLibrary("ocstack-jni"); - } - - // ENUM definition. Need to match with OCApi.h - public class ServiceType - { - static final public int INPROC = 0; - static final public int OUTPROC = 1; - }; - - public class ModeType - { - static final public int SERVER = 0; - static final public int CLIENT = 1; - static final public int BOTH = 2; - - }; - - public class QualityOfService - { - static final public int LO_QOS = 0; - static final public int ME_QOS = 1; - static final public int HI_QOS = 2; - static final public int NA_QOS = 3; - } - - public PlatformConfig(int serviceType, - int mode, - String ipAddress, - int port, - int QoS) - { - super.nativeHandle = createNativeInstance(serviceType, mode, ipAddress, port, QoS); - } - - - protected native long createNativeInstance(int serviceType, - int mode, - String ipAddress, - int port, - int QoS); -} diff --git a/android/Base/app/src/main/res/values/strings.xml b/android/Base/app/src/main/res/values/strings.xml deleted file mode 100644 index 73ef225..0000000 --- a/android/Base/app/src/main/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - Base - diff --git a/android/Base/gradle.properties b/android/Base/gradle.properties deleted file mode 100644 index 5d08ba7..0000000 --- a/android/Base/gradle.properties +++ /dev/null @@ -1,18 +0,0 @@ -# Project-wide Gradle settings. - -# IDE (e.g. Android Studio) users: -# Settings specified in this file will override any Gradle settings -# configured through the IDE. - -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html - -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -# Default value: -Xmx10248m -XX:MaxPermSize=256m -# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 - -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true \ No newline at end of file diff --git a/android/Base/settings.gradle b/android/Base/settings.gradle deleted file mode 100644 index e7b4def..0000000 --- a/android/Base/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include ':app' diff --git a/android/BuildInstructionsForAndroidAPI.txt b/android/BuildInstructionsForAndroidAPI.txt new file mode 100644 index 0000000..8dda6db --- /dev/null +++ b/android/BuildInstructionsForAndroidAPI.txt @@ -0,0 +1,45 @@ +Build Instructions for Android-API: + +1.Verify that you have the latest JDK (you might need to set the JDK_HOME variable) +2.Clone the latest iotivity codebase. +3.set environment variables: + a.platform=android + b.If running in windows, change the following line in the build.gradle file (/android/android_api/base/build.gradle): + def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build') + to + def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build.cmd') + +4.Build scons for android and your targeted architecture (This will also build Android API): + a.scons TARGET_OS=android TARGET_ARCH= TARGET_TRANSPORT=IP RELEASE=1 + where can be armeabi, armeabi-v7a, x86. + Note: To build in debug mode, use RELEASE=0. + Note: The minimum SDK version supported is 21. + Note: Only TARGET_TRANSPORT currently supported is IP + b.If the project is setup correctly, you should see a BUILD SUCCESSFUL message on the terminal + c.You should see the .aar files generated inside of '/android/android_api/base/build/outputs/aar' directory. The .aar files contain jni directory and also a .jar file + + +TO RUN UNIT TESTS IN ANDROID-API + +5.The '/android/android_api/base/src/androidTest/...' directory contains tests which can be used to get an idea about the Android API usage. + + +TO USE THE .AAR FILE IN /android/examples project + +6. Verify that 9 different *.so files exist inside /android/android-api/base/libs/ directory. (They should already be present in the *.aar file.) +7. Import Project 'Examples' into android-studio. +8.To add an .aar file to the 'Examples' project, + a.Right click on Examples->New->Module->Import .JAR or .AAR Package + b.Select the .aar file from the location in step 6e above + c.Right click on Examples->Open Module Settings + d.Select each sample app module under 'Modules'->Dependencies->Add->Module Dependency + e.The .aar file selected in step 10b above should be present. Select it. + f.Repeat steps d and e for each sample app module. + + +TO USE THE .AAR FILE IN A DIFFERENT PROJECT + +9. Verify that 9 different *.so files exist inside /android/android-api/base/libs/ directory. +10. Import the .aar file in your project to use it + + diff --git a/android/SimpleClient/app/build.gradle b/android/SimpleClient/app/build.gradle deleted file mode 100644 index bf753bf..0000000 --- a/android/SimpleClient/app/build.gradle +++ /dev/null @@ -1,40 +0,0 @@ -apply plugin: 'com.android.application' - -android { - compileSdkVersion 20 - buildToolsVersion "19.1.0" - - defaultConfig { - applicationId "org.iotivity.simpleclient" - minSdkVersion 19 - targetSdkVersion 20 - versionCode 1 - versionName "1.0" - } - buildTypes { - release { - runProguard false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } -} - -dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) -} - -repositories { - mavenCentral() - flatDir { - dirs 'libs' - } -} - - -dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - compile fileTree(dir: 'libs', include: ['*.so']) - compile fileTree(dir: 'libs', include: ['**/*.so']) -// compile(name: 'OicLib', ext:'aar') - compile 'org.iotivity.Base:app:1.0@aar' -} \ No newline at end of file diff --git a/android/SimpleClient/app/proguard-rules.pro b/android/SimpleClient/app/proguard-rules.pro deleted file mode 100644 index 0e559b0..0000000 --- a/android/SimpleClient/app/proguard-rules.pro +++ /dev/null @@ -1,17 +0,0 @@ -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in /home/vchen/ubuntu_sw/adt-bundle-linux-x86_64/sdk/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} diff --git a/android/SimpleClient/app/src/androidTest/java/org/iotivity/simpleclient/ApplicationTest.java b/android/SimpleClient/app/src/androidTest/java/org/iotivity/simpleclient/ApplicationTest.java deleted file mode 100644 index a2b6778..0000000 --- a/android/SimpleClient/app/src/androidTest/java/org/iotivity/simpleclient/ApplicationTest.java +++ /dev/null @@ -1,33 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -package org.iotivity.simpleclient; - -import android.app.Application; -import android.test.ApplicationTestCase; - -/** - * Testing Fundamentals - */ -public class ApplicationTest extends ApplicationTestCase { - public ApplicationTest() { - super(Application.class); - } -} diff --git a/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/FoundResource.java b/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/FoundResource.java deleted file mode 100644 index cd558f4..0000000 --- a/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/FoundResource.java +++ /dev/null @@ -1,72 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -package org.iotivity.simpleclient; - -import android.util.Log; - -import org.iotivity.base.AbstractFindCallback; -import org.iotivity.base.OCResource; - -public class FoundResource extends AbstractFindCallback { - final private static String TAG = "FoundResource"; - - - public void Callback(OCResource resource) { - - if(SimpleClient.curResource != null) { - Log.e(TAG, "Found another resource, ignoring"); - } - - String resourceURI; - String hostAddress; - - if(resource != null) { - Log.i(TAG, "DISCOVERED Resource"); - - resourceURI = resource.uri(); - Log.i(TAG, "URI of the resource: " + resourceURI); - - hostAddress = resource.host(); - Log.i(TAG, "Host address of the resource: " + hostAddress); - - new SimpleToast().execute("URI of the resource: " + resourceURI + "\nHost address of the resource: " + hostAddress); - - String[] resourceTypes = resource.getResourceTypes(); - for(int i=0; i 5) { - Log.i(TAG, "Cancelling Observe ..."); - OCStackResult result = SimpleClient.curResource.cancelObserve(); - Log.i(TAG, "Cancel result : " + result); - try { - Thread.sleep(10000); // 10 sec - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - Log.i(TAG, "DONE"); - new SimpleToast().execute( - "DONE" - ); - } - - } - } - else { - Log.e(TAG, "onPut Response error : " + eCode); - } - - } -} diff --git a/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/OnPost.java b/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/OnPost.java deleted file mode 100644 index ca7e1ae..0000000 --- a/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/OnPost.java +++ /dev/null @@ -1,77 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -package org.iotivity.simpleclient; - -import android.util.Log; - -import org.iotivity.base.AbstractPostCallback; -import org.iotivity.base.OCHeaderOption; -import org.iotivity.base.OCRepresentation; - -public class OnPost extends AbstractPostCallback { - - final private static String TAG = "OnPost"; - - public void Callback(OCHeaderOption[] options, OCRepresentation rep, int eCode) { -//FIXME : Need to check why ocstack is returning error code 28 to us after 12/6/14 rebase -// if(eCode == OCStackResult.OC_STACK_OK || eCode == OCStackResult.OC_STACK_RESOURCE_CREATED) { - if(true) { - Log.i(TAG, "POST request was successful"); - - if(rep.hasAttribute("createduri")) { - Log.i(TAG, "Uri of the created resource : " + rep.getValueString("createduri")); - } - else { - SimpleClient.mylight.m_state = rep.getValueBool("state"); - Log.i(TAG, "state : " + SimpleClient.mylight.m_state); - SimpleClient.mylight.m_power = rep.getValueInt("power"); - Log.i(TAG, "power : " + SimpleClient.mylight.m_power); - SimpleClient.mylight.m_name = rep.getValueString("name"); - Log.i(TAG, "name : " + SimpleClient.mylight.m_name); - - new SimpleToast().execute( - "state : " + SimpleClient.mylight.m_state + - "\npower : " + SimpleClient.mylight.m_power + - "\nname : " + SimpleClient.mylight.m_name - ); - } - - OCRepresentation rep2 = new OCRepresentation(); - - Log.e(TAG, "Posting Light Representation ..."); - - SimpleClient.mylight.m_state = true; - SimpleClient.mylight.m_power = 55; - - Log.i(TAG, "setValueBool : " + SimpleClient.mylight.m_state); - Log.i(TAG, "setValueInt : " + SimpleClient.mylight.m_power); - rep2.setValueBool("state", SimpleClient.mylight.m_state); - rep2.setValueInt("power", SimpleClient.mylight.m_power); - - OnPost2 onPost2 = new OnPost2(); - SimpleClient.curResource.post(rep2, onPost2); - } - else { - Log.e(TAG, "onPost Response error : " + eCode); - } - - } -} diff --git a/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/OnPost2.java b/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/OnPost2.java deleted file mode 100644 index cfc6ae6..0000000 --- a/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/OnPost2.java +++ /dev/null @@ -1,75 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -package org.iotivity.simpleclient; - -import android.util.Log; - -import org.iotivity.base.AbstractPostCallback; -import org.iotivity.base.OCHeaderOption; -import org.iotivity.base.OCRepresentation; -import org.iotivity.base.OCStackResult; -import org.iotivity.base.ObserveType; - -public class OnPost2 extends AbstractPostCallback { - - final private static String TAG = "OnPost2"; - - public void Callback(OCHeaderOption[] options, OCRepresentation rep, int eCode) { -//FIXME : Need to check why ocstack is returning error code 28 to us after 12/6/14 rebase -// if(eCode == OCStackResult.OC_STACK_OK || eCode == OCStackResult.OC_STACK_RESOURCE_CREATED) { - if(true) { - - Log.i(TAG, "POST2 request was successful"); - - if(rep.hasAttribute("createduri")) { - String createdUri = rep.getValueString("createduri"); - Log.i(TAG, "Uri of the created resource : " + createdUri); // FIXME - new SimpleToast().execute( - "Uri of the created resource : " + createdUri - ); - } - else { - SimpleClient.mylight.m_state = rep.getValueBool("state"); - Log.i(TAG, "state : " + SimpleClient.mylight.m_state); - SimpleClient.mylight.m_power = rep.getValueInt("power"); - Log.i(TAG, "power : " + SimpleClient.mylight.m_power); - SimpleClient.mylight.m_name = rep.getValueString("name"); - Log.i(TAG, "name : " + SimpleClient.mylight.m_name); - new SimpleToast().execute( - "state : " + SimpleClient.mylight.m_state + - "\npower : " + SimpleClient.mylight.m_power + - "\nname : " + SimpleClient.mylight.m_name - ); - } - - if(SimpleClient.OBSERVE_TYPE_TO_USE == ObserveType.Observe) - Log.i(TAG, "Observe is used"); - else if(SimpleClient.OBSERVE_TYPE_TO_USE == ObserveType.ObserveAll) - Log.i(TAG, "ObserveAll is used"); - - OnObserve onObserve = new OnObserve(); - SimpleClient.curResource.observe(SimpleClient.OBSERVE_TYPE_TO_USE, onObserve); - } - else { - Log.e(TAG, "onPost Response error : " + eCode); - } - } -} diff --git a/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/OnPut.java b/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/OnPut.java deleted file mode 100644 index fa8410c..0000000 --- a/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/OnPut.java +++ /dev/null @@ -1,59 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -package org.iotivity.simpleclient; - -import android.util.Log; - -import org.iotivity.base.AbstractPutCallback; -import org.iotivity.base.OCHeaderOption; -import org.iotivity.base.OCRepresentation; -import org.iotivity.base.OCStackResult; - -public class OnPut extends AbstractPutCallback { - - final private static String TAG = "OnGet"; - - public void Callback(OCHeaderOption[] options, OCRepresentation rep, int eCode) { - if(eCode == OCStackResult.OC_STACK_OK) { - { - Log.i(TAG, "PUT request was successful"); - - SimpleClient.mylight.m_state = rep.getValueBool("state"); - Log.i(TAG, "state : " + SimpleClient.mylight.m_state); - SimpleClient.mylight.m_power = rep.getValueInt("power"); - Log.i(TAG, "power : " + SimpleClient.mylight.m_power); - SimpleClient.mylight.m_name = rep.getValueString("name"); - Log.i(TAG, "name : " + SimpleClient.mylight.m_name); - new SimpleToast().execute( - "state : " + SimpleClient.mylight.m_state + - "\npower : " + SimpleClient.mylight.m_power + - "\nname : " + SimpleClient.mylight.m_name - ); - - SimpleClient.postLightRepresentation(SimpleClient.curResource); - } - } - else { - Log.e(TAG, "onPut Response error : " + eCode); - } - - } -} diff --git a/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/SimpleClient.java b/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/SimpleClient.java deleted file mode 100644 index 7413ca2..0000000 --- a/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/SimpleClient.java +++ /dev/null @@ -1,151 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -package org.iotivity.simpleclient; - -import android.app.Activity; -import android.os.Bundle; -import android.util.Log; -import android.view.Menu; -import android.view.MenuItem; - -import org.iotivity.base.OCPlatform; -import org.iotivity.base.OCRepresentation; -import org.iotivity.base.OCResource; -import org.iotivity.base.ObserveType; -import org.iotivity.base.PlatformConfig; - - -public class SimpleClient extends Activity { - final private static String TAG = "SimpleClient"; - - class Light { - public boolean m_state; - public int m_power; - public String m_name; - - public Light() { - m_state = false; - m_power = 0; - m_name = "vincent"; - } - } - - static int OBSERVE_TYPE_TO_USE = ObserveType.Observe; - - public static Light mylight; - public static OCResource curResource; - static int oc = 0; - static Activity mActivity; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - mActivity = this; - - mylight = new Light(); - - PlatformConfig cfg = new PlatformConfig(PlatformConfig.ServiceType.INPROC, - PlatformConfig.ModeType.CLIENT, - "0.0.0.0", - 0, - PlatformConfig.QualityOfService.LO_QOS); - - OCPlatform.configure(cfg); - FoundResource foundResource = new FoundResource(); - OCPlatform.findResource("", "coap://224.0.1.187/oc/core?rt=core.light", foundResource); - - setContentView(R.layout.activity_simple_client); - } - - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - // Inflate the menu; this adds items to the action bar if it is present. - getMenuInflater().inflate(R.menu.simple_client, menu); - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - // Handle action bar item clicks here. The action bar will - // automatically handle clicks on the Home/Up button, so long - // as you specify a parent activity in AndroidManifest.xml. - int id = item.getItemId(); - if (id == R.id.action_settings) { - return true; - } - return super.onOptionsItemSelected(item); - } - - protected static void getLightRepresentation(OCResource resource) { - if(resource != null) { - Log.e(TAG, "Getting Light Representation ..."); - - OnGet onGet = new OnGet(); - resource.get(onGet); - } - } - - protected static void putLightRepresentation(OCResource resource) { - if(resource != null) { - - OCRepresentation rep = new OCRepresentation(); - - Log.e(TAG, "Putting Light Representation ..."); - - mylight.m_state = true; - mylight.m_power = 15; - - Log.i(TAG, "setValueBool : " + SimpleClient.mylight.m_state); - Log.i(TAG, "setValueInt : " + SimpleClient.mylight.m_power); - rep.setValueBool("state", mylight.m_state); - rep.setValueInt("power", mylight.m_power); - - OnPut onPut = new OnPut(); - resource.put(rep, onPut); - } - } - - protected static void postLightRepresentation(OCResource resource) { - if(resource != null) { - - OCRepresentation rep = new OCRepresentation(); - - Log.e(TAG, "Posting Light Representation ..."); - - mylight.m_state = false; - mylight.m_power = 105; - - Log.i(TAG, "setValueBool : " + SimpleClient.mylight.m_state); - Log.i(TAG, "setValueInt : " + SimpleClient.mylight.m_power); - rep.setValueBool("state", mylight.m_state); - rep.setValueInt("power", mylight.m_power); - - OnPost onPost = new OnPost(); - resource.post(rep, onPost); - } - } - - protected static int observe_count() { - return ++oc; - } - -} diff --git a/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/SimpleToast.java b/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/SimpleToast.java deleted file mode 100644 index 8f7d672..0000000 --- a/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/SimpleToast.java +++ /dev/null @@ -1,44 +0,0 @@ -//****************************************************************** -// -// Copyright 2014 MediaTek 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. -// -//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -package org.iotivity.simpleclient; - -import android.os.AsyncTask; -import android.widget.Toast; - -public class SimpleToast extends AsyncTask { - String toastMessage; - - @Override - protected String doInBackground(String... params) { - toastMessage = params[0]; - return toastMessage; - } - - protected void OnProgressUpdate(String... values) { - super.onProgressUpdate(values); - } - // This is executed in the context of the main GUI thread - protected void onPostExecute(String result){ - Toast toast = Toast.makeText(SimpleClient.mActivity, result, Toast.LENGTH_SHORT); - toast.show(); - } - -} diff --git a/android/SimpleClient/app/src/main/res/layout/activity_simple_client.xml b/android/SimpleClient/app/src/main/res/layout/activity_simple_client.xml deleted file mode 100644 index f347f6c..0000000 --- a/android/SimpleClient/app/src/main/res/layout/activity_simple_client.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - diff --git a/android/SimpleClient/app/src/main/res/menu/simple_client.xml b/android/SimpleClient/app/src/main/res/menu/simple_client.xml deleted file mode 100644 index 1a65997..0000000 --- a/android/SimpleClient/app/src/main/res/menu/simple_client.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - diff --git a/android/SimpleClient/build.gradle b/android/SimpleClient/build.gradle deleted file mode 100644 index 9b8abe4..0000000 --- a/android/SimpleClient/build.gradle +++ /dev/null @@ -1,19 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - -buildscript { - repositories { - jcenter() - } - dependencies { - classpath 'com.android.tools.build:gradle:0.12.2' - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -allprojects { - repositories { - jcenter() - } -} diff --git a/android/SimpleClient/gradle.properties b/android/SimpleClient/gradle.properties deleted file mode 100644 index 5d08ba7..0000000 --- a/android/SimpleClient/gradle.properties +++ /dev/null @@ -1,18 +0,0 @@ -# Project-wide Gradle settings. - -# IDE (e.g. Android Studio) users: -# Settings specified in this file will override any Gradle settings -# configured through the IDE. - -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html - -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -# Default value: -Xmx10248m -XX:MaxPermSize=256m -# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 - -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true \ No newline at end of file diff --git a/android/SimpleClient/settings.gradle b/android/SimpleClient/settings.gradle deleted file mode 100644 index e7b4def..0000000 --- a/android/SimpleClient/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include ':app' diff --git a/android/android_api/.gitignore b/android/android_api/.gitignore new file mode 100755 index 0000000..e86e67c --- /dev/null +++ b/android/android_api/.gitignore @@ -0,0 +1,10 @@ +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build/* +/base/build/* +/base/obj/* +/base/libs/* +/sample/* diff --git a/android/android_api/SConscript b/android/android_api/SConscript new file mode 100755 index 0000000..2575c97 --- /dev/null +++ b/android/android_api/SConscript @@ -0,0 +1,48 @@ +import os +import platform +Import('env') + +android_home = env.get('ANDROID_HOME') + +ANDROID_TARGET_ARCH = env.get('TARGET_ARCH') +if env.get('RELEASE'): + ANDROID_RELEASE="release" +else: + ANDROID_RELEASE="debug" + +os.environ['ANDROID_HOME'] = env.get('ANDROID_HOME') +os.environ['ANDROID_NDK_HOME'] = env.get('ANDROID_NDK') + +if not os.path.exists(android_home + '/platforms/android-21') or not os.path.exists(android_home + '/build-tools/20.0.0'): + print ''' +***************************************** Info ******************************** +* Either 'Android API 21' is not installed or 'Android SDK Build Tools * +* 20.0.0' is not installed. The Android SDK Manager will now open. Please * +* be sure to deselect all options, then select the following 2 packages: * +* 1. Under "Tools" select "Android SDK Build-tools" Revision 20. * +* 2. Under "Android 5.0.1 (API 21)" select "SDK Platform" * +* 3. Continue by selecting "Install 2 Packages" * +* * +* NOTE: If you have an http proxy, please press ctrl+c now and edit/create * +* the following file in your $HOME directory as follows: * +* * +* Edit/Create file: "$HOME/.android/androidtool.cfg" * +* * +* http.proxyPort= * +* sdkman.monitor.density=108 * +* http.proxyHost= * +* sdkman.show.update.only=true * +* sdkman.ask.adb.restart=false * +* sdkman.force.http=true * +* sdkman.show.updateonly=true * +* * +******************************************************************************* + +...Opening Android SDK Manager now. Once you are finished, the build will continue. +''' + os.system(android_home + '/tools/android') + +jdk_env = Environment(ENV=os.environ) +jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b' + os.getcwd()+'/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE)) +jdk_env.Gradle(target="base/objs", source="base/src/main/java/org/iotivity/base/OcResource.java") + diff --git a/android/android_api/android_api.iml b/android/android_api/android_api.iml new file mode 100755 index 0000000..8d49284 --- /dev/null +++ b/android/android_api/android_api.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + diff --git a/android/android_api/base/.gitignore b/android/android_api/base/.gitignore new file mode 100755 index 0000000..6e8872c --- /dev/null +++ b/android/android_api/base/.gitignore @@ -0,0 +1,5 @@ +.gradle/ +.idea/ +sample/ +base/build/ +base/obj/ diff --git a/android/android_api/base/base.iml b/android/android_api/base/base.iml new file mode 100755 index 0000000..36cf651 --- /dev/null +++ b/android/android_api/base/base.iml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/android_api/base/build.gradle b/android/android_api/base/build.gradle new file mode 100755 index 0000000..9cbdaf8 --- /dev/null +++ b/android/android_api/base/build.gradle @@ -0,0 +1,115 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +apply plugin: 'com.android.library' + +android { + compileSdkVersion 21 + buildToolsVersion "20.0.0" + archivesBaseName = "iotivity" + + libraryVariants.all { variant -> + variant.outputs.each { output -> + def outputFile = output.outputFile + if (outputFile != null && outputFile.name.endsWith('.aar')) { + def fileName = "${archivesBaseName}-${TARGET_ARCH}-${outputFile.name}" + output.outputFile = new File(outputFile.parent, fileName) + } + } + } + + defaultConfig { + minSdkVersion 21 + targetSdkVersion 21 + versionCode 1 + versionName "0.9" + } + buildTypes { + release { + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + + lintOptions { + abortOnError false + } + + sourceSets { + main { + manifest.srcFile 'src/main/AndroidManifest.xml' + jniLibs.srcDir 'libs' + jni.srcDirs = [] //disable automatic ndk-build call + } + } +} + + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) +} + +//////////////// +////NDK Support +//////////////// +//If using this, Android studio will fail run the following to set the environment variable for android studio: +//launchctl setenv ANDROID_NDK_HOME /Users/boos_patrick/Development/Android/android-ndk-r8e +//otherwise remove the dependsOn part and run ./gradlew buildNative from the command line + +task copyNativeLibs(type: Copy, dependsOn: 'buildNative') { + dependsOn 'buildNative' + from(new File('libs')) { include '**/*.so' } + into new File(buildDir, 'native-libs') +} + +tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn copyNativeLibs } + +clean.dependsOn 'cleanCopyNativeLibs' + +tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask -> + pkgTask.jniFolders = new HashSet() + pkgTask.jniFolders.add(new File(buildDir, 'native-libs')) +} + +task buildNative(type: Exec) { + if (System.env.ANDROID_NDK_HOME != null) { + //for windows use 'ndk-build.cmd' + //def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build.cmd') + def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build') + commandLine ndkBuild, "APP_ABI=$TARGET_ARCH", "APP_OPTIM=$RELEASE" + } else { + println '##################' + println 'Skipping NDK build' + println 'Reason: ANDROID_NDK_HOME not set.' + println '##################' + } +} +// +//task (copyARR, type: Copy) { +// copy { +// from 'build/outputs/aar/' +// into '../../../out/android/' +// include '**/*.aar' +// } +//} +//build.finalizedBy(copyARR) + + diff --git a/android/android_api/base/jni/Android.mk b/android/android_api/base/jni/Android.mk new file mode 100755 index 0000000..aa2cbae --- /dev/null +++ b/android/android_api/base/jni/Android.mk @@ -0,0 +1,78 @@ +LOCAL_PATH := $(call my-dir) +TARGET_ARCH_ABI := $(APP_ABI) + +include $(CLEAR_VARS) +OIC_LIB_PATH := ../../../../out/android/$(APP_ABI)/$(APP_OPTIM) +LOCAL_MODULE := libandroid-oc_logger +LOCAL_SRC_FILES := $(OIC_LIB_PATH)/liboc_logger.so +include $(PREBUILT_SHARED_LIBRARY) + +include $(CLEAR_VARS) +OIC_LIB_PATH := ../../../../out/android/$(APP_ABI)/$(APP_OPTIM) +LOCAL_MODULE := libandroid-octbstack +LOCAL_SRC_FILES := $(OIC_LIB_PATH)/liboctbstack.so +include $(PREBUILT_SHARED_LIBRARY) + +include $(CLEAR_VARS) +OIC_LIB_PATH := ../../../../out/android/$(APP_ABI)/$(APP_OPTIM) +LOCAL_MODULE := libandroid-oc +LOCAL_SRC_FILES := $(OIC_LIB_PATH)/liboc.so +include $(PREBUILT_SHARED_LIBRARY) + +include $(CLEAR_VARS) +OIC_LIB_PATH := ../../../../out/android/$(APP_ABI)/$(APP_OPTIM) +LOCAL_MODULE := libandroid-ca +LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libconnectivity_abstraction.so +include $(PREBUILT_SHARED_LIBRARY) + +include $(CLEAR_VARS) +OIC_SRC_PATH := ../../../resource +LOCAL_MODULE := libca-interface +LOCAL_SRC_FILES := JniCaInterface.c +LOCAL_STATIC_LIBRARIES := libandroid-ca +LOCAL_LDLIBS := -llog +LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/connectivity/api +include $(BUILD_SHARED_LIBRARY) + +include $(CLEAR_VARS) +OIC_SRC_PATH := ../../../resource +OIC_OUT_PATH := ../../../out +LOCAL_MODULE := ocstack-jni +LOCAL_SRC_FILES := JniOcStack.cpp \ + JniUtils.cpp \ + JniEntityHandler.cpp \ + JniOnResourceFoundListener.cpp \ + JniOnDeviceInfoListener.cpp \ + JniOnPresenceListener.cpp \ + JniOnGetListener.cpp \ + JniOnPutListener.cpp \ + JniOnPostListener.cpp \ + JniOnDeleteListener.cpp \ + JniOnObserveListener.cpp \ + JniOcRepresentation.cpp \ + JniOcResourceHandle.cpp \ + JniOcPresenceHandle.cpp \ + JniOcRequestHandle.cpp \ + JniOcResourceRequest.cpp \ + JniOcResourceResponse.cpp \ + JniOcPlatform.cpp \ + JniOcResource.cpp \ + JniOcResourceIdentifier.cpp + +LOCAL_LDLIBS := -llog +LOCAL_STATIC_LIBRARIES := android-oc +LOCAL_STATIC_LIBRARIES += android-octbstack +LOCAL_STATIC_LIBRARIES += android-coap +LOCAL_STATIC_LIBRARIES += android-oc_logger +LOCAL_STATIC_LIBRARIES += android-ca +LOCAL_STATIC_LIBRARIES += android_cpp11_compat + +LOCAL_CPPFLAGS += -std=c++0x +LOCAL_CPP_FEATURES := rtti exceptions +LOCAL_C_INCLUDES := $(OIC_SRC_PATH)/include +LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/stack/include +LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/ocsocket/include +LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/oc_logger/include +LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/../extlibs/boost/boost_1_58_0 +LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/../build_common/android/compatibility +include $(BUILD_SHARED_LIBRARY) diff --git a/android/android_api/base/jni/Application.mk b/android/android_api/base/jni/Application.mk new file mode 100755 index 0000000..089c9b3 --- /dev/null +++ b/android/android_api/base/jni/Application.mk @@ -0,0 +1,2 @@ +NDK_TOOLCHAIN_VERSION := 4.9 +APP_STL := gnustl_shared \ No newline at end of file diff --git a/android/android_api/base/jni/JniCaInterface.c b/android/android_api/base/jni/JniCaInterface.c new file mode 100644 index 0000000..eb1e07a --- /dev/null +++ b/android/android_api/base/jni/JniCaInterface.c @@ -0,0 +1,60 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 +#include +#include +#include "cainterface.h" +#include "JniCaInterface.h" + +#define LOG_TAG "JNI_CA_INTERFACE" +#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__) +#define LOGE(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__) + +JNIEXPORT jint JNI_OnLoad(JavaVM *jvm, void *reserved) +{ + LOGI("CaInterface_initialize"); + CANativeJNISetJavaVM(jvm); + + return JNI_VERSION_1_6; +} + +void JNI_OnUnload(JavaVM *jvm, void *reserved) +{ + return; +} + +JNIEXPORT void JNICALL +Java_org_iotivity_ca_CaInterface_initialize +(JNIEnv *env, jclass clazz, jobject context) +{ + LOGI("CaInterface_initialize"); + + CANativeJNISetContext(env, context); + + CAResult_t res = CAInitialize(); + + if (CA_STATUS_OK != res) + { + LOGE("Could not Initialize"); + } +} \ No newline at end of file diff --git a/android/android_api/base/jni/JniCaInterface.h b/android/android_api/base/jni/JniCaInterface.h new file mode 100644 index 0000000..ee77a97 --- /dev/null +++ b/android/android_api/base/jni/JniCaInterface.h @@ -0,0 +1,44 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 +// THIS FILE IS SUBJECT TO CHANGE DUE TO THE ONGOING DEVELOPMENT OF THE CA FOR ANDROID +// DO NOT REVIEW THIS FILE + +/* Header for class org_iotivity_ca_CaInterface */ + +#ifndef _Included_org_iotivity_ca_CaInterface +#define _Included_org_iotivity_ca_CaInterface +#ifdef __cplusplus +extern "C" { +#endif + /* + * Class: org_iotivity_ca_CaInterface_Initialize + * Method: Initialize + * Signature: (Landroid/content/Context;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_ca_CaInterface_initialize + (JNIEnv *, jclass, jobject); + +#ifdef __cplusplus +} +#endif +#endif \ No newline at end of file diff --git a/android/android_api/base/jni/JniEntityHandler.cpp b/android/android_api/base/jni/JniEntityHandler.cpp new file mode 100644 index 0000000..860d52b --- /dev/null +++ b/android/android_api/base/jni/JniEntityHandler.cpp @@ -0,0 +1,111 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniEntityHandler.h" +#include "JniOcResourceRequest.h" +#include "JniOcResourceResponse.h" +#include "JniUtils.h" + +JniEntityHandler::JniEntityHandler(JNIEnv *env, jobject entityHandler) +{ + m_jListener = env->NewGlobalRef(entityHandler); +} + +JniEntityHandler::~JniEntityHandler() +{ + LOGD("~JniEntityHandler"); + if (m_jListener) + { + jint ret; + JNIEnv *env = GetJNIEnv(ret); + if (NULL == env) return; + env->DeleteGlobalRef(m_jListener); + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + } +} + +OCEntityHandlerResult JniEntityHandler::handleEntity(const std::shared_ptr request) +{ + LOGD("JniEntityHandler_handleEntity"); + jint envRet; + JNIEnv *env = GetJNIEnv(envRet); + if (NULL == env) return OC_EH_ERROR; + + JniOcResourceRequest* jniResReq = new JniOcResourceRequest(request); + jlong reqHandle = reinterpret_cast(jniResReq); + jobject jResourceRequest = env->NewObject(g_cls_OcResourceRequest, g_mid_OcResourceRequest_N_ctor, + reqHandle); + if (!jResourceRequest) + { + LOGE("Failed to create OcResourceRequest"); + delete jniResReq; + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return OC_EH_ERROR; + } + + jclass clsL = env->GetObjectClass(m_jListener); + if (!clsL) + { + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return OC_EH_ERROR; + } + jmethodID midL = env->GetMethodID(clsL, "handleEntity", + "(Lorg/iotivity/base/OcResourceRequest;)Lorg/iotivity/base/EntityHandlerResult;"); + if (!midL) + { + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return OC_EH_ERROR; + } + jobject entityHandlerResult = env->CallObjectMethod(m_jListener, midL, jResourceRequest); + if (env->ExceptionCheck()) + { + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return OC_EH_ERROR; + } + if (!entityHandlerResult) + { + ThrowOcException(JNI_INVALID_VALUE, "EntityHandlerResult cannot be null"); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return OC_EH_ERROR; + } + jclass clsResult = env->GetObjectClass(entityHandlerResult); + if (!clsResult) + { + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return OC_EH_ERROR; + } + jmethodID getValue_ID = env->GetMethodID(clsResult, "getValue", "()I"); + if (!getValue_ID) + { + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return OC_EH_ERROR; + } + jint jResult = env->CallIntMethod(entityHandlerResult, getValue_ID); + if (env->ExceptionCheck()) + { + LOGE("Java exception is thrown"); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return OC_EH_ERROR; + } + + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return JniUtils::getOCEntityHandlerResult(env, static_cast(jResult)); +} \ No newline at end of file diff --git a/android/android_api/base/jni/JniEntityHandler.h b/android/android_api/base/jni/JniEntityHandler.h new file mode 100644 index 0000000..8cf3373 --- /dev/null +++ b/android/android_api/base/jni/JniEntityHandler.h @@ -0,0 +1,39 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOcStack.h" + +#ifndef _Included_org_iotivity_base_JniEntityHandler +#define _Included_org_iotivity_base_JniEntityHandler + +class JniEntityHandler +{ +public: + JniEntityHandler(JNIEnv *env, jobject listener); + ~JniEntityHandler(); + + OCEntityHandlerResult handleEntity(const std::shared_ptr request); + +private: + jobject m_jListener; +}; + +#endif \ No newline at end of file diff --git a/android/android_api/base/jni/JniListenerManager.cpp b/android/android_api/base/jni/JniListenerManager.cpp new file mode 100644 index 0000000..c9ccaa3 --- /dev/null +++ b/android/android_api/base/jni/JniListenerManager.cpp @@ -0,0 +1,103 @@ +///* +//* //****************************************************************** +//* // +//* // Copyright 2015 Intel Corporation. +//* // +//* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +//* // +//* // 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 "JniListenerManager.h" +// +//#include "JniOnGetListener.h" +// +//template +//T* JniListenerManager::addListener(JNIEnv* env, jobject jListener) +//{ +// T *onEventListener = NULL; +// +// m_mapMutex.lock(); +// +// for (auto it = m_listenerMap.begin(); it != m_listenerMap.end(); ++it) +// { +// if (env->IsSameObject(jListener, it->first)) +// { +// auto refPair = it->second; +// onEventListener = refPair.first; +// refPair.second++; +// it->second = refPair; +// m_listenerMap.insert(*it); +// LOGD("OnEventListener: ref. count is incremented"); +// break; +// } +// } +// +// if (!onEventListener) +// { +// onEventListener = new T(env, jListener, this); +// jobject jgListener = env->NewGlobalRef(jListener); +// +// m_listenerMap.insert(std::pair>(jgListener, std::pair(onEventListener, 1))); +// LOGD("OnEventListener: new listener"); +// } +// +// m_mapMutex.unlock(); +// +// return onEventListener; +//} +// +//template +//void JniListenerManager::removeListener(JNIEnv* env, jobject jListener) +//{ +// m_mapMutex.lock(); +// +// bool isFound = false; +// +// for (auto it = m_listenerMap.begin(); it != m_listenerMap.end(); ++it) +// { +// if (env->IsSameObject(jListener, it->first)) +// { +// auto refPair = it->second; +// if (refPair.second > 1) +// { +// refPair.second--; +// it->second = refPair; +// m_listenerMap.insert(*it); +// LOGI("OnEventListener: ref. count is decremented"); +// } +// else +// { +// env->DeleteGlobalRef(it->first); +// T* listener = refPair.first; +// delete listener; +// m_listenerMap.erase(it); +// +// LOGI("OnEventListener is removed"); +// } +// +// isFound = true; +// break; +// } +// } +// +// if (!isFound) +// { +// ThrowOcException(JNI_EXCEPTION, "OnEventListener isn't found"); +// } +// +// m_mapMutex.unlock(); +//} +// diff --git a/android/android_api/base/jni/JniListenerManager.h b/android/android_api/base/jni/JniListenerManager.h new file mode 100644 index 0000000..a43ea82 --- /dev/null +++ b/android/android_api/base/jni/JniListenerManager.h @@ -0,0 +1,125 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOcStack.h" +#include + +#ifndef _JniListenerManager +#define _JniListenerManager + +class JniOcResource; + +template +class JniListenerManager +{ +public: + T* addListener(JNIEnv* env, jobject jListener, JniOcResource* owner) + { + T *onEventListener = NULL; + + m_mapMutex.lock(); + + for (auto it = m_listenerMap.begin(); it != m_listenerMap.end(); ++it) + { + if (env->IsSameObject(jListener, it->first)) + { + auto refPair = it->second; + onEventListener = refPair.first; + refPair.second++; + it->second = refPair; + m_listenerMap.insert(*it); + LOGD("OnEventListener: ref. count is incremented"); + break; + } + } + if (!onEventListener) + { + onEventListener = new T(env, jListener, owner); + jobject jgListener = env->NewGlobalRef(jListener); + + if (jgListener) + { + m_listenerMap.insert(std::pair>(jgListener, std::pair(onEventListener, 1))); + } + else + { + LOGD("OnEventListener: Failed to create global listener ref."); + delete onEventListener; + } + LOGD("OnEventListener: new listener"); + } + m_mapMutex.unlock(); + return onEventListener; + } + + void removeListener(JNIEnv* env, jobject jListener) + { + m_mapMutex.lock(); + for (auto it = m_listenerMap.begin(); it != m_listenerMap.end(); ++it) + { + if (env->IsSameObject(jListener, it->first)) + { + auto refPair = it->second; + if (refPair.second > 1) + { + refPair.second--; + it->second = refPair; + m_listenerMap.insert(*it); + LOGI("OnEventListener: ref. count is decremented"); + } + else + { + env->DeleteGlobalRef(it->first); + T* listener = refPair.first; + delete listener; + m_listenerMap.erase(it); + + LOGI("OnEventListener is removed"); + } + break; + } + } + m_mapMutex.unlock(); + } + + void removeAllListeners(JNIEnv* env) + { + m_mapMutex.lock(); + + for (auto it = m_listenerMap.begin(); it != m_listenerMap.end(); ++it) + { + env->DeleteGlobalRef(it->first); + auto refPair = it->second; + T* listener = refPair.first; + delete listener; + m_listenerMap.erase(it); + } + + m_mapMutex.unlock(); + } + +private: + std::map> m_listenerMap; + std::mutex m_mapMutex; +}; + +#endif diff --git a/android/android_api/base/jni/JniOcPlatform.cpp b/android/android_api/base/jni/JniOcPlatform.cpp new file mode 100644 index 0000000..0a50d8e --- /dev/null +++ b/android/android_api/base/jni/JniOcPlatform.cpp @@ -0,0 +1,1591 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOcPlatform.h" +#include "OCPlatform.h" +#include "JniOcResource.h" +#include "JniOcResourceHandle.h" +#include "JniOcPresenceHandle.h" +#include "JniOcResourceResponse.h" +#include "JniUtils.h" + +using namespace OC; + +JniOnResourceFoundListener* AddOnResourceFoundListener(JNIEnv* env, jobject jListener) +{ + JniOnResourceFoundListener *onResourceFoundListener = NULL; + + resourceFoundMapLock.lock(); + + for (auto it = onResourceFoundListenerMap.begin(); it != onResourceFoundListenerMap.end(); ++it) + { + if (env->IsSameObject(jListener, it->first)) + { + auto refPair = it->second; + onResourceFoundListener = refPair.first; + refPair.second++; + it->second = refPair; + onResourceFoundListenerMap.insert(*it); + LOGD("OnResourceFoundListener: ref. count incremented"); + break; + } + } + + if (!onResourceFoundListener) + { + onResourceFoundListener = new JniOnResourceFoundListener(env, jListener, RemoveOnResourceFoundListener); + jobject jgListener = env->NewGlobalRef(jListener); + + onResourceFoundListenerMap.insert(std::pair < jobject, std::pair < JniOnResourceFoundListener*, + int >> (jgListener, std::pair(onResourceFoundListener, 1))); + LOGD("OnResourceFoundListener: new listener"); + } + resourceFoundMapLock.unlock(); + return onResourceFoundListener; +} + +void RemoveOnResourceFoundListener(JNIEnv* env, jobject jListener) +{ + resourceFoundMapLock.lock(); + + for (auto it = onResourceFoundListenerMap.begin(); it != onResourceFoundListenerMap.end(); ++it) + { + if (env->IsSameObject(jListener, it->first)) + { + auto refPair = it->second; + if (refPair.second > 1) + { + refPair.second--; + it->second = refPair; + onResourceFoundListenerMap.insert(*it); + LOGI("OnResourceFoundListener: ref. count decremented"); + } + else + { + env->DeleteGlobalRef(it->first); + JniOnResourceFoundListener* listener = refPair.first; + delete listener; + onResourceFoundListenerMap.erase(it); + LOGI("OnResourceFoundListener removed"); + } + break; + } + } + resourceFoundMapLock.unlock(); +} + +JniOnDeviceInfoListener* AddOnDeviceInfoListener(JNIEnv* env, jobject jListener) +{ + JniOnDeviceInfoListener *onDeviceInfoListener = NULL; + + deviceInfoMapLock.lock(); + + for (auto it = onDeviceInfoListenerMap.begin(); it != onDeviceInfoListenerMap.end(); ++it) + { + if (env->IsSameObject(jListener, it->first)) + { + auto refPair = it->second; + onDeviceInfoListener = refPair.first; + refPair.second++; + it->second = refPair; + onDeviceInfoListenerMap.insert(*it); + LOGD("OnDeviceInfoListener: ref. count incremented"); + break; + } + } + + if (!onDeviceInfoListener) + { + onDeviceInfoListener = new JniOnDeviceInfoListener(env, jListener, RemoveOnDeviceInfoListener); + jobject jgListener = env->NewGlobalRef(jListener); + + onDeviceInfoListenerMap.insert(std::pair < jobject, std::pair < JniOnDeviceInfoListener*, + int >> (jgListener, std::pair(onDeviceInfoListener, 1))); + LOGI("OnDeviceInfoListener: new listener"); + } + + deviceInfoMapLock.unlock(); + return onDeviceInfoListener; +} + +void RemoveOnDeviceInfoListener(JNIEnv* env, jobject jListener) +{ + deviceInfoMapLock.lock(); + bool isFound = false; + for (auto it = onDeviceInfoListenerMap.begin(); it != onDeviceInfoListenerMap.end(); ++it) + { + if (env->IsSameObject(jListener, it->first)) + { + auto refPair = it->second; + if (refPair.second > 1) + { + refPair.second--; + it->second = refPair; + onDeviceInfoListenerMap.insert(*it); + LOGI("OnDeviceInfoListener: ref. count decremented"); + } + else + { + env->DeleteGlobalRef(it->first); + JniOnDeviceInfoListener* listener = refPair.first; + delete listener; + onDeviceInfoListenerMap.erase(it); + + LOGI("OnDeviceInfoListener removed"); + } + + isFound = true; + break; + } + } + + if (!isFound) + { + ThrowOcException(JNI_EXCEPTION, "OnDeviceInfoListenet not found"); + } + deviceInfoMapLock.unlock(); +} + +JniOnPresenceListener* AddOnPresenceListener(JNIEnv* env, jobject jListener) +{ + JniOnPresenceListener *onPresenceListener = NULL; + + presenceMapLock.lock(); + + for (auto it = onPresenceListenerMap.begin(); it != onPresenceListenerMap.end(); ++it) + { + if (env->IsSameObject(jListener, it->first)) + { + auto refPair = it->second; + onPresenceListener = refPair.first; + refPair.second++; + it->second = refPair; + onPresenceListenerMap.insert(*it); + LOGD("OnPresenceListener: ref. count incremented"); + break; + } + } + if (!onPresenceListener) + { + onPresenceListener = new JniOnPresenceListener(env, jListener, RemoveOnPresenceListener); + jobject jgListener = env->NewGlobalRef(jListener); + onPresenceListenerMap.insert(std::pair < jobject, std::pair < JniOnPresenceListener*, + int >> (jgListener, std::pair(onPresenceListener, 1))); + LOGI("OnPresenceListener: new listener"); + } + presenceMapLock.unlock(); + return onPresenceListener; +} + +void RemoveOnPresenceListener(JNIEnv* env, jobject jListener) +{ + presenceMapLock.lock(); + bool isFound = false; + for (auto it = onPresenceListenerMap.begin(); it != onPresenceListenerMap.end(); ++it) + { + if (env->IsSameObject(jListener, it->first)) + { + auto refPair = it->second; + if (refPair.second > 1) + { + refPair.second--; + it->second = refPair; + onPresenceListenerMap.insert(*it); + LOGI("OnPresenceListener: ref. count decremented"); + } + else + { + env->DeleteGlobalRef(it->first); + JniOnPresenceListener* listener = refPair.first; + delete listener; + onPresenceListenerMap.erase(it); + LOGI("OnPresenceListener is removed"); + } + isFound = true; + break; + } + } + if (!isFound) + { + ThrowOcException(JNI_EXCEPTION, "OnPresenceListener not found"); + } + presenceMapLock.unlock(); +} + +/* +* Class: org_iotivity_base_OcPlatform +* Method: configure +* Signature: (IILjava/lang/String;II)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_configure +(JNIEnv *env, jclass clazz, jint jServiceType, jint jModeType, jstring jIpAddress, jint jPort, jint jQOS) +{ + LOGI("OcPlatform_configure"); + + std::string ipAddress; + if (jIpAddress) + { + ipAddress = env->GetStringUTFChars(jIpAddress, NULL); + } + uint16_t port; + if (jPort > 0) + { + port = static_cast(jPort); + } + PlatformConfig cfg{ + JniUtils::getServiceType(env, jServiceType), + JniUtils::getModeType(env, jModeType), + ipAddress, + port, + JniUtils::getQOS(env, static_cast(jQOS)) + }; + + OCPlatform::Configure(cfg); +} + +/* +* Class: org_iotivity_base_OcPlatform +* Method: notifyAllObservers0 +* Signature: (Lorg/iotivity/base/OcResourceHandle;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyAllObservers0 +(JNIEnv *env, jclass clazz, jobject jResourceHandle) +{ + LOGI("OcPlatform_notifyAllObservers"); + if (!jResourceHandle) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null"); + return; + } + + JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr( + env, jResourceHandle); + if (!jniOcResourceHandle) return; + + try + { + OCStackResult result = OCPlatform::notifyAllObservers(jniOcResourceHandle->getOCResourceHandle()); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "Failed to notify all observers"); + return; + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(OC_STACK_ERROR, e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcPlatform +* Method: notifyAllObservers1 +* Signature: (Lorg/iotivity/base/OcResourceHandle;I)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyAllObservers1 +(JNIEnv *env, jclass clazz, jobject jResourceHandle, jint jQoS) +{ + LOGI("OcPlatform_notifyAllObservers1"); + + if (!jResourceHandle) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null"); + return; + } + + JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr( + env, jResourceHandle); + if (!jniOcResourceHandle) return; + + try{ + OCStackResult result = OCPlatform::notifyAllObservers( + jniOcResourceHandle->getOCResourceHandle(), + JniUtils::getQOS(env, static_cast(jQoS))); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "Failed to notify all observers"); + return; + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(OC_STACK_ERROR, e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcPlatform +* Method: notifyListOfObservers2 +* Signature: (Lorg/iotivity/base/OcResourceHandle;[Ljava/lang/Byte;Lorg/iotivity/base/OcResourceResponse;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyListOfObservers2 +(JNIEnv *env, jclass clazz, jobject jResourceHandle, jbyteArray jObservationIdArr, jobject jResourceResponse) +{ + LOGD("OcPlatform_notifyListOfObservers2"); + if (!jResourceHandle) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null"); + return; + } + if (!jObservationIdArr) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "observationIdList cannot be null"); + return; + } + if (!jResourceResponse) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "resourceResponse cannot be null"); + return; + } + + JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr( + env, jResourceHandle); + if (!jniOcResourceHandle) return; + + JniOcResourceResponse* jniOcResourceResponse = JniOcResourceResponse::getJniOcResourceResponsePtr( + env, jResourceResponse); + if (!jniOcResourceResponse) return; + + int len = env->GetArrayLength(jObservationIdArr); + uint8_t* bArr = (uint8_t*)env->GetByteArrayElements(jObservationIdArr, 0); + + ObservationIds observationIds; + for (int i = 0; i < len; ++i) + { + observationIds.push_back(bArr[i]); + } + + env->ReleaseByteArrayElements(jObservationIdArr, (jbyte*)bArr, 0); + + try{ + OCStackResult result = OCPlatform::notifyListOfObservers( + jniOcResourceHandle->getOCResourceHandle(), + observationIds, + jniOcResourceResponse->getOCResourceResponse()); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "Failed to notify all observers"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(OC_STACK_ERROR, e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcPlatform +* Method: notifyListOfObservers3 +* Signature: (Lorg/iotivity/base/OcResourceHandle;[Ljava/lang/Byte;Lorg/iotivity/base/OcResourceResponse;I)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyListOfObservers3 +(JNIEnv *env, jclass clazz, jobject jResourceHandle, jbyteArray jObservationIdArr, jobject jResourceResponse, jint jQoS) +{ + LOGD("OcPlatform_notifyListOfObservers3"); + if (!jResourceHandle) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null"); + return; + } + if (!jObservationIdArr) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "observationIdList cannot be null"); + return; + } + if (!jResourceResponse) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "resourceResponse cannot be null"); + return; + } + + JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr( + env, jResourceHandle); + if (!jniOcResourceHandle) return; + + JniOcResourceResponse* jniOcResourceResponse = JniOcResourceResponse::getJniOcResourceResponsePtr( + env, jResourceResponse); + if (!jniOcResourceResponse) return; + + int len = env->GetArrayLength(jObservationIdArr); + uint8_t* bArr = (uint8_t*)env->GetByteArrayElements(jObservationIdArr, 0); + + ObservationIds observationIds; + for (int i = 0; i < len; ++i) + { + observationIds.push_back(bArr[i]); + } + + env->ReleaseByteArrayElements(jObservationIdArr, (jbyte*)bArr, 0); + + try{ + OCStackResult result = OCPlatform::notifyListOfObservers( + jniOcResourceHandle->getOCResourceHandle(), + observationIds, + jniOcResourceResponse->getOCResourceResponse(), + JniUtils::getQOS(env, static_cast(jQoS))); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "Failed to notify all observers"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(OC_STACK_ERROR, e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcPlatform +* Method: findResource0 +* Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnResourceFoundListener;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_findResource0 +(JNIEnv *env, jclass clazz, jstring jHost, jstring jResourceUri, jint jConnectivityType, jobject jListener) +{ + LOGD("OcPlatform_findResource"); + std::string host; + if (jHost) + { + host = env->GetStringUTFChars(jHost, NULL); + } + std::string resourceUri; + if (jResourceUri) + { + resourceUri = env->GetStringUTFChars(jResourceUri, NULL); + } + if (!jListener) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "onResourceFoundListener cannot be null"); + return; + } + + JniOnResourceFoundListener *onResFoundListener = AddOnResourceFoundListener(env, jListener); + + FindCallback findCallback = [onResFoundListener](std::shared_ptr resource) + { + onResFoundListener->foundResourceCallback(resource); + }; + + try + { + OCStackResult result = OCPlatform::findResource( + host, + resourceUri, + JniUtils::getConnectivityType(env, static_cast(jConnectivityType)), + findCallback); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "Find resource has failed"); + return; + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(OC_STACK_ERROR, e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcPlatform +* Method: findResource1 +* Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnResourceFoundListener;I)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_findResource1 +(JNIEnv *env, jclass clazz, jstring jHost, jstring jResourceUri, jint jConnectivityType, jobject jListener, jint jQoS) +{ + LOGD("OcPlatform_findResource"); + std::string host; + if (jHost) + { + host = env->GetStringUTFChars(jHost, NULL); + } + std::string resourceUri; + if (jResourceUri) + { + resourceUri = env->GetStringUTFChars(jResourceUri, NULL); + } + if (!jListener) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "onResourceFoundListener cannot be null"); + return; + } + JniOnResourceFoundListener *onResFoundListener = AddOnResourceFoundListener(env, jListener); + + FindCallback findCallback = [onResFoundListener](std::shared_ptr resource) + { + onResFoundListener->foundResourceCallback(resource); + }; + + try + { + OCStackResult result = OCPlatform::findResource( + host, + resourceUri, + JniUtils::getConnectivityType(env, static_cast(jConnectivityType)), + findCallback, + JniUtils::getQOS(env, static_cast(jQoS))); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "Find resource has failed"); + return; + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(OC_STACK_ERROR, e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcPlatform +* Method: getDeviceInfo0 +* Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnDeviceFoundListener;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getDeviceInfo0 +(JNIEnv *env, jclass clazz, jstring jHost, jstring jResourceUri, jint jConnectivityType, jobject jListener) +{ + LOGD("OcPlatform_getDeviceInfo0"); + std::string host; + if (jHost) + { + host = env->GetStringUTFChars(jHost, NULL); + } + std::string resourceUri; + if (jResourceUri) + { + resourceUri = env->GetStringUTFChars(jResourceUri, NULL); + } + if (!jListener) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "onDeviceFoundListener cannot be null"); + return; + } + JniOnDeviceInfoListener *onDeviceInfoListener = AddOnDeviceInfoListener(env, jListener); + + FindDeviceCallback findDeviceCallback = [onDeviceInfoListener](const OCRepresentation& ocRepresentation) + { + onDeviceInfoListener->foundDeviceCallback(ocRepresentation); + }; + + try + { + OCStackResult result = OCPlatform::getDeviceInfo( + host, + resourceUri, + JniUtils::getConnectivityType(env, static_cast(jConnectivityType)), + findDeviceCallback); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "Find device has failed"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(OC_STACK_ERROR, e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcPlatform +* Method: getDeviceInfo1 +* Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnDeviceFoundListener;I)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getDeviceInfo1 +(JNIEnv *env, jclass clazz, jstring jHost, jstring jResourceUri, jint jConnectivityType, jobject jListener, jint jQoS) +{ + LOGD("OcPlatform_getDeviceInfo1"); + std::string host; + if (jHost) + { + host = env->GetStringUTFChars(jHost, NULL); + } + std::string resourceUri; + if (jResourceUri) + { + resourceUri = env->GetStringUTFChars(jResourceUri, NULL); + } + if (!jListener) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "onDeviceFoundListener cannot be null"); + return; + } + JniOnDeviceInfoListener *onDeviceInfoListener = AddOnDeviceInfoListener(env, jListener); + + FindDeviceCallback findDeviceCallback = [onDeviceInfoListener](const OCRepresentation& ocRepresentation) + { + onDeviceInfoListener->foundDeviceCallback(ocRepresentation); + }; + + try + { + OCStackResult result = OCPlatform::getDeviceInfo( + host, + resourceUri, + JniUtils::getConnectivityType(env, static_cast(jConnectivityType)), + findDeviceCallback, + JniUtils::getQOS(env, static_cast(jQoS))); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "Find device has failed"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(OC_STACK_ERROR, e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcPlatform +* Method: registerResource0 +* Signature: (Lorg/iotivity/base/OcResource;)Lorg/iotivity/base/OcResourceHandle; +*/ +JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_registerResource0 +(JNIEnv *env, jclass clazz, jobject jResource) +{ + LOGD("OcPlatform_registerResource"); + if (!jResource) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "Resource cannot be null"); + return nullptr; + } + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, jResource); + if (!resource) return nullptr; + + OCResourceHandle resourceHandle; + try + { + OCStackResult result = OCPlatform::registerResource( + resourceHandle, + resource->getOCResource()); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "register resource"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(OC_STACK_ERROR, e.reason().c_str()); + return nullptr; + } + + JniOcResourceHandle* jniHandle = new JniOcResourceHandle(resourceHandle); + jlong handle = reinterpret_cast(jniHandle); + jobject jResourceHandle = env->NewObject(g_cls_OcResourceHandle, g_mid_OcResourceHandle_N_ctor, handle); + if (!jResourceHandle) + { + LOGE("Failed to create OcResourceHandle"); + delete jniHandle; + } + return jResourceHandle; +} + +/* +* Class: org_iotivity_base_OcPlatform +* Method: registerResource1 +* Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcPlatform/EntityHandler;I)Lorg/iotivity/base/OcResourceHandle; +*/ +JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_registerResource1 +(JNIEnv *env, jclass clazz, jstring jResourceUri, jstring jResourceTypeName, jstring jResourceInterface, +jobject jListener, jint jResourceProperty) +{ + LOGI("OcPlatform_registerResource1"); + std::string resourceUri; + if (jResourceUri) + { + resourceUri = env->GetStringUTFChars(jResourceUri, NULL); + } + std::string resourceTypeName; + if (jResourceTypeName) + { + resourceTypeName = env->GetStringUTFChars(jResourceTypeName, NULL); + } + std::string resourceInterface; + if (jResourceInterface) + { + resourceInterface = env->GetStringUTFChars(jResourceInterface, NULL); + } + if (!jListener) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "entityHandler cannot be null"); + return nullptr; + } + JniEntityHandler* entityHandler = new JniEntityHandler(env, jListener); + EntityHandler handleEntityCallback = [entityHandler](const std::shared_ptr request) -> + OCEntityHandlerResult{ + return entityHandler->handleEntity(request); + }; + + OCResourceHandle resourceHandle; + try + { + OCStackResult result = OCPlatform::registerResource( + resourceHandle, + resourceUri, + resourceTypeName, + resourceInterface, + handleEntityCallback, + static_cast(jResourceProperty)); + + if (OC_STACK_OK != result) + { + delete entityHandler; + ThrowOcException(result, "register resource"); + return nullptr; + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + delete entityHandler; + ThrowOcException(OC_STACK_ERROR, e.reason().c_str()); + return nullptr; + } + + JniOcResourceHandle* jniHandle = new JniOcResourceHandle(resourceHandle); + jlong handle = reinterpret_cast(jniHandle); + jobject jResourceHandle = env->NewObject(g_cls_OcResourceHandle, g_mid_OcResourceHandle_N_ctor, handle); + if (!jResourceHandle) + { + LOGE("Failed to create OcResourceHandle"); + delete jniHandle; + } + + return jResourceHandle; +} + +/* +* Class: org_iotivity_base_OcPlatform +* Method: registerDeviceInfo0 +* Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_registerDeviceInfo0 +(JNIEnv *env, +jclass clazz, +jstring jDeviceName, +jstring jHostName, +jstring jDeviceUUID, +jstring jContentType, +jstring jVersion, +jstring jManufacturerName, +jstring jManufacturerUrl, +jstring jModelNumber, +jstring jDateOfManufacture, +jstring jPlatformVersion, +jstring jFirmwareVersion, +jstring jSupportUrl) +{ + LOGI("OcPlatform_registerDeviceInfo"); + + std::string deviceName; + if (jDeviceName) + { + deviceName = env->GetStringUTFChars(jDeviceName, NULL); + } + std::string hostName; + if (jHostName) + { + hostName = env->GetStringUTFChars(jHostName, NULL); + } + std::string deviceUUID; + if (jDeviceUUID) + { + deviceUUID = env->GetStringUTFChars(jDeviceUUID, NULL); + } + std::string contentType; + if (jContentType) + { + contentType = env->GetStringUTFChars(jContentType, NULL); + } + std::string version; + if (jVersion) + { + version = env->GetStringUTFChars(jVersion, NULL); + } + std::string manufacturerName; + if (jManufacturerName) + { + manufacturerName = env->GetStringUTFChars(jManufacturerName, NULL); + } + std::string manufacturerUrl; + if (jManufacturerUrl) + { + manufacturerUrl = env->GetStringUTFChars(jManufacturerUrl, NULL); + } + std::string modelNumber; + if (jModelNumber) + { + modelNumber = env->GetStringUTFChars(jModelNumber, NULL); + } + std::string dateOfManufacture; + if (jDateOfManufacture) + { + dateOfManufacture = env->GetStringUTFChars(jDateOfManufacture, NULL); + } + std::string platformVersion; + if (jPlatformVersion) + { + platformVersion = env->GetStringUTFChars(jPlatformVersion, NULL); + } + std::string firmwareVersion; + if (jFirmwareVersion) + { + firmwareVersion = env->GetStringUTFChars(jFirmwareVersion, NULL); + } + std::string supportUrl; + if (jSupportUrl) + { + supportUrl = env->GetStringUTFChars(jSupportUrl, NULL); + } + + OCDeviceInfo deviceInfo; + try + { + DuplicateString(&deviceInfo.contentType, contentType); + DuplicateString(&deviceInfo.dateOfManufacture, dateOfManufacture); + DuplicateString(&deviceInfo.deviceName, deviceName); + DuplicateString(&deviceInfo.deviceUUID, deviceUUID); + DuplicateString(&deviceInfo.firmwareVersion, firmwareVersion); + DuplicateString(&deviceInfo.hostName, hostName); + DuplicateString(&deviceInfo.manufacturerName, manufacturerName); + DuplicateString(&deviceInfo.manufacturerUrl, manufacturerUrl); + DuplicateString(&deviceInfo.modelNumber, modelNumber); + DuplicateString(&deviceInfo.platformVersion, platformVersion); + DuplicateString(&deviceInfo.supportUrl, supportUrl); + DuplicateString(&deviceInfo.version, version); + } + catch (std::exception &e) + { + ThrowOcException(JNI_EXCEPTION, "Failed to register device info"); + return; + } + + try + { + OCStackResult result = OCPlatform::registerDeviceInfo(deviceInfo); + + delete deviceInfo.contentType; + delete deviceInfo.dateOfManufacture; + delete deviceInfo.deviceName; + delete deviceInfo.deviceUUID; + delete deviceInfo.firmwareVersion; + delete deviceInfo.hostName; + delete deviceInfo.manufacturerName; + delete deviceInfo.manufacturerUrl; + delete deviceInfo.modelNumber; + delete deviceInfo.platformVersion; + delete deviceInfo.supportUrl; + delete deviceInfo.version; + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "Failed to register device info"); + return; + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(OC_STACK_ERROR, e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcPlatform +* Method: unregisterResource0 +* Signature: (Lorg/iotivity/base/OcResourceHandle;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unregisterResource0 +(JNIEnv *env, jclass clazz, jobject jResourceHandle) +{ + LOGI("OcPlatform_unregisterResource"); + if (!jResourceHandle) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null"); + return; + } + JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr( + env, jResourceHandle); + if (!jniOcResourceHandle) return; + + try + { + OCResourceHandle resHandle = jniOcResourceHandle->getOCResourceHandle(); + OCStackResult result = OCPlatform::unregisterResource(resHandle); + if (OC_STACK_OK != result) + { + ThrowOcException(result, "Failed to unregister resource"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(OC_STACK_ERROR, e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcPlatform +* Method: bindResource0 +* Signature: (Lorg/iotivity/base/OcResourceHandle;Lorg/iotivity/base/OcResourceHandle;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindResource0 +(JNIEnv *env, jclass clazz, jobject jResourceCollectionHandle, jobject jResourceHandle) +{ + LOGI("OcPlatform_bindResource"); + if (!jResourceCollectionHandle) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "resourceCollectionHandle cannot be null"); + return; + } + if (!jResourceHandle) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null"); + return; + } + JniOcResourceHandle* jniOcResourceCollectionHandle = JniOcResourceHandle::getJniOcResourceHandlePtr( + env, jResourceCollectionHandle); + if (!jniOcResourceCollectionHandle) return; + + JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr( + env, jResourceHandle); + if (!jniOcResourceHandle) return; + + try + { + OCStackResult result = OCPlatform::bindResource( + jniOcResourceCollectionHandle->getOCResourceHandle(), + jniOcResourceHandle->getOCResourceHandle() + ); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "Failed to bind resource"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(OC_STACK_ERROR, e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcPlatform +* Method: bindResources0 +* Signature: (Lorg/iotivity/base/OcResourceHandle;[Lorg/iotivity/base/OcResourceHandle;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindResources0 +(JNIEnv *env, jclass clazz, jobject jResourceCollectionHandle, jobjectArray jResourceHandleArray) +{ + LOGI("OcPlatform_bindResources"); + + if (!jResourceCollectionHandle) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "resourceCollectionHandle cannot be null"); + return; + } + if (!jResourceHandleArray) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandleList cannot be null"); + return; + } + + JniOcResourceHandle* jniOcResourceCollectionHandle = JniOcResourceHandle::getJniOcResourceHandlePtr( + env, jResourceCollectionHandle); + if (!jniOcResourceCollectionHandle) return; + + std::vector resourceHandleList; + int len = env->GetArrayLength(jResourceHandleArray); + for (int i = 0; i < len; ++i) + { + jobject jResourceHandle = env->GetObjectArrayElement(jResourceHandleArray, i); + if (!jResourceHandle) + { + ThrowOcException(JNI_EXCEPTION, "resource handle cannot be null"); + return; + } + + JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr( + env, jResourceHandle); + if (!jniOcResourceHandle) return; + + resourceHandleList.push_back( + jniOcResourceHandle->getOCResourceHandle()); + } + + try + { + OCStackResult result = OCPlatform::bindResources( + jniOcResourceCollectionHandle->getOCResourceHandle(), + resourceHandleList + ); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "Failed to bind resources"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(OC_STACK_ERROR, e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcPlatform +* Method: unbindResource0 +* Signature: (Lorg/iotivity/base/OcResourceHandle;Lorg/iotivity/base/OcResourceHandle;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unbindResource0 +(JNIEnv *env, jclass clazz, jobject jResourceCollectionHandle, jobject jResourceHandle) +{ + LOGI("OcPlatform_unbindResource"); + if (!jResourceCollectionHandle) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "resourceCollectionHandle cannot be null"); + return; + } + if (!jResourceHandle) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null"); + return; + } + + JniOcResourceHandle* jniOcResourceCollectionHandle = JniOcResourceHandle::getJniOcResourceHandlePtr( + env, jResourceCollectionHandle); + if (!jniOcResourceCollectionHandle) return; + + JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr( + env, jResourceHandle); + if (!jniOcResourceHandle) return; + + try + { + OCStackResult result = OCPlatform::unbindResource( + jniOcResourceCollectionHandle->getOCResourceHandle(), + jniOcResourceHandle->getOCResourceHandle() + ); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "Failed to unbind resource"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(OC_STACK_ERROR, e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcPlatform +* Method: unbindResources0 +* Signature: (Lorg/iotivity/base/OcResourceHandle;[Lorg/iotivity/base/OcResourceHandle;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unbindResources0 +(JNIEnv *env, jclass clazz, jobject jResourceCollectionHandle, jobjectArray jResourceHandleArray) +{ + LOGI("OcPlatform_unbindResources"); + if (!jResourceCollectionHandle) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "resourceCollectionHandle cannot be null"); + return; + } + if (!jResourceHandleArray) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandleList cannot be null"); + return; + } + + JniOcResourceHandle* jniOcResourceCollectionHandle = JniOcResourceHandle::getJniOcResourceHandlePtr( + env, jResourceCollectionHandle); + if (!jniOcResourceCollectionHandle) return; + + std::vector resourceHandleList; + int len = env->GetArrayLength(jResourceHandleArray); + for (int i = 0; i < len; ++i) + { + jobject jResourceHandle = env->GetObjectArrayElement(jResourceHandleArray, i); + if (!jResourceHandle) + { + ThrowOcException(JNI_EXCEPTION, "resource handle cannot be null"); + return; + } + + JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr( + env, jResourceHandle); + if (!jniOcResourceHandle) return; + + resourceHandleList.push_back( + jniOcResourceHandle->getOCResourceHandle()); + } + + try + { + OCStackResult result = OCPlatform::unbindResources( + jniOcResourceCollectionHandle->getOCResourceHandle(), + resourceHandleList + ); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "Failed to unbind resources"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(OC_STACK_ERROR, e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcPlatform +* Method: bindTypeToResource0 +* Signature: (Lorg/iotivity/base/OcResourceHandle;Ljava/lang/String;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindTypeToResource0 +(JNIEnv *env, jclass clazz, jobject jResourceHandle, jstring jResourceTypeName) +{ + LOGI("OcPlatform_bindTypeToResource"); + if (!jResourceHandle) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null"); + return; + } + std::string typeName; + if (jResourceTypeName) + { + typeName = env->GetStringUTFChars(jResourceTypeName, NULL); + } + + JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr( + env, jResourceHandle); + if (!jniOcResourceHandle) return; + + try + { + OCStackResult result = OCPlatform::bindTypeToResource( + jniOcResourceHandle->getOCResourceHandle(), + typeName + ); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "Failed to bind type to resource"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(OC_STACK_ERROR, e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcPlatform +* Method: bindInterfaceToResource0 +* Signature: (Lorg/iotivity/base/OcResourceHandle;Ljava/lang/String;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindInterfaceToResource0 +(JNIEnv *env, jclass clazz, jobject jResourceHandle, jstring jResourceInterfaceName) +{ + LOGI("OcPlatform_bindInterfaceToResource"); + if (!jResourceHandle) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null"); + return; + } + std::string interfaceName; + if (jResourceInterfaceName) + { + interfaceName = env->GetStringUTFChars(jResourceInterfaceName, NULL); + } + + JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr( + env, jResourceHandle); + if (!jniOcResourceHandle) return; + + try + { + OCStackResult result = OCPlatform::bindInterfaceToResource( + jniOcResourceHandle->getOCResourceHandle(), + interfaceName + ); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "Failed to bind interface to resource"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(OC_STACK_ERROR, e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcPlatform +* Method: startPresence0 +* Signature: (I)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_startPresence0 +(JNIEnv *env, jclass clazz, jint ttl) +{ + LOGI("OcPlatform_startPresence"); + + try + { + OCStackResult result = OCPlatform::startPresence((unsigned int)ttl); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "Failed to start presence"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(OC_STACK_ERROR, e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcPlatform +* Method: stopPresence0 +* Signature: ()V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_stopPresence0 +(JNIEnv *env, jclass clazz) +{ + LOGI("OcPlatform_stopPresence"); + + try + { + OCStackResult result = OCPlatform::stopPresence(); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "Failed to stop presence"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(OC_STACK_ERROR, e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcPlatform +* Method: subscribePresence0 +* Signature: (Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnPresenceListener;)Lorg/iotivity/base/OcPresenceHandle; +*/ +JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_subscribePresence0 +(JNIEnv *env, jclass clazz, jstring jHost, jint jConnectivityType, jobject jListener) +{ + LOGD("OcPlatform_subscribePresence"); + std::string host; + if (jHost) + { + host = env->GetStringUTFChars(jHost, NULL); + } + if (!jListener) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "onPresenceListener cannot be null"); + return nullptr; + } + + JniOnPresenceListener *onPresenceListener = AddOnPresenceListener(env, jListener); + + SubscribeCallback subscribeCallback = [onPresenceListener](OCStackResult result, const unsigned int nonce, + const std::string& hostAddress) + { + onPresenceListener->onPresenceCallback(result, nonce, hostAddress); + }; + + OCPlatform::OCPresenceHandle presenceHandle; + try + { + OCStackResult result = OCPlatform::subscribePresence( + presenceHandle, + host, + JniUtils::getConnectivityType(env, static_cast(jConnectivityType)), + subscribeCallback); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "subscribe presence has failed"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(OC_STACK_ERROR, e.reason().c_str()); + return nullptr; + } + + JniOcPresenceHandle* jniPresenceHandle = new JniOcPresenceHandle(onPresenceListener, presenceHandle); + jlong jhandle = reinterpret_cast(jniPresenceHandle); + jobject jPresenceHandle = env->NewObject(g_cls_OcPresenceHandle, g_mid_OcPresenceHandle_N_ctor, jhandle); + if (!jPresenceHandle) + { + LOGE("Failed to create OcPresenceHandle"); + delete jniPresenceHandle; + } + + return jPresenceHandle; +} + +/* +* Class: org_iotivity_base_OcPlatform +* Method: subscribePresence1 +* Signature: (Ljava/lang/String;Ljava/lang/String;I +Lorg/iotivity/base/OcPlatform/OnPresenceListener;)Lorg/iotivity/base/OcPresenceHandle; +*/ +JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_subscribePresence1 +(JNIEnv *env, jclass clazz, jstring jHost, jstring jResourceType, jint jConnectivityType, jobject jListener) +{ + LOGD("OcPlatform_subscribePresence1"); + std::string host; + if (jHost) + { + host = env->GetStringUTFChars(jHost, NULL); + } + std::string resourceType; + if (jResourceType) + { + resourceType = env->GetStringUTFChars(jResourceType, NULL); + } + if (!jListener) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "onPresenceListener cannot be null"); + return nullptr; + } + + JniOnPresenceListener *onPresenceListener = AddOnPresenceListener(env, jListener); + + SubscribeCallback subscribeCallback = [onPresenceListener](OCStackResult result, + const unsigned int nonce, const std::string& hostAddress) + { + onPresenceListener->onPresenceCallback(result, nonce, hostAddress); + }; + + OCPlatform::OCPresenceHandle presenceHandle; + try + { + OCStackResult result = OCPlatform::subscribePresence( + presenceHandle, + host, + resourceType, + JniUtils::getConnectivityType(env, static_cast(jConnectivityType)), + subscribeCallback); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "subscribe presence has failed"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(OC_STACK_ERROR, e.reason().c_str()); + return nullptr; + } + + JniOcPresenceHandle* jniPresenceHandle = new JniOcPresenceHandle(onPresenceListener, presenceHandle); + jlong jhandle = reinterpret_cast(jniPresenceHandle); + jobject jPresenceHandle = env->NewObject(g_cls_OcPresenceHandle, g_mid_OcPresenceHandle_N_ctor, jhandle); + if (!jPresenceHandle) + { + LOGE("Failed to create OcPresenceHandle"); + delete jniPresenceHandle; + } + return jPresenceHandle; +} + +/* +* Class: org_iotivity_base_OcPlatform +* Method: unsubscribePresence0 +* Signature: (Lorg/iotivity/base/OcPresenceHandle;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unsubscribePresence0 +(JNIEnv *env, jclass clazz, jobject jPresenceHandle) +{ + LOGD("OcPlatform_unsubscribePresence"); + if (!jPresenceHandle) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "presenceHandle cannot be null"); + return; + } + JniOcPresenceHandle* jniPresenceHandle = JniOcPresenceHandle::getJniOcPresenceHandlePtr(env, jPresenceHandle); + if (!jniPresenceHandle) return; + + OCPresenceHandle presenceHandle = jniPresenceHandle->getOCPresenceHandle(); + + try + { + OCStackResult result = OCPlatform::unsubscribePresence(presenceHandle); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "unsubscribe presence has failed"); + return; + } + jweak jwOnPresenceListener = jniPresenceHandle->getJniOnPresenceListener()->getJWListener(); + if (jwOnPresenceListener) + { + RemoveOnPresenceListener(env, jwOnPresenceListener); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(OC_STACK_ERROR, e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcPlatform +* Method: constructResourceObject0 +* Signature: (Ljava/lang/String;Ljava/lang/String;IZ[Ljava/lang/String;[Ljava/lang/String;) +Lorg/iotivity/base/OcResource; +*/ +JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_constructResourceObject0 +(JNIEnv *env, jclass clazz, jstring jHost, jstring jUri, jint jConnectivityType, +jboolean jIsObservable, jobjectArray jResourceTypeArray, jobjectArray jInterfaceArray) +{ + LOGD("OcPlatform_constructResourceObject"); + std::string host; + if (jHost) + { + host = env->GetStringUTFChars(jHost, NULL); + } + std::string uri; + if (jUri) + { + uri = env->GetStringUTFChars(jUri, NULL); + } + if (!jResourceTypeArray) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "resourceTypeList cannot be null"); + return nullptr; + } + if (!jInterfaceArray) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "interfaceList cannot be null"); + return nullptr; + } + + std::vector resourceTypes; + JniUtils::convertJavaStrArrToStrVector(env, jResourceTypeArray, resourceTypes); + + std::vector interfaces; + JniUtils::convertJavaStrArrToStrVector(env, jInterfaceArray, interfaces); + + std::shared_ptr resource = OCPlatform::constructResourceObject( + host, + uri, + JniUtils::getConnectivityType(env, static_cast(jConnectivityType)), + static_cast(jIsObservable), + resourceTypes, + interfaces); + + if (!resource) + { + ThrowOcException(OC_STACK_ERROR, "Failed to create OCResource"); + return nullptr; + } + + JniOcResource *jniOcResource = new JniOcResource(resource); + jlong handle = reinterpret_cast(jniOcResource); + + jobject jResource = env->NewObject(g_cls_OcResource, g_mid_OcResource_ctor); + if (!jResource) + { + delete jniOcResource; + return nullptr; + } + SetHandle(env, jResource, jniOcResource); + if (env->ExceptionCheck()) + { + delete jniOcResource; + return nullptr; + } + return jResource; +} + +/* +* Class: org_iotivity_base_OcPlatform +* Method: sendResponse0 +* Signature: (Lorg/iotivity/base/OcResourceResponse;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_sendResponse0 +(JNIEnv *env, jclass clazz, jobject jResourceResponse) +{ + LOGD("OcPlatform_sendResponse"); + if (!jResourceResponse) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "resourceResponse cannot be null"); + return; + } + + JniOcResourceResponse *jniResponse = JniOcResourceResponse::getJniOcResourceResponsePtr( + env, jResourceResponse); + if (!jniResponse) return; + + try + { + OCStackResult result = OCPlatform::sendResponse(jniResponse->getOCResourceResponse()); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "failed to send response"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(OC_STACK_ERROR, e.reason().c_str()); + } +} \ No newline at end of file diff --git a/android/android_api/base/jni/JniOcPlatform.h b/android/android_api/base/jni/JniOcPlatform.h new file mode 100644 index 0000000..1019147 --- /dev/null +++ b/android/android_api/base/jni/JniOcPlatform.h @@ -0,0 +1,264 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOcStack.h" +#include "JniOnResourceFoundListener.h" +#include "JniOnDeviceInfoListener.h" +#include "JniOnPresenceListener.h" +#include + +#ifndef _Included_org_iotivity_base_OcPlatform +#define _Included_org_iotivity_base_OcPlatform + +using namespace OC; + +JniOnResourceFoundListener* AddOnResourceFoundListener(JNIEnv* env, jobject jListener); +void RemoveOnResourceFoundListener(JNIEnv* env, jobject jListener); + +JniOnDeviceInfoListener* AddOnDeviceInfoListener(JNIEnv* env, jobject jListener); +void RemoveOnDeviceInfoListener(JNIEnv* env, jobject jListener); + +JniOnPresenceListener* AddOnPresenceListener(JNIEnv* env, jobject jListener); +void RemoveOnPresenceListener(JNIEnv* env, jobject jListener); + +std::map> onResourceFoundListenerMap; +std::map> onDeviceInfoListenerMap; +std::map> onPresenceListenerMap; + +std::mutex resourceFoundMapLock; +std::mutex deviceInfoMapLock; +std::mutex presenceMapLock; + +#ifdef __cplusplus +extern "C" { +#endif + /* + * Class: org_iotivity_base_OcPlatform + * Method: configure + * Signature: (IILjava/lang/String;II)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_configure + (JNIEnv *, jclass, jint, jint, jstring, jint, jint); + + /* + * Class: org_iotivity_base_OcPlatform + * Method: notifyAllObservers0 + * Signature: (Lorg/iotivity/base/OcResourceHandle;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyAllObservers0 + (JNIEnv *, jclass, jobject); + + /* + * Class: org_iotivity_base_OcPlatform + * Method: notifyAllObservers1 + * Signature: (Lorg/iotivity/base/OcResourceHandle;I)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyAllObservers1 + (JNIEnv *, jclass, jobject, jint); + + /* + * Class: org_iotivity_base_OcPlatform + * Method: notifyListOfObservers2 + * Signature: (Lorg/iotivity/base/OcResourceHandle;[BLorg/iotivity/base/OcResourceResponse;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyListOfObservers2 + (JNIEnv *, jclass, jobject, jbyteArray, jobject); + + /* + * Class: org_iotivity_base_OcPlatform + * Method: notifyListOfObservers3 + * Signature: (Lorg/iotivity/base/OcResourceHandle;[BLorg/iotivity/base/OcResourceResponse;I)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyListOfObservers3 + (JNIEnv *, jclass, jobject, jbyteArray, jobject, jint); + + /* + * Class: org_iotivity_base_OcPlatform + * Method: findResource0 + * Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnResourceFoundListener;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_findResource0 + (JNIEnv *, jclass, jstring, jstring, jint, jobject); + + /* + * Class: org_iotivity_base_OcPlatform + * Method: findResource1 + * Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnResourceFoundListener;I)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_findResource1 + (JNIEnv *, jclass, jstring, jstring, jint, jobject, jint); + + /* + * Class: org_iotivity_base_OcPlatform + * Method: getDeviceInfo0 + * Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnDeviceFoundListener;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getDeviceInfo0 + (JNIEnv *, jclass, jstring, jstring, jint, jobject); + + /* + * Class: org_iotivity_base_OcPlatform + * Method: getDeviceInfo1 + * Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnDeviceFoundListener;I)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getDeviceInfo1 + (JNIEnv *, jclass, jstring, jstring, jint, jobject, jint); + + /* + * Class: org_iotivity_base_OcPlatform + * Method: registerResource0 + * Signature: (Lorg/iotivity/base/OcResource;)Lorg/iotivity/base/OcResourceHandle; + */ + JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_registerResource0 + (JNIEnv *, jclass, jobject); + + /* + * Class: org_iotivity_base_OcPlatform + * Method: registerResource1 + * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcPlatform/EntityHandler;I)Lorg/iotivity/base/OcResourceHandle; + */ + JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_registerResource1 + (JNIEnv *, jclass, jstring, jstring, jstring, jobject, jint); + + /* + * Class: org_iotivity_base_OcPlatform + * Method: registerDeviceInfo0 + * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_registerDeviceInfo0 + (JNIEnv *, jclass, jstring, jstring, jstring, jstring, jstring, jstring, jstring, jstring, jstring, jstring, jstring, jstring); + + /* + * Class: org_iotivity_base_OcPlatform + * Method: unregisterResource0 + * Signature: (Lorg/iotivity/base/OcResourceHandle;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unregisterResource0 + (JNIEnv *, jclass, jobject); + + /* + * Class: org_iotivity_base_OcPlatform + * Method: bindResource0 + * Signature: (Lorg/iotivity/base/OcResourceHandle;Lorg/iotivity/base/OcResourceHandle;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindResource0 + (JNIEnv *, jclass, jobject, jobject); + + /* + * Class: org_iotivity_base_OcPlatform + * Method: bindResources0 + * Signature: (Lorg/iotivity/base/OcResourceHandle;[Lorg/iotivity/base/OcResourceHandle;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindResources0 + (JNIEnv *, jclass, jobject, jobjectArray); + + /* + * Class: org_iotivity_base_OcPlatform + * Method: unbindResource0 + * Signature: (Lorg/iotivity/base/OcResourceHandle;Lorg/iotivity/base/OcResourceHandle;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unbindResource0 + (JNIEnv *, jclass, jobject, jobject); + + /* + * Class: org_iotivity_base_OcPlatform + * Method: unbindResources0 + * Signature: (Lorg/iotivity/base/OcResourceHandle;[Lorg/iotivity/base/OcResourceHandle;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unbindResources0 + (JNIEnv *, jclass, jobject, jobjectArray); + + /* + * Class: org_iotivity_base_OcPlatform + * Method: bindTypeToResource0 + * Signature: (Lorg/iotivity/base/OcResourceHandle;Ljava/lang/String;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindTypeToResource0 + (JNIEnv *, jclass, jobject, jstring); + + /* + * Class: org_iotivity_base_OcPlatform + * Method: bindInterfaceToResource0 + * Signature: (Lorg/iotivity/base/OcResourceHandle;Ljava/lang/String;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindInterfaceToResource0 + (JNIEnv *, jclass, jobject, jstring); + + /* + * Class: org_iotivity_base_OcPlatform + * Method: startPresence0 + * Signature: (I)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_startPresence0 + (JNIEnv *, jclass, jint); + + /* + * Class: org_iotivity_base_OcPlatform + * Method: stopPresence0 + * Signature: ()V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_stopPresence0 + (JNIEnv *, jclass); + + /* + * Class: org_iotivity_base_OcPlatform + * Method: subscribePresence0 + * Signature: (Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnPresenceListener;)Lorg/iotivity/base/OcPresenceHandle; + */ + JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_subscribePresence0 + (JNIEnv *, jclass, jstring, jint, jobject); + + /* + * Class: org_iotivity_base_OcPlatform + * Method: subscribePresence1 + * Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnPresenceListener;)Lorg/iotivity/base/OcPresenceHandle; + */ + JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_subscribePresence1 + (JNIEnv *, jclass, jstring, jstring, jint, jobject); + + /* + * Class: org_iotivity_base_OcPlatform + * Method: unsubscribePresence0 + * Signature: (Lorg/iotivity/base/OcPresenceHandle;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unsubscribePresence0 + (JNIEnv *, jclass, jobject); + + /* + * Class: org_iotivity_base_OcPlatform + * Method: constructResourceObject0 + * Signature: (Ljava/lang/String;Ljava/lang/String;IZ[Ljava/lang/String;[Ljava/lang/String;)Lorg/iotivity/base/OcResource; + */ + JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_constructResourceObject0 + (JNIEnv *, jclass, jstring, jstring, jint, jboolean, jobjectArray, jobjectArray); + + /* + * Class: org_iotivity_base_OcPlatform0 + * Method: sendResponse0 + * Signature: (Lorg/iotivity/base/OcResourceResponse;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_sendResponse0 + (JNIEnv *, jclass, jobject); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/android/android_api/base/jni/JniOcPresenceHandle.cpp b/android/android_api/base/jni/JniOcPresenceHandle.cpp new file mode 100644 index 0000000..83950bc --- /dev/null +++ b/android/android_api/base/jni/JniOcPresenceHandle.cpp @@ -0,0 +1,73 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOcPresenceHandle.h" +#include "OCPlatform.h" + +JniOcPresenceHandle::JniOcPresenceHandle(JniOnPresenceListener* jniListener, OCPresenceHandle presenceHandle) + : m_jniListener(jniListener), m_presenceHandle(presenceHandle) +{} + +JniOcPresenceHandle::~JniOcPresenceHandle() +{ + LOGD("~JniOcPresenceHandle()"); + + //delete m_jniListener; + m_presenceHandle = nullptr; +} + +JniOcPresenceHandle* JniOcPresenceHandle::getJniOcPresenceHandlePtr +(JNIEnv *env, jobject thiz) +{ + JniOcPresenceHandle *handle = GetHandle(env, thiz); + if (env->ExceptionCheck()) + { + LOGE("Failed to get native handle from OcPresenceHandle"); + } + if (!handle) + { + ThrowOcException(JNI_NO_NATIVE_POINTER, ""); + } + return handle; +} + +OCPresenceHandle JniOcPresenceHandle::getOCPresenceHandle() +{ + return this->m_presenceHandle; +} + +JniOnPresenceListener* JniOcPresenceHandle::getJniOnPresenceListener() +{ + return this->m_jniListener; +} + +/* +* Class: org_iotivity_base_OcPresenceHandle +* Method: dispose +* Signature: ()V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcPresenceHandle_dispose +(JNIEnv *env, jobject thiz) +{ + LOGD("OcPresenceHandle_dispose"); + JniOcPresenceHandle *presenceHandle = JniOcPresenceHandle::getJniOcPresenceHandlePtr(env, thiz); + delete presenceHandle; +} \ No newline at end of file diff --git a/android/android_api/base/jni/JniOcPresenceHandle.h b/android/android_api/base/jni/JniOcPresenceHandle.h new file mode 100644 index 0000000..26f6a8d --- /dev/null +++ b/android/android_api/base/jni/JniOcPresenceHandle.h @@ -0,0 +1,65 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOcStack.h" +#include "JniOnPresenceListener.h" +#include "OCPlatform.h" + +#ifndef _Included_org_iotivity_base_OcPresenceHandle +#define _Included_org_iotivity_base_OcPresenceHandle + +using namespace OC::OCPlatform; + +class JniOcPresenceHandle +{ +public: + + JniOcPresenceHandle(JniOnPresenceListener* jniListener, OCPresenceHandle presenceHandle); + ~JniOcPresenceHandle(); + JniOcPresenceHandle(const JniOcPresenceHandle &) = delete; + void operator=(const JniOcPresenceHandle &) = delete; + + static JniOcPresenceHandle* getJniOcPresenceHandlePtr(JNIEnv *env, jobject thiz); + + OCPresenceHandle getOCPresenceHandle(); + JniOnPresenceListener* getJniOnPresenceListener(); + +private: + JniOnPresenceListener* m_jniListener; + OCPresenceHandle m_presenceHandle; +}; + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * Class: org_iotivity_base_OcPresenceHandle + * Method: dispose + * Signature: ()V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcPresenceHandle_dispose + (JNIEnv *, jobject); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/android/android_api/base/jni/JniOcRepresentation.cpp b/android/android_api/base/jni/JniOcRepresentation.cpp new file mode 100644 index 0000000..e2c2cd0 --- /dev/null +++ b/android/android_api/base/jni/JniOcRepresentation.cpp @@ -0,0 +1,1040 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOcRepresentation.h" +#include "JniUtils.h" + +using namespace OC; + +OCRepresentation* JniOcRepresentation::getOCRepresentationPtr(JNIEnv *env, jobject thiz) +{ + OCRepresentation *rep = GetHandle(env, thiz); + if (env->ExceptionCheck()) + { + LOGE("Failed to get native handle from OcRepresentation"); + } + if (!rep) + { + ThrowOcException(JNI_NO_NATIVE_POINTER, ""); + } + return rep; +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: getValueN +* Signature: (Ljava/lang/String;)Ljava/lang/Object; +*/ +JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcRepresentation_getValueN +(JNIEnv *env, jobject thiz, jstring jKey) +{ + LOGD("OcRepresentation_getValue"); + if (!jKey) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "attributeKey cannot be null"); + return nullptr; + } + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return nullptr; + + std::string key = env->GetStringUTFChars(jKey, NULL); + + AttributeValue attrValue; + if (!rep->getAttributeValue(key.c_str(), attrValue)) + { + ThrowOcException(JNI_NO_SUCH_KEY, " attribute key does not exist"); + return nullptr; + } + return boost::apply_visitor(JObjectConverter(env), attrValue); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: setValueInteger +* Signature: (Ljava/lang/String;I)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueInteger +(JNIEnv *env, jobject thiz, jstring jKey, jint jValue) +{ + LOGD("OcRepresentation_setValueInteger"); + if (!jKey) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null"); + return; + } + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return; + + std::string str = env->GetStringUTFChars(jKey, NULL); + rep->setValue(str, static_cast(jValue)); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: setValueDouble +* Signature: (Ljava/lang/String;D)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDouble +(JNIEnv *env, jobject thiz, jstring jKey, jdouble jValue) +{ + LOGD("OcRepresentation_setValueDouble"); + if (!jKey) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null"); + return; + } + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return; + + std::string str = env->GetStringUTFChars(jKey, NULL); + rep->setValue(str, static_cast(jValue)); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: setValueBoolean +* Signature: (Ljava/lang/String;Z)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBoolean +(JNIEnv *env, jobject thiz, jstring jKey, jboolean jValue) +{ + LOGD("OcRepresentation_setValueBoolean"); + if (!jKey) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null"); + return; + } + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return; + + std::string str = env->GetStringUTFChars(jKey, NULL); + rep->setValue(str, static_cast(jValue)); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: setValueStringN +* Signature: (Ljava/lang/String;Ljava/lang/String;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueStringN +(JNIEnv *env, jobject thiz, jstring jKey, jstring jValue) +{ + LOGD("OcRepresentation_setValueString"); + if (!jKey) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null"); + return; + } + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return; + + std::string key = env->GetStringUTFChars(jKey, NULL); + std::string value = env->GetStringUTFChars(jValue, NULL); + + rep->setValue(key, value); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: setValueRepresentation +* Signature: (Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresentation +(JNIEnv *env, jobject thiz, jstring jKey, jobject jValue) +{ + LOGD("OcRepresentation_setValueRepresentation"); + if (!jKey) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null"); + return; + } + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return; + + std::string key = env->GetStringUTFChars(jKey, NULL); + OCRepresentation *value = JniOcRepresentation::getOCRepresentationPtr(env, jValue); + if (!value) return; + + rep->setValue(key, *value); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: setValueIntegerArray +* Signature: (Ljava/lang/String;[I)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueIntegerArray +(JNIEnv *env, jobject thiz, jstring jKey, jintArray jValue) +{ + LOGD("OcRepresentation_setValueIntegerArray"); + if (!jKey) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null"); + return; + } + + const jsize len = env->GetArrayLength(jValue); + jint* ints = env->GetIntArrayElements(jValue, NULL); + + std::vector value; + for (jsize i = 0; i < len; ++i) + { + value.push_back(static_cast(ints[i])); + } + env->ReleaseIntArrayElements(jValue, ints, JNI_ABORT); + + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return; + + std::string key = env->GetStringUTFChars(jKey, NULL); + rep->setValue(key, value); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: setValueInteger2DArray +* Signature: (Ljava/lang/String;[[I)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueInteger2DArray +(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue) +{ + LOGD("OcRepresentation__setValueInteger2DArray"); + if (!jKey) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null"); + return; + } + std::vector> value; + const jsize lenOuter = env->GetArrayLength(jValue); + for (jsize j = 0; j < lenOuter; ++j) + { + jintArray jInnerArray = static_cast(env->GetObjectArrayElement(jValue, j)); + jint* ints = env->GetIntArrayElements(jInnerArray, NULL); + std::vector innerVector; + const jsize lenInner = env->GetArrayLength(jInnerArray); + for (jsize i = 0; i < lenInner; ++i) + { + innerVector.push_back(static_cast(ints[i])); + } + env->ReleaseIntArrayElements(jInnerArray, ints, JNI_ABORT); + env->DeleteLocalRef(jInnerArray); + value.push_back(innerVector); + } + + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return; + + std::string key = env->GetStringUTFChars(jKey, NULL); + rep->setValue(key, value); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: setValueInteger3DArray +* Signature: (Ljava/lang/String;[[[I)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueInteger3DArray +(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue) +{ + LOGD("OcRepresentation_setValueInteger3DArray"); + if (!jKey) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null"); + return; + } + std::vector>> value; + const jsize lenOuter = env->GetArrayLength(jValue); + for (jsize k = 0; k < lenOuter; ++k) + { + jobjectArray jMiddleArray = static_cast(env->GetObjectArrayElement(jValue, k)); + const jsize lenMiddle = env->GetArrayLength(jMiddleArray); + std::vector> middleArray; + for (jsize j = 0; j < lenMiddle; ++j) + { + jintArray jInnerArray = static_cast(env->GetObjectArrayElement(jMiddleArray, j)); + jint* ints = env->GetIntArrayElements(jInnerArray, NULL); + std::vector innerVector; + const jsize lenInner = env->GetArrayLength(jInnerArray); + for (jsize i = 0; i < lenInner; ++i) + { + innerVector.push_back(static_cast(ints[i])); + } + env->ReleaseIntArrayElements(jInnerArray, ints, JNI_ABORT); + env->DeleteLocalRef(jInnerArray); + middleArray.push_back(innerVector); + } + env->DeleteLocalRef(jMiddleArray); + value.push_back(middleArray); + } + + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return; + + std::string key = env->GetStringUTFChars(jKey, NULL); + rep->setValue(key, value); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: setValueDoubleArray +* Signature: (Ljava/lang/String;[D)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDoubleArray +(JNIEnv *env, jobject thiz, jstring jKey, jdoubleArray jValue) +{ + LOGD("OcRepresentation_setValueDoubleArray"); + if (!jKey) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null"); + return; + } + + const jsize len = env->GetArrayLength(jValue); + jdouble* doubles = env->GetDoubleArrayElements(jValue, NULL); + + std::vector value; + for (jsize i = 0; i < len; ++i) + { + value.push_back(static_cast(doubles[i])); + } + env->ReleaseDoubleArrayElements(jValue, doubles, JNI_ABORT); + + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return; + + std::string key = env->GetStringUTFChars(jKey, NULL); + rep->setValue(key, value); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: setValueDouble2DArray +* Signature: (Ljava/lang/String;[[D)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDouble2DArray +(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue) +{ + LOGD("OcRepresentation_setValueDouble2DArray"); + if (!jKey) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null"); + return; + } + std::vector> value; + const jsize lenOuter = env->GetArrayLength(jValue); + for (jsize j = 0; j < lenOuter; ++j) + { + jdoubleArray jInnerArray = static_cast(env->GetObjectArrayElement(jValue, j)); + jdouble* doubles = env->GetDoubleArrayElements(jInnerArray, NULL); + std::vector innerVector; + const jsize lenInner = env->GetArrayLength(jInnerArray); + for (jsize i = 0; i < lenInner; ++i) + { + innerVector.push_back(static_cast(doubles[i])); + } + env->ReleaseDoubleArrayElements(jInnerArray, doubles, JNI_ABORT); + env->DeleteLocalRef(jInnerArray); + value.push_back(innerVector); + } + + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return; + + std::string key = env->GetStringUTFChars(jKey, NULL); + rep->setValue(key, value); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: setValueDouble3DArray +* Signature: (Ljava/lang/String;[[[D)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDouble3DArray +(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue) +{ + LOGD("OcRepresentation_setValueDouble3DArray"); + if (!jKey) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null"); + return; + } + std::vector>> value; + const jsize lenOuter = env->GetArrayLength(jValue); + for (jsize k = 0; k < lenOuter; ++k) + { + jobjectArray jMiddleArray = static_cast(env->GetObjectArrayElement(jValue, k)); + const jsize lenMiddle = env->GetArrayLength(jMiddleArray); + std::vector> middleArray; + for (jsize j = 0; j < lenMiddle; ++j) + { + jdoubleArray jInnerArray = static_cast(env->GetObjectArrayElement(jMiddleArray, j)); + jdouble* doubles = env->GetDoubleArrayElements(jInnerArray, NULL); + std::vector innerVector; + const jsize lenInner = env->GetArrayLength(jInnerArray); + for (jsize i = 0; i < lenInner; ++i) + { + innerVector.push_back(static_cast(doubles[i])); + } + env->ReleaseDoubleArrayElements(jInnerArray, doubles, JNI_ABORT); + env->DeleteLocalRef(jInnerArray); + middleArray.push_back(innerVector); + } + env->DeleteLocalRef(jMiddleArray); + value.push_back(middleArray); + } + + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return; + + std::string key = env->GetStringUTFChars(jKey, NULL); + rep->setValue(key, value); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: setValueBooleanArray +* Signature: (Ljava/lang/String;[Z)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBooleanArray +(JNIEnv *env, jobject thiz, jstring jKey, jbooleanArray jValue) +{ + LOGD("OcRepresentation_setValueBooleanArray"); + if (!jKey) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null"); + return; + } + + const jsize len = env->GetArrayLength(jValue); + jboolean* booleans = env->GetBooleanArrayElements(jValue, NULL); + + std::vector value; + for (jsize i = 0; i < len; ++i) + { + value.push_back(static_cast(booleans[i])); + } + env->ReleaseBooleanArrayElements(jValue, booleans, JNI_ABORT); + + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return; + + std::string key = env->GetStringUTFChars(jKey, NULL); + rep->setValue(key, value); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: setValueBoolean2DArray +* Signature: (Ljava/lang/String;[[Z)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBoolean2DArray +(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue) +{ + LOGD("OcRepresentation_setValueBoolean2DArray"); + if (!jKey) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null"); + return; + } + std::vector> value; + const jsize lenOuter = env->GetArrayLength(jValue); + for (jsize j = 0; j < lenOuter; ++j) + { + jbooleanArray jInnerArray = static_cast(env->GetObjectArrayElement(jValue, j)); + const jsize lenInner = env->GetArrayLength(jInnerArray); + jboolean* booleans = env->GetBooleanArrayElements(jInnerArray, NULL); + + std::vector innerVector; + for (jsize i = 0; i < lenInner; ++i) + { + innerVector.push_back(static_cast(booleans[i])); + } + env->ReleaseBooleanArrayElements(jInnerArray, booleans, JNI_ABORT); + env->DeleteLocalRef(jInnerArray); + value.push_back(innerVector); + } + + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return; + + std::string key = env->GetStringUTFChars(jKey, NULL); + rep->setValue(key, value); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: setValueBoolean3DArray +* Signature: (Ljava/lang/String;[[[Z)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBoolean3DArray +(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue) +{ + LOGD("OcRepresentation_setValueBoolean3DArray"); + if (!jKey) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null"); + return; + } + std::vector>> value; + const jsize lenOuter = env->GetArrayLength(jValue); + for (jsize k = 0; k < lenOuter; ++k) + { + jobjectArray jMiddleArray = static_cast(env->GetObjectArrayElement(jValue, k)); + const jsize lenMiddle = env->GetArrayLength(jMiddleArray); + std::vector> middleArray; + for (jsize j = 0; j < lenMiddle; ++j) + { + jbooleanArray jInnerArray = static_cast(env->GetObjectArrayElement(jMiddleArray, j)); + const jsize lenInner = env->GetArrayLength(jInnerArray); + jboolean* booleans = env->GetBooleanArrayElements(jInnerArray, NULL); + + std::vector innerVector; + for (jsize i = 0; i < lenInner; ++i) + { + innerVector.push_back(static_cast(booleans[i])); + } + env->ReleaseBooleanArrayElements(jInnerArray, booleans, JNI_ABORT); + env->DeleteLocalRef(jInnerArray); + middleArray.push_back(innerVector); + } + env->DeleteLocalRef(jMiddleArray); + value.push_back(middleArray); + } + + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return; + + std::string key = env->GetStringUTFChars(jKey, NULL); + rep->setValue(key, value); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: setValueStringArray +* Signature: (Ljava/lang/String;[Ljava/lang/String;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueStringArray +(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue) +{ + LOGD("OcRepresentation_setValueStringArray"); + if (!jKey) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null"); + return; + } + + std::vector value; + JniUtils::convertJavaStrArrToStrVector(env, jValue, value); + + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return; + + std::string key = env->GetStringUTFChars(jKey, NULL); + rep->setValue(key, value); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: setValueString2DArray +* Signature: (Ljava/lang/String;[[Ljava/lang/String;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueString2DArray +(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue) +{ + LOGD("OcRepresentation_setValueString2DArray"); + if (!jKey) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null"); + return; + } + std::vector> value; + const jsize lenOuter = env->GetArrayLength(jValue); + for (jsize j = 0; j < lenOuter; ++j) + { + jobjectArray jInnerArray = static_cast(env->GetObjectArrayElement(jValue, j)); + std::vector innerVector; + JniUtils::convertJavaStrArrToStrVector(env, jInnerArray, innerVector); + env->DeleteLocalRef(jInnerArray); + value.push_back(innerVector); + } + + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return; + + std::string key = env->GetStringUTFChars(jKey, NULL); + rep->setValue(key, value); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: setValueString3DArray +* Signature: (Ljava/lang/String;[[[Ljava/lang/String;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueString3DArray +(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue) +{ + LOGD("OcRepresentation_setValueString3DArray"); + if (!jKey) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null"); + return; + } + std::vector>> value; + const jsize lenOuter = env->GetArrayLength(jValue); + for (jsize k = 0; k < lenOuter; ++k) + { + jobjectArray jMiddleArray = static_cast(env->GetObjectArrayElement(jValue, k)); + const jsize lenMiddle = env->GetArrayLength(jMiddleArray); + std::vector> middleArray; + for (jsize j = 0; j < lenMiddle; ++j) + { + jobjectArray jInnerArray = static_cast(env->GetObjectArrayElement(jMiddleArray, j)); + std::vector innerVector; + JniUtils::convertJavaStrArrToStrVector(env, jInnerArray, innerVector); + env->DeleteLocalRef(jInnerArray); + middleArray.push_back(innerVector); + } + env->DeleteLocalRef(jMiddleArray); + value.push_back(middleArray); + } + + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return; + + std::string key = env->GetStringUTFChars(jKey, NULL); + rep->setValue(key, value); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: setValueRepresentationArray +* Signature: (Ljava/lang/String;[Lorg/iotivity/base/OcRepresentation;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresentationArray +(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue) +{ + LOGD("OcRepresentation_setValueRepresentationArray"); + if (!jKey) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null"); + return; + } + + std::vector value; + JniUtils::convertJavaRepresentationArrToVector(env, jValue, value); + + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return; + + std::string key = env->GetStringUTFChars(jKey, NULL); + rep->setValue(key, value); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: setValueRepresentation2DArray +* Signature: (Ljava/lang/String;[[Lorg/iotivity/base/OcRepresentation;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresentation2DArray +(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue) +{ + LOGD("OcRepresentation_setValueRepresentation2DArray"); + if (!jKey) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null"); + return; + } + std::vector> value; + const jsize lenOuter = env->GetArrayLength(jValue); + for (jsize j = 0; j < lenOuter; ++j) + { + jobjectArray jInnerArray = static_cast(env->GetObjectArrayElement(jValue, j)); + std::vector innerVector; + JniUtils::convertJavaRepresentationArrToVector(env, jInnerArray, innerVector); + env->DeleteLocalRef(jInnerArray); + value.push_back(innerVector); + } + + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return; + + std::string key = env->GetStringUTFChars(jKey, NULL); + rep->setValue(key, value); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: setValueRepresentation3DArray +* Signature: (Ljava/lang/String;[[[Lorg/iotivity/base/OcRepresentation;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresentation3DArray +(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue) +{ + LOGD("OcRepresentation_setValueRepresentation3DArray"); + if (!jKey) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null"); + return; + } + std::vector>> value; + const jsize lenOuter = env->GetArrayLength(jValue); + for (jsize k = 0; k < lenOuter; ++k) + { + jobjectArray jMiddleArray = static_cast(env->GetObjectArrayElement(jValue, k)); + const jsize lenMiddle = env->GetArrayLength(jMiddleArray); + std::vector> middleArray; + for (jsize j = 0; j < lenMiddle; ++j) + { + jobjectArray jInnerArray = static_cast(env->GetObjectArrayElement(jMiddleArray, j)); + std::vector innerVector; + JniUtils::convertJavaRepresentationArrToVector(env, jInnerArray, innerVector); + env->DeleteLocalRef(jInnerArray); + middleArray.push_back(innerVector); + } + env->DeleteLocalRef(jMiddleArray); + value.push_back(middleArray); + } + + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return; + + std::string key = env->GetStringUTFChars(jKey, NULL); + rep->setValue(key, value); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: getJSONRepresentation +* Signature: ()Ljava/lang/String; +*/ +JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcRepresentation_getJSONRepresentation +(JNIEnv *env, jobject thiz) +{ + LOGD("OcRepresentation_getJSONRepresentation"); + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return nullptr; + + std::string jsonStr = rep->getJSONRepresentation(); + return env->NewStringUTF(jsonStr.c_str()); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: addChild +* Signature: (Lorg/iotivity/base/OcRepresentation;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_addChild +(JNIEnv *env, jobject thiz, jobject jOcRepresentation) +{ + LOGD("OcRepresentation_addChild"); + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return; + + OCRepresentation *child = JniOcRepresentation::getOCRepresentationPtr(env, jOcRepresentation); + if (!child) return; + + rep->addChild(*child); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: clearChildren +* Signature: ()V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_clearChildren +(JNIEnv *env, jobject thiz) +{ + LOGD("OcRepresentation_clearChildren"); + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return; + + rep->clearChildren(); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: getChildrenArray +* Signature: ()[Lorg/iotivity/base/OcRepresentation; +*/ +JNIEXPORT jobjectArray JNICALL Java_org_iotivity_base_OcRepresentation_getChildrenArray +(JNIEnv *env, jobject thiz) +{ + LOGD("OcRepresentation_getChildrenArray"); + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return nullptr; + + return JniUtils::convertRepresentationVectorToJavaArray(env, rep->getChildren()); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: getUri +* Signature: ()Ljava/lang/String; +*/ +JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcRepresentation_getUri +(JNIEnv *env, jobject thiz) +{ + LOGD("OcRepresentation_getUri"); + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return nullptr; + + std::string uri(rep->getUri()); + return env->NewStringUTF(uri.c_str()); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: setUri +* Signature: (Ljava/lang/String;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setUri +(JNIEnv *env, jobject thiz, jstring jUri) +{ + LOGD("OcRepresentation_setUri"); + if (!jUri) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "uri cannot be null"); + return; + } + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return; + + rep->setUri(env->GetStringUTFChars(jUri, NULL)); +} + +JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_hasAttribute +(JNIEnv *env, jobject thiz, jstring jstr) +{ + LOGD("OcRepresentation_hasAttribute"); + if (!jstr) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "attributeKey cannot be null"); + return false; + } + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return false; + + std::string str = env->GetStringUTFChars(jstr, NULL); + return rep->hasAttribute(str); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: getResourceTypes +* Signature: ()Ljava/util/List; +*/ +JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcRepresentation_getResourceTypes +(JNIEnv *env, jobject thiz) +{ + LOGD("OcRepresentation_getResourceTypes"); + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return nullptr; + + std::vector resourceTypes = rep->getResourceTypes(); + return JniUtils::convertStrVectorToJavaStrList(env, resourceTypes); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: setResourceTypeArray +* Signature: ([Ljava/lang/String;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setResourceTypeArray +(JNIEnv *env, jobject thiz, jobjectArray jResourceTypeArray) +{ + LOGD("OcRepresentation_setResourceTypeArray"); + if (!jResourceTypeArray) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "resourceTypeList cannot be null"); + return; + } + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return; + + std::vector resourceTypes; + JniUtils::convertJavaStrArrToStrVector(env, jResourceTypeArray, resourceTypes); + rep->setResourceTypes(resourceTypes); +} +/* +* Class: org_iotivity_base_OcRepresentation +* Method: getResourceInterfaces +* Signature: ()Ljava/util/List; +*/ +JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcRepresentation_getResourceInterfaces +(JNIEnv *env, jobject thiz) +{ + LOGD("OcRepresentation_getResourceInterfaces"); + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return nullptr; + + std::vector resourceInterfaces = rep->getResourceInterfaces(); + return JniUtils::convertStrVectorToJavaStrList(env, resourceInterfaces); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: setResourceInterfaceArray +* Signature: ([Ljava/lang/String;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setResourceInterfaceArray +(JNIEnv *env, jobject thiz, jobjectArray jResourceInterfaceArray) +{ + LOGD("OcRepresentation_setResourceInterfaceArray"); + if (!jResourceInterfaceArray) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "resourceInterfaceList cannot be null"); + return; + } + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return; + + std::vector resourceInterfaces; + JniUtils::convertJavaStrArrToStrVector(env, jResourceInterfaceArray, resourceInterfaces); + rep->setResourceInterfaces(resourceInterfaces); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: isEmpty +* Signature: ()Z +*/ +JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_isEmpty +(JNIEnv *env, jobject thiz) +{ + LOGD("OcRepresentation_isEmpty"); + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return false; + + return static_cast(rep->empty()); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: size +* Signature: ()I +*/ +JNIEXPORT jint JNICALL Java_org_iotivity_base_OcRepresentation_size +(JNIEnv *env, jobject thiz) +{ + LOGD("OcRepresentation_size"); + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return -1; + + return static_cast(rep->numberOfAttributes()); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: remove +* Signature: (Ljava/lang/String;)Z +*/ +JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_remove +(JNIEnv *env, jobject thiz, jstring jAttributeKey) +{ + LOGD("OcRepresentation_remove"); + if (!jAttributeKey) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "attributeKey cannot be null"); + return false; + } + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return false; + + std::string attributeKey = env->GetStringUTFChars(jAttributeKey, NULL); + return static_cast(rep->erase(attributeKey)); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: setNull +* Signature: (Ljava/lang/String;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setNull +(JNIEnv *env, jobject thiz, jstring jAttributeKey) +{ + LOGD("OcRepresentation_setNull"); + if (!jAttributeKey) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "attributeKey cannot be null"); + return; + } + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return; + + std::string attributeKey = env->GetStringUTFChars(jAttributeKey, NULL); + rep->setNULL(attributeKey); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: isNull +* Signature: (Ljava/lang/String;)Z +*/ +JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_isNull +(JNIEnv *env, jobject thiz, jstring jAttributeKey) +{ + LOGD("OcRepresentation_isNull"); + if (!jAttributeKey) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "attributeKey cannot be null"); + return false; + } + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + if (!rep) return false; + + std::string attributeKey = env->GetStringUTFChars(jAttributeKey, NULL); + return static_cast(rep->isNULL(attributeKey)); +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: create +* Signature: ()V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_create +(JNIEnv *env, jobject thiz) +{ + LOGD("OcRepresentation_create"); + OCRepresentation *rep = new OCRepresentation(); + SetHandle(env, thiz, rep); + if (env->ExceptionCheck()) + { + LOGE("Failed to set native handle for OcRepresentation"); + delete rep; + } +} + +/* +* Class: org_iotivity_base_OcRepresentation +* Method: dispose +* Signature: ()V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_dispose +(JNIEnv *env, jobject thiz, jboolean jNeedsDelete) +{ + LOGD("OcRepresentation_dispose"); + OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); + + if (jNeedsDelete) + { + delete rep; + } +} \ No newline at end of file diff --git a/android/android_api/base/jni/JniOcRepresentation.h b/android/android_api/base/jni/JniOcRepresentation.h new file mode 100644 index 0000000..3f25c29 --- /dev/null +++ b/android/android_api/base/jni/JniOcRepresentation.h @@ -0,0 +1,769 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOcStack.h" +#include + +#ifndef _Included_org_iotivity_base_OcRepresentation +#define _Included_org_iotivity_base_OcRepresentation + +using namespace OC; + +class JniOcRepresentation +{ +public: + static OCRepresentation* getOCRepresentationPtr(JNIEnv *env, jobject thiz); +}; + +struct JObjectConverter : boost::static_visitor < jobject > +{ + JObjectConverter(JNIEnv *env) : env(env){} + + jobject operator()(const NullType&) const { return nullptr; } + jobject operator()(const int& val) const + { + jobject jobj = env->NewObject( + g_cls_Integer, + g_mid_Integer_ctor, + static_cast(val)); + return jobj; + } + jobject operator()(const double& val) const + { + jobject jobj = env->NewObject( + g_cls_Double, + g_mid_Double_ctor, + static_cast(val)); + return jobj; + } + jobject operator()(const bool& val) const + { + jobject jobj = env->NewObject( + g_cls_Boolean, + g_mid_Boolean_ctor, + static_cast(val)); + return jobj; + } + jobject operator()(const std::string& val) const + { + jstring jstr = env->NewStringUTF(val.c_str()); + return static_cast(jstr); + } + jobject operator()(const OC::OCRepresentation& val) const + { + OCRepresentation * rep = new OCRepresentation(val); + jlong handle = reinterpret_cast(rep); + jobject jRepresentation = env->NewObject( + g_cls_OcRepresentation, + g_mid_OcRepresentation_N_ctor_bool, + handle, true); + if (!jRepresentation) + { + delete rep; + } + return jRepresentation; + } + + // Sequences: + jobject operator()(const std::vector& val) const + { + size_t len = val.size(); + jintArray jIntArray = env->NewIntArray(len); + if (!jIntArray) return nullptr; + const int* ints = &val[0]; + env->SetIntArrayRegion(jIntArray, 0, len, reinterpret_cast(ints)); + return jIntArray; + } + jobject operator()(const std::vector& val) const + { + size_t len = val.size(); + jdoubleArray jDoubleArray = env->NewDoubleArray(len); + if (!jDoubleArray) return nullptr; + const double* doubles = &val[0]; + env->SetDoubleArrayRegion(jDoubleArray, 0, len, reinterpret_cast(doubles)); + return jDoubleArray; + } + jobject operator()(const std::vector& val) const + { + size_t len = val.size(); + jbooleanArray jBooleanArray = env->NewBooleanArray(len); + if (!jBooleanArray) return nullptr; + jboolean* booleans = new jboolean[len]; + for (size_t i = 0; i < len; ++i) { + booleans[i] = static_cast(val[i]); + } + env->SetBooleanArrayRegion(jBooleanArray, 0, len, booleans); + if (env->ExceptionCheck()) return nullptr; + env->ReleaseBooleanArrayElements(jBooleanArray, booleans, 0); + return jBooleanArray; + } + jobject operator()(const std::vector& val) const + { + size_t len = val.size(); + jobjectArray strArr = env->NewObjectArray(len, g_cls_String, NULL); + if (!strArr) return nullptr; + for (size_t i = 0; i < len; ++i) + { + jstring jString = env->NewStringUTF(val[i].c_str()); + env->SetObjectArrayElement(strArr, static_cast(i), jString); + if (env->ExceptionCheck()) return nullptr; + env->DeleteLocalRef(jString); + } + return strArr; + } + jobject operator()(const std::vector& val) const + { + jsize len = static_cast(val.size()); + jobjectArray repArr = env->NewObjectArray(len, g_cls_OcRepresentation, NULL); + if (!repArr) return nullptr; + for (jsize i = 0; i < len; ++i) + { + OCRepresentation* rep = new OCRepresentation(val[i]); + jlong handle = reinterpret_cast(rep); + jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool, + handle, true); + if (!jRepresentation) + { + delete rep; + return nullptr; + } + env->SetObjectArrayElement(repArr, i, jRepresentation); + if (env->ExceptionCheck()) + { + delete rep; + return nullptr; + } + env->DeleteLocalRef(jRepresentation); + } + return repArr; + } + + // Nested sequences: + jobject operator()(const std::vector>& val) const + { + jsize lenOuter = static_cast(val.size()); + jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_int1DArray, NULL); + if (!jOuterArr) + { + return nullptr; + } + for (jsize i = 0; i < lenOuter; ++i) + { + size_t lenInner = val[i].size(); + jintArray jIntArray = env->NewIntArray(lenInner); + if (!jIntArray) return nullptr; + const int* ints = &val[i][0]; + env->SetIntArrayRegion(jIntArray, 0, lenInner, reinterpret_cast(ints)); + if (env->ExceptionCheck()) return nullptr; + env->SetObjectArrayElement(jOuterArr, i, static_cast(jIntArray)); + if (env->ExceptionCheck()) return nullptr; + env->DeleteLocalRef(jIntArray); + } + return jOuterArr; + } + jobject operator()(const std::vector>>& val) const + { + jsize lenOuter = static_cast(val.size()); + jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_int2DArray, NULL); + if (!jOuterArr) return nullptr; + for (jsize k = 0; k < lenOuter; ++k) + { + jsize lenMiddle = static_cast(val[k].size()); + jobjectArray jMiddleArr = env->NewObjectArray(lenMiddle, g_cls_int1DArray, NULL); + if (!jMiddleArr) return nullptr; + for (jsize i = 0; i < lenMiddle; ++i) + { + jsize lenInner = static_cast(val[k][i].size()); + jintArray jIntArray = env->NewIntArray(lenInner); + if (!jIntArray) return nullptr; + const int* ints = &val[k][i][0]; + env->SetIntArrayRegion(jIntArray, 0, lenInner, reinterpret_cast(ints)); + if (env->ExceptionCheck()) return nullptr; + env->SetObjectArrayElement(jMiddleArr, i, jIntArray); + if (env->ExceptionCheck()) return nullptr; + env->DeleteLocalRef(jIntArray); + } + env->SetObjectArrayElement(jOuterArr, k, jMiddleArr); + if (env->ExceptionCheck()) return nullptr; + env->DeleteLocalRef(jMiddleArr); + } + return jOuterArr; + } + + jobject operator()(const std::vector>& val) const + { + jsize lenOuter = static_cast(val.size()); + jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_double1DArray, NULL); + if (!jOuterArr) return nullptr; + for (jsize i = 0; i < lenOuter; ++i) + { + size_t lenInner = val[i].size(); + jdoubleArray jDoubleArray = env->NewDoubleArray(lenInner); + if (!jDoubleArray) return nullptr; + const double* doubles = &val[i][0]; + env->SetDoubleArrayRegion(jDoubleArray, 0, lenInner, reinterpret_cast(doubles)); + if (env->ExceptionCheck()) return nullptr; + env->SetObjectArrayElement(jOuterArr, i, jDoubleArray); + if (env->ExceptionCheck()) return nullptr; + env->DeleteLocalRef(jDoubleArray); + } + + return jOuterArr; + } + jobject operator()(const std::vector>>& val) const + { + jsize lenOuter = static_cast(val.size()); + jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_double2DArray, NULL); + if (!jOuterArr) return nullptr; + for (jsize k = 0; k < lenOuter; ++k) + { + jsize lenMiddle = static_cast(val[k].size()); + jobjectArray jMiddleArr = env->NewObjectArray(lenMiddle, g_cls_double1DArray, NULL); + if (!jMiddleArr) return nullptr; + for (jsize i = 0; i < lenMiddle; ++i) + { + jsize lenInner = static_cast(val[k][i].size()); + jdoubleArray jDoubleArray = env->NewDoubleArray(lenInner); + if (!jDoubleArray) return nullptr; + const double* doubles = &val[k][i][0]; + env->SetDoubleArrayRegion(jDoubleArray, 0, lenInner, reinterpret_cast(doubles)); + if (env->ExceptionCheck()) return nullptr; + env->SetObjectArrayElement(jMiddleArr, i, jDoubleArray); + if (env->ExceptionCheck()) return nullptr; + env->DeleteLocalRef(jDoubleArray); + } + env->SetObjectArrayElement(jOuterArr, k, jMiddleArr); + if (env->ExceptionCheck()) return nullptr; + env->DeleteLocalRef(jMiddleArr); + } + return jOuterArr; + } + + jobject operator()(const std::vector>& val) const + { + jsize lenOuter = static_cast(val.size()); + jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_boolean1DArray, 0); + if (!jOuterArr) return nullptr; + for (jsize i = 0; i < lenOuter; ++i) + { + size_t lenInner = val[i].size(); + jbooleanArray jBooleanArray = env->NewBooleanArray(lenInner); + if (!jBooleanArray) return nullptr; + jboolean* booleans = new jboolean[lenInner]; + for (size_t j = 0; j < lenInner; ++j) { + booleans[j] = static_cast(val[i][j]); + } + env->SetBooleanArrayRegion(jBooleanArray, 0, lenInner, booleans); + if (env->ExceptionCheck()) return nullptr; + env->SetObjectArrayElement(jOuterArr, i, jBooleanArray); + if (env->ExceptionCheck()) return nullptr; + env->ReleaseBooleanArrayElements(jBooleanArray, booleans, 0); + if (env->ExceptionCheck()) return nullptr; + env->DeleteLocalRef(jBooleanArray); + } + return jOuterArr; + } + jobject operator()(const std::vector>>& val) const + { + jsize lenOuter = static_cast(val.size()); + jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_boolean2DArray, NULL); + if (!jOuterArr) return nullptr; + for (jsize k = 0; k < lenOuter; ++k) + { + jsize lenMiddle = static_cast(val[k].size()); + jobjectArray jMiddleArr = env->NewObjectArray(lenMiddle, g_cls_boolean1DArray, NULL); + if (!jMiddleArr) return nullptr; + for (jsize i = 0; i < lenMiddle; ++i) + { + size_t lenInner = val[k][i].size(); + jbooleanArray jBooleanArray = env->NewBooleanArray(lenInner); + jboolean* booleans = new jboolean[lenInner]; + for (size_t j = 0; j < lenInner; ++j) { + booleans[j] = val[k][i][j]; + } + env->SetBooleanArrayRegion(jBooleanArray, 0, lenInner, booleans); + if (env->ExceptionCheck()) return nullptr; + env->SetObjectArrayElement(jMiddleArr, i, jBooleanArray); + if (env->ExceptionCheck()) return nullptr; + env->ReleaseBooleanArrayElements(jBooleanArray, booleans, 0); + if (env->ExceptionCheck()) return nullptr; + env->DeleteLocalRef(jBooleanArray); + } + env->SetObjectArrayElement(jOuterArr, k, jMiddleArr); + if (env->ExceptionCheck()) return nullptr; + env->DeleteLocalRef(jMiddleArr); + } + return jOuterArr; + } + + jobject operator()(const std::vector>& val) const + { + jsize lenOuter = static_cast(val.size()); + jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_String1DArray, NULL); + if (!jOuterArr) return nullptr; + for (jsize i = 0; i < lenOuter; ++i) + { + jsize lenInner = static_cast(val[i].size()); + jobjectArray strArr = env->NewObjectArray(lenInner, g_cls_String, NULL); + if (!strArr) return nullptr; + for (jsize j = 0; j < lenInner; ++j) + { + jstring jString = env->NewStringUTF(val[i][j].c_str()); + env->SetObjectArrayElement(strArr, j, jString); + if (env->ExceptionCheck()) return nullptr; + env->DeleteLocalRef(jString); + } + env->SetObjectArrayElement(jOuterArr, i, strArr); + if (env->ExceptionCheck()) return nullptr; + env->DeleteLocalRef(strArr); + } + + return jOuterArr; + } + jobject operator()(const std::vector>>& val) const + { + jsize lenOuter = static_cast(val.size()); + jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_String2DArray, NULL); + if (!jOuterArr) return nullptr; + for (jsize k = 0; k < lenOuter; ++k) + { + jsize lenMiddle = static_cast(val[k].size()); + jobjectArray jMiddleArr = env->NewObjectArray(lenMiddle, g_cls_String1DArray, NULL); + if (!jMiddleArr) return nullptr; + for (jsize i = 0; i < lenMiddle; ++i) + { + jsize lenInner = static_cast(val[k][i].size()); + jobjectArray strArr = env->NewObjectArray(lenInner, g_cls_String, NULL); + if (!strArr) return nullptr; + for (jsize j = 0; j < lenInner; ++j) + { + jstring jString = env->NewStringUTF(val[k][i][j].c_str()); + env->SetObjectArrayElement(strArr, j, jString); + if (env->ExceptionCheck()) return nullptr; + env->DeleteLocalRef(jString); + } + env->SetObjectArrayElement(jMiddleArr, i, strArr); + if (env->ExceptionCheck()) return nullptr; + env->DeleteLocalRef(strArr); + } + env->SetObjectArrayElement(jOuterArr, k, jMiddleArr); + if (env->ExceptionCheck()) return nullptr; + env->DeleteLocalRef(jMiddleArr); + } + return jOuterArr; + } + + jobject operator()(const std::vector>& val) const + { + jsize lenOuter = static_cast(val.size()); + jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_OcRepresentation1DArray, NULL); + if (!jOuterArr) return nullptr; + for (jsize i = 0; i < lenOuter; ++i) + { + jsize lenInner = static_cast(val[i].size()); + jobjectArray repArr = env->NewObjectArray(lenInner, g_cls_OcRepresentation, NULL); + if (!repArr) return nullptr; + for (jsize j = 0; j < lenInner; ++j) + { + OCRepresentation* rep = new OCRepresentation(val[i][j]); + jlong handle = reinterpret_cast(rep); + jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool, + handle, true); + if (!jRepresentation) + { + delete rep; + return nullptr; + } + env->SetObjectArrayElement(repArr, j, jRepresentation); + if (env->ExceptionCheck()) return nullptr; + env->DeleteLocalRef(jRepresentation); + } + env->SetObjectArrayElement(jOuterArr, i, repArr); + if (env->ExceptionCheck()) return nullptr; + env->DeleteLocalRef(repArr); + } + return jOuterArr; + } + jobject operator()(const std::vector>>& val) const + { + jsize lenOuter = static_cast(val.size()); + jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_OcRepresentation2DArray, NULL); + if (!jOuterArr) return nullptr; + for (jsize k = 0; k < lenOuter; ++k) + { + jsize lenMiddle = static_cast(val[k].size()); + jobjectArray jMiddleArr = env->NewObjectArray(lenMiddle, g_cls_OcRepresentation1DArray, NULL); + if (!jMiddleArr) return nullptr; + for (jsize i = 0; i < lenMiddle; ++i) + { + jsize lenInner = static_cast(val[k][i].size()); + jobjectArray repArr = env->NewObjectArray(lenInner, g_cls_OcRepresentation, NULL); + if (!repArr) return nullptr; + for (jsize j = 0; j < lenInner; ++j) + { + OCRepresentation* rep = new OCRepresentation(val[k][i][j]); + jlong handle = reinterpret_cast(rep); + jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool, + handle, true); + if (!jRepresentation) + { + delete rep; + return nullptr; + } + env->SetObjectArrayElement(repArr, j, jRepresentation); + if (env->ExceptionCheck()) return nullptr; + env->DeleteLocalRef(jRepresentation); + } + env->SetObjectArrayElement(jMiddleArr, i, repArr); + if (env->ExceptionCheck()) return nullptr; + env->DeleteLocalRef(repArr); + } + env->SetObjectArrayElement(jOuterArr, k, jMiddleArr); + if (env->ExceptionCheck()) return nullptr; + env->DeleteLocalRef(jMiddleArr); + } + return jOuterArr; + } + +private: + JNIEnv *env; +}; + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: getValueN + * Signature: (Ljava/lang/String;)Ljava/lang/Object; + */ + JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcRepresentation_getValueN + (JNIEnv *, jobject, jstring); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: setValueInteger + * Signature: (Ljava/lang/String;I)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueInteger + (JNIEnv *, jobject, jstring, jint); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: setValueDouble + * Signature: (Ljava/lang/String;D)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDouble + (JNIEnv *, jobject, jstring, jdouble); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: setValueBoolean + * Signature: (Ljava/lang/String;Z)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBoolean + (JNIEnv *, jobject, jstring, jboolean); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: setValueStringN + * Signature: (Ljava/lang/String;Ljava/lang/String;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueStringN + (JNIEnv *, jobject, jstring, jstring); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: setValueRepresentation + * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresentation + (JNIEnv *, jobject, jstring, jobject); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: setValueIntegerArray + * Signature: (Ljava/lang/String;[I)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueIntegerArray + (JNIEnv *, jobject, jstring, jintArray); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: setValueInteger2DArray + * Signature: (Ljava/lang/String;[[I)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueInteger2DArray + (JNIEnv *, jobject, jstring, jobjectArray); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: setValueInteger3DArray + * Signature: (Ljava/lang/String;[[[I)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueInteger3DArray + (JNIEnv *, jobject, jstring, jobjectArray); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: setValueDoubleArray + * Signature: (Ljava/lang/String;[D)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDoubleArray + (JNIEnv *, jobject, jstring, jdoubleArray); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: setValueDouble2DArray + * Signature: (Ljava/lang/String;[[D)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDouble2DArray + (JNIEnv *, jobject, jstring, jobjectArray); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: setValueDouble3DArray + * Signature: (Ljava/lang/String;[[[D)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDouble3DArray + (JNIEnv *, jobject, jstring, jobjectArray); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: setValueBooleanArray + * Signature: (Ljava/lang/String;[Z)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBooleanArray + (JNIEnv *, jobject, jstring, jbooleanArray); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: setValueBoolean2DArray + * Signature: (Ljava/lang/String;[[Z)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBoolean2DArray + (JNIEnv *, jobject, jstring, jobjectArray); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: setValueBoolean3DArray + * Signature: (Ljava/lang/String;[[[Z)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBoolean3DArray + (JNIEnv *, jobject, jstring, jobjectArray); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: setValueStringArray + * Signature: (Ljava/lang/String;[Ljava/lang/String;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueStringArray + (JNIEnv *, jobject, jstring, jobjectArray); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: setValueString2DArray + * Signature: (Ljava/lang/String;[[Ljava/lang/String;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueString2DArray + (JNIEnv *, jobject, jstring, jobjectArray); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: setValueString3DArray + * Signature: (Ljava/lang/String;[[[Ljava/lang/String;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueString3DArray + (JNIEnv *, jobject, jstring, jobjectArray); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: setValueRepresentationArray + * Signature: (Ljava/lang/String;[Lorg/iotivity/base/OcRepresentation;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresentationArray + (JNIEnv *, jobject, jstring, jobjectArray); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: setValueRepresentation2DArray + * Signature: (Ljava/lang/String;[[Lorg/iotivity/base/OcRepresentation;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresentation2DArray + (JNIEnv *, jobject, jstring, jobjectArray); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: setValueRepresentation3DArray + * Signature: (Ljava/lang/String;[[[Lorg/iotivity/base/OcRepresentation;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresentation3DArray + (JNIEnv *, jobject, jstring, jobjectArray); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: getJSONRepresentation + * Signature: ()Ljava/lang/String; + */ + JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcRepresentation_getJSONRepresentation + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: addChild + * Signature: (Lorg/iotivity/base/OcRepresentation;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_addChild + (JNIEnv *, jobject, jobject); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: clearChildren + * Signature: ()V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_clearChildren + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: getChildrenArray + * Signature: ()[Lorg/iotivity/base/OcRepresentation; + */ + JNIEXPORT jobjectArray JNICALL Java_org_iotivity_base_OcRepresentation_getChildrenArray + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: getUri + * Signature: ()Ljava/lang/String; + */ + JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcRepresentation_getUri + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: setUri + * Signature: (Ljava/lang/String;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setUri + (JNIEnv *, jobject, jstring); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: getResourceTypes + * Signature: ()Ljava/util/List; + */ + JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcRepresentation_getResourceTypes + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: setResourceTypeArray + * Signature: ([Ljava/lang/String;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setResourceTypeArray + (JNIEnv *, jobject, jobjectArray); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: getResourceInterfaces + * Signature: ()Ljava/util/List; + */ + JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcRepresentation_getResourceInterfaces + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: setResourceInterfaceArray + * Signature: ([Ljava/lang/String;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setResourceInterfaceArray + (JNIEnv *, jobject, jobjectArray); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: isEmpty + * Signature: ()Z + */ + JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_isEmpty + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: size + * Signature: ()I + */ + JNIEXPORT jint JNICALL Java_org_iotivity_base_OcRepresentation_size + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: remove + * Signature: (Ljava/lang/String;)Z + */ + JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_remove + (JNIEnv *, jobject, jstring); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: hasAttribute + * Signature: (Ljava/lang/String;)Z + */ + JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_hasAttribute + (JNIEnv *, jobject, jstring); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: setNull + * Signature: (Ljava/lang/String;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setNull + (JNIEnv *, jobject, jstring); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: isNull + * Signature: (Ljava/lang/String;)Z + */ + JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_isNull + (JNIEnv *, jobject, jstring); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: create + * Signature: ()V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_create + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcRepresentation + * Method: dispose + * Signature: ()V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_dispose + (JNIEnv *, jobject, jboolean); + +#ifdef __cplusplus +} +#endif +#endif \ No newline at end of file diff --git a/android/android_api/base/jni/JniOcRequestHandle.cpp b/android/android_api/base/jni/JniOcRequestHandle.cpp new file mode 100644 index 0000000..444689d --- /dev/null +++ b/android/android_api/base/jni/JniOcRequestHandle.cpp @@ -0,0 +1,63 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOcRequestHandle.h" + +JniOcRequestHandle::JniOcRequestHandle(OCRequestHandle requestHandle) : m_requestHandle(requestHandle) +{} + +JniOcRequestHandle::~JniOcRequestHandle() +{ + LOGD("~JniOcRequestHandle()"); +} + +JniOcRequestHandle* JniOcRequestHandle::getJniOcRequestHandlePtr +(JNIEnv *env, jobject thiz) +{ + JniOcRequestHandle *handle = GetHandle(env, thiz); + if (env->ExceptionCheck()) + { + LOGE("Failed to get native handle from OcRequestHandle"); + } + if (!handle) + { + ThrowOcException(JNI_NO_NATIVE_POINTER, ""); + } + return handle; +} + +OCRequestHandle JniOcRequestHandle::getOCRequestHandle() +{ + return this->m_requestHandle; +} + +/* +* Class: org_iotivity_base_OcRequestHandle +* Method: dispose +* Signature: ()V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcRequestHandle_dispose +(JNIEnv *env, jobject thiz) +{ + LOGD("OcRequestHandle_dispose"); + JniOcRequestHandle *handle = JniOcRequestHandle::getJniOcRequestHandlePtr(env, thiz); + delete handle; +} \ No newline at end of file diff --git a/android/android_api/base/jni/JniOcRequestHandle.h b/android/android_api/base/jni/JniOcRequestHandle.h new file mode 100644 index 0000000..2160728 --- /dev/null +++ b/android/android_api/base/jni/JniOcRequestHandle.h @@ -0,0 +1,58 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOcStack.h" +#include "ocstack.h" + +#ifndef _Included_org_iotivity_base_OcRequestHandle +#define _Included_org_iotivity_base_OcRequestHandle + +class JniOcRequestHandle +{ +public: + + JniOcRequestHandle(OCRequestHandle request); + ~JniOcRequestHandle(); + + static JniOcRequestHandle* getJniOcRequestHandlePtr(JNIEnv *env, jobject thiz); + + OCRequestHandle getOCRequestHandle(); + +private: + OCRequestHandle m_requestHandle; +}; + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * Class: org_iotivity_base_OcRequestHandle + * Method: dispose + * Signature: ()V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcRequestHandle_dispose + (JNIEnv *, jobject); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/android/android_api/base/jni/JniOcResource.cpp b/android/android_api/base/jni/JniOcResource.cpp new file mode 100644 index 0000000..2850d65 --- /dev/null +++ b/android/android_api/base/jni/JniOcResource.cpp @@ -0,0 +1,1520 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOcResource.h" +#include "JniOcRepresentation.h" +#include "JniUtils.h" + +JniOcResource::JniOcResource(std::shared_ptr resource) + : m_sharedResource(resource) +{} + +JniOcResource::~JniOcResource() +{ + LOGD("~JniOcResource()"); + m_sharedResource = NULL; + + jint envRet; + JNIEnv *env = GetJNIEnv(envRet); + if (NULL == env) return; + + m_onGetManager.removeAllListeners(env); + m_onPutManager.removeAllListeners(env); + m_onPostManager.removeAllListeners(env); + m_onDeleteManager.removeAllListeners(env); + m_onObserveManager.removeAllListeners(env); + + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); +} + +OCStackResult JniOcResource::get(JNIEnv* env, const QueryParamsMap &queryParametersMap, jobject jListener) +{ + JniOnGetListener *onGetListener = addOnGetListener(env, jListener); + + GetCallback getCallback = [onGetListener]( + const HeaderOptions& opts, + const OCRepresentation& rep, + const int eCode) + { + onGetListener->onGetCallback(opts, rep, eCode); + }; + + return m_sharedResource->get(queryParametersMap, getCallback); +} + +OCStackResult JniOcResource::get(JNIEnv* env, const QueryParamsMap &queryParametersMap, jobject jListener, + QualityOfService QoS) +{ + JniOnGetListener *onGetListener = addOnGetListener(env, jListener); + + GetCallback getCallback = [onGetListener](const HeaderOptions& opts, const OCRepresentation& rep, + const int eCode) + { + onGetListener->onGetCallback(opts, rep, eCode); + }; + + return m_sharedResource->get(queryParametersMap, getCallback, QoS); +} + +OCStackResult JniOcResource::get( + JNIEnv* env, + const std::string &resourceType, + const std::string &resourceInterface, + const QueryParamsMap &queryParametersMap, + jobject jListener) +{ + JniOnGetListener *onGetListener = addOnGetListener(env, jListener); + + GetCallback getCallback = [onGetListener](const HeaderOptions& opts, + const OCRepresentation& rep, const int eCode) + { + onGetListener->onGetCallback(opts, rep, eCode); + }; + + return m_sharedResource->get(resourceType, resourceInterface, queryParametersMap, + getCallback); +} + +OCStackResult JniOcResource::get(JNIEnv* env, const std::string &resourceType, + const std::string &resourceInterface, const QueryParamsMap &queryParametersMap, + jobject jListener, QualityOfService QoS) +{ + JniOnGetListener *onGetListener = addOnGetListener(env, jListener); + + GetCallback getCallback = [onGetListener](const HeaderOptions& opts, + const OCRepresentation& rep, const int eCode) + { + onGetListener->onGetCallback(opts, rep, eCode); + }; + + return m_sharedResource->get(resourceType, resourceInterface, queryParametersMap, + getCallback, QoS); +} + +OCStackResult JniOcResource::put(JNIEnv* env, const OCRepresentation &representation, + const QueryParamsMap &queryParametersMap, jobject jListener) +{ + JniOnPutListener *onPutListener = addOnPutListener(env, jListener); + + PutCallback putCallback = [onPutListener](const HeaderOptions& opts, + const OCRepresentation& rep, const int eCode) + { + onPutListener->onPutCallback(opts, rep, eCode); + }; + + return m_sharedResource->put(representation, queryParametersMap, putCallback); +} + +OCStackResult JniOcResource::put(JNIEnv* env, const OCRepresentation &representation, + const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS) +{ + JniOnPutListener *onPutListener = addOnPutListener(env, jListener); + + PutCallback putCallback = [onPutListener](const HeaderOptions& opts, + const OCRepresentation& rep, const int eCode) + { + onPutListener->onPutCallback(opts, rep, eCode); + }; + + return m_sharedResource->put(representation, queryParametersMap, putCallback, QoS); +} + +OCStackResult JniOcResource::put(JNIEnv* env, const std::string &resourceType, + const std::string &resourceInterface, const OCRepresentation &representation, + const QueryParamsMap &queryParametersMap, jobject jListener) +{ + JniOnPutListener *onPutListener = addOnPutListener(env, jListener); + + PutCallback putCallback = [onPutListener](const HeaderOptions& opts, + const OCRepresentation& rep, const int eCode) + { + onPutListener->onPutCallback(opts, rep, eCode); + }; + + return m_sharedResource->put(resourceType, resourceInterface, representation, + queryParametersMap, putCallback); +} + +OCStackResult JniOcResource::put(JNIEnv* env, const std::string &resourceType, + const std::string &resourceInterface, const OCRepresentation &representation, + const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS) +{ + JniOnPutListener *onPutListener = addOnPutListener(env, jListener); + + PutCallback putCallback = [onPutListener](const HeaderOptions& opts, + const OCRepresentation& rep, const int eCode) + { + onPutListener->onPutCallback(opts, rep, eCode); + }; + + return m_sharedResource->put(resourceType, resourceInterface, representation, + queryParametersMap, putCallback, QoS); +} + +OCStackResult JniOcResource::post(JNIEnv* env, const OCRepresentation &representation, + const QueryParamsMap &queryParametersMap, jobject jListener) +{ + JniOnPostListener *onPostListener = addOnPostListener(env, jListener); + + PostCallback postCallback = [onPostListener](const HeaderOptions& opts, + const OCRepresentation& rep, const int eCode) + { + onPostListener->onPostCallback(opts, rep, eCode); + }; + + return m_sharedResource->post(representation, queryParametersMap, postCallback); +} + +OCStackResult JniOcResource::post(JNIEnv* env, const OCRepresentation &representation, + const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS) +{ + JniOnPostListener *onPostListener = addOnPostListener(env, jListener); + + PostCallback postCallback = [onPostListener](const HeaderOptions& opts, + const OCRepresentation& rep, const int eCode) + { + onPostListener->onPostCallback(opts, rep, eCode); + }; + + return m_sharedResource->post(representation, queryParametersMap, postCallback, QoS); +} + +OCStackResult JniOcResource::post(JNIEnv* env, const std::string &resourceType, + const std::string &resourceInterface, const OCRepresentation &representation, + const QueryParamsMap &queryParametersMap, jobject jListener) +{ + JniOnPostListener *onPostListener = addOnPostListener(env, jListener); + + PostCallback postCallback = [onPostListener](const HeaderOptions& opts, + const OCRepresentation& rep, const int eCode) + { + onPostListener->onPostCallback(opts, rep, eCode); + }; + + return m_sharedResource->post(resourceType, resourceInterface, representation, + queryParametersMap, postCallback); +} + +OCStackResult JniOcResource::post(JNIEnv* env, const std::string &resourceType, + const std::string &resourceInterface, const OCRepresentation &representation, + const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS) +{ + JniOnPostListener *onPostListener = addOnPostListener(env, jListener); + + PostCallback postCallback = [onPostListener](const HeaderOptions& opts, + const OCRepresentation& rep, const int eCode) + { + onPostListener->onPostCallback(opts, rep, eCode); + }; + + return m_sharedResource->post(resourceType, resourceInterface, representation, + queryParametersMap, postCallback, QoS); +} + +OCStackResult JniOcResource::deleteResource(JNIEnv* env, jobject jListener) +{ + JniOnDeleteListener *onDeleteListener = addOnDeleteListener(env, jListener); + + DeleteCallback deleteCallback = [onDeleteListener](const HeaderOptions& opts, + const int eCode) + { + onDeleteListener->onDeleteCallback(opts, eCode); + }; + + return m_sharedResource->deleteResource(deleteCallback); +} + +OCStackResult JniOcResource::deleteResource(JNIEnv* env, jobject jListener, QualityOfService QoS) +{ + JniOnDeleteListener *onDeleteListener = addOnDeleteListener(env, jListener); + + DeleteCallback deleteCallback = [onDeleteListener](const HeaderOptions& opts, const int eCode) + { + onDeleteListener->onDeleteCallback(opts, eCode); + }; + + return m_sharedResource->deleteResource(deleteCallback, QoS); +} + +OCStackResult JniOcResource::observe(JNIEnv* env, ObserveType observeType, + const QueryParamsMap &queryParametersMap, jobject jListener) +{ + JniOnObserveListener *onObserveListener = addOnObserveListener(env, jListener); + + ObserveCallback observeCallback = [onObserveListener](const HeaderOptions& opts, + const OCRepresentation& rep, const int& eCode, const int& sequenceNumber) + { + onObserveListener->onObserveCallback(opts, rep, eCode, sequenceNumber); + }; + + return m_sharedResource->observe(observeType, queryParametersMap, observeCallback); +} + +OCStackResult JniOcResource::observe(JNIEnv* env, ObserveType observeType, + const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS) +{ + JniOnObserveListener *onObserveListener = addOnObserveListener(env, jListener); + + ObserveCallback observeCallback = [onObserveListener](const HeaderOptions& opts, + const OCRepresentation& rep, const int& eCode, const int& sequenceNumber) + { + onObserveListener->onObserveCallback(opts, rep, eCode, sequenceNumber); + }; + + return m_sharedResource->observe(observeType, queryParametersMap, observeCallback, QoS); +} + +OCStackResult JniOcResource::cancelObserve(JNIEnv* env) +{ + this->m_onObserveManager.removeAllListeners(env); + return m_sharedResource->cancelObserve(); +} + +OCStackResult JniOcResource::cancelObserve(JNIEnv* env, QualityOfService qos) +{ + //TODO confirm behavior + //add removal of java listeners by qos + this->m_onObserveManager.removeAllListeners(env); + return m_sharedResource->cancelObserve(qos); +} + +void JniOcResource::setHeaderOptions(const HeaderOptions &headerOptions) +{ + m_sharedResource->setHeaderOptions(headerOptions); +} + +void JniOcResource::unsetHeaderOptions() +{ + m_sharedResource->unsetHeaderOptions(); +} + +std::string JniOcResource::host() +{ + return m_sharedResource->host(); +} + +std::string JniOcResource::uri() +{ + return m_sharedResource->uri(); +} + +OCConnectivityType JniOcResource::connectivityType() const +{ + return m_sharedResource->connectivityType(); +} + +bool JniOcResource::isObservable() +{ + return m_sharedResource->isObservable(); +} + +std::vector< std::string > JniOcResource::getResourceTypes() const +{ + return m_sharedResource->getResourceTypes(); +} + +std::vector< std::string > JniOcResource::getResourceInterfaces(void) const +{ + return m_sharedResource->getResourceInterfaces(); +} + +OCResourceIdentifier JniOcResource::uniqueIdentifier() const +{ + return m_sharedResource->uniqueIdentifier(); +} + +std::string JniOcResource::sid() const +{ + return m_sharedResource->sid(); +} + +JniOnGetListener* JniOcResource::addOnGetListener(JNIEnv* env, jobject jListener) +{ + return this->m_onGetManager.addListener(env, jListener, this); +} + +JniOnPutListener* JniOcResource::addOnPutListener(JNIEnv* env, jobject jListener) +{ + return this->m_onPutManager.addListener(env, jListener, this); +} + +JniOnPostListener* JniOcResource::addOnPostListener(JNIEnv* env, jobject jListener) +{ + return this->m_onPostManager.addListener(env, jListener, this); +} + +JniOnDeleteListener* JniOcResource::addOnDeleteListener(JNIEnv* env, jobject jListener) +{ + return this->m_onDeleteManager.addListener(env, jListener, this); +} + +JniOnObserveListener* JniOcResource::addOnObserveListener(JNIEnv* env, jobject jListener) +{ + return this->m_onObserveManager.addListener(env, jListener, this); +} + +void JniOcResource::removeOnGetListener(JNIEnv* env, jobject jListener) +{ + this->m_onGetManager.removeListener(env, jListener); +} + +void JniOcResource::removeOnPutListener(JNIEnv* env, jobject jListener) +{ + this->m_onPutManager.removeListener(env, jListener); +} + +void JniOcResource::removeOnPostListener(JNIEnv* env, jobject jListener) +{ + this->m_onPostManager.removeListener(env, jListener); +} + +void JniOcResource::removeOnDeleteListener(JNIEnv* env, jobject jListener) +{ + this->m_onDeleteManager.removeListener(env, jListener); +} + +void JniOcResource::removeOnObserveListener(JNIEnv* env, jobject jListener) +{ + this->m_onObserveManager.removeListener(env, jListener); +} + +std::shared_ptr JniOcResource::getOCResource() +{ + return this->m_sharedResource; +} + +JniOcResource* JniOcResource::getJniOcResourcePtr(JNIEnv *env, jobject thiz) +{ + JniOcResource *resource = GetHandle(env, thiz); + if (env->ExceptionCheck()) + { + LOGE("Failed to get native handle from OcResource"); + } + if (!resource) + { + ThrowOcException(JNI_NO_NATIVE_POINTER, ""); + } + return resource; +} + +/* +* Class: org_iotivity_base_OcResource +* Method: get +* Signature: (Ljava/util/Map;Lorg/iotivity/base/OcResource/OnGetListener;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get +(JNIEnv *env, jobject thiz, jobject jQueryParamsMap, jobject jListener) +{ + LOGD("OcResource_get"); + if (!jQueryParamsMap) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null"); + return; + } + if (!jListener) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "onGetListener cannot be null"); + return; + } + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz); + if (!resource) return; + + QueryParamsMap qpm; + JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm); + + try + { + OCStackResult result = resource->get( + env, + qpm, + jListener); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "OcResource_get"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(e.code(), e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcResource +* Method: get1 +* Signature: (Ljava/util/Map;Lorg/iotivity/base/OcResource/OnGetListener;I)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get1 +(JNIEnv *env, jobject thiz, jobject jQueryParamsMap, jobject jListener, jint jQoS) +{ + LOGD("OcResource_get"); + if (!jQueryParamsMap) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null"); + return; + } + if (!jListener) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "onGetListener cannot be null"); + return; + } + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz); + if (!resource) return; + + QueryParamsMap qpm; + JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm); + + try + { + OCStackResult result = resource->get( + env, + qpm, + jListener, + JniUtils::getQOS(env, static_cast(jQoS))); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "OcResource_get"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(e.code(), e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcResource +* Method: get2 +* Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/util/Map; +Lorg/iotivity/base/OcResource/OnGetListener;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get2 +(JNIEnv *env, jobject thiz, jstring jResourceType, jstring jResourceInterface, +jobject jQueryParamsMap, jobject jListener) +{ + LOGD("OcResource_get"); + std::string resourceType; + if (jResourceType) + { + resourceType = env->GetStringUTFChars(jResourceType, NULL); + } + std::string resourceInterface; + if (jResourceInterface) + { + resourceInterface = env->GetStringUTFChars(jResourceInterface, NULL); + } + if (!jQueryParamsMap) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null"); + return; + } + if (!jListener) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "onGetListener cannot be null"); + return; + } + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz); + if (!resource) return; + + QueryParamsMap qpm; + JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm); + try + { + OCStackResult result = resource->get( + env, + resourceType, + resourceInterface, + qpm, + jListener); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "OcResource_get"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(e.code(), e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcResource +* Method: get3 +* Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/util/Map; +Lorg/iotivity/base/OcResource/OnGetListener;I)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get3 +(JNIEnv *env, jobject thiz, jstring jResourceType, jstring jResourceInterface, +jobject jQueryParamsMap, jobject jListener, jint jQoS) +{ + LOGD("OcResource_get"); + if (!jQueryParamsMap) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null"); + return; + } + if (!jListener) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "onGetListener cannot be null"); + return; + } + std::string resourceType; + if (jResourceType) + { + resourceType = env->GetStringUTFChars(jResourceType, NULL); + } + std::string resourceInterface; + if (jResourceInterface) + { + resourceInterface = env->GetStringUTFChars(jResourceInterface, NULL); + } + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz); + if (!resource) return; + + QueryParamsMap qpm; + JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm); + + try + { + OCStackResult result = resource->get( + env, + resourceType, + resourceInterface, + qpm, + jListener, + JniUtils::getQOS(env, static_cast(jQoS))); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "OcResource_get"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(e.code(), e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcResource +* Method: put +* Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map; +Lorg/iotivity/base/OcResource/OnPutListener;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put +(JNIEnv *env, jobject thiz, jobject jRepresentation, jobject jQueryParamsMap, jobject jListener) +{ + LOGD("OcResource_put"); + if (!jRepresentation) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null"); + return; + } + if (!jQueryParamsMap) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null"); + return; + } + if (!jListener) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "onPutListener cannot be null"); + return; + } + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz); + if (!resource) return; + + OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation); + if (!representation) return; + + QueryParamsMap qpm; + JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm); + + try + { + OCStackResult result = resource->put( + env, + *representation, + qpm, + jListener); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "OcResource_put"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(e.code(), e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcResource +* Method: put1 +* Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map; +Lorg/iotivity/base/OcResource/OnPutListener;I)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put1 +(JNIEnv *env, jobject thiz, jobject jRepresentation, jobject jQueryParamsMap, +jobject jListener, jint jQoS) +{ + LOGD("OcResource_put"); + if (!jRepresentation) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null"); + return; + } + if (!jQueryParamsMap) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null"); + return; + } + if (!jListener) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "onPutListener cannot be null"); + return; + } + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz); + if (!resource) return; + + OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation); + if (!representation) return; + + QueryParamsMap qpm; + JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm); + + try + { + OCStackResult result = resource->put( + env, + *representation, + qpm, + jListener, + JniUtils::getQOS(env, static_cast(jQoS))); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "OcResource_put"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(e.code(), e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcResource +* Method: put2 +* Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation; +Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPutListener;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put2 +(JNIEnv *env, jobject thiz, jstring jResourceType, jstring jResourceInterface, +jobject jRepresentation, jobject jQueryParamsMap, jobject jListener) +{ + LOGD("OcResource_put"); + std::string resourceType; + if (jResourceType) + { + resourceType = env->GetStringUTFChars(jResourceType, NULL); + } + std::string resourceInterface; + if (jResourceInterface) + { + resourceInterface = env->GetStringUTFChars(jResourceInterface, NULL); + } + if (!jRepresentation) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null"); + return; + } + if (!jQueryParamsMap) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null"); + return; + } + if (!jListener) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "onPutListener cannot be null"); + return; + } + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz); + if (!resource) return; + + OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation); + if (!representation) return; + + QueryParamsMap qpm; + JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm); + + try + { + OCStackResult result = resource->put( + env, + resourceType, + resourceInterface, + *representation, + qpm, + jListener); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "OcResource_put"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(e.code(), e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcResource +* Method: put3 +* Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation; +Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPutListener;I)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put3 +(JNIEnv *env, jobject thiz, jstring jResourceType, jstring jResourceInterface, jobject jRepresentation, +jobject jQueryParamsMap, jobject jListener, jint jQoS) +{ + LOGD("OcResource_put"); + if (!jRepresentation) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "representation cannot be null"); + return; + } + if (!jQueryParamsMap) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null"); + return; + } + if (!jListener) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "onPutListener cannot be null"); + return; + } + std::string resourceType; + if (jResourceType) + { + resourceType = env->GetStringUTFChars(jResourceType, NULL); + } + std::string resourceInterface; + if (jResourceInterface) + { + resourceInterface = env->GetStringUTFChars(jResourceInterface, NULL); + } + + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz); + if (!resource) return; + + OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation); + if (!representation) return; + + QueryParamsMap qpm; + JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm); + + try + { + OCStackResult result = resource->put( + env, + resourceType, + resourceInterface, + *representation, + qpm, + jListener, + JniUtils::getQOS(env, static_cast(jQoS))); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "OcResource_put"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(e.code(), e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcResource +* Method: post +* Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post +(JNIEnv *env, jobject thiz, jobject jRepresentation, jobject jQueryParamsMap, jobject jListener) +{ + LOGD("OcResource_post"); + if (!jRepresentation) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "representation cannot be null"); + return; + } + if (!jQueryParamsMap) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null"); + return; + } + if (!jListener) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "onPostListener cannot be null"); + return; + } + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz); + if (!resource) return; + + OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation); + if (!representation) return; + + QueryParamsMap qpm; + JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm); + + try + { + OCStackResult result = resource->post( + env, + *representation, + qpm, + jListener); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "OcResource_post"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(e.code(), e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcResource +* Method: post1 +* Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;I)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post1 +(JNIEnv *env, jobject thiz, jobject jRepresentation, jobject jQueryParamsMap, jobject jListener, jint jQoS) +{ + LOGD("OcResource_post"); + if (!jRepresentation) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "representation cannot be null"); + return; + } + if (!jQueryParamsMap) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null"); + return; + } + if (!jListener) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "onPostListener cannot be null"); + return; + } + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz); + if (!resource) return; + + OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation); + if (!representation) return; + + QueryParamsMap qpm; + JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm); + + try + { + OCStackResult result = resource->post( + env, + *representation, + qpm, + jListener, + JniUtils::getQOS(env, static_cast(jQoS))); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "OcResource_post"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(e.code(), e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcResource +* Method: post2 +* Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation; +Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post2 +(JNIEnv *env, jobject thiz, jstring jResourceType, jstring jResourceInterface, +jobject jRepresentation, jobject jQueryParamsMap, jobject jListener) +{ + LOGD("OcResource_post"); + if (!jRepresentation) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "representation cannot be null"); + return; + } + if (!jQueryParamsMap) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null"); + return; + } + if (!jListener) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "onPostListener cannot be null"); + return; + } + std::string resourceType; + if (jResourceType) + { + resourceType = env->GetStringUTFChars(jResourceType, NULL); + } + std::string resourceInterface; + if (jResourceInterface) + { + resourceInterface = env->GetStringUTFChars(jResourceInterface, NULL); + } + + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz); + if (!resource) return; + + OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation); + if (!representation) return; + + QueryParamsMap qpm; + JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm); + + try + { + OCStackResult result = resource->post( + env, + resourceType, + resourceInterface, + *representation, + qpm, + jListener); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "OcResource_post"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(e.code(), e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcResource +* Method: post3 +* Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation; +Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;I)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post3 +(JNIEnv *env, jobject thiz, jstring jResourceType, jstring jResourceInterface, +jobject jRepresentation, jobject jQueryParamsMap, jobject jListener, jint jQoS) +{ + LOGD("OcResource_post"); + if (!jRepresentation) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "representation cannot be null"); + return; + } + if (!jQueryParamsMap) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null"); + return; + } + if (!jListener) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "onPostListener cannot be null"); + return; + } + std::string resourceType; + if (jResourceType) + { + resourceType = env->GetStringUTFChars(jResourceType, NULL); + } + std::string resourceInterface; + if (jResourceInterface) + { + resourceInterface = env->GetStringUTFChars(jResourceInterface, NULL); + } + + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz); + if (!resource) return; + + OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation); + if (!representation) return; + + QueryParamsMap qpm; + JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm); + + try + { + OCStackResult result = resource->post( + env, + resourceType, + resourceInterface, + *representation, + qpm, + jListener, + JniUtils::getQOS(env, static_cast(jQoS))); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "OcResource_post"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(e.code(), e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcResource +* Method: deleteResource +* Signature: (Lorg/iotivity/base/OcResource/OnDeleteListener;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_deleteResource +(JNIEnv *env, jobject thiz, jobject jListener) +{ + LOGD("OcResource_deleteResource"); + if (!jListener) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "onDeleteListener cannot be null"); + return; + } + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz); + if (!resource) return; + + try + { + OCStackResult result = resource->deleteResource( + env, + jListener); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "OcResource_deleteResource"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(e.code(), e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcResource +* Method: deleteResource1 +* Signature: (Lorg/iotivity/base/OcResource/OnDeleteListener;I)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_deleteResource1 +(JNIEnv *env, jobject thiz, jobject jListener, jint jQoS) +{ + LOGD("OcResource_deleteResource"); + if (!jListener) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "onDeleteListener cannot be null"); + return; + } + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz); + if (!resource) return; + + try + { + OCStackResult result = resource->deleteResource( + env, + jListener, + JniUtils::getQOS(env, static_cast(jQoS))); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "OcResource_deleteResource"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(e.code(), e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcResource +* Method: observe +* Signature: (Lorg/iotivity/base/ObserveType;Ljava/util/Map; +Lorg/iotivity/base/OcResource/OnObserveListener;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_observe +(JNIEnv *env, jobject thiz, jint observeType, jobject jQueryParamsMap, jobject jListener) +{ + LOGD("OcResource_observe"); + if (!jQueryParamsMap) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null"); + return; + } + if (!jListener) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "onObserveListener cannot be null"); + return; + } + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz); + if (!resource) return; + + QueryParamsMap qpm; + JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm); + + try + { + OCStackResult result = resource->observe( + env, + JniUtils::getObserveType(env, static_cast(observeType)), + qpm, + jListener); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "OcResource_observe"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(e.code(), e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcResource +* Method: observe1 +* Signature: (Lorg/iotivity/base/ObserveType;Ljava/util/Map; +Lorg/iotivity/base/OcResource/OnObserveListener;I)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_observe1 +(JNIEnv *env, jobject thiz, jint observeType, jobject jQueryParamsMap, +jobject jListener, jint jQoS) +{ + LOGD("OcResource_observe"); + if (!jQueryParamsMap) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null"); + return; + } + if (!jListener) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "onObserveListener cannot be null"); + return; + } + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz); + if (!resource) return; + + QueryParamsMap qpm; + JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm); + + try + { + OCStackResult result = resource->observe( + env, + JniUtils::getObserveType(env, static_cast(observeType)), + qpm, + jListener, + JniUtils::getQOS(env, static_cast(jQoS))); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "OcResource_observe"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(e.code(), e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcResource +* Method: cancelObserve +* Signature: ()V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_cancelObserve +(JNIEnv *env, jobject thiz) +{ + LOGD("OcResource_cancelObserve"); + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz); + if (!resource) return; + + try + { + OCStackResult result = resource->cancelObserve(env); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "OcResource_cancelObserve"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(e.code(), e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcResource +* Method: cancelObserve1 +* Signature: I)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_cancelObserve1 +(JNIEnv *env, jobject thiz, jint jQoS) +{ + LOGD("OcResource_cancelObserve1"); + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz); + if (!resource) return; + + try + { + OCStackResult result = resource->cancelObserve( + env, + JniUtils::getQOS(env, static_cast(jQoS))); + + if (OC_STACK_OK != result) + { + ThrowOcException(result, "OcResource_cancelObserve"); + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(e.code(), e.reason().c_str()); + } +} + +/* +* Class: org_iotivity_base_OcResource +* Method: setHeaderOptions +* Signature: ([Lorg/iotivity/OcHeaderOption;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_setHeaderOptions +(JNIEnv *env, jobject thiz, jobjectArray jheaderOptionArr) +{ + LOGD("OcResource_setHeaderOptions"); + if (!jheaderOptionArr) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "headerOptionList cannot be null"); + return; + } + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz); + if (!resource) return; + + HeaderOptions headerOptions; + JniUtils::convertJavaHeaderOptionsArrToVector(env, jheaderOptionArr, headerOptions); + + resource->setHeaderOptions(headerOptions); +} + +/* +* Class: org_iotivity_base_OcResource +* Method: unsetHeaderOptions +* Signature: ()V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_unsetHeaderOptions +(JNIEnv *env, jobject thiz) +{ + LOGD("OcResource_unsetHeaderOptions"); + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz); + if (!resource) return; + + resource->unsetHeaderOptions(); +} + +/* +* Class: org_iotivity_base_OcResource +* Method: getHost +* Signature: ()Ljava/lang/String; +*/ +JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getHost +(JNIEnv *env, jobject thiz) +{ + LOGD("OcResource_getHost"); + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz); + if (!resource) return nullptr; + + return env->NewStringUTF(resource->host().c_str()); +} + +/* +* Class: org_iotivity_base_OcResource +* Method: getUri +* Signature: ()Ljava/lang/String; +*/ +JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getUri +(JNIEnv *env, jobject thiz) +{ + LOGD("OcResource_getUri"); + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz); + if (!resource) return nullptr; + + return env->NewStringUTF(resource->uri().c_str()); +} + +/* +* Class: org_iotivity_base_OcResource +* Method: getConnectivityTypeN +* Signature: ()I +*/ +JNIEXPORT jint JNICALL Java_org_iotivity_base_OcResource_getConnectivityTypeN +(JNIEnv *env, jobject thiz) +{ + LOGD("OcResource_getConnectivityType"); + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz); + if (!resource) return -1; + + OCConnectivityType connectivityType = resource->connectivityType(); + return static_cast(connectivityType); +} + +/* +* Class: org_iotivity_base_OcResource +* Method: isObservable +* Signature: ()Z +*/ +JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcResource_isObservable +(JNIEnv *env, jobject thiz) +{ + LOGD("OcResource_isObservable"); + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz); + return (jboolean)resource->isObservable(); +} + +/* +* Class: org_iotivity_base_OcResource +* Method: getResourceTypes +* Signature: ()Ljava/util/List; +*/ +JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResource_getResourceTypes +(JNIEnv *env, jobject thiz) +{ + LOGD("OcResource_getResourceTypes"); + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz); + if (!resource) return nullptr; + + std::vector resourceTypes = resource->getResourceTypes(); + + return JniUtils::convertStrVectorToJavaStrList(env, resourceTypes); +} + +/* +* Class: org_iotivity_base_OcResource +* Method: getResourceInterfaces +* Signature: ()Ljava/util/List; +*/ +JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResource_getResourceInterfaces +(JNIEnv *env, jobject thiz) +{ + LOGD("OcResource_getResourceInterfaces"); + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz); + if (!resource) return nullptr; + + std::vector resourceInterfaces = resource->getResourceInterfaces(); + + return JniUtils::convertStrVectorToJavaStrList(env, resourceInterfaces); +} + +/* +* Class: org_iotivity_base_OcResource +* Method: getUniqueIdentifier +* Signature: ()Lorg/iotivity/base/OcResourceIdentifier; +*/ +JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResource_getUniqueIdentifier +(JNIEnv *env, jobject thiz) +{ + LOGD("OcResource_getUniqueIdentifier"); + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz); + if (!resource) return nullptr; + + JniOcResourceIdentifier *jniResourceIdentifier = + new JniOcResourceIdentifier(resource->uniqueIdentifier()); + if (!jniResourceIdentifier) return nullptr; + + jlong handle = reinterpret_cast(jniResourceIdentifier); + jobject jResourceIdentifier = env->NewObject(g_cls_OcResourceIdentifier, + g_mid_OcResourceIdentifier_N_ctor, handle); + if (!jResourceIdentifier) + { + delete jniResourceIdentifier; + } + return jResourceIdentifier; +} + +/* +* Class: org_iotivity_base_OcResource +* Method: getServerId +* Signature: ()Ljava/lang/String; +*/ +JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getServerId +(JNIEnv *env, jobject thiz) +{ + LOGD("OcResource_getServerId"); + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz); + if (!resource) return nullptr; + + return env->NewStringUTF(resource->sid().c_str()); +} + +/* +* Class: org_iotivity_base_OcResource +* Method: dispose +* Signature: ()V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_dispose +(JNIEnv *env, jobject thiz) +{ + LOGD("OcResource_dispose"); + JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz); + delete resource; +} \ No newline at end of file diff --git a/android/android_api/base/jni/JniOcResource.h b/android/android_api/base/jni/JniOcResource.h new file mode 100644 index 0000000..737dd5f --- /dev/null +++ b/android/android_api/base/jni/JniOcResource.h @@ -0,0 +1,359 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOcStack.h" +#include "OCResource.h" +#include "JniListenerManager.h" +#include "JniOnGetListener.h" +#include "JniOnPutListener.h" +#include "JniOnPostListener.h" +#include "JniOnDeleteListener.h" +#include "JniOnObserveListener.h" +#include "JniOcResourceIdentifier.h" + +#ifndef _Included_org_iotivity_base_OcResource +#define _Included_org_iotivity_base_OcResource + +using namespace OC; + +class JniOcResource +{ +public: + JniOcResource(std::shared_ptr resource); + ~JniOcResource(); + + OCStackResult get(JNIEnv* env, const QueryParamsMap &queryParametersMap, jobject jListener); + OCStackResult get(JNIEnv* env, const QueryParamsMap &queryParametersMap, jobject jListener, + QualityOfService QoS); + OCStackResult get(JNIEnv* env, const std::string &resourceType, const std::string &resourceInterface, + const QueryParamsMap &queryParametersMap, jobject jListener); + OCStackResult get(JNIEnv* env, const std::string &resourceType, const std::string &resourceInterface, + const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS); + + OCStackResult put(JNIEnv* env, const OCRepresentation &representation, const QueryParamsMap &queryParametersMap, + jobject jListener); + OCStackResult put(JNIEnv* env, const OCRepresentation &representation, const QueryParamsMap &queryParametersMap, + jobject jListener, QualityOfService QoS); + OCStackResult put(JNIEnv* env, const std::string &resourceType, const std::string &resourceInterface, + const OCRepresentation &representation, const QueryParamsMap &queryParametersMap, jobject jListener); + OCStackResult put(JNIEnv* env, const std::string &resourceType, const std::string &resourceInterface, + const OCRepresentation &representation, const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS); + + OCStackResult post(JNIEnv* env, const OCRepresentation &representation, const QueryParamsMap &queryParametersMap, + jobject jListener); + OCStackResult post(JNIEnv* env, const OCRepresentation &representation, const QueryParamsMap &queryParametersMap, + jobject jListener, QualityOfService QoS); + OCStackResult post(JNIEnv* env, const std::string &resourceType, const std::string &resourceInterface, + const OCRepresentation &representation, const QueryParamsMap &queryParametersMap, jobject jListener); + OCStackResult post(JNIEnv* env, const std::string &resourceType, const std::string &resourceInterface, + const OCRepresentation &representation, const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS); + + OCStackResult deleteResource(JNIEnv* env, jobject jListener); + OCStackResult deleteResource(JNIEnv* env, jobject jListener, QualityOfService QoS); + + OCStackResult observe(JNIEnv* env, ObserveType observeType, const QueryParamsMap &queryParametersMap, + jobject jListener); + OCStackResult observe(JNIEnv* env, ObserveType observeType, const QueryParamsMap &queryParametersMap, + jobject jListener, QualityOfService qos); + + OCStackResult cancelObserve(JNIEnv* env); + OCStackResult cancelObserve(JNIEnv* env, QualityOfService qos); + + void setHeaderOptions(const HeaderOptions &headerOptions); + void unsetHeaderOptions(); + std::string host(); + std::string uri(); + OCConnectivityType connectivityType() const; + bool isObservable(); + std::vector< std::string > getResourceTypes() const; + std::vector< std::string > getResourceInterfaces(void) const; + OCResourceIdentifier uniqueIdentifier() const; + std::string sid() const; + + JniOnGetListener* addOnGetListener(JNIEnv* env, jobject jListener); + JniOnPutListener* addOnPutListener(JNIEnv* env, jobject jListener); + JniOnPostListener* addOnPostListener(JNIEnv* env, jobject jListener); + JniOnDeleteListener* addOnDeleteListener(JNIEnv* env, jobject jListener); + JniOnObserveListener* addOnObserveListener(JNIEnv* env, jobject jListener); + + void removeOnGetListener(JNIEnv* env, jobject jListener); + void removeOnPutListener(JNIEnv* env, jobject jListener); + void removeOnPostListener(JNIEnv* env, jobject jListener); + void removeOnDeleteListener(JNIEnv* env, jobject jListener); + void removeOnObserveListener(JNIEnv* env, jobject jListener); + + std::shared_ptr getOCResource(); + + static JniOcResource* getJniOcResourcePtr(JNIEnv *env, jobject thiz); + +private: + JniListenerManager m_onGetManager; + JniListenerManager m_onPutManager; + JniListenerManager m_onPostManager; + JniListenerManager m_onDeleteManager; + JniListenerManager m_onObserveManager; + + std::shared_ptr m_sharedResource; +}; + +/* DO NOT EDIT THIS FILE BEYOND THIS LINE - it is machine generated */ + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * Class: org_iotivity_base_OcResource + * Method: get + * Signature: (Ljava/util/Map;Lorg/iotivity/base/OcResource/OnGetListener;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get + (JNIEnv *, jobject, jobject, jobject); + + /* + * Class: org_iotivity_base_OcResource + * Method: get1 + * Signature: (Ljava/util/Map;Lorg/iotivity/base/OcResource/OnGetListener;I)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get1 + (JNIEnv *, jobject, jobject, jobject, jint); + + /* + * Class: org_iotivity_base_OcResource + * Method: get2 + * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnGetListener;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get2 + (JNIEnv *, jobject, jstring, jstring, jobject, jobject); + + /* + * Class: org_iotivity_base_OcResource + * Method: get3 + * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnGetListener;I)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get3 + (JNIEnv *, jobject, jstring, jstring, jobject, jobject, jint); + + /* + * Class: org_iotivity_base_OcResource + * Method: put + * Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPutListener;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put + (JNIEnv *, jobject, jobject, jobject, jobject); + + /* + * Class: org_iotivity_base_OcResource + * Method: put1 + * Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPutListener;I)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put1 + (JNIEnv *, jobject, jobject, jobject, jobject, jint); + + /* + * Class: org_iotivity_base_OcResource + * Method: put2 + * Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPutListener;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put2 + (JNIEnv *, jobject, jstring, jstring, jobject, jobject, jobject); + + /* + * Class: org_iotivity_base_OcResource + * Method: put3 + * Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPutListener;I)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put3 + (JNIEnv *, jobject, jstring, jstring, jobject, jobject, jobject, jint); + + /* + * Class: org_iotivity_base_OcResource + * Method: post + * Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post + (JNIEnv *, jobject, jobject, jobject, jobject); + + /* + * Class: org_iotivity_base_OcResource + * Method: post1 + * Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;I)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post1 + (JNIEnv *, jobject, jobject, jobject, jobject, jint); + + /* + * Class: org_iotivity_base_OcResource + * Method: post2 + * Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post2 + (JNIEnv *, jobject, jstring, jstring, jobject, jobject, jobject); + + /* + * Class: org_iotivity_base_OcResource + * Method: post3 + * Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;I)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post3 + (JNIEnv *, jobject, jstring, jstring, jobject, jobject, jobject, jint); + + /* + * Class: org_iotivity_base_OcResource + * Method: deleteResource + * Signature: (Lorg/iotivity/base/OcResource/OnDeleteListener;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_deleteResource + (JNIEnv *, jobject, jobject); + + /* + * Class: org_iotivity_base_OcResource + * Method: deleteResource1 + * Signature: (Lorg/iotivity/base/OcResource/OnDeleteListener;I)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_deleteResource1 + (JNIEnv *, jobject, jobject, jint); + + /* + * Class: org_iotivity_base_OcResource + * Method: observe + * Signature: (Lorg/iotivity/base/ObserveType;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnObserveListener;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_observe + (JNIEnv *, jobject, jint, jobject, jobject); + + /* + * Class: org_iotivity_base_OcResource + * Method: observe1 + * Signature: (Lorg/iotivity/base/ObserveType;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnObserveListener;I)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_observe1 + (JNIEnv *, jobject, jint, jobject, jobject, jint); + + /* + * Class: org_iotivity_base_OcResource + * Method: cancelObserve + * Signature: ()V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_cancelObserve + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcResource + * Method: cancelObserve1 + * Signature: (I)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_cancelObserve1 + (JNIEnv *, jobject, jint); + + /* + * Class: org_iotivity_base_OcResource + * Method: setHeaderOptions + * Signature: ([Lorg/iotivity/OcHeaderOption;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_setHeaderOptions + (JNIEnv *, jobject, jobjectArray); + + /* + * Class: org_iotivity_base_OcResource + * Method: unsetHeaderOptions + * Signature: ()V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_unsetHeaderOptions + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcResource + * Method: getHost + * Signature: ()Ljava/lang/String; + */ + JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getHost + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcResource + * Method: getUri + * Signature: ()Ljava/lang/String; + */ + JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getUri + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcResource + * Method: getConnectivityTypeN + * Signature: ()I + */ + JNIEXPORT jint JNICALL Java_org_iotivity_base_OcResource_getConnectivityTypeN + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcResource + * Method: isObservable + * Signature: ()Z + */ + JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcResource_isObservable + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcResource + * Method: getResourceTypes + * Signature: ()Ljava/util/List; + */ + JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResource_getResourceTypes + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcResource + * Method: getResourceInterfaces + * Signature: ()Ljava/util/List; + */ + JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResource_getResourceInterfaces + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcResource + * Method: getUniqueIdentifier + * Signature: ()Lorg/iotivity/base/OcResourceIdentifier; + */ + JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResource_getUniqueIdentifier + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcResource + * Method: getServerId + * Signature: ()Ljava/lang/String; + */ + JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getServerId + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcResource + * Method: dispose + * Signature: ()V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_dispose + (JNIEnv *, jobject); + +#ifdef __cplusplus +} +#endif +#endif \ No newline at end of file diff --git a/android/android_api/base/jni/JniOcResourceHandle.cpp b/android/android_api/base/jni/JniOcResourceHandle.cpp new file mode 100644 index 0000000..84f748e --- /dev/null +++ b/android/android_api/base/jni/JniOcResourceHandle.cpp @@ -0,0 +1,66 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOcResourceHandle.h" + +using namespace OC; + +JniOcResourceHandle::JniOcResourceHandle(OCResourceHandle resourceHandle) + : m_resourceHandle(resourceHandle) +{} + +JniOcResourceHandle::~JniOcResourceHandle() +{ + LOGD("~JniOcResourceHandle()"); +} + +JniOcResourceHandle* JniOcResourceHandle::getJniOcResourceHandlePtr +(JNIEnv *env, jobject thiz) +{ + JniOcResourceHandle *handle = GetHandle(env, thiz); + if (env->ExceptionCheck()) + { + LOGE("Failed to get native handle from OcResourceHandle"); + } + if (!handle) + { + ThrowOcException(JNI_NO_NATIVE_POINTER, ""); + } + return handle; +} + +OCResourceHandle JniOcResourceHandle::getOCResourceHandle() +{ + return this->m_resourceHandle; +} + +/* +* Class: org_iotivity_base_OcResourceHandle +* Method: dispose +* Signature: ()V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceHandle_dispose +(JNIEnv *env, jobject thiz) +{ + LOGD("OcResourceHandle_dispose"); + JniOcResourceHandle *resourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(env, thiz); + delete resourceHandle; +} \ No newline at end of file diff --git a/android/android_api/base/jni/JniOcResourceHandle.h b/android/android_api/base/jni/JniOcResourceHandle.h new file mode 100644 index 0000000..b8b4e1c --- /dev/null +++ b/android/android_api/base/jni/JniOcResourceHandle.h @@ -0,0 +1,56 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOcStack.h" +#include "JniEntityHandler.h" + +#ifndef _Included_org_iotivity_base_OcResourceHandle +#define _Included_org_iotivity_base_OcResourceHandle + +class JniOcResourceHandle +{ +public: + JniOcResourceHandle(OCResourceHandle resourceHandle); + ~JniOcResourceHandle(); + + static JniOcResourceHandle* getJniOcResourceHandlePtr(JNIEnv *env, jobject thiz); + + OCResourceHandle getOCResourceHandle(); +private: + OCResourceHandle m_resourceHandle; +}; + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * Class: org_iotivity_base_OcResourceHandle + * Method: dispose + * Signature: ()V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceHandle_dispose + (JNIEnv *, jobject); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/android/android_api/base/jni/JniOcResourceIdentifier.cpp b/android/android_api/base/jni/JniOcResourceIdentifier.cpp new file mode 100644 index 0000000..59b918c --- /dev/null +++ b/android/android_api/base/jni/JniOcResourceIdentifier.cpp @@ -0,0 +1,89 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOcResourceIdentifier.h" + +JniOcResourceIdentifier::JniOcResourceIdentifier(OC::OCResourceIdentifier resourceIdentifier) + : m_resourceIdentifier(resourceIdentifier) +{} + +JniOcResourceIdentifier::~JniOcResourceIdentifier() +{ + LOGD("~JniOcResourceIdentifier()"); +} + +OC::OCResourceIdentifier JniOcResourceIdentifier::getOCResourceIdentifier() +{ + return this->m_resourceIdentifier; +} + +JniOcResourceIdentifier* JniOcResourceIdentifier::getJniOcResourceIdentifierPtr +(JNIEnv *env, jobject thiz) +{ + JniOcResourceIdentifier *identifier = GetHandle(env, thiz); + if (env->ExceptionCheck()) + { + LOGE("Failed to get native handle from OcResourceIdentifier"); + } + if (!identifier) + { + ThrowOcException(JNI_NO_NATIVE_POINTER, ""); + } + return identifier; +} + +/* +* Class: org_iotivity_base_OcResourceIdentifier +* Method: equalsN +* Signature: (Lorg/iotivity/base/OcResourceIdentifier;)Z +*/ +JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcResourceIdentifier_equalsN +(JNIEnv *env, jobject jThiz, jobject jOther) +{ + JniOcResourceIdentifier *thiz = JniOcResourceIdentifier::getJniOcResourceIdentifierPtr(env, jThiz); + if (!thiz) return false; + + JniOcResourceIdentifier *other = JniOcResourceIdentifier::getJniOcResourceIdentifierPtr(env, jOther); + if (!other) return false; + + if (thiz->getOCResourceIdentifier() == other->getOCResourceIdentifier()) + { + return true; + } + else + { + return false; + } +} + +/* +* Class: org_iotivity_base_OcResourceIdentifier +* Method: dispose +* Signature: ()V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceIdentifier_dispose +(JNIEnv *env, jobject thiz) +{ + LOGD("JniOcResourceIdentifier_dispose"); + JniOcResourceIdentifier *identifier = JniOcResourceIdentifier::getJniOcResourceIdentifierPtr(env, thiz); + delete identifier; +} \ No newline at end of file diff --git a/android/android_api/base/jni/JniOcResourceIdentifier.h b/android/android_api/base/jni/JniOcResourceIdentifier.h new file mode 100644 index 0000000..9c7651a --- /dev/null +++ b/android/android_api/base/jni/JniOcResourceIdentifier.h @@ -0,0 +1,65 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOcStack.h" +#include "OCResource.h" + +#ifndef _Included_org_iotivity_base_OcResourceIdentifier +#define _Included_org_iotivity_base_OcResourceIdentifier + +class JniOcResourceIdentifier +{ +public: + + JniOcResourceIdentifier(OC::OCResourceIdentifier identifier); + ~JniOcResourceIdentifier(); + + static JniOcResourceIdentifier* getJniOcResourceIdentifierPtr(JNIEnv *env, jobject thiz); + + OC::OCResourceIdentifier getOCResourceIdentifier(); + +private: + OC::OCResourceIdentifier m_resourceIdentifier; +}; + +#ifdef __cplusplus +extern "C" { +#endif + /* + * Class: org_iotivity_base_OcResourceIdentifier + * Method: equalsN + * Signature: (Lorg/iotivity/base/OcResourceIdentifier;)Z + */ + JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcResourceIdentifier_equalsN + (JNIEnv *, jobject, jobject); + + /* + * Class: org_iotivity_base_OcResourceIdentifier + * Method: dispose + * Signature: ()V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceIdentifier_dispose + (JNIEnv *, jobject); + +#ifdef __cplusplus +} +#endif +#endif \ No newline at end of file diff --git a/android/android_api/base/jni/JniOcResourceRequest.cpp b/android/android_api/base/jni/JniOcResourceRequest.cpp new file mode 100644 index 0000000..b1d981c --- /dev/null +++ b/android/android_api/base/jni/JniOcResourceRequest.cpp @@ -0,0 +1,321 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOcResourceRequest.h" +#include "OCResourceRequest.h" +#include "JniOcResourceHandle.h" +#include "JniOcRequestHandle.h" +#include "JniUtils.h" + +using namespace OC; + +JniOcResourceRequest::JniOcResourceRequest(const std::shared_ptr request) + : m_request(request) +{} + +JniOcResourceRequest::~JniOcResourceRequest() +{} + +std::string +JniOcResourceRequest::getRequestType() +{ + return m_request->getRequestType(); +} + +const QueryParamsMap& +JniOcResourceRequest::getQueryParameters() const +{ + return m_request->getQueryParameters(); +} + +int +JniOcResourceRequest::getRequestHandlerFlag() const +{ + return m_request->getRequestHandlerFlag(); +} + +const OCRepresentation& +JniOcResourceRequest::getResourceRepresentation() const +{ + return m_request->getResourceRepresentation(); +} + +const ObservationInfo& +JniOcResourceRequest::getObservationInfo() const +{ + return m_request->getObservationInfo(); +} + +void +JniOcResourceRequest::setResourceUri(const std::string resourceUri) +{ + m_request->setResourceUri(resourceUri); +} + +std::string +JniOcResourceRequest::getResourceUri(void) +{ + return m_request->getResourceUri(); +} + +const HeaderOptions& +JniOcResourceRequest::getHeaderOptions() const +{ + return m_request->getHeaderOptions(); +} + +const OCRequestHandle& +JniOcResourceRequest::getRequestHandle() const +{ + return m_request->getRequestHandle(); +} + +const OCResourceHandle& +JniOcResourceRequest::getResourceHandle() const +{ + return m_request->getResourceHandle(); +} + +JniOcResourceRequest* JniOcResourceRequest::getJniOcResourceRequestPtr +(JNIEnv *env, jobject thiz) +{ + JniOcResourceRequest *request = GetHandle(env, thiz); + if (env->ExceptionCheck()) + { + LOGE("Failed to get native handle from OcResourceRequest"); + } + if (!request) + { + ThrowOcException(JNI_NO_NATIVE_POINTER, ""); + } + return request; +} + +/* +* Class: org_iotivity_base_OcResourceRequest +* Method: getRequestTypeNative +* Signature: ()Ljava/lang/String; +*/ +JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResourceRequest_getRequestTypeNative +(JNIEnv *env, jobject thiz) +{ + LOGD("OcResourceRequest_getRequestTypeNative"); + JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz); + if (!request) return nullptr; + + std::string requestType = request->getRequestType(); + return env->NewStringUTF(requestType.c_str()); +} + +/* +* Class: org_iotivity_base_OcResourceRequest +* Method: getQueryParameters +* Signature: ()Ljava/util/Map; +*/ +JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getQueryParameters +(JNIEnv *env, jobject thiz) +{ + LOGD("OcResourceRequest_getQueryParameters"); + JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz); + if (!request) return nullptr; + + return JniUtils::convertQueryParamsMapToJavaMap(env, request->getQueryParameters()); +} + +/* +* Class: org_iotivity_base_OcResourceRequest +* Method: getRequestHandlerFlagNative +* Signature: ()I +*/ +JNIEXPORT jint JNICALL Java_org_iotivity_base_OcResourceRequest_getRequestHandlerFlagNative +(JNIEnv *env, jobject thiz) +{ + LOGD("OcResourceRequest_getRequestHandlerFlagNative"); + JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz); + if (!request) return -1; + + return static_cast(request->getRequestHandlerFlag()); +} + +/* +* Class: org_iotivity_base_OcResourceRequest +* Method: getResourceRepresentation +* Signature: ()Lorg/iotivity/base/OcRepresentation; +*/ +JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getResourceRepresentation +(JNIEnv *env, jobject thiz) +{ + LOGD("OcResourceRequest_getResourceRepresentation"); + JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz); + if (!request) return nullptr; + + OCRepresentation *ocRepresentation = new OCRepresentation(request->getResourceRepresentation()); + if (!ocRepresentation) return nullptr; + + jlong handle = reinterpret_cast(ocRepresentation); + jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool, + handle, true); + if (!jRepresentation) + { + LOGE("Failed to create OcRepresentation"); + delete ocRepresentation; + } + + return jRepresentation; +} + +/* +* Class: org_iotivity_base_OcResourceRequest +* Method: getObservationInfo +* Signature: ()Lorg/iotivity/base/ObservationInfo; +*/ +JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getObservationInfo +(JNIEnv *env, jobject thiz) +{ + LOGD("OcResourceRequest_getObservationInfo"); + JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz); + if (!request) return nullptr; + + ObservationInfo oInfo = request->getObservationInfo(); + + jobject jObservationInfo = env->NewObject(g_cls_ObservationInfo, g_mid_ObservationInfo_N_ctor, + (jint)oInfo.action, (jbyte)oInfo.obsId); + + if (!jObservationInfo) + { + LOGE("Failed to create ObservationInfo"); + } + + return jObservationInfo; +} + +/* +* Class: org_iotivity_base_OcResourceRequest +* Method: setResourceUri +* Signature: (Ljava/lang/String); +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceRequest_setResourceUri +(JNIEnv *env, jobject thiz, jstring jUri) +{ + LOGD("OcResourceRequest_setResourceUri"); + if (!jUri) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "URI cannot be null"); + return; + } + JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz); + if (!request) return; + + request->setResourceUri(env->GetStringUTFChars(jUri, 0)); +} + +/* +* Class: org_iotivity_base_OcResourceRequest +* Method: getResourceUri +* Signature: ()Ljava/lang/String; +*/ +JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResourceRequest_getResourceUri +(JNIEnv *env, jobject thiz) +{ + LOGD("OcResourceRequest_getResourceUri"); + JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz); + if (!request) return nullptr; + + std::string requestUri = request->getResourceUri(); + return env->NewStringUTF(requestUri.c_str()); +} + +/* +* Class: org_iotivity_base_OcResourceRequest +* Method: getHeaderOptions +* Signature: ()Ljava/util/List; +*/ +JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getHeaderOptions +(JNIEnv *env, jobject thiz) +{ + LOGD("OcResourceRequest_getHeaderOptions"); + JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz); + if (!request) return nullptr; + + return JniUtils::convertHeaderOptionsVectorToJavaList(env, request->getHeaderOptions()); +} + +/* +* Class: org_iotivity_base_OcResourceRequest +* Method: getRequestHandle +* Signature: ()Lorg/iotivity/base/OcRequestHandle; +*/ +JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getRequestHandle +(JNIEnv *env, jobject thiz) +{ + LOGD("OcResourceRequest_getRequestHandle"); + JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz); + if (!request) return nullptr; + + JniOcRequestHandle* jniHandle = new JniOcRequestHandle(request->getRequestHandle()); + jlong handle = reinterpret_cast(jniHandle); + jobject jRequestHandle = env->NewObject(g_cls_OcRequestHandle, g_mid_OcRequestHandle_N_ctor, handle); + if (!jRequestHandle) + { + LOGE("Failed to create OcRequestHandle"); + delete jniHandle; + } + + return jRequestHandle; +} + +/* +* Class: org_iotivity_base_OcResourceRequest +* Method: getResourceHandle +* Signature: ()Lorg/iotivity/base/OcResourceHandle; +*/ +JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getResourceHandle +(JNIEnv *env, jobject thiz) +{ + LOGD("OcResourceRequest_getResourceHandle"); + JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz); + if (!request) return nullptr; + + JniOcResourceHandle* jniHandle = new JniOcResourceHandle( + request->getResourceHandle()); + jlong handle = reinterpret_cast(jniHandle); + jobject jResourceHandle = env->NewObject(g_cls_OcResourceHandle, g_mid_OcResourceHandle_N_ctor, handle); + if (!jResourceHandle) + { + LOGE("Failed to create OcResourceHandle"); + delete jniHandle; + } + + return jResourceHandle; +} + +/* +* Class: org_iotivity_base_OcResourceRequest +* Method: dispose +* Signature: ()V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceRequest_dispose +(JNIEnv *env, jobject thiz) +{ + LOGD("OcResourceRequest_dispose"); + JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz); + delete request; +} \ No newline at end of file diff --git a/android/android_api/base/jni/JniOcResourceRequest.h b/android/android_api/base/jni/JniOcResourceRequest.h new file mode 100644 index 0000000..5b58f0c --- /dev/null +++ b/android/android_api/base/jni/JniOcResourceRequest.h @@ -0,0 +1,158 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOcStack.h" + +#ifndef _Included_org_iotivity_base_OcResourceRequest +#define _Included_org_iotivity_base_OcResourceRequest + +using namespace OC; + +class JniOcResourceRequest +{ +public: + JniOcResourceRequest(const std::shared_ptr resourceRequest); + + ~JniOcResourceRequest(); + + std::string getRequestType(); + + const QueryParamsMap& getQueryParameters() const; + + int getRequestHandlerFlag() const; + + const OCRepresentation& getResourceRepresentation() const; + + const ObservationInfo& getObservationInfo() const; + + void setResourceUri(const std::string resourceUri); + + std::string getResourceUri(void); + + const HeaderOptions& getHeaderOptions() const; + + const OCRequestHandle& getRequestHandle() const; + + const OCResourceHandle& getResourceHandle() const; + + static JniOcResourceRequest* getJniOcResourceRequestPtr + (JNIEnv *env, jobject thiz); + +private: + std::shared_ptr m_request; +}; + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * Class: org_iotivity_base_OcResourceRequest + * Method: getRequestTypeNative + * Signature: ()Ljava/lang/String; + */ + JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResourceRequest_getRequestTypeNative + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcResourceRequest + * Method: getQueryParameters + * Signature: ()Ljava/util/Map; + */ + JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getQueryParameters + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcResourceRequest + * Method: getRequestHandlerFlagNative + * Signature: ()I + */ + JNIEXPORT jint JNICALL Java_org_iotivity_base_OcResourceRequest_getRequestHandlerFlagNative + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcResourceRequest + * Method: getResourceRepresentation + * Signature: ()Lorg/iotivity/base/OcRepresentation; + */ + JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getResourceRepresentation + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcResourceRequest + * Method: getObservationInfo + * Signature: ()Lorg/iotivity/base/ObservationInfo; + */ + JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getObservationInfo + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcResourceRequest + * Method: setResourceUri + * Signature: (Ljava/lang/String;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceRequest_setResourceUri + (JNIEnv *, jobject, jstring); + + /* + * Class: org_iotivity_base_OcResourceRequest + * Method: getResourceUri + * Signature: ()Ljava/lang/String; + */ + JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResourceRequest_getResourceUri + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcResourceRequest + * Method: getHeaderOptions + * Signature: ()Ljava/util/List; + */ + JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getHeaderOptions + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcResourceRequest + * Method: getRequestHandle + * Signature: ()Lorg/iotivity/base/OcRequestHandle; + */ + JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getRequestHandle + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcResourceRequest + * Method: getResourceHandle + * Signature: ()Lorg/iotivity/base/OcResourceHandle; + */ + JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getResourceHandle + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcResourceRequest + * Method: dispose + * Signature: ()V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceRequest_dispose + (JNIEnv *, jobject); + +#ifdef __cplusplus +} +#endif +#endif \ No newline at end of file diff --git a/android/android_api/base/jni/JniOcResourceResponse.cpp b/android/android_api/base/jni/JniOcResourceResponse.cpp new file mode 100644 index 0000000..f8771c3 --- /dev/null +++ b/android/android_api/base/jni/JniOcResourceResponse.cpp @@ -0,0 +1,320 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOcResourceResponse.h" +#include "OCResourceResponse.h" +#include "JniOcRepresentation.h" +#include "JniOcRequestHandle.h" +#include "JniOcResourceHandle.h" +#include "JniUtils.h" + +using namespace OC; + +JniOcResourceResponse::JniOcResourceResponse +(std::shared_ptr resourceResponse) +: m_response(resourceResponse){} + +JniOcResourceResponse::~JniOcResourceResponse() +{} + +void JniOcResourceResponse::setErrorCode(const int eCode) +{ + this->m_response->setErrorCode(eCode); +} + +std::string JniOcResourceResponse::getNewResourceUri(void) +{ + this->m_response->getNewResourceUri(); +} + +void +JniOcResourceResponse::setNewResourceUri(const std::string newResourceUri) +{ + this->m_response->setNewResourceUri(newResourceUri); +} + +void JniOcResourceResponse::setHeaderOptions(const HeaderOptions& headerOptions) +{ + this->m_response->setHeaderOptions(headerOptions); +} + +void JniOcResourceResponse::setRequestHandle(const OCRequestHandle& requestHandle) +{ + this->m_response->setRequestHandle(requestHandle); +} + +void JniOcResourceResponse::setResourceHandle(const OCResourceHandle& resourceHandle) +{ + this->m_response->setResourceHandle(resourceHandle); +} + +void JniOcResourceResponse::setResponseResult(const OCEntityHandlerResult& responseResult) +{ + this->m_response->setResponseResult(responseResult); +} + +void JniOcResourceResponse::setResourceRepresentation(OCRepresentation& rep, + std::string interfaceStr) +{ + this->m_response->setResourceRepresentation(rep, interfaceStr); +} + +void JniOcResourceResponse::setResourceRepresentation(OCRepresentation& rep) +{ + this->m_response->setResourceRepresentation(rep); +} + +std::shared_ptr JniOcResourceResponse::getOCResourceResponse() +{ + return this->m_response; +} + +JniOcResourceResponse* JniOcResourceResponse::getJniOcResourceResponsePtr +(JNIEnv *env, jobject thiz) +{ + JniOcResourceResponse *request = GetHandle(env, thiz); + if (env->ExceptionCheck()) + { + LOGE("Failed to get native handle from JniOcResourceResponse"); + } + if (!request) + { + ThrowOcException(JNI_NO_NATIVE_POINTER, ""); + } + return request; +} +/* +* Class: org_iotivity_base_OcResourceResponse +* Method: setErrorCode +* Signature: (I)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setErrorCode +(JNIEnv *env, jobject thiz, jint eCode) +{ + LOGD("OcResourceResponse_setErrorCode"); + JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz); + if (!response) return; + + response->setErrorCode(static_cast(eCode)); +} + +/* +* Class: org_iotivity_base_OcResourceResponse +* Method: getNewResourceUri +* Signature: ()Ljava/lang/String; +*/ +JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResourceResponse_getNewResourceUri +(JNIEnv *env, jobject thiz) +{ + LOGD("OcResourceResponse_getNewResourceUri"); + JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz); + if (!response) return nullptr; + + return env->NewStringUTF(response->getNewResourceUri().c_str()); +} + +/* +* Class: org_iotivity_base_OcResourceResponse +* Method: setNewResourceUri +* Signature: (Ljava/lang/String;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setNewResourceUri +(JNIEnv *env, jobject thiz, jstring jstr) +{ + LOGD("OcResourceResponse_setNewResourceUri"); + JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz); + if (!response) return; + + response->setNewResourceUri(env->GetStringUTFChars(jstr, 0)); +} + +/* +* Class: org_iotivity_base_OcResourceResponse +* Method: setHeaderOptions +* Signature: (Ljava/util/List;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setHeaderOptions +(JNIEnv *env, jobject thiz, jobjectArray jHeaderOptions) +{ + LOGD("OcResourceResponse_setHeaderOptions"); + if (!jHeaderOptions) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "headerOptionList cannot be null"); + return; + } + JniOcResourceResponse *jniResponse = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz); + if (!jniResponse) return; + + HeaderOptions headerOptions; + JniUtils::convertJavaHeaderOptionsArrToVector(env, jHeaderOptions, headerOptions); + + jniResponse->setHeaderOptions(headerOptions); +} + +/* +* Class: org_iotivity_base_OcResourceResponse +* Method: setRequestHandle +* Signature: (Lorg/iotivity/base/OcRequestHandle;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setRequestHandle +(JNIEnv *env, jobject thiz, jobject jRequestHandle) +{ + LOGI("OcResourceResponse_setRequestHandle"); + if (!jRequestHandle) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "requestHandle cannot be null"); + return; + } + JniOcResourceResponse *jniResponse = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz); + if (!jniResponse) return; + + JniOcRequestHandle* jniOcRequestHandle = JniOcRequestHandle::getJniOcRequestHandlePtr(env, jRequestHandle); + if (!jniOcRequestHandle) return; + + jniResponse->setRequestHandle(jniOcRequestHandle->getOCRequestHandle()); +} + +/* +* Class: org_iotivity_base_OcResourceResponse +* Method: setResourceHandle +* Signature: (Lorg/iotivity/base/OcResourceHandle;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResourceHandle +(JNIEnv *env, jobject thiz, jobject jResourceHandle) +{ + LOGI("OcResourceResponse_setResourceHandle"); + if (!jResourceHandle) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null"); + return; + } + JniOcResourceResponse *jniResponse = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz); + if (!jniResponse) return; + + JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(env, jResourceHandle); + if (!jniOcResourceHandle) return; + + jniResponse->setResourceHandle(jniOcResourceHandle->getOCResourceHandle()); +} + +/* +* Class: org_iotivity_base_OcResourceResponse +* Method: setResponseResult +* Signature: (I)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResponseResult +(JNIEnv *env, jobject thiz, jint responseResult) +{ + LOGD("OcResourceResponse_setResponseResult"); + JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz); + if (!response) return; + + response->setResponseResult(JniUtils::getOCEntityHandlerResult(env, static_cast(responseResult))); +} + +/* +* Class: org_iotivity_base_OcResourceResponse +* Method: setResourceRepresentation +* Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/lang/String;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResourceRepresentation +(JNIEnv *env, jobject thiz, jobject jRepresentation, jstring jstr) +{ + LOGD("OcResourceResponse_setResourceRepresentation"); + if (!jRepresentation) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "Representation cannot be null"); + return; + } + if (!jstr) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "interface cannot be null"); + return; + } + + JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, + thiz); + if (!response) return; + + OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, + jRepresentation); + if (!representation) return; + + response->setResourceRepresentation(*representation, env->GetStringUTFChars(jstr, 0)); +} + +/* +* Class: org_iotivity_base_OcResourceResponse +* Method: setResourceRepresentation1 +* Signature: (Lorg/iotivity/base/OcRepresentation;)V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResourceRepresentation1 +(JNIEnv *env, jobject thiz, jobject jRepresentation) +{ + LOGD("OcResourceResponse_setResourceRepresentation"); + if (!jRepresentation) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "Representation cannot be null"); + return; + } + JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz); + if (!response) return; + + OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, + jRepresentation); + + if (representation) + { + response->setResourceRepresentation(*representation); + } +} + +/* +* Class: org_iotivity_base_OcResourceResponse +* Method: create +* Signature: ()V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_create +(JNIEnv *env, jobject thiz) +{ + LOGI("OcResourceResponse_create"); + auto pResponse = std::make_shared(); + JniOcResourceResponse* jniResourceResponse = new JniOcResourceResponse(pResponse); + SetHandle(env, thiz, jniResourceResponse); + if (env->ExceptionCheck()) + { + LOGE("Failed to create OcResourceResponse"); + delete jniResourceResponse; + } +} + +/* +* Class: org_iotivity_base_OcResourceResponse +* Method: dispose +* Signature: ()V +*/ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_dispose +(JNIEnv *env, jobject thiz) +{ + LOGD("OcResourceResponse_dispose"); + JniOcResourceResponse *resp = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz); + delete resp; +} \ No newline at end of file diff --git a/android/android_api/base/jni/JniOcResourceResponse.h b/android/android_api/base/jni/JniOcResourceResponse.h new file mode 100644 index 0000000..acabdf6 --- /dev/null +++ b/android/android_api/base/jni/JniOcResourceResponse.h @@ -0,0 +1,144 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOcStack.h" +#include "OCResourceResponse.h" + +#ifndef _Included_org_iotivity_base_OcResourceResponse +#define _Included_org_iotivity_base_OcResourceResponse + +using namespace OC; + +class JniOcResourceResponse +{ +public: + JniOcResourceResponse(std::shared_ptr resourceResponse); + ~JniOcResourceResponse(); + void setErrorCode(const int eCode); + std::string getNewResourceUri(void); + void setNewResourceUri(const std::string newResourceUri); + void setHeaderOptions(const HeaderOptions& headerOptions); + void setRequestHandle(const OCRequestHandle& requestHandle); + void setResourceHandle(const OCResourceHandle& resourceHandle); + void setResponseResult(const OCEntityHandlerResult& responseResult); + void setResourceRepresentation(OCRepresentation& rep, std::string interfaceStr); + void setResourceRepresentation(OCRepresentation& rep); + std::shared_ptr getOCResourceResponse(); + static JniOcResourceResponse* getJniOcResourceResponsePtr(JNIEnv *env, jobject thiz); +private: + std::shared_ptr m_response; +}; + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * Class: org_iotivity_base_OcResourceResponse + * Method: setErrorCode + * Signature: (I)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setErrorCode + (JNIEnv *, jobject, jint); + + /* + * Class: org_iotivity_base_OcResourceResponse + * Method: getNewResourceUri + * Signature: ()Ljava/lang/String; + */ + JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResourceResponse_getNewResourceUri + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcResourceResponse + * Method: setNewResourceUri + * Signature: (Ljava/lang/String;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setNewResourceUri + (JNIEnv *, jobject, jstring); + + /* + * Class: org_iotivity_base_OcResourceResponse + * Method: setHeaderOptions + * Signature: (Ljava/util/List;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setHeaderOptions + (JNIEnv *, jobject, jobjectArray); + + /* + * Class: org_iotivity_base_OcResourceResponse + * Method: setRequestHandle + * Signature: (Lorg/iotivity/base/OcRequestHandle;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setRequestHandle + (JNIEnv *, jobject, jobject); + + /* + * Class: org_iotivity_base_OcResourceResponse + * Method: setResourceHandle + * Signature: (Lorg/iotivity/base/OcResourceHandle;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResourceHandle + (JNIEnv *, jobject, jobject); + + /* + * Class: org_iotivity_base_OcResourceResponse + * Method: setResponseResult + * Signature: (I)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResponseResult + (JNIEnv *, jobject, jint); + + /* + * Class: org_iotivity_base_OcResourceResponse + * Method: setResourceRepresentation + * Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/lang/String;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResourceRepresentation + (JNIEnv *, jobject, jobject, jstring); + + /* + * Class: org_iotivity_base_OcResourceResponse + * Method: setResourceRepresentation1 + * Signature: (Lorg/iotivity/base/OcRepresentation;)V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResourceRepresentation1 + (JNIEnv *, jobject, jobject); + + /* + * Class: org_iotivity_base_OcResourceResponse + * Method: create + * Signature: ()V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_create + (JNIEnv *, jobject); + + /* + * Class: org_iotivity_base_OcResourceResponse + * Method: dispose + * Signature: ()V + */ + JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_dispose + (JNIEnv *, jobject); +#ifdef __cplusplus +} +#endif +#endif \ No newline at end of file diff --git a/android/android_api/base/jni/JniOcStack.cpp b/android/android_api/base/jni/JniOcStack.cpp new file mode 100644 index 0000000..5f6c1d4 --- /dev/null +++ b/android/android_api/base/jni/JniOcStack.cpp @@ -0,0 +1,449 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOcStack.h" +#include "OCApi.h" +#include "OCPlatform.h" +#include "OCRepresentation.h" +#include "JniUtils.h" + +JavaVM* g_jvm = NULL; + +jclass g_cls_Integer = NULL; +jclass g_cls_int1DArray = NULL; +jclass g_cls_int2DArray = NULL; +jclass g_cls_Double = NULL; +jclass g_cls_double1DArray = NULL; +jclass g_cls_double2DArray = NULL; +jclass g_cls_Boolean = NULL; +jclass g_cls_boolean1DArray = NULL; +jclass g_cls_boolean2DArray = NULL; +jclass g_cls_String = NULL; +jclass g_cls_String1DArray = NULL; +jclass g_cls_String2DArray = NULL; +jclass g_cls_LinkedList = NULL; +jclass g_cls_Map = NULL; +jclass g_cls_MapEntry = NULL; +jclass g_cls_Set = NULL; +jclass g_cls_Iterator = NULL; +jclass g_cls_HashMap = NULL; +jclass g_cls_OcException = NULL; +jclass g_cls_OcResource = NULL; +jclass g_cls_OcRepresentation = NULL; +jclass g_cls_OcRepresentation1DArray = NULL; +jclass g_cls_OcRepresentation2DArray = NULL; +jclass g_cls_OcResourceRequest = NULL; +jclass g_cls_OcResourceResponse = NULL; +jclass g_cls_OcResourceHandle = NULL; +jclass g_cls_OcPresenceHandle = NULL; +jclass g_cls_OcRequestHandle = NULL; +jclass g_cls_OcPresenceStatus = NULL; +jclass g_cls_OcHeaderOption = NULL; +jclass g_cls_ObservationInfo = NULL; +jclass g_cls_OcResourceIdentifier = NULL; + +jmethodID g_mid_Integer_ctor = NULL; +jmethodID g_mid_Double_ctor = NULL; +jmethodID g_mid_Boolean_ctor = NULL; +jmethodID g_mid_LinkedList_ctor = NULL; +jmethodID g_mid_LinkedList_add_object = NULL; +jmethodID g_mid_Map_entrySet = NULL; +jmethodID g_mid_MapEntry_getKey = NULL; +jmethodID g_mid_MapEntry_getValue = NULL; +jmethodID g_mid_Set_iterator = NULL; +jmethodID g_mid_Iterator_hasNext = NULL; +jmethodID g_mid_Iterator_next = NULL; +jmethodID g_mid_HashMap_ctor = NULL; +jmethodID g_mid_HashMap_put = NULL; +jmethodID g_mid_OcException_ctor = NULL; +jmethodID g_mid_OcException_setNativeExceptionLocation = NULL; +jmethodID g_mid_OcResource_ctor = NULL; +jmethodID g_mid_OcRepresentation_N_ctor = NULL; +jmethodID g_mid_OcRepresentation_N_ctor_bool = NULL; +jmethodID g_mid_OcResourceRequest_N_ctor = NULL; +jmethodID g_mid_OcResourceResponse_N_ctor = NULL; +jmethodID g_mid_OcResourceHandle_N_ctor = NULL; +jmethodID g_mid_OcPresenceHandle_N_ctor = NULL; +jmethodID g_mid_OcRequestHandle_N_ctor = NULL; +jmethodID g_mid_OcHeaderOption_ctor = NULL; +jmethodID g_mid_OcHeaderOption_get_id = NULL; +jmethodID g_mid_OcHeaderOption_get_data = NULL; +jmethodID g_mid_ObservationInfo_N_ctor = NULL; +jmethodID g_mid_OcPresenceStatus_get = NULL; +jmethodID g_mid_OcResourceIdentifier_N_ctor = NULL; + +jobject getOcException(JNIEnv* env, const char* file, const char* functionName, + const int line, const int code, const char* message) +{ + std::string codeStr = JniUtils::stackResultToStr(code); + if (codeStr.empty()) + { + codeStr = JniUtils::stackResultToStr(JNI_INVALID_VALUE); + } + jobject ex = env->NewObject(g_cls_OcException, + g_mid_OcException_ctor, + env->NewStringUTF(codeStr.c_str()), + env->NewStringUTF(message)); + if (!ex) + { + return nullptr; + } + env->CallVoidMethod(ex, + g_mid_OcException_setNativeExceptionLocation, + env->NewStringUTF(file), + env->NewStringUTF(functionName), + line); + if (env->ExceptionCheck()) + { + return nullptr; + } + return ex; +} + +void throwOcException(JNIEnv* env, jobject ex) +{ + env->Throw((jthrowable)ex); +} + +// JNI OnLoad +JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) +{ + LOGI("JNI_OnLoad"); + JNIEnv* env; + g_jvm = vm; + + if (g_jvm->GetEnv((void **)&env, JNI_CURRENT_VERSION) != JNI_OK) + { + LOGE("Failed to get the environment using GetEnv()"); + return JNI_ERR; + } + + jclass clazz = nullptr; + + //Integer + clazz = env->FindClass("java/lang/Integer"); + if (!clazz) return JNI_ERR; + g_cls_Integer = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + + g_mid_Integer_ctor = env->GetMethodID(g_cls_Integer, "", "(I)V"); + if (!g_mid_Integer_ctor) return JNI_ERR; + + clazz = env->FindClass("[I"); + if (!clazz) return JNI_ERR; + g_cls_int1DArray = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + + clazz = env->FindClass("[[I"); + if (!clazz) return JNI_ERR; + g_cls_int2DArray = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + + //Double + clazz = env->FindClass("java/lang/Double"); + if (!clazz) return JNI_ERR; + g_cls_Double = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + + g_mid_Double_ctor = env->GetMethodID(g_cls_Double, "", "(D)V"); + if (!g_mid_Double_ctor) return JNI_ERR; + + clazz = env->FindClass("[D"); + if (!clazz) return JNI_ERR; + g_cls_double1DArray = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + + clazz = env->FindClass("[[D"); + if (!clazz) return JNI_ERR; + g_cls_double2DArray = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + + //Boolean + clazz = env->FindClass("java/lang/Boolean"); + if (!clazz) return JNI_ERR; + g_cls_Boolean = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + + g_mid_Boolean_ctor = env->GetMethodID(g_cls_Boolean, "", "(Z)V"); + if (!g_mid_Boolean_ctor) return JNI_ERR; + + clazz = env->FindClass("[Z"); + if (!clazz) return JNI_ERR; + g_cls_boolean1DArray = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + + clazz = env->FindClass("[[Z"); + if (!clazz) return JNI_ERR; + g_cls_boolean2DArray = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + + //String + clazz = env->FindClass("java/lang/String"); + if (!clazz) return JNI_ERR; + g_cls_String = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + + clazz = env->FindClass("[Ljava/lang/String;"); + if (!clazz) return JNI_ERR; + g_cls_String1DArray = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + + clazz = env->FindClass("[[Ljava/lang/String;"); + if (!clazz) return JNI_ERR; + g_cls_String2DArray = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + + //LinkedList + clazz = env->FindClass("java/util/LinkedList"); + if (!clazz) return JNI_ERR; + g_cls_LinkedList = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + + g_mid_LinkedList_ctor = env->GetMethodID(g_cls_LinkedList, "", "()V"); + if (!g_mid_LinkedList_ctor) return JNI_ERR; + + g_mid_LinkedList_add_object = env->GetMethodID(g_cls_LinkedList, "add", "(Ljava/lang/Object;)Z"); + if (!g_mid_LinkedList_add_object) return JNI_ERR; + + //Map + clazz = env->FindClass("java/util/Map"); + if (!clazz) return JNI_ERR; + g_cls_Map = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + + g_mid_Map_entrySet = env->GetMethodID(g_cls_Map, "entrySet", "()Ljava/util/Set;"); + if (!g_mid_Map_entrySet) return JNI_ERR; + + //MapEntry + clazz = env->FindClass("java/util/Map$Entry"); + if (!clazz) return JNI_ERR; + g_cls_MapEntry = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + + g_mid_MapEntry_getKey = env->GetMethodID(g_cls_MapEntry, "getKey", "()Ljava/lang/Object;"); + if (!g_mid_MapEntry_getKey) return JNI_ERR; + g_mid_MapEntry_getValue = env->GetMethodID(g_cls_MapEntry, "getValue", "()Ljava/lang/Object;"); + if (!g_mid_MapEntry_getValue) return JNI_ERR; + + //Set + clazz = env->FindClass("java/util/Set"); + if (!clazz) return JNI_ERR; + g_cls_Set = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + + g_mid_Set_iterator = env->GetMethodID(g_cls_Set, "iterator", "()Ljava/util/Iterator;"); + if (!g_mid_Set_iterator) return JNI_ERR; + + //Iterator + clazz = env->FindClass("java/util/Iterator"); + if (!clazz) return JNI_ERR; + g_cls_Iterator = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + + g_mid_Iterator_hasNext = env->GetMethodID(g_cls_Iterator, "hasNext", "()Z"); + if (!g_mid_Iterator_hasNext) return JNI_ERR; + + g_mid_Iterator_next = env->GetMethodID(g_cls_Iterator, "next", "()Ljava/lang/Object;"); + if (!g_mid_Iterator_next) return JNI_ERR; + + //HashMap + clazz = env->FindClass("java/util/HashMap"); + if (!clazz) return JNI_ERR; + g_cls_HashMap = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + + g_mid_HashMap_ctor = env->GetMethodID(g_cls_HashMap, "", "()V"); + if (!g_mid_HashMap_ctor) return JNI_ERR; + + g_mid_HashMap_put = env->GetMethodID(g_cls_HashMap, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); + if (!g_mid_HashMap_put) return JNI_ERR; + + //OcException + clazz = env->FindClass("org/iotivity/base/OcException"); + if (!clazz) return JNI_ERR; + g_cls_OcException = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + + g_mid_OcException_ctor = env->GetMethodID(g_cls_OcException, "", "(Ljava/lang/String;Ljava/lang/String;)V"); + if (!g_mid_OcException_ctor) return JNI_ERR; + + g_mid_OcException_setNativeExceptionLocation = env->GetMethodID(g_cls_OcException, "setNativeExceptionLocation", + "(Ljava/lang/String;""Ljava/lang/String;""I)V"); + if (!g_mid_OcException_setNativeExceptionLocation) return JNI_ERR; + + //OcResource + clazz = env->FindClass("org/iotivity/base/OcResource"); + if (!clazz) return JNI_ERR; + g_cls_OcResource = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + + g_mid_OcResource_ctor = env->GetMethodID(g_cls_OcResource, "", "(J)V"); + if (!g_mid_OcResource_ctor) return JNI_ERR; + + //OcRepresentation + clazz = env->FindClass("org/iotivity/base/OcRepresentation"); + if (!clazz) return JNI_ERR; + g_cls_OcRepresentation = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + + g_mid_OcRepresentation_N_ctor = env->GetMethodID(g_cls_OcRepresentation, "", "(J)V"); + if (!g_mid_OcRepresentation_N_ctor) return JNI_ERR; + + g_mid_OcRepresentation_N_ctor_bool = env->GetMethodID(g_cls_OcRepresentation, "", "(JZ)V"); + if (!g_mid_OcRepresentation_N_ctor_bool) return JNI_ERR; + + clazz = env->FindClass("[Lorg/iotivity/base/OcRepresentation;"); + if (!clazz) return JNI_ERR; + g_cls_OcRepresentation1DArray = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + + clazz = env->FindClass("[[Lorg/iotivity/base/OcRepresentation;"); + if (!clazz) return JNI_ERR; + g_cls_OcRepresentation2DArray = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + + //HeaderOptions + clazz = env->FindClass("org/iotivity/base/OcHeaderOption"); + if (!clazz) return JNI_ERR; + g_cls_OcHeaderOption = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + g_mid_OcHeaderOption_ctor = env->GetMethodID(g_cls_OcHeaderOption, "", "(ILjava/lang/String;)V"); + if (!g_mid_OcHeaderOption_ctor) return JNI_ERR; + + g_mid_OcHeaderOption_get_id = env->GetMethodID(g_cls_OcHeaderOption, "getOptionId", "()I"); + if (!g_mid_OcHeaderOption_get_id) return JNI_ERR; + + g_mid_OcHeaderOption_get_data = env->GetMethodID(g_cls_OcHeaderOption, "getOptionData", "()Ljava/lang/String;"); + if (!g_mid_OcHeaderOption_get_data) return JNI_ERR; + + //OcResourceRequest + clazz = env->FindClass("org/iotivity/base/OcResourceRequest"); + if (!clazz) return JNI_ERR; + g_cls_OcResourceRequest = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + + g_mid_OcResourceRequest_N_ctor = env->GetMethodID(g_cls_OcResourceRequest, "", "(J)V"); + if (!g_mid_OcResourceRequest_N_ctor) return JNI_ERR; + + //OcResourceResponse + clazz = env->FindClass("org/iotivity/base/OcResourceResponse"); + if (!clazz) return JNI_ERR; + g_cls_OcResourceResponse = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + + g_mid_OcResourceResponse_N_ctor = env->GetMethodID(g_cls_OcResourceResponse, "", "(J)V"); + if (!g_mid_OcResourceResponse_N_ctor) return JNI_ERR; + + //OcResourceHandle + clazz = env->FindClass("org/iotivity/base/OcResourceHandle"); + if (!clazz) return JNI_ERR; + g_cls_OcResourceHandle = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + g_mid_OcResourceHandle_N_ctor = env->GetMethodID(g_cls_OcResourceHandle, "", "(J)V"); + if (!g_mid_OcResourceHandle_N_ctor) return JNI_ERR; + + //OcPresenceHandle + clazz = env->FindClass("org/iotivity/base/OcPresenceHandle"); + if (!clazz) return JNI_ERR; + g_cls_OcPresenceHandle = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + g_mid_OcPresenceHandle_N_ctor = env->GetMethodID(g_cls_OcPresenceHandle, "", "(J)V"); + if (!g_mid_OcPresenceHandle_N_ctor) return JNI_ERR; + + //OcRequestHandle + clazz = env->FindClass("org/iotivity/base/OcRequestHandle"); + if (!clazz) return JNI_ERR; + g_cls_OcRequestHandle = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + g_mid_OcRequestHandle_N_ctor = env->GetMethodID(g_cls_OcRequestHandle, "", "(J)V"); + if (!g_mid_OcRequestHandle_N_ctor) return JNI_ERR; + + //OcPresenceStatus + clazz = env->FindClass("org/iotivity/base/OcPresenceStatus"); + if (!clazz) return JNI_ERR; + g_cls_OcPresenceStatus = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + g_mid_OcPresenceStatus_get = env->GetStaticMethodID(g_cls_OcPresenceStatus, "get", + "(Ljava/lang/String;)Lorg/iotivity/base/OcPresenceStatus;"); + if (!g_mid_OcPresenceStatus_get) return JNI_ERR; + + //ObservationInfo + clazz = env->FindClass("org/iotivity/base/ObservationInfo"); + if (!clazz) return JNI_ERR; + g_cls_ObservationInfo = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + g_mid_ObservationInfo_N_ctor = env->GetMethodID(g_cls_ObservationInfo, "", "(IB)V"); + if (!g_mid_ObservationInfo_N_ctor) return JNI_ERR; + + clazz = env->FindClass("org/iotivity/base/OcResourceIdentifier"); + if (!clazz) return JNI_ERR; + g_cls_OcResourceIdentifier = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + g_mid_OcResourceIdentifier_N_ctor = env->GetMethodID(g_cls_OcResourceIdentifier, "", "(J)V"); + if (!g_mid_OcResourceIdentifier_N_ctor) return JNI_ERR; + + return JNI_CURRENT_VERSION; +} + +JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved) +{ + LOGI("JNI_OnUnload"); + JNIEnv* env; + + if (g_jvm->GetEnv((void **)&env, JNI_CURRENT_VERSION) != JNI_OK) + { + LOGE("Failed to get the environment using GetEnv()"); + return; + } + + env->DeleteGlobalRef(g_cls_Integer); + env->DeleteGlobalRef(g_cls_int1DArray); + env->DeleteGlobalRef(g_cls_int2DArray); + env->DeleteGlobalRef(g_cls_Double); + env->DeleteGlobalRef(g_cls_double1DArray); + env->DeleteGlobalRef(g_cls_double2DArray); + env->DeleteGlobalRef(g_cls_Boolean); + env->DeleteGlobalRef(g_cls_boolean1DArray); + env->DeleteGlobalRef(g_cls_boolean2DArray); + env->DeleteGlobalRef(g_cls_String); + env->DeleteGlobalRef(g_cls_String1DArray); + env->DeleteGlobalRef(g_cls_String2DArray); + env->DeleteGlobalRef(g_cls_LinkedList); + env->DeleteGlobalRef(g_cls_Map); + env->DeleteGlobalRef(g_cls_MapEntry); + env->DeleteGlobalRef(g_cls_Set); + env->DeleteGlobalRef(g_cls_Iterator); + env->DeleteGlobalRef(g_cls_HashMap); + env->DeleteGlobalRef(g_cls_OcResource); + env->DeleteGlobalRef(g_cls_OcException); + env->DeleteGlobalRef(g_cls_OcRepresentation); + env->DeleteGlobalRef(g_cls_OcRepresentation1DArray); + env->DeleteGlobalRef(g_cls_OcRepresentation2DArray); + env->DeleteGlobalRef(g_cls_OcResourceRequest); + env->DeleteGlobalRef(g_cls_OcResourceResponse); + env->DeleteGlobalRef(g_cls_OcResourceHandle); + env->DeleteGlobalRef(g_cls_OcPresenceHandle); + env->DeleteGlobalRef(g_cls_OcRequestHandle); + env->DeleteGlobalRef(g_cls_OcPresenceStatus); + env->DeleteGlobalRef(g_cls_OcHeaderOption); + env->DeleteGlobalRef(g_cls_ObservationInfo); + env->DeleteGlobalRef(g_cls_OcResourceIdentifier); +} \ No newline at end of file diff --git a/android/android_api/base/jni/JniOcStack.h b/android/android_api/base/jni/JniOcStack.h new file mode 100644 index 0000000..bd0ddd5 --- /dev/null +++ b/android/android_api/base/jni/JniOcStack.h @@ -0,0 +1,169 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 +#include +#include "OCApi.h" + +#ifndef _Included_org_iotivity_base_ocstack +#define _Included_org_iotivity_base_ocstack + +#define TAG "OIC-JNI" + +#define JNI_CURRENT_VERSION JNI_VERSION_1_6 + +#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__) +#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__) +#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__) + +#define JNI_EXCEPTION 1000 +#define JNI_NO_NATIVE_POINTER 1001 +#define JNI_INVALID_VALUE 1002 +#define JNI_NO_SUCH_KEY 1003 + +jobject getOcException(JNIEnv* env, const char* file, const char* functionName, const int line, + const int code, const char* message); +void throwOcException(JNIEnv* env, jobject ex); +#define GetOcException(code, message) getOcException (env,__FILE__,__func__,__LINE__,code,message) +#define ThrowOcException(code, message) throwOcException (env, GetOcException(code, message)) + +extern JavaVM* g_jvm; + +extern jclass g_cls_Integer; +extern jclass g_cls_int1DArray; +extern jclass g_cls_int2DArray; +extern jclass g_cls_Double; +extern jclass g_cls_double1DArray; +extern jclass g_cls_double2DArray; +extern jclass g_cls_Boolean; +extern jclass g_cls_boolean1DArray; +extern jclass g_cls_boolean2DArray; +extern jclass g_cls_String; +extern jclass g_cls_String1DArray; +extern jclass g_cls_String2DArray; +extern jclass g_cls_LinkedList; +extern jclass g_cls_Map; +extern jclass g_cls_MapEntry; +extern jclass g_cls_Set; +extern jclass g_cls_Iterator; +extern jclass g_cls_HashMap; +extern jclass g_cls_OcException; +extern jclass g_cls_OcResource; +extern jclass g_cls_OcRepresentation; +extern jclass g_cls_OcRepresentation1DArray; +extern jclass g_cls_OcRepresentation2DArray; +extern jclass g_cls_OcResourceRequest; +extern jclass g_cls_OcResourceResponse; +extern jclass g_cls_OcResourceHandle; +extern jclass g_cls_OcPresenceHandle; +extern jclass g_cls_OcRequestHandle; +extern jclass g_cls_OcPresenceStatus; +extern jclass g_cls_OcHeaderOption; +extern jclass g_cls_ObservationInfo; +extern jclass g_cls_OcResourceIdentifier; + +extern jmethodID g_mid_Integer_ctor; +extern jmethodID g_mid_Double_ctor; +extern jmethodID g_mid_Boolean_ctor; +extern jmethodID g_mid_LinkedList_ctor; +extern jmethodID g_mid_LinkedList_add_object; +extern jmethodID g_mid_Map_entrySet; +extern jmethodID g_mid_MapEntry_getKey; +extern jmethodID g_mid_MapEntry_getValue; +extern jmethodID g_mid_Set_iterator; +extern jmethodID g_mid_Iterator_hasNext; +extern jmethodID g_mid_Iterator_next; +extern jmethodID g_mid_HashMap_ctor; +extern jmethodID g_mid_HashMap_put; +extern jmethodID g_mid_OcException_ctor; +extern jmethodID g_mid_OcException_setNativeExceptionLocation; +extern jmethodID g_mid_OcResource_ctor; +extern jmethodID g_mid_OcRepresentation_N_ctor; +extern jmethodID g_mid_OcRepresentation_N_ctor_bool; +extern jmethodID g_mid_OcResourceRequest_N_ctor; +extern jmethodID g_mid_OcResourceResponse_N_ctor; +extern jmethodID g_mid_OcResourceHandle_N_ctor; +extern jmethodID g_mid_OcPresenceHandle_N_ctor; +extern jmethodID g_mid_OcRequestHandle_N_ctor; +extern jmethodID g_mid_OcHeaderOption_ctor; +extern jmethodID g_mid_OcHeaderOption_get_id; +extern jmethodID g_mid_OcHeaderOption_get_data; +extern jmethodID g_mid_ObservationInfo_N_ctor; +extern jmethodID g_mid_OcPresenceStatus_get; +extern jmethodID g_mid_OcResourceIdentifier_N_ctor; + +typedef void(*RemoveListenerCallback)(JNIEnv* env, jobject jListener); + +static jfieldID GetHandleField(JNIEnv *env, jobject jobj) +{ + jclass cls = env->GetObjectClass(jobj); + return env->GetFieldID(cls, "mNativeHandle", "J"); +} + +template +static T *GetHandle(JNIEnv *env, jobject jobj) +{ + jlong handle = env->GetLongField(jobj, GetHandleField(env, jobj)); + return reinterpret_cast(handle); +} + +template +static void SetHandle(JNIEnv *env, jobject jobj, T *type) +{ + jlong handle = reinterpret_cast(type); + + env->SetLongField(jobj, GetHandleField(env, jobj), handle); +} + +static JNIEnv* GetJNIEnv(jint& ret) +{ + JNIEnv *env = NULL; + + ret = g_jvm->GetEnv((void **)&env, JNI_CURRENT_VERSION); + switch (ret) { + case JNI_OK: + return env; + case JNI_EDETACHED: + if (g_jvm->AttachCurrentThread(&env, NULL) < 0) + { + LOGE("Failed to get the environment"); + return nullptr; + } + else + { + return env; + } + + case JNI_EVERSION: + LOGE("JNI version not supported"); + default: + LOGE("Failed to get the environment"); + return nullptr; + } +} + +static void DuplicateString(char ** targetString, std::string sourceString) +{ + *targetString = new char[sourceString.length() + 1]; + strncpy(*targetString, sourceString.c_str(), (sourceString.length() + 1)); +} + +#endif // _Included_org_iotivity_base_ocstack \ No newline at end of file diff --git a/android/android_api/base/jni/JniOnDeleteListener.cpp b/android/android_api/base/jni/JniOnDeleteListener.cpp new file mode 100644 index 0000000..ed39e3b --- /dev/null +++ b/android/android_api/base/jni/JniOnDeleteListener.cpp @@ -0,0 +1,121 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOnDeleteListener.h" +#include "JniOcResource.h" +#include "JniUtils.h" + +JniOnDeleteListener::JniOnDeleteListener(JNIEnv *env, jobject jListener, JniOcResource* owner) + : m_ownerResource(owner) +{ + m_jwListener = env->NewWeakGlobalRef(jListener); +} + +JniOnDeleteListener::~JniOnDeleteListener() +{ + if (m_jwListener) + { + jint ret; + JNIEnv *env = GetJNIEnv(ret); + if (NULL == env) return; + env->DeleteWeakGlobalRef(m_jwListener); + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + } +} + +void JniOnDeleteListener::onDeleteCallback(const HeaderOptions& headerOptions, const int eCode) +{ + jint envRet; + JNIEnv *env = GetJNIEnv(envRet); + if (NULL == env) return; + + jobject jListener = env->NewLocalRef(m_jwListener); + if (!jListener) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + jclass clsL = env->GetObjectClass(jListener); + if (!clsL) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + + if (OC_STACK_RESOURCE_DELETED != eCode) + { + jobject ex = GetOcException(eCode, "stack error in onDeleteCallback"); + if (!ex) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + jmethodID midL = env->GetMethodID(clsL, "onDeleteFailed", "(Ljava/lang/Throwable;)V"); + if (!midL) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + env->CallVoidMethod(jListener, midL, ex); + } + else + { + jobject jHeaderOptionList = JniUtils::convertHeaderOptionsVectorToJavaList(env, headerOptions); + if (!jHeaderOptionList) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + + jmethodID midL = env->GetMethodID(clsL, "onDeleteCompleted", "(Ljava/util/List;)V"); + if (!midL) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + env->CallVoidMethod(jListener, midL, jHeaderOptionList); + } + + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); +} + +void JniOnDeleteListener::checkExAndRemoveListener(JNIEnv* env) +{ + if (env->ExceptionCheck()) + { + jthrowable ex = env->ExceptionOccurred(); + env->ExceptionClear(); + m_ownerResource->removeOnDeleteListener(env, m_jwListener); + env->Throw((jthrowable)ex); + } + else + { + m_ownerResource->removeOnDeleteListener(env, m_jwListener); + } +} \ No newline at end of file diff --git a/android/android_api/base/jni/JniOnDeleteListener.h b/android/android_api/base/jni/JniOnDeleteListener.h new file mode 100644 index 0000000..45ae34b --- /dev/null +++ b/android/android_api/base/jni/JniOnDeleteListener.h @@ -0,0 +1,45 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOcStack.h" + +#ifndef _Included_org_iotivity_base_OcResource_OnDeleteListener +#define _Included_org_iotivity_base_OcResource_OnDeleteListener + +using namespace OC; + +class JniOcResource; + +class JniOnDeleteListener +{ +public: + JniOnDeleteListener(JNIEnv *env, jobject jListener, JniOcResource* owner); + ~JniOnDeleteListener(); + + void onDeleteCallback(const HeaderOptions&, const int eCode); + +private: + jweak m_jwListener; + JniOcResource* m_ownerResource; + void checkExAndRemoveListener(JNIEnv *env); +}; + +#endif \ No newline at end of file diff --git a/android/android_api/base/jni/JniOnDeviceInfoListener.cpp b/android/android_api/base/jni/JniOnDeviceInfoListener.cpp new file mode 100644 index 0000000..483fac6 --- /dev/null +++ b/android/android_api/base/jni/JniOnDeviceInfoListener.cpp @@ -0,0 +1,113 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOnDeviceInfoListener.h" +#include "JniOcRepresentation.h" + +JniOnDeviceInfoListener::JniOnDeviceInfoListener(JNIEnv *env, jobject jListener, + RemoveListenerCallback removeListenerCallback) +{ + m_jwListener = env->NewWeakGlobalRef(jListener); + m_removeListenerCallback = removeListenerCallback; +} + +JniOnDeviceInfoListener::~JniOnDeviceInfoListener() +{ + LOGI("~JniOnDeviceInfoListener"); + if (m_jwListener) + { + jint ret; + JNIEnv *env = GetJNIEnv(ret); + if (NULL == env) return; + env->DeleteWeakGlobalRef(m_jwListener); + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + } +} + +void JniOnDeviceInfoListener::foundDeviceCallback(const OC::OCRepresentation& ocRepresentation) +{ + jint ret; + JNIEnv *env = GetJNIEnv(ret); + if (NULL == env) return; + + jobject jListener = env->NewLocalRef(m_jwListener); + if (!jListener) + { + LOGI("Java onDeviceInfoListener object is already destroyed, quiting"); + checkExAndRemoveListener(env); + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + return; + } + + OCRepresentation* rep = new OCRepresentation(ocRepresentation); + jlong handle = reinterpret_cast(rep); + jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool, + handle, true); + if (!jRepresentation) + { + delete rep; + checkExAndRemoveListener(env); + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + return; + } + + jclass clsL = env->GetObjectClass(jListener); + if (!clsL) + { + delete rep; + checkExAndRemoveListener(env); + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + return; + } + jmethodID midL = env->GetMethodID(clsL, "onDeviceFound", "(Lorg/iotivity/base/OcRepresentation;)V"); + if (!midL) + { + delete rep; + checkExAndRemoveListener(env); + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + return; + } + + env->CallVoidMethod(jListener, midL, jRepresentation); + if (env->ExceptionCheck()) + { + LOGE("Java exception is thrown"); + delete rep; + checkExAndRemoveListener(env); + } + + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); +} + +void JniOnDeviceInfoListener::checkExAndRemoveListener(JNIEnv* env) +{ + if (env->ExceptionCheck()) + { + jthrowable ex = env->ExceptionOccurred(); + env->ExceptionClear(); + m_removeListenerCallback(env, m_jwListener); + env->Throw((jthrowable)ex); + } + else + { + m_removeListenerCallback(env, m_jwListener); + } +} \ No newline at end of file diff --git a/android/android_api/base/jni/JniOnDeviceInfoListener.h b/android/android_api/base/jni/JniOnDeviceInfoListener.h new file mode 100644 index 0000000..152ca8c --- /dev/null +++ b/android/android_api/base/jni/JniOnDeviceInfoListener.h @@ -0,0 +1,42 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 +#include "JniOcStack.h" + +#ifndef _Included_org_iotivity_base_OcPlatform_OnDeviceFoundListener +#define _Included_org_iotivity_base_OcPlatform_OnDeviceFoundListener + +class JniOnDeviceInfoListener +{ +public: + JniOnDeviceInfoListener(JNIEnv *env, jobject jListener, RemoveListenerCallback removeListener); + ~JniOnDeviceInfoListener(); + + void foundDeviceCallback(const OC::OCRepresentation& ocRepresentation); + +private: + jweak m_jwListener; + RemoveListenerCallback m_removeListenerCallback; + void checkExAndRemoveListener(JNIEnv* env); +}; + +#endif diff --git a/android/android_api/base/jni/JniOnGetListener.cpp b/android/android_api/base/jni/JniOnGetListener.cpp new file mode 100644 index 0000000..4ac19bc --- /dev/null +++ b/android/android_api/base/jni/JniOnGetListener.cpp @@ -0,0 +1,144 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOnGetListener.h" +#include "JniOcResource.h" +#include "JniOcRepresentation.h" +#include "JniUtils.h" + +JniOnGetListener::JniOnGetListener(JNIEnv *env, jobject jListener, JniOcResource* owner) + : m_ownerResource(owner) +{ + m_jwListener = env->NewWeakGlobalRef(jListener); +} + +JniOnGetListener::~JniOnGetListener() +{ + if (m_jwListener) + { + jint ret; + JNIEnv *env = GetJNIEnv(ret); + if (NULL == env) return; + + env->DeleteWeakGlobalRef(m_jwListener); + + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + } +} + +void JniOnGetListener::onGetCallback(const HeaderOptions& headerOptions, + const OCRepresentation& ocRepresentation, const int eCode) +{ + jint envRet; + JNIEnv *env = GetJNIEnv(envRet); + if (NULL == env) return; + + jobject jListener = env->NewLocalRef(m_jwListener); + if (!jListener) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + jclass clsL = env->GetObjectClass(jListener); + + if (!clsL) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + + if (OC_STACK_OK != eCode) + { + jobject ex = GetOcException(eCode, "stack error in onGetCallback"); + if (!ex) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + jmethodID midL = env->GetMethodID(clsL, "onGetFailed", "(Ljava/lang/Throwable;)V"); + if (!midL) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + env->CallVoidMethod(jListener, midL, ex); + } + else + { + jobject jHeaderOptionList = JniUtils::convertHeaderOptionsVectorToJavaList(env, headerOptions); + if (!jHeaderOptionList) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + + OCRepresentation* rep = new OCRepresentation(ocRepresentation); + jlong handle = reinterpret_cast(rep); + jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool, + handle, true); + if (!jRepresentation) + { + delete rep; + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + + jmethodID midL = env->GetMethodID(clsL, "onGetCompleted", + "(Ljava/util/List;Lorg/iotivity/base/OcRepresentation;)V"); + if (!midL) + { + delete rep; + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + env->CallVoidMethod(jListener, midL, jHeaderOptionList, jRepresentation); + if (env->ExceptionCheck()) + { + LOGE("Java exception is thrown"); + delete rep; + } + } + + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); +} + +void JniOnGetListener::checkExAndRemoveListener(JNIEnv* env) +{ + if (env->ExceptionCheck()) + { + jthrowable ex = env->ExceptionOccurred(); + env->ExceptionClear(); + m_ownerResource->removeOnGetListener(env, m_jwListener); + env->Throw((jthrowable)ex); + } + else + { + m_ownerResource->removeOnGetListener(env, m_jwListener); + } +} \ No newline at end of file diff --git a/android/android_api/base/jni/JniOnGetListener.h b/android/android_api/base/jni/JniOnGetListener.h new file mode 100644 index 0000000..af69f1b --- /dev/null +++ b/android/android_api/base/jni/JniOnGetListener.h @@ -0,0 +1,43 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOcStack.h" + +#ifndef _Included_org_iotivity_base_OcResource_OnGetListener +#define _Included_org_iotivity_base_OcResource_OnGetListener + +using namespace OC; + +class JniOcResource; + +class JniOnGetListener +{ +public: + JniOnGetListener(JNIEnv *env, jobject listener, JniOcResource* resource); + ~JniOnGetListener(); + void onGetCallback(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode); +private: + jweak m_jwListener; + JniOcResource* m_ownerResource; + void checkExAndRemoveListener(JNIEnv *env); +}; + +#endif \ No newline at end of file diff --git a/android/android_api/base/jni/JniOnObserveListener.cpp b/android/android_api/base/jni/JniOnObserveListener.cpp new file mode 100644 index 0000000..7afb1e1 --- /dev/null +++ b/android/android_api/base/jni/JniOnObserveListener.cpp @@ -0,0 +1,147 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOnObserveListener.h" +#include "JniOcResource.h" +#include "JniOcRepresentation.h" +#include "JniUtils.h" + +JniOnObserveListener::JniOnObserveListener(JNIEnv *env, jobject jListener, JniOcResource* owner) + : m_ownerResource(owner) +{ + m_jwListener = env->NewWeakGlobalRef(jListener); +} + +JniOnObserveListener::~JniOnObserveListener() +{ + if (m_jwListener) + { + jint ret; + JNIEnv *env = GetJNIEnv(ret); + if (NULL == env) return; + + env->DeleteWeakGlobalRef(m_jwListener); + + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + } +} + +void JniOnObserveListener::onObserveCallback(const HeaderOptions headerOptions, + const OCRepresentation& ocRepresentation, const int& eCode, const int& sequenceNumber) +{ + jint envRet; + JNIEnv *env = GetJNIEnv(envRet); + if (NULL == env) return; + + jobject jListener = env->NewLocalRef(m_jwListener); + if (!jListener) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + jclass clsL = env->GetObjectClass(jListener); + if (!clsL) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + + if (OC_STACK_OK != eCode && OC_STACK_RESOURCE_CREATED != eCode && OC_STACK_RESOURCE_DELETED != eCode) + { + jobject ex = GetOcException(eCode, "stack error in onObserveCallback"); + if (!ex) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + jmethodID midL = env->GetMethodID(clsL, "onObserveFailed", "(Ljava/lang/Throwable;)V"); + if (!midL) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + env->CallVoidMethod(jListener, midL, ex); + } + else + { + jobject jHeaderOptionList = JniUtils::convertHeaderOptionsVectorToJavaList(env, headerOptions); + if (!jHeaderOptionList) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + + OCRepresentation * rep = new OCRepresentation(ocRepresentation); + jlong handle = reinterpret_cast(rep); + jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, + g_mid_OcRepresentation_N_ctor_bool, handle, true); + if (!jRepresentation) + { + delete rep; + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + + jmethodID midL = env->GetMethodID(clsL, "onObserveCompleted", + "(Ljava/util/List;Lorg/iotivity/base/OcRepresentation;I)V"); + if (!midL) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + + env->CallVoidMethod(jListener, midL, jHeaderOptionList, jRepresentation, + static_cast(sequenceNumber)); + if (env->ExceptionCheck()) + { + LOGE("Java exception is thrown"); + delete rep; + jthrowable ex = env->ExceptionOccurred(); + env->ExceptionClear(); + m_ownerResource->removeOnObserveListener(env, m_jwListener); + env->Throw((jthrowable)ex); + } + } + + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); +} + +void JniOnObserveListener::checkExAndRemoveListener(JNIEnv* env) +{ + if (env->ExceptionCheck()) + { + jthrowable ex = env->ExceptionOccurred(); + env->ExceptionClear(); + m_ownerResource->removeOnObserveListener(env, m_jwListener); + env->Throw((jthrowable)ex); + } + else + { + m_ownerResource->removeOnObserveListener(env, m_jwListener); + } +} \ No newline at end of file diff --git a/android/android_api/base/jni/JniOnObserveListener.h b/android/android_api/base/jni/JniOnObserveListener.h new file mode 100644 index 0000000..ae1d042 --- /dev/null +++ b/android/android_api/base/jni/JniOnObserveListener.h @@ -0,0 +1,44 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOcStack.h" + +#ifndef _Included_org_iotivity_base_OcResource_OnObserveListener +#define _Included_org_iotivity_base_OcResource_OnObserveListener + +using namespace OC; + +class JniOcResource; + +class JniOnObserveListener +{ +public: + JniOnObserveListener(JNIEnv *env, jobject jListener, JniOcResource* owner); + ~JniOnObserveListener(); + void onObserveCallback(const HeaderOptions headerOptions, const OCRepresentation& rep, + const int& eCode, const int& sequenceNumber); +private: + jweak m_jwListener; + JniOcResource* m_ownerResource; + void checkExAndRemoveListener(JNIEnv *env); +}; + +#endif \ No newline at end of file diff --git a/android/android_api/base/jni/JniOnPostListener.cpp b/android/android_api/base/jni/JniOnPostListener.cpp new file mode 100644 index 0000000..b9eb997 --- /dev/null +++ b/android/android_api/base/jni/JniOnPostListener.cpp @@ -0,0 +1,143 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOnPostListener.h" +#include "JniOcResource.h" +#include "JniOcRepresentation.h" +#include "JniUtils.h" + +JniOnPostListener::JniOnPostListener(JNIEnv *env, jobject jListener, JniOcResource* owner) + : m_ownerResource(owner) +{ + m_jwListener = env->NewWeakGlobalRef(jListener); +} + +JniOnPostListener::~JniOnPostListener() +{ + if (m_jwListener) + { + jint ret; + JNIEnv *env = GetJNIEnv(ret); + if (NULL == env) return; + + env->DeleteWeakGlobalRef(m_jwListener); + + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + } +} + +void JniOnPostListener::onPostCallback(const HeaderOptions& headerOptions, + const OCRepresentation& ocRepresentation, const int eCode) +{ + jint envRet; + JNIEnv *env = GetJNIEnv(envRet); + if (NULL == env) return; + + jobject jListener = env->NewLocalRef(m_jwListener); + if (!jListener) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + jclass clsL = env->GetObjectClass(jListener); + if (!clsL) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + + if (OC_STACK_OK != eCode && OC_STACK_RESOURCE_CREATED != eCode) + { + jobject ex = GetOcException(eCode, "stack error in onPostCallback"); + if (!ex) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + jmethodID midL = env->GetMethodID(clsL, "onPostFailed", "(Ljava/lang/Throwable;)V"); + if (!midL) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + env->CallVoidMethod(jListener, midL, ex); + } + else + { + jobject jHeaderOptionList = JniUtils::convertHeaderOptionsVectorToJavaList(env, headerOptions); + if (!jHeaderOptionList) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + + OCRepresentation * rep = new OCRepresentation(ocRepresentation); + jlong handle = reinterpret_cast(rep); + jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool, + handle, true); + if (!jRepresentation) + { + delete rep; + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + + jmethodID midL = env->GetMethodID(clsL, "onPostCompleted", + "(Ljava/util/List;Lorg/iotivity/base/OcRepresentation;)V"); + if (!midL) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + + env->CallVoidMethod(jListener, midL, jHeaderOptionList, jRepresentation); + if (env->ExceptionCheck()) + { + LOGE("Java exception is thrown"); + delete rep; + } + } + + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); +} + +void JniOnPostListener::checkExAndRemoveListener(JNIEnv* env) +{ + if (env->ExceptionCheck()) + { + jthrowable ex = env->ExceptionOccurred(); + env->ExceptionClear(); + m_ownerResource->removeOnPostListener(env, m_jwListener); + env->Throw((jthrowable)ex); + } + else + { + m_ownerResource->removeOnPostListener(env, m_jwListener); + } +} \ No newline at end of file diff --git a/android/android_api/base/jni/JniOnPostListener.h b/android/android_api/base/jni/JniOnPostListener.h new file mode 100644 index 0000000..9090507 --- /dev/null +++ b/android/android_api/base/jni/JniOnPostListener.h @@ -0,0 +1,45 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOcStack.h" + +#ifndef _Included_org_iotivity_base_OcResource_OnPostListener +#define _Included_org_iotivity_base_OcResource_OnPostListener + +using namespace OC; + +class JniOcResource; + +class JniOnPostListener +{ +public: + JniOnPostListener(JNIEnv *env, jobject jListener, JniOcResource* owner); + ~JniOnPostListener(); + + void onPostCallback(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode); + +private: + jweak m_jwListener; + JniOcResource* m_ownerResource; + void checkExAndRemoveListener(JNIEnv *env); +}; + +#endif \ No newline at end of file diff --git a/android/android_api/base/jni/JniOnPresenceListener.cpp b/android/android_api/base/jni/JniOnPresenceListener.cpp new file mode 100644 index 0000000..7c99445 --- /dev/null +++ b/android/android_api/base/jni/JniOnPresenceListener.cpp @@ -0,0 +1,133 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOnPresenceListener.h" +#include "JniUtils.h" + +JniOnPresenceListener::JniOnPresenceListener(JNIEnv *env, jobject jListener, + RemoveListenerCallback removeListenerCallback) +{ + m_jwListener = env->NewWeakGlobalRef(jListener); + m_removeListenerCallback = removeListenerCallback; +} + +JniOnPresenceListener::~JniOnPresenceListener() +{ + LOGD("~JniOnPresenceListener"); + if (m_jwListener) + { + jint ret; + JNIEnv *env = GetJNIEnv(ret); + if (NULL == env) return; + env->DeleteWeakGlobalRef(m_jwListener); + m_jwListener = nullptr; + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + } +} + +void JniOnPresenceListener::onPresenceCallback(OCStackResult result, const unsigned int nonce, + const std::string& hostAddress) +{ + LOGI("JniOnPresenceListener::onPresenceCallback"); + if (!m_jwListener) return; + + jint ret; + JNIEnv *env = GetJNIEnv(ret); + if (NULL == env) return; + + if (OC_STACK_OK != result && OC_STACK_PRESENCE_STOPPED != result && + OC_STACK_PRESENCE_TIMEOUT != result && OC_STACK_PRESENCE_DO_NOT_HANDLE != result) + { + ThrowOcException(result, "onPresenceCallback: stack failure"); + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + return; + } + + std::string enumField = JniUtils::stackResultToStr(result); + if (enumField.empty()) + { + ThrowOcException(JNI_INVALID_VALUE, "Unexpected OCStackResult value"); + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + return; + } + + jobject jPresenceStatus = env->CallStaticObjectMethod(g_cls_OcPresenceStatus, + g_mid_OcPresenceStatus_get, env->NewStringUTF(enumField.c_str())); + if (!jPresenceStatus) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + return; + } + + jobject jListener = env->NewLocalRef(m_jwListener); + if (!jListener) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + return; + } + + jclass clsL = env->GetObjectClass(jListener); + if (!clsL) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + return; + } + jmethodID midL = env->GetMethodID(clsL, "onPresence", + "(Lorg/iotivity/base/OcPresenceStatus;ILjava/lang/String;)V"); + if (!midL) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + return; + } + + env->CallVoidMethod(jListener, midL, jPresenceStatus, + (jint)nonce, env->NewStringUTF(hostAddress.c_str())); + if (env->ExceptionCheck()) + { + LOGE("Java exception is thrown"); + checkExAndRemoveListener(env); + } + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); +} + +void JniOnPresenceListener::checkExAndRemoveListener(JNIEnv* env) +{ + if (env->ExceptionCheck()) + { + jthrowable ex = env->ExceptionOccurred(); + env->ExceptionClear(); + m_removeListenerCallback(env, m_jwListener); + env->Throw((jthrowable)ex); + } + else + { + m_removeListenerCallback(env, m_jwListener); + } +} + +jweak JniOnPresenceListener::getJWListener() +{ + return this->m_jwListener; +} \ No newline at end of file diff --git a/android/android_api/base/jni/JniOnPresenceListener.h b/android/android_api/base/jni/JniOnPresenceListener.h new file mode 100644 index 0000000..7cea026 --- /dev/null +++ b/android/android_api/base/jni/JniOnPresenceListener.h @@ -0,0 +1,43 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOcStack.h" +#include + +#ifndef _Included_org_iotivity_base_OcPlatform_OnPresenceListener +#define _Included_org_iotivity_base_OcPlatform_OnPresenceListener + +class JniOnPresenceListener +{ +public: + JniOnPresenceListener(JNIEnv *env, jobject jListener, RemoveListenerCallback removeListener); + ~JniOnPresenceListener(); + + void onPresenceCallback(OCStackResult result, const unsigned int nonce, const std::string& hostAddress); + jweak getJWListener(); + +private: + RemoveListenerCallback m_removeListenerCallback; + jweak m_jwListener; + void checkExAndRemoveListener(JNIEnv* env); +}; + +#endif diff --git a/android/android_api/base/jni/JniOnPutListener.cpp b/android/android_api/base/jni/JniOnPutListener.cpp new file mode 100644 index 0000000..df18490 --- /dev/null +++ b/android/android_api/base/jni/JniOnPutListener.cpp @@ -0,0 +1,144 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOnPutListener.h" +#include "JniOcResource.h" +#include "JniOcRepresentation.h" +#include "JniUtils.h" + +JniOnPutListener::JniOnPutListener(JNIEnv *env, jobject jListener, JniOcResource* owner) + : m_ownerResource(owner) +{ + m_jwListener = env->NewWeakGlobalRef(jListener); +} + +JniOnPutListener::~JniOnPutListener() +{ + if (m_jwListener) + { + jint ret; + JNIEnv *env = GetJNIEnv(ret); + if (NULL == env) return; + + env->DeleteWeakGlobalRef(m_jwListener); + + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + } +} + +void JniOnPutListener::onPutCallback(const HeaderOptions& headerOptions, + const OCRepresentation& ocRepresentation, const int eCode) +{ + jint envRet; + JNIEnv *env = GetJNIEnv(envRet); + if (NULL == env) return; + + jobject jListener = env->NewLocalRef(m_jwListener); + if (!jListener) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + jclass clsL = env->GetObjectClass(jListener); + if (!clsL) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + + if (OC_STACK_OK != eCode) + { + jobject ex = GetOcException(eCode, "stack error in onPutCallback"); + if (!ex) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + jmethodID midL = env->GetMethodID(clsL, "onPutFailed", "(Ljava/lang/Throwable;)V"); + if (!midL) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + env->CallVoidMethod(jListener, midL, ex); + } + else + { + jobject jHeaderOptionList = JniUtils::convertHeaderOptionsVectorToJavaList(env, headerOptions); + if (!jHeaderOptionList) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + + OCRepresentation * rep = new OCRepresentation(ocRepresentation); + jlong handle = reinterpret_cast(rep); + jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool, + handle, true); + if (!jRepresentation) + { + delete rep; + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + + jmethodID midL = env->GetMethodID(clsL, "onPutCompleted", + "(Ljava/util/List;Lorg/iotivity/base/OcRepresentation;)V"); + + if (!midL) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); + return; + } + + env->CallVoidMethod(jListener, midL, jHeaderOptionList, jRepresentation); + if (env->ExceptionCheck()) + { + LOGE("Java exception is thrown"); + delete rep; + } + } + + checkExAndRemoveListener(env); + if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread(); +} + +void JniOnPutListener::checkExAndRemoveListener(JNIEnv* env) +{ + if (env->ExceptionCheck()) + { + jthrowable ex = env->ExceptionOccurred(); + env->ExceptionClear(); + m_ownerResource->removeOnPutListener(env, m_jwListener); + env->Throw((jthrowable)ex); + } + else + { + m_ownerResource->removeOnPutListener(env, m_jwListener); + } +} \ No newline at end of file diff --git a/android/android_api/base/jni/JniOnPutListener.h b/android/android_api/base/jni/JniOnPutListener.h new file mode 100644 index 0000000..f29e43f --- /dev/null +++ b/android/android_api/base/jni/JniOnPutListener.h @@ -0,0 +1,45 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOcStack.h" + +#ifndef _Included_org_iotivity_base_OcResource_OnPutListener +#define _Included_org_iotivity_base_OcResource_OnPutListener + +using namespace OC; + +class JniOcResource; + +class JniOnPutListener +{ +public: + JniOnPutListener(JNIEnv *env, jobject jListener, JniOcResource* resource); + ~JniOnPutListener(); + + void onPutCallback(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode); + +private: + jweak m_jwListener; + JniOcResource* m_ownerResource; + void checkExAndRemoveListener(JNIEnv *env); +}; + +#endif diff --git a/android/android_api/base/jni/JniOnResourceFoundListener.cpp b/android/android_api/base/jni/JniOnResourceFoundListener.cpp new file mode 100644 index 0000000..652e0cb --- /dev/null +++ b/android/android_api/base/jni/JniOnResourceFoundListener.cpp @@ -0,0 +1,118 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOnResourceFoundListener.h" +#include "JniOcResource.h" + +JniOnResourceFoundListener::JniOnResourceFoundListener(JNIEnv *env, jobject jListener, + RemoveListenerCallback removeListenerCallback) +{ + m_jwListener = env->NewWeakGlobalRef(jListener); + m_removeListenerCallback = removeListenerCallback; +} + +JniOnResourceFoundListener::~JniOnResourceFoundListener() +{ + LOGI("~JniOnResourceFoundListener()"); + if (m_jwListener) + { + jint ret; + JNIEnv *env = GetJNIEnv(ret); + if (NULL == env) return; + env->DeleteWeakGlobalRef(m_jwListener); + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + } +} + +void JniOnResourceFoundListener::foundResourceCallback(std::shared_ptr resource) +{ + jint ret; + JNIEnv *env = GetJNIEnv(ret); + if (NULL == env) return; + + jobject jListener = env->NewLocalRef(m_jwListener); + if (!jListener) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + return; + } + + jobject jResource = env->NewObject(g_cls_OcResource, g_mid_OcResource_ctor); + if (!jResource) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + return; + } + + JniOcResource *jniOcResource = new JniOcResource(resource); + SetHandle(env, jResource, jniOcResource); + if (env->ExceptionCheck()) + { + delete jniOcResource; + checkExAndRemoveListener(env); + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + return; + } + jclass clsL = env->GetObjectClass(jListener); + if (!clsL) + { + delete jniOcResource; + checkExAndRemoveListener(env); + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + return; + } + jmethodID midL = env->GetMethodID(clsL, "onResourceFound", "(Lorg/iotivity/base/OcResource;)V"); + if (!midL) + { + delete jniOcResource; + checkExAndRemoveListener(env); + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + return; + } + env->CallVoidMethod(jListener, midL, jResource); + if (env->ExceptionCheck()) + { + LOGE("Java exception is thrown"); + delete jniOcResource; + checkExAndRemoveListener(env); + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); + return; + } + + if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread(); +} + +void JniOnResourceFoundListener::checkExAndRemoveListener(JNIEnv* env) +{ + if (env->ExceptionCheck()) + { + jthrowable ex = env->ExceptionOccurred(); + env->ExceptionClear(); + m_removeListenerCallback(env, m_jwListener); + env->Throw((jthrowable)ex); + } + else + { + m_removeListenerCallback(env, m_jwListener); + } +} \ No newline at end of file diff --git a/android/android_api/base/jni/JniOnResourceFoundListener.h b/android/android_api/base/jni/JniOnResourceFoundListener.h new file mode 100644 index 0000000..2cb9749 --- /dev/null +++ b/android/android_api/base/jni/JniOnResourceFoundListener.h @@ -0,0 +1,43 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 +#include "JniOcStack.h" + +#ifndef _Included_org_iotivity_base_OcPlatform_OnResourceFoundListener +#define _Included_org_iotivity_base_OcPlatform_OnResourceFoundListener + +class JniOnResourceFoundListener +{ +public: + JniOnResourceFoundListener(JNIEnv *env, jobject jListener, + RemoveListenerCallback removeListenerCallback); + ~JniOnResourceFoundListener(); + + void foundResourceCallback(std::shared_ptr resource); + +private: + RemoveListenerCallback m_removeListenerCallback; + jweak m_jwListener; + void checkExAndRemoveListener(JNIEnv* env); +}; + +#endif diff --git a/android/android_api/base/jni/JniUtils.cpp b/android/android_api/base/jni/JniUtils.cpp new file mode 100644 index 0000000..6ec806c --- /dev/null +++ b/android/android_api/base/jni/JniUtils.cpp @@ -0,0 +1,193 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniUtils.h" +#include "JniOcRepresentation.h" + +jobject JniUtils::convertStrVectorToJavaStrList(JNIEnv *env, std::vector &vector) +{ + jobject jList = env->NewObject(g_cls_LinkedList, g_mid_LinkedList_ctor); + if (!jList) return nullptr; + for (size_t i = 0; i < vector.size(); ++i) + { + jstring jStr = env->NewStringUTF(vector[i].c_str()); + if (!jStr) return nullptr; + env->CallBooleanMethod(jList, g_mid_LinkedList_add_object, jStr); + if (env->ExceptionCheck()) return nullptr; + env->DeleteLocalRef(jStr); + } + return jList; +} + +void JniUtils::convertJavaStrArrToStrVector(JNIEnv *env, jobjectArray jStrArr, std::vector &vector) +{ + if (!jStrArr) return; + + jsize len = env->GetArrayLength(jStrArr); + for (jsize i = 0; i < len; ++i) + { + jstring jStr = (jstring)env->GetObjectArrayElement(jStrArr, i); + if (!jStr) return; + vector.push_back(env->GetStringUTFChars(jStr, NULL)); + if (env->ExceptionCheck()) return; + env->DeleteLocalRef(jStr); + } +} + +void JniUtils::convertJavaHeaderOptionsArrToVector(JNIEnv *env, jobjectArray jHeaderOptions, + OC::HeaderOptions &headerOptions) +{ + if (!jHeaderOptions) return; + + jsize len = env->GetArrayLength(jHeaderOptions); + for (jsize i = 0; i < len; ++i) + { + jobject header = env->GetObjectArrayElement(jHeaderOptions, i); + if (!header) nullptr; + jint jId = env->CallIntMethod(header, g_mid_OcHeaderOption_get_id); + jstring jData = (jstring)env->CallObjectMethod(header, g_mid_OcHeaderOption_get_data); + if (jData) return; + + OC::HeaderOption::OCHeaderOption hopt( + static_cast(jId), + env->GetStringUTFChars(jData, NULL)); + + headerOptions.push_back(hopt); + + if (env->ExceptionCheck()) return; + env->DeleteLocalRef(header); + env->DeleteLocalRef(jData); + } +} + +jobject JniUtils::convertHeaderOptionsVectorToJavaList(JNIEnv *env, const OC::HeaderOptions& headerOptions) +{ + jobject jHeaderOptionList = env->NewObject(g_cls_LinkedList, g_mid_LinkedList_ctor); + if (!jHeaderOptionList) return nullptr; + + for (size_t i = 0; i < headerOptions.size(); ++i) + { + jobject jHeaderOption = env->NewObject( + g_cls_OcHeaderOption, + g_mid_OcHeaderOption_ctor, + static_cast(headerOptions[i].getOptionID()), + env->NewStringUTF(headerOptions[i].getOptionData().c_str()) + ); + if (!jHeaderOption) return nullptr; + + env->CallBooleanMethod(jHeaderOptionList, g_mid_LinkedList_add_object, jHeaderOption); + if (env->ExceptionCheck()) return nullptr; + env->DeleteLocalRef(jHeaderOption); + } + + return jHeaderOptionList; +} + +void JniUtils::convertJavaMapToQueryParamsMap(JNIEnv *env, jobject hashMap, OC::QueryParamsMap &map) +{ + if (!hashMap) return; + + jobject jEntrySet = env->CallObjectMethod(hashMap, g_mid_Map_entrySet); + jobject jIterator = env->CallObjectMethod(jEntrySet, g_mid_Set_iterator); + if (!jEntrySet || !jIterator || env->ExceptionCheck()) return; + + while (env->CallBooleanMethod(jIterator, g_mid_Iterator_hasNext)) + { + jobject jEntry = env->CallObjectMethod(jIterator, g_mid_Iterator_next); + if (!jEntry) return; + jstring jKey = (jstring)env->CallObjectMethod(jEntry, g_mid_MapEntry_getKey); + if (!jKey) return; + jstring jValue = (jstring)env->CallObjectMethod(jEntry, g_mid_MapEntry_getValue); + if (!jValue) return; + + map.insert(std::make_pair(env->GetStringUTFChars(jKey, NULL), + env->GetStringUTFChars(jValue, NULL))); + + if (env->ExceptionCheck()) return; + env->DeleteLocalRef(jEntry); + env->DeleteLocalRef(jKey); + env->DeleteLocalRef(jValue); + } +} + +jobject JniUtils::convertQueryParamsMapToJavaMap(JNIEnv *env, const OC::QueryParamsMap &map) +{ + jobject hashMap = env->NewObject(g_cls_HashMap, g_mid_HashMap_ctor); + if (!hashMap) return nullptr; + + for (auto it = map.begin(); it != map.end(); ++it) + { + std::string key = it->first; + std::string value = it->second; + + env->CallObjectMethod(hashMap, + g_mid_HashMap_put, + env->NewStringUTF(key.c_str()), + env->NewStringUTF(value.c_str())); + if (env->ExceptionCheck()) return nullptr; + } + + return hashMap; +} + +void JniUtils::convertJavaRepresentationArrToVector(JNIEnv *env, + jobjectArray jRepresentationArray, + std::vector& representationVector) +{ + if (!jRepresentationArray) return; + jsize len = env->GetArrayLength(jRepresentationArray); + + for (jsize i = 0; i < len; ++i) + { + jobject jRep = env->GetObjectArrayElement(jRepresentationArray, i); + if (!jRep) return; + OC::OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, jRep); + representationVector.push_back(*rep); + if (env->ExceptionCheck()) return; + env->DeleteLocalRef(jRep); + } +} + +jobjectArray JniUtils::convertRepresentationVectorToJavaArray(JNIEnv *env, + const std::vector& representationVector) +{ + jsize len = static_cast(representationVector.size()); + jobjectArray repArr = env->NewObjectArray(len, g_cls_OcRepresentation, NULL); + if (!repArr) return nullptr; + for (jsize i = 0; i < len; ++i) + { + OCRepresentation* rep = new OCRepresentation(representationVector[i]); + jlong handle = reinterpret_cast(rep); + jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool, + handle, true); + if (!jRepresentation) + { + delete rep; + return nullptr; + } + env->SetObjectArrayElement(repArr, i, jRepresentation); + if (env->ExceptionCheck()) return nullptr; + env->DeleteLocalRef(jRepresentation); + } + + return repArr; +} \ No newline at end of file diff --git a/android/android_api/base/jni/JniUtils.h b/android/android_api/base/jni/JniUtils.h new file mode 100644 index 0000000..e64e16b --- /dev/null +++ b/android/android_api/base/jni/JniUtils.h @@ -0,0 +1,230 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Intel Corporation. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // 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 "JniOcStack.h" +#include "OCRepresentation.h" + +class JniUtils +{ +public: + static void convertJavaMapToQueryParamsMap(JNIEnv *env, jobject hashMap, + OC::QueryParamsMap &map); + static jobject convertQueryParamsMapToJavaMap(JNIEnv *env, const OC::QueryParamsMap &map); + + static jobject convertStrVectorToJavaStrList(JNIEnv *env, std::vector &vector); + static void convertJavaStrArrToStrVector(JNIEnv *env, jobjectArray jStrArr, + std::vector &vector); + + static void convertJavaHeaderOptionsArrToVector(JNIEnv *env, jobjectArray jHeaderOptions, + OC::HeaderOptions& headerOptions); + static jobject convertHeaderOptionsVectorToJavaList(JNIEnv *env, + const OC::HeaderOptions& headerOptions); + + static void convertJavaRepresentationArrToVector(JNIEnv *env, + jobjectArray jRepresentationArray, + std::vector& representationVector); + static jobjectArray convertRepresentationVectorToJavaArray(JNIEnv *env, + const std::vector& representationVector); + + static OC::ServiceType getServiceType(JNIEnv *env, int type) + { + switch (type) { + case 0: + return OC::ServiceType::InProc; + case 1: + return OC::ServiceType::OutOfProc; + default: + ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected service type"); + return OC::ServiceType::OutOfProc; + }; + } + + static OC::ModeType getModeType(JNIEnv *env, int type) + { + switch (type) { + case 0: + return OC::ModeType::Server; + case 1: + return OC::ModeType::Client; + case 2: + return OC::ModeType::Both; + default: + ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected mode type"); + return OC::ModeType::Both; + }; + } + + static OC::QualityOfService getQOS(JNIEnv *env, int type) + { + switch (type) { + case 0: + return OC::QualityOfService::LowQos; + case 1: + return OC::QualityOfService::MidQos; + case 2: + return OC::QualityOfService::HighQos; + case 3: + return OC::QualityOfService::NaQos; + default: + ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected quality of service"); + return OC::QualityOfService::NaQos; + }; + } + + static OC::ObserveType getObserveType(JNIEnv *env, int type) + { + switch (type) { + case 0: + return OC::ObserveType::Observe; + case 1: + return OC::ObserveType::ObserveAll; + default: + ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected observe type"); + return OC::ObserveType::ObserveAll; + }; + } + + static OCEntityHandlerResult getOCEntityHandlerResult(JNIEnv *env, int type) + { + switch (type) { + case 0: + return OCEntityHandlerResult::OC_EH_OK; + case 1: + return OCEntityHandlerResult::OC_EH_ERROR; + case 2: + return OCEntityHandlerResult::OC_EH_RESOURCE_CREATED; + case 3: + return OCEntityHandlerResult::OC_EH_RESOURCE_DELETED; + case 4: + return OCEntityHandlerResult::OC_EH_SLOW; + case 5: + return OCEntityHandlerResult::OC_EH_FORBIDDEN; + default: + ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected OCEntityHandlerResult"); + return OCEntityHandlerResult::OC_EH_ERROR; + }; + } + + static OCConnectivityType getConnectivityType(JNIEnv *env, int type) + { + switch (type) { + case 0: + return OCConnectivityType::OC_ETHERNET; + case 1: + return OCConnectivityType::OC_WIFI; + case 2: + return OCConnectivityType::OC_EDR; + case 3: + return OCConnectivityType::OC_LE; + case 4: + return OCConnectivityType::OC_ALL; + default: + ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected connectivity type"); + return OCConnectivityType::OC_ALL; + }; + } + + static std::string stackResultToStr(const int result) + { + switch (result) + { + case OC_STACK_OK: + return "OK"; + case OC_STACK_RESOURCE_CREATED: + return "RESOURCE_CREATED"; + case OC_STACK_RESOURCE_DELETED: + return "RESOURCE_DELETED"; + case OC_STACK_CONTINUE: + return "CONTINUE"; + /* Success status code - END HERE */ + /* Error status code - START HERE */ + case OC_STACK_INVALID_URI: + return "INVALID_URI"; + case OC_STACK_INVALID_QUERY: + return "INVALID_QUERY"; + case OC_STACK_INVALID_IP: + return "INVALID_IP"; + + case OC_STACK_INVALID_PORT: + return "INVALID_PORT"; + case OC_STACK_INVALID_CALLBACK: + return "INVALID_CALLBACK"; + case OC_STACK_INVALID_METHOD: + return "INVALID_METHOD"; + case OC_STACK_INVALID_PARAM: + return "INVALID_PARAM"; + case OC_STACK_INVALID_OBSERVE_PARAM: + return "INVALID_OBSERVE_PARAM"; + case OC_STACK_NO_MEMORY: + return "NO_MEMORY"; + case OC_STACK_COMM_ERROR: + return "COMM_ERROR"; + case OC_STACK_NOTIMPL: + return "NOTIMPL"; + case OC_STACK_NO_RESOURCE: + return "NO_RESOURCE"; + case OC_STACK_RESOURCE_ERROR: + return "RESOURCE_ERROR"; + case OC_STACK_SLOW_RESOURCE: + return "SLOW_RESOURCE"; + //case OC_STACK_DUPLICATE_REQUEST: + // return "DUPLICATE_REQUEST"; + case OC_STACK_NO_OBSERVERS: + return "NO_OBSERVERS"; + case OC_STACK_OBSERVER_NOT_FOUND: + return "OBSERVER_NOT_FOUND"; + case OC_STACK_VIRTUAL_DO_NOT_HANDLE: + return "VIRTUAL_DO_NOT_HANDLE"; + case OC_STACK_INVALID_OPTION: + return "INVALID_OPTION"; + case OC_STACK_MALFORMED_RESPONSE: + return "MALFORMED_RESPONSE"; + case OC_STACK_PERSISTENT_BUFFER_REQUIRED: + return "PERSISTENT_BUFFER_REQUIRED"; + case OC_STACK_INVALID_REQUEST_HANDLE: + return "INVALID_REQUEST_HANDLE"; + case OC_STACK_INVALID_DEVICE_INFO: + return "INVALID_DEVICE_INFO"; + //case OC_STACK_INVALID_JSON: + // return "INVALID_JSON"; + + case OC_STACK_PRESENCE_STOPPED: + return "PRESENCE_STOPPED"; + case OC_STACK_PRESENCE_TIMEOUT: + return "PRESENCE_TIMEOUT"; + case OC_STACK_PRESENCE_DO_NOT_HANDLE: + return "PRESENCE_DO_NOT_HANDLE"; + + case OC_STACK_ERROR: + return "ERROR"; + + case JNI_EXCEPTION: + return "JNI_EXCEPTION"; + case JNI_NO_NATIVE_POINTER: + return "JNI_NO_NATIVE_POINTER"; + case JNI_INVALID_VALUE: + return "JNI_INVALID_VALUE"; + default: + return ""; + } + } +}; \ No newline at end of file diff --git a/android/Base/app/proguard-rules.pro b/android/android_api/base/proguard-rules.pro old mode 100644 new mode 100755 similarity index 86% rename from android/Base/app/proguard-rules.pro rename to android/android_api/base/proguard-rules.pro index 0e559b0..ea26467 --- a/android/Base/app/proguard-rules.pro +++ b/android/android_api/base/proguard-rules.pro @@ -1,17 +1,17 @@ -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in /home/vchen/ubuntu_sw/adt-bundle-linux-x86_64/sdk/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in C:/android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/android/android_api/base/src/androidTest/AndroidManifest.xml b/android/android_api/base/src/androidTest/AndroidManifest.xml new file mode 100755 index 0000000..183e674 --- /dev/null +++ b/android/android_api/base/src/androidTest/AndroidManifest.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + diff --git a/android/android_api/base/src/androidTest/java/org/iotivity/base/OcRepresentationTest.java b/android/android_api/base/src/androidTest/java/org/iotivity/base/OcRepresentationTest.java new file mode 100755 index 0000000..0834201 --- /dev/null +++ b/android/android_api/base/src/androidTest/java/org/iotivity/base/OcRepresentationTest.java @@ -0,0 +1,593 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base; + +import android.test.InstrumentationTestCase; + +import java.security.InvalidParameterException; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; + +public class OcRepresentationTest extends InstrumentationTestCase { + + private static final String TAG = "OcRepresentationTest"; + + @Override + protected void setUp() throws Exception { + super.setUp(); + } + + public void testChildrenManagement() throws OcException { + OcRepresentation representation = new OcRepresentation(); + + List emptyList = representation.getChildren(); + assertTrue(emptyList.isEmpty()); + + OcRepresentation child1 = new OcRepresentation(); + OcRepresentation child2 = new OcRepresentation(); + String key = "key"; + int value = 75; + + child1.setValue(key, value); + child2.setValue(key, value); + representation.addChild(child1); + representation.addChild(child2); + List twoChildren = representation.getChildren(); + assertEquals(2, twoChildren.size()); + for (OcRepresentation rep : twoChildren) { + assertEquals(value, rep.getValue(key)); + } + + representation.clearChildren(); + emptyList = representation.getChildren(); + assertTrue(emptyList.isEmpty()); + } + + public void testUriGetSet() { + OcRepresentation representation = new OcRepresentation(); + + String emptyUri = representation.getUri(); + assertTrue(emptyUri.isEmpty()); + + String expected = "a/resource/uri"; + representation.setUri(expected); + String actual = representation.getUri(); + assertEquals(expected, actual); + } + + public void testJSONRepresentation() throws OcException { + OcRepresentation representation = new OcRepresentation(); + String key = "key"; + int value = 75; + + String emptyJson1 = representation.getJSONRepresentation(); + representation.setValue(key, value); + String intValue1 = representation.getJSONRepresentation(); + representation.remove(key); + String emptyJson2 = representation.getJSONRepresentation(); + assertEquals(emptyJson1, emptyJson2); + representation.setValue(key, value); + String intValue2 = representation.getJSONRepresentation(); + assertEquals(intValue1, intValue2); + } + + public void testResourceTypesGetSet() { + OcRepresentation representation = new OcRepresentation(); + + List emptyResourceTypeList = representation.getResourceTypes(); + assertTrue(emptyResourceTypeList.isEmpty()); + + representation.setResourceTypes(emptyResourceTypeList); + emptyResourceTypeList = representation.getResourceTypes(); + assertTrue(emptyResourceTypeList.isEmpty()); + + List resourceTypeListExpected = new LinkedList(); + resourceTypeListExpected.add("type1"); + resourceTypeListExpected.add("type2"); + resourceTypeListExpected.add("type3"); + + representation.setResourceTypes(resourceTypeListExpected); + List resourceTypeListActual = representation.getResourceTypes(); + assertEquals(resourceTypeListExpected.size(), resourceTypeListActual.size()); + for (int i = 0; i < resourceTypeListExpected.size(); i++) { + assertEquals(resourceTypeListExpected.get(i), resourceTypeListActual.get(i)); + } + + boolean thrown = false; + try { + representation.setResourceTypes(null); + } catch (InvalidParameterException e) { + thrown = true; + } + assertTrue(thrown); + } + + public void testResourceInterfacesGetSet() { + OcRepresentation representation = new OcRepresentation(); + + List emptyResourceInterfaceList = representation.getResourceInterfaces(); + assertTrue(emptyResourceInterfaceList.isEmpty()); + + representation.setResourceInterfaces(emptyResourceInterfaceList); + emptyResourceInterfaceList = representation.getResourceInterfaces(); + assertTrue(emptyResourceInterfaceList.isEmpty()); + + List resourceInterfaceListExpected = new LinkedList(); + resourceInterfaceListExpected.add("Interface1"); + resourceInterfaceListExpected.add("Interface2"); + resourceInterfaceListExpected.add("Interface3"); + + representation.setResourceInterfaces(resourceInterfaceListExpected); + List resourceInterfaceListActual = representation.getResourceInterfaces(); + assertEquals(resourceInterfaceListExpected.size(), resourceInterfaceListActual.size()); + for (int i = 0; i < resourceInterfaceListExpected.size(); i++) { + assertEquals(resourceInterfaceListExpected.get(i), resourceInterfaceListActual.get(i)); + } + + boolean thrown = false; + try { + representation.setResourceInterfaces(null); + } catch (InvalidParameterException e) { + thrown = true; + } + assertTrue(thrown); + } + + public void testAttributeManagement() { + OcRepresentation representation = new OcRepresentation(); + + assertTrue(representation.isEmpty()); + assertEquals(0, representation.size()); + + try { + String integerKey = "integerKey"; + int integerValue = 75; + representation.setValue(integerKey, integerValue); + assertFalse(representation.isEmpty()); + assertEquals(1, representation.size()); + + int actualIntValue = representation.getValue(integerKey); + assertEquals(integerValue, actualIntValue); + + String stringKey = "stringKey"; + String stringValue = "stringValue"; + representation.setValue(stringKey, stringValue); + assertEquals(2, representation.size()); + + assertTrue(representation.hasAttribute(integerKey)); + representation.remove(integerKey); + assertFalse(representation.hasAttribute(integerKey)); + assertEquals(1, representation.size()); + + representation.setValue(integerKey, integerValue); + assertFalse(representation.isNull(integerKey)); + representation.setNull(integerKey); + assertTrue(representation.isNull(integerKey)); + } catch (OcException e) { + assertTrue(false); + } + + String nonexistentKey = "nonexistentKey"; + assertFalse(representation.hasAttribute(nonexistentKey)); + representation.setNull(nonexistentKey); + assertTrue(representation.isNull(nonexistentKey)); + + String nonexistentKey2 = "nonexistentKey2"; + boolean thrown = false; + try { + boolean nonexistentValue = representation.getValue(nonexistentKey2); + } catch (OcException e) { + thrown = true; + } + assertTrue(thrown); + } + + public void testAttributeAccessByType() throws OcException { + OcRepresentation rep = new OcRepresentation(); + + //integer + String intK = "intK"; + int intV = 4; + rep.setValue(intK, intV); + int intVa = rep.getValue(intK); + assertEquals(intV, intVa); + + //double + String doubleK = "doubleK"; + double doubleV = 4.5; + rep.setValue(doubleK, doubleV); + double doubleVa = rep.getValue(doubleK); + assertEquals(doubleV, doubleVa); + + //boolean + String booleanK = "booleanK"; + boolean booleanV = true; + rep.setValue(booleanK, booleanV); + boolean booleanVa = rep.getValue(booleanK); + assertEquals(booleanV, booleanVa); + + //String + String stringK = "stringK"; + String stringV = "stringV"; + rep.setValue(stringK, stringV); + String stringVa = rep.getValue(stringK); + assertEquals(stringV, stringVa); + + //OcRepresentation + String repK = "repK"; + OcRepresentation repV = new OcRepresentation(); + repV.setValue(intK, intV); + rep.setValue(repK, repV); + OcRepresentation repVa = rep.getValue(repK); + assertEquals(intV, repVa.getValue(intK)); + } + + public void testAttributeAccessBySequenceType() throws OcException { + OcRepresentation rep = new OcRepresentation(); + + //integer + String intK = "intK"; + int[] intArrV = {1, 2, 3, 4}; + rep.setValue(intK, intArrV); + int[] intArrVa = rep.getValue(intK); + assertTrue(Arrays.equals(intArrV, intArrVa)); + + int[] intArrVEmpty = {}; + rep.setValue(intK, intArrVEmpty); + int[] intArrVEmptyA = rep.getValue(intK); + assertTrue(Arrays.equals(intArrVEmpty, intArrVEmptyA)); + + //double + String doubleK = "doubleK"; + double[] doubleArrV = {1.1, 2.2, 3.3, 4.4}; + rep.setValue(doubleK, doubleArrV); + double[] doubleArrVa = rep.getValue(doubleK); + assertTrue(Arrays.equals(doubleArrV, doubleArrVa)); + + double[] doubleArrVEmpty = {}; + rep.setValue(doubleK, doubleArrVEmpty); + double[] doubleArrVEmptyA = rep.getValue(doubleK); + assertTrue(Arrays.equals(doubleArrVEmpty, doubleArrVEmptyA)); + + //boolean + String booleanK = "booleanK"; + boolean[] booleanArrV = {true, false, true, false}; + rep.setValue(booleanK, booleanArrV); + boolean[] booleanArrVa = rep.getValue(booleanK); + assertTrue(Arrays.equals(booleanArrV, booleanArrVa)); + + boolean[] booleanArrVEmpty = {}; + rep.setValue(booleanK, booleanArrVEmpty); + boolean[] booleanArrVEmptyA = rep.getValue(booleanK); + assertTrue(Arrays.equals(booleanArrVEmpty, booleanArrVEmptyA)); + + //String + String stringK = "stringK"; + String[] stringArrV = {"aaa", "bbb", "ccc", "ddd"}; + rep.setValue(stringK, stringArrV); + String[] stringArrVa = rep.getValue(stringK); + assertTrue(Arrays.equals(stringArrV, stringArrVa)); + + String[] stringArrVEmpty = {}; + rep.setValue(stringK, stringArrVEmpty); + String[] stringArrVEmptyA = rep.getValue(stringK); + assertTrue(Arrays.equals(stringArrVEmpty, stringArrVEmptyA)); + + //OcRepresentation + String representationK = "representationK"; + OcRepresentation[] representationArrV = { + new OcRepresentation(), + new OcRepresentation(), + new OcRepresentation(), + new OcRepresentation()}; + representationArrV[0].setValue(intK, 0); + representationArrV[1].setValue(intK, 1); + representationArrV[2].setValue(intK, 2); + representationArrV[3].setValue(intK, 3); + + rep.setValue(representationK, representationArrV); + OcRepresentation[] representationArrVa = rep.getValue(representationK); + + assertEquals(representationArrV.length, representationArrVa.length); + for (int i = 0; i < representationArrV.length; ++i) { + assertEquals(representationArrV[i].getValue(intK), + representationArrVa[i].getValue(intK)); + } + + OcRepresentation[] representationArrVEmpty = {}; + rep.setValue(representationK, representationArrVEmpty); + OcRepresentation[] representationArrVEmptyA = rep.getValue(representationK); + assertEquals(representationArrVEmpty.length, representationArrVEmptyA.length); + } + + public void testAttributeAccessBy2DType() throws OcException { + OcRepresentation rep = new OcRepresentation(); + //integer + String int2DK = "int2DK"; + int[] intArrV1 = {1, 2, 3, 4}; + int[] intArrV2 = {5, 6, 7, 8}; + int[][] int2DArrV = {intArrV1, intArrV2}; + rep.setValue(int2DK, int2DArrV); + int[][] int2DArrVa = rep.getValue(int2DK); + for (int i = 0; i < int2DArrV.length; i++) { + assertTrue(Arrays.equals(int2DArrV[i], int2DArrVa[i])); + } + //double + String double2DK = "double2DK"; + double[] doubleArrV1 = {1.1, 2.2, 3.3, 4.4}; + double[] doubleArrV2 = {5, 6, 7, 8}; + double[][] double2DArrV = {doubleArrV1, doubleArrV2}; + rep.setValue(double2DK, double2DArrV); + double[][] double2DArrVa = rep.getValue(double2DK); + for (int i = 0; i < double2DArrV.length; i++) { + assertTrue(Arrays.equals(double2DArrV[i], double2DArrVa[i])); + } + double[][] double2DArrVEmpty = {{}}; + rep.setValue(double2DK, double2DArrVEmpty); + double[][] double2DArrVEmptyA = rep.getValue(double2DK); + for (int i = 0; i < double2DArrVEmpty.length; i++) { + assertTrue(Arrays.equals(double2DArrVEmpty[i], double2DArrVEmptyA[i])); + } + //boolean + String boolean2DK = "boolean2DK"; + boolean[] booleanArrV1 = {true, true, false}; + boolean[] booleanArrV2 = {true, false, false, true}; + boolean[][] boolean2DArrV = {booleanArrV1, booleanArrV2}; + rep.setValue(boolean2DK, boolean2DArrV); + boolean[][] boolean2DArrVa = rep.getValue(boolean2DK); + for (int i = 0; i < boolean2DArrV.length; i++) { + assertTrue(Arrays.equals(boolean2DArrV[i], boolean2DArrVa[i])); + } + boolean[][] boolean2DArrVEmpty = {{}}; + rep.setValue(boolean2DK, boolean2DArrVEmpty); + boolean[][] boolean2DArrVEmptyA = rep.getValue(boolean2DK); + for (int i = 0; i < boolean2DArrVEmpty.length; i++) { + assertTrue(Arrays.equals(boolean2DArrVEmpty[i], boolean2DArrVEmptyA[i])); + } + + //String + String string2DK = "string2DK"; + String[] stringArrV1 = {"aaa", "bbb", "ccc"}; + String[] stringArrV2 = {"111", "222", "333", "444"}; + String[][] string2DArrV = {stringArrV1, stringArrV2}; + rep.setValue(string2DK, string2DArrV); + String[][] string2DArrVa = rep.getValue(string2DK); + for (int i = 0; i < string2DArrV.length; i++) { + assertTrue(Arrays.equals(string2DArrV[i], string2DArrVa[i])); + } + String[][] string2DArrVEmpty = {{}}; + rep.setValue(string2DK, string2DArrVEmpty); + String[][] string2DArrVEmptyA = rep.getValue(string2DK); + for (int i = 0; i < string2DArrVEmpty.length; i++) { + assertTrue(Arrays.equals(string2DArrVEmpty[i], string2DArrVEmptyA[i])); + } + + //OcRepresentation + String intK = "intK"; + String representation2DK = "representation2DK"; + OcRepresentation[] representation2DArrV1 = { + new OcRepresentation(), + new OcRepresentation(), + new OcRepresentation(), + new OcRepresentation()}; + representation2DArrV1[0].setValue(intK, 0); + representation2DArrV1[1].setValue(intK, 1); + representation2DArrV1[2].setValue(intK, 2); + representation2DArrV1[3].setValue(intK, 3); + + OcRepresentation[] representation2DArrV2 = { + new OcRepresentation(), + new OcRepresentation(), + new OcRepresentation(), + new OcRepresentation()}; + representation2DArrV2[0].setValue(intK, 4); + representation2DArrV2[1].setValue(intK, 5); + representation2DArrV2[2].setValue(intK, 6); + representation2DArrV2[3].setValue(intK, 7); + + OcRepresentation[][] representation2DArrV = {representation2DArrV1, representation2DArrV2}; + rep.setValue(representation2DK, representation2DArrV); + OcRepresentation[][] representation2DArrVa = rep.getValue(representation2DK); + assertEquals(representation2DArrV.length, representation2DArrVa.length); + for (int i = 0; i < representation2DArrV.length; ++i) { + OcRepresentation[] repArrV = representation2DArrV[i]; + OcRepresentation[] repArrVa = representation2DArrVa[i]; + assertEquals(repArrV.length, repArrVa.length); + for (int j = 0; j < representation2DArrV.length; ++j) { + assertEquals(repArrV[j].getValue(intK), + repArrVa[j].getValue(intK)); + } + } + + OcRepresentation[][] representation2DArrVEmpty = {{}}; + rep.setValue(representation2DK, representation2DArrVEmpty); + OcRepresentation[][] representation2DArrVEmptyA = rep.getValue(representation2DK); + assertEquals(representation2DArrVEmpty.length, representation2DArrVEmptyA.length); + } + + public void testAttributeAccessBy3DType() throws OcException { + OcRepresentation rep = new OcRepresentation(); + //integer + String int3DK = "int3DK"; + int[] intArrV1 = {0, 1, 2, 3, 4}; + int[] intArrV2 = {5, 6, 7, 8}; + int[][] int2DArrV1 = {intArrV1, intArrV2}; + int[] intArrV3 = {9, 10}; + int[] intArrV4 = {11}; + int[][] int2DArrV2 = {intArrV3, intArrV4}; + int[][][] int3DArrV = {int2DArrV1, int2DArrV2}; + rep.setValue(int3DK, int3DArrV); + int[][][] int3DArrVa = rep.getValue(int3DK); + assertEquals(int3DArrV.length, int3DArrVa.length); + for (int i = 0; i < int3DArrV.length; i++) { + int[][] int2DT = int3DArrV[i]; + int[][] int2DTa = int3DArrVa[i]; + assertEquals(int2DT.length, int2DTa.length); + for (int j = 0; j < int2DT.length; j++) { + assertTrue(Arrays.equals(int2DT[j], int2DTa[j])); + } + } + //double + String double3DK = "double3DK"; + double[] doubleArrV1 = {0.0, 1.1, 2.2, 3.3, 4.4}; + double[] doubleArrV2 = {5.5, 6.6, 7.7, 8.8}; + double[][] double2DArrV1 = {doubleArrV1, doubleArrV2}; + double[] doubleArrV3 = {9.9, 10.1}; + double[] doubleArrV4 = {11.1}; + double[][] double2DArrV2 = {doubleArrV3, doubleArrV4}; + double[][][] double3DArrV = {double2DArrV1, double2DArrV2}; + rep.setValue(double3DK, double3DArrV); + double[][][] double3DArrVa = rep.getValue(double3DK); + assertEquals(double3DArrV.length, double3DArrVa.length); + for (int i = 0; i < double3DArrV.length; i++) { + double[][] double2DT = double3DArrV[i]; + double[][] double2DTa = double3DArrVa[i]; + assertEquals(double2DT.length, double2DTa.length); + for (int j = 0; j < double2DT.length; j++) { + assertTrue(Arrays.equals(double2DT[j], double2DTa[j])); + } + } + double[][][] double3DArrVEmpty = {}; + rep.setValue(double3DK, double3DArrVEmpty); + double[][][] double3DArrVEmptyA = rep.getValue(double3DK); + assertEquals(double3DArrVEmpty.length, double3DArrVEmptyA.length); + for (int i = 0; i < double3DArrVEmpty.length; i++) { + double[][] double2DT = double3DArrVEmpty[i]; + double[][] double2DTa = double3DArrVEmptyA[i]; + assertEquals(double2DT.length, double2DTa.length); + for (int j = 0; j < double2DT.length; j++) { + assertTrue(Arrays.equals(double2DT[j], double2DTa[j])); + } + } + + //boolean + String boolean3DK = "boolean3DK"; + boolean[] booleanArrV1 = {true, false, true, true, false}; + boolean[] booleanArrV2 = {false, false, false, true}; + boolean[][] boolean2DArrV1 = {booleanArrV1, booleanArrV2}; + boolean[] booleanArrV3 = {true, true}; + boolean[] booleanArrV4 = {false}; + boolean[][] boolean2DArrV2 = {booleanArrV3, booleanArrV4}; + boolean[][][] boolean3DArrV = {boolean2DArrV1, boolean2DArrV2}; + rep.setValue(boolean3DK, boolean3DArrV); + boolean[][][] boolean3DArrVa = rep.getValue(boolean3DK); + assertEquals(boolean3DArrV.length, boolean3DArrVa.length); + for (int i = 0; i < boolean3DArrV.length; i++) { + boolean[][] boolean2DT = boolean3DArrV[i]; + boolean[][] boolean2DTa = boolean3DArrVa[i]; + assertEquals(boolean2DT.length, boolean2DTa.length); + for (int j = 0; j < boolean2DT.length; j++) { + assertTrue(Arrays.equals(boolean2DT[j], boolean2DTa[j])); + } + } + boolean[][][] boolean3DArrVEmpty = {}; + rep.setValue(boolean3DK, boolean3DArrVEmpty); + boolean[][][] boolean3DArrVEmptyA = rep.getValue(boolean3DK); + assertEquals(boolean3DArrVEmpty.length, boolean3DArrVEmptyA.length); + for (int i = 0; i < boolean3DArrVEmpty.length; i++) { + boolean[][] boolean2DT = boolean3DArrVEmpty[i]; + boolean[][] boolean2DTa = boolean3DArrVEmptyA[i]; + assertEquals(boolean2DT.length, boolean2DTa.length); + for (int j = 0; j < boolean2DT.length; j++) { + assertTrue(Arrays.equals(boolean2DT[j], boolean2DTa[j])); + } + } + + //String + String string3DK = "string3DK"; + String[] stringArrV1 = {"a", "bb", "ccc", "dddd", "eeee"}; + String[] stringArrV2 = {"f", "gg", "hhh", "ii"}; + String[][] string2DArrV1 = {stringArrV1, stringArrV2}; + String[] stringArrV3 = {"j", "jj"}; + String[] stringArrV4 = {"jjj"}; + String[][] string2DArrV2 = {stringArrV3, stringArrV4}; + String[][][] string3DArrV = {string2DArrV1, string2DArrV2}; + rep.setValue(string3DK, string3DArrV); + String[][][] string3DArrVa = rep.getValue(string3DK); + assertEquals(string3DArrV.length, string3DArrVa.length); + for (int i = 0; i < string3DArrV.length; i++) { + String[][] string2DT = string3DArrV[i]; + String[][] string2DTa = string3DArrVa[i]; + assertEquals(string2DT.length, string2DTa.length); + for (int j = 0; j < string2DT.length; j++) { + assertTrue(Arrays.equals(string2DT[j], string2DTa[j])); + } + } + String[][][] string3DArrVEmpty = {}; + rep.setValue(string3DK, string3DArrVEmpty); + String[][][] string3DArrVEmptyA = rep.getValue(string3DK); + assertEquals(string3DArrVEmpty.length, string3DArrVEmptyA.length); + for (int i = 0; i < string3DArrVEmpty.length; i++) { + String[][] string2DT = string3DArrVEmpty[i]; + String[][] string2DTa = string3DArrVEmptyA[i]; + assertEquals(string2DT.length, string2DTa.length); + for (int j = 0; j < string2DT.length; j++) { + assertTrue(Arrays.equals(string2DT[j], string2DTa[j])); + } + } + + //OcRepresentation + String intK = "intK"; + String representation3DK = "representation3DK"; + OcRepresentation[] representation2DArrV1 = { + new OcRepresentation(), + new OcRepresentation(), + new OcRepresentation(), + new OcRepresentation()}; + representation2DArrV1[0].setValue(intK, 0); + representation2DArrV1[1].setValue(intK, 1); + representation2DArrV1[2].setValue(intK, 2); + representation2DArrV1[3].setValue(intK, 3); + + OcRepresentation[] representation2DArrV2 = { + new OcRepresentation(), + new OcRepresentation(), + new OcRepresentation(), + new OcRepresentation()}; + representation2DArrV2[0].setValue(intK, 4); + representation2DArrV2[1].setValue(intK, 5); + representation2DArrV2[2].setValue(intK, 6); + representation2DArrV2[3].setValue(intK, 7); + + OcRepresentation[][] representation2DArrV = {representation2DArrV1, representation2DArrV2}; + OcRepresentation[][][] representation3DArrV = {representation2DArrV, representation2DArrV}; + + rep.setValue(representation3DK, representation3DArrV); + OcRepresentation[][][] representation3DArrVa = rep.getValue(representation3DK); + assertEquals(representation3DArrV.length, representation3DArrVa.length); + for (int i = 0; i < representation3DArrV.length; ++i) { + OcRepresentation[][] repArr2V = representation3DArrV[i]; + OcRepresentation[][] repArr2Va = representation3DArrVa[i]; + assertEquals(repArr2V.length, repArr2Va.length); + for (int j = 0; j < repArr2V.length; ++j) { + OcRepresentation[] repArrV = repArr2V[j]; + OcRepresentation[] repArrVa = repArr2Va[j]; + assertEquals(repArrV.length, repArrVa.length); + for (int k = 0; k < repArrV.length; ++k) { + assertEquals(repArrV[k].getValue(intK), repArrVa[k].getValue(intK)); + } + } + } + } +} \ No newline at end of file diff --git a/android/android_api/base/src/androidTest/java/org/iotivity/base/SmokeTest.java b/android/android_api/base/src/androidTest/java/org/iotivity/base/SmokeTest.java new file mode 100755 index 0000000..04e8cb0 --- /dev/null +++ b/android/android_api/base/src/androidTest/java/org/iotivity/base/SmokeTest.java @@ -0,0 +1,1563 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base; + +import android.test.InstrumentationTestCase; +import android.util.Log; + +import java.util.Date; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.Timer; +import java.util.TimerTask; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +public class SmokeTest extends InstrumentationTestCase { + private static final String TAG = "SmokeTest"; + private Random rnd = new Random(); + + @Override + protected void setUp() throws Exception { + super.setUp(); + PlatformConfig cfg = new PlatformConfig( + getInstrumentation().getContext(), + ServiceType.IN_PROC, + ModeType.CLIENT_SERVER, + "0.0.0.0", + 0, + QualityOfService.LOW); + + OcPlatform.Configure(cfg); + } + + @Override + protected void tearDown() throws Exception { + super.tearDown(); + } + + public void testResourceRegisterUnregister() throws InterruptedException { + final String resourceType = "unit.test.resource" + + new Date().getTime(); + final CountDownLatch signal = new CountDownLatch(1); + + OcPlatform.EntityHandler entityHandler = new OcPlatform.EntityHandler() { + @Override + public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) { + return EntityHandlerResult.OK; + } + }; + + OcPlatform.OnResourceFoundListener resourceFoundListener = + new OcPlatform.OnResourceFoundListener() { + @Override + public void onResourceFound(OcResource resource) { + Log.i(TAG, "Host: " + resource.getHost()); + Log.i(TAG, "Server ID: " + resource.getServerId()); + Log.i(TAG, "Connectivity Type: " + resource.getConnectivityType()); + signal.countDown(); + } + }; + + try { + //server + OcResourceHandle resourceHandle = OcPlatform.registerResource( + "/a/unittest", + resourceType, + OcPlatform.DEFAULT_INTERFACE, + entityHandler, + EnumSet.of(ResourceProperty.DISCOVERABLE) + ); + + //client + OcPlatform.findResource("", + OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType, + OcConnectivityType.WIFI, + resourceFoundListener); + + //wait for onResourceFound event + assertTrue(signal.await(60, TimeUnit.SECONDS)); + + //server + OcPlatform.unregisterResource(resourceHandle); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + assertTrue(false); + } + } + + public void testStartStopListenForPresence() throws InterruptedException { + final String resourceType = "unit.test.resource" + + new Date().getTime(); + final CountDownLatch signal = new CountDownLatch(1); + + OcPlatform.EntityHandler entityHandler = new OcPlatform.EntityHandler() { + @Override + public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) { + return EntityHandlerResult.OK; + } + }; + + final OcPlatform.OnPresenceListener presenceListener = new OcPlatform.OnPresenceListener() { + @Override + public void onPresence(OcPresenceStatus ocPresenceStatus, int nonce, String hostAddress) { + Log.i(TAG, "onPresence status " + ocPresenceStatus.toString() + " nonce " + nonce); + signal.countDown(); + } + }; + + OcPlatform.OnResourceFoundListener resourceFoundListener = + new OcPlatform.OnResourceFoundListener() { + @Override + public void onResourceFound(OcResource resource) { + try { + //client + OcPresenceHandle presenceHandle = OcPlatform.subscribePresence( + resource.getHost(), + OcConnectivityType.WIFI, + presenceListener + ); + + //wait for onPresence event + assertTrue(signal.await(60, TimeUnit.SECONDS)); + + //client + OcPlatform.unsubscribePresence(presenceHandle); + } catch (OcException e) { + assertTrue(false); + } catch (InterruptedException e) { + assertTrue(false); + } + } + }; + + try { + //server + OcResourceHandle resourceHandle = OcPlatform.registerResource( + "/a/unittest", + resourceType, + OcPlatform.DEFAULT_INTERFACE, + entityHandler, + EnumSet.of(ResourceProperty.DISCOVERABLE) + ); + + //client + OcPlatform.findResource("", + OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType, + OcConnectivityType.WIFI, + resourceFoundListener); + + //server + OcPlatform.startPresence(OcPlatform.DEFAULT_PRESENCE_TTL); + + //wait for onPresence event + assertTrue(signal.await(60, TimeUnit.SECONDS)); + + //server + OcPlatform.stopPresence(); + + //client + OcPlatform.unregisterResource(resourceHandle); + + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + assertTrue(false); + } + } + + public void testHandleGetRequest() throws InterruptedException { + final String someKey = "SomeKey"; + final String someValue = "SomeValue"; + final String resourceType = "unit.test.resource" + new Date().getTime(); + final CountDownLatch signal1 = new CountDownLatch(1); + final CountDownLatch signal2 = new CountDownLatch(1); + final List ocResourceList = new LinkedList(); + + //client + final OcResource.OnGetListener onGetListener = new OcResource.OnGetListener() { + @Override + public void onGetCompleted(List headerOptionList, OcRepresentation ocRepresentation) { + if (!headerOptionList.isEmpty()) { + for (OcHeaderOption headerOption : headerOptionList) { + Log.i(TAG, "Header option " + + headerOption.getOptionId() + + " : " + + headerOption.getOptionData()); + } + } + try { + Log.i(TAG, "Power: " + ocRepresentation.getValue("power")); + } catch (OcException e) { + Log.e(TAG, e.toString()); + assertTrue(false); + } + signal2.countDown(); + } + + @Override + public void onGetFailed(Throwable ex) { + if (ex instanceof OcException) { + OcException ocEx = (OcException) ex; + ErrorCode errCode = ocEx.getErrorCode(); + } + Log.e(TAG, ex.toString()); + assertTrue(false); + } + }; + + //client + final OcPlatform.OnResourceFoundListener resourceFoundListener = + new OcPlatform.OnResourceFoundListener() { + @Override + public void onResourceFound(OcResource resource) { + Map queryParamsMap = new HashMap(); + queryParamsMap.put(someKey, someValue); + + ocResourceList.add(resource); + try { + resource.get(queryParamsMap, onGetListener); + //TODO there is a bug in the stack that prevents the usage of the following APIs +// resource.get(resourceType, OcPlatform.DEFAULT_INTERFACE, queryParamsMap, +// onGetListener); +// +// resource.get(queryParamsMap, onGetListener, QualityOfService.LOW); +// +// resource.get(resourceType, OcPlatform.DEFAULT_INTERFACE,queryParamsMap, +// onGetListener, QualityOfService.LOW); + } catch (OcException e) { + Log.e(TAG, e.toString()); + assertTrue(false); + } + signal1.countDown(); + } + }; + + try { + //server + OcResourceHandle resourceHandle = OcPlatform.registerResource( + "/a/unittest", + resourceType, + OcPlatform.DEFAULT_INTERFACE, + new OcPlatform.EntityHandler() { + @Override + public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) { + EnumSet handlerFlagSet = + ocResourceRequest.getRequestHandlerFlagSet(); + + RequestType requestType = ocResourceRequest.getRequestType(); + + if (handlerFlagSet.contains(RequestHandlerFlag.INIT)) { + } + if (handlerFlagSet.contains(RequestHandlerFlag.REQUEST)) { + OcResourceResponse ocResourceResponse = new OcResourceResponse(); + ocResourceResponse.setRequestHandle( + ocResourceRequest.getRequestHandle()); + ocResourceResponse.setResourceHandle( + ocResourceRequest.getResourceHandle()); + + switch (requestType) { + case GET: + Map queryParams = + ocResourceRequest.getQueryParameters(); +//TODO after the merge with CA, the query params are missing +// if (!(queryParams.containsKey(someKey) && +// someValue.equals(queryParams.get(someKey)))) { +// assertTrue(false); +// } + + ocResourceResponse.setErrorCode(200); + ocResourceResponse.setResponseResult(EntityHandlerResult.OK); + ocResourceResponse.setResourceRepresentation( + getRepresentation(74)); + break; + } + + try { + OcPlatform.sendResponse(ocResourceResponse); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + return EntityHandlerResult.ERROR; + } + } + if (handlerFlagSet.contains(RequestHandlerFlag.OBSERVER)) { + } + return EntityHandlerResult.OK; + } + }, + EnumSet.of(ResourceProperty.DISCOVERABLE) + ); + + //client + OcPlatform.findResource(null, + OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType, + OcConnectivityType.WIFI, + resourceFoundListener); + + //wait for onResourceFound event + assertTrue(signal1.await(60, TimeUnit.SECONDS)); + + //wait for onGetCompleted event + assertTrue(signal2.await(60, TimeUnit.SECONDS)); + + //server + OcPlatform.unregisterResource(resourceHandle); + + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + assertTrue(false); + } + } + + public void testHandlePutRequest() throws InterruptedException { + final String resourceType = "unit.test.resource" + new Date().getTime(); + final CountDownLatch signal1 = new CountDownLatch(1); + final CountDownLatch signal2 = new CountDownLatch(3); + final List ocResourceList = new LinkedList(); + + final OcResource.OnPutListener onPutListener = new OcResource.OnPutListener() { + @Override + public void onPutCompleted(List headerOptionList, OcRepresentation ocRepresentation) { + if (!headerOptionList.isEmpty()) { + for (OcHeaderOption headerOption : headerOptionList) { + Log.i(TAG, "Header option " + + headerOption.getOptionId() + + " : " + + headerOption.getOptionData()); + } + } + try { + Log.i(TAG, "onPutCompleted Power: " + ocRepresentation.getValue("power")); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + assertTrue(false); + } + Log.i(TAG, "onPutCompleted Uri: " + ocRepresentation.getUri()); + signal2.countDown(); + } + + @Override + public void onPutFailed(Throwable ex) { + if (ex instanceof OcException) { + OcException ocEx = (OcException) ex; + ErrorCode errCode = ocEx.getErrorCode(); + } + Log.e(TAG, ex.toString()); + assertTrue(false); + } + }; + + final OcPlatform.OnResourceFoundListener resourceFoundListener = + new OcPlatform.OnResourceFoundListener() { + @Override + public void onResourceFound(OcResource resource) { + ocResourceList.add(resource); + try { + resource.put( + getRepresentation(), + new HashMap(), + onPutListener); + + resource.put( + getRepresentation(), + new HashMap(), + onPutListener); + + resource.put( + getRepresentation(), + new HashMap(), + new OcResource.OnPutListener() { + @Override + public void onPutCompleted(List headerOptionList, OcRepresentation ocRepresentation) { + signal2.countDown(); + } + + @Override + public void onPutFailed(Throwable ex) { + if (ex instanceof OcException) { + OcException ocEx = (OcException) ex; + ErrorCode errCode = ocEx.getErrorCode(); + } + Log.e(TAG, ex.toString()); + assertTrue(false); + } + }); + + } catch (OcException e) { + assertTrue(false); + } + signal1.countDown(); + } + }; + + try { + //server + OcResourceHandle resourceHandle = OcPlatform.registerResource( + "/a/unittest", + resourceType, + OcPlatform.DEFAULT_INTERFACE, + new OcPlatform.EntityHandler() { + @Override + public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) { + EnumSet handlerFlagSet = ocResourceRequest.getRequestHandlerFlagSet(); + RequestType requestType = ocResourceRequest.getRequestType(); + + if (handlerFlagSet.contains(RequestHandlerFlag.INIT)) { + } + if (handlerFlagSet.contains(RequestHandlerFlag.REQUEST)) { + OcResourceResponse ocResourceResponse = new OcResourceResponse(); + ocResourceResponse.setRequestHandle( + ocResourceRequest.getRequestHandle()); + ocResourceResponse.setResourceHandle( + ocResourceRequest.getResourceHandle()); + + switch (requestType) { + case GET: + assertTrue(false); + break; + case PUT: + OcRepresentation rep = ocResourceRequest.getResourceRepresentation(); + try { + Log.i(TAG, "Put res. power: " + rep.getValue("power")); + } catch (OcException e) { + Log.e(TAG, e.toString()); + assertTrue(false); + } + Log.i(TAG, "URI: " + rep.getUri()); + + ocResourceResponse.setResponseResult(EntityHandlerResult.OK); + ocResourceResponse.setErrorCode(200); + ocResourceResponse.setResourceRepresentation(rep); + break; + case POST: + assertTrue(false); + break; + case DELETE: + break; + } + + try { + OcPlatform.sendResponse(ocResourceResponse); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + return EntityHandlerResult.ERROR; + } + } + if (handlerFlagSet.contains(RequestHandlerFlag.OBSERVER)) { + } + return EntityHandlerResult.OK; + } + }, + EnumSet.of(ResourceProperty.DISCOVERABLE) + ); + + //client + OcPlatform.findResource("", + OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType, + OcConnectivityType.WIFI, + resourceFoundListener); + + //wait for onResourceFound event + assertTrue(signal1.await(60, TimeUnit.SECONDS)); + + //wait for onGetCompleted event + assertTrue(signal2.await(60, TimeUnit.SECONDS)); + + //server + OcPlatform.unregisterResource(resourceHandle); + + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + assertTrue(false); + } + } + + public void testHandlePostRequest() throws InterruptedException { + final String resourceType = "unit.test.resource" + new Date().getTime(); + final CountDownLatch signal1 = new CountDownLatch(1); + final CountDownLatch signal2 = new CountDownLatch(3); + final List ocResourceList = new LinkedList(); + + final OcResource.OnPostListener onPostListener = new OcResource.OnPostListener() { + @Override + public void onPostCompleted(List headerOptionList, OcRepresentation ocRepresentation) { + if (!headerOptionList.isEmpty()) { + for (OcHeaderOption headerOption : headerOptionList) { + Log.i(TAG, "Header option " + + headerOption.getOptionId() + + " : " + + headerOption.getOptionData()); + } + } + try { + Log.i(TAG, "onPostCompleted Power: " + ocRepresentation.getValue("power")); + } catch (OcException e) { + Log.e(TAG, e.toString()); + assertTrue(false); + } + Log.i(TAG, "onPostCompleted Uri: " + ocRepresentation.getUri()); + signal2.countDown(); + } + + @Override + public void onPostFailed(Throwable ex) { + if (ex instanceof OcException) { + OcException ocEx = (OcException) ex; + ErrorCode errCode = ocEx.getErrorCode(); + } + Log.e(TAG, ex.toString()); + assertTrue(false); + } + }; + + final OcPlatform.OnResourceFoundListener resourceFoundListener = + new OcPlatform.OnResourceFoundListener() { + @Override + public void onResourceFound(OcResource resource) { + ocResourceList.add(resource); + try { + resource.post( + getRepresentation(), + new HashMap(), + onPostListener); + + resource.post( + getRepresentation(), + new HashMap(), + onPostListener); + + resource.post( + getRepresentation(), + new HashMap(), + new OcResource.OnPostListener() { + @Override + public void onPostCompleted(List headerOptionList, OcRepresentation ocRepresentation) { + signal2.countDown(); + } + + @Override + public void onPostFailed(Throwable ex) { + if (ex instanceof OcException) { + OcException ocEx = (OcException) ex; + ErrorCode errCode = ocEx.getErrorCode(); + } + Log.e(TAG, ex.toString()); + assertTrue(false); + } + }); + + } catch (OcException e) { + assertTrue(false); + } + signal1.countDown(); + } + }; + + try { + //server + OcResourceHandle resourceHandle = OcPlatform.registerResource( + "/a/unittest", + resourceType, + OcPlatform.DEFAULT_INTERFACE, + new OcPlatform.EntityHandler() { + @Override + public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) { + EnumSet handlerFlagSet = ocResourceRequest.getRequestHandlerFlagSet(); + RequestType requestType = ocResourceRequest.getRequestType(); + + if (handlerFlagSet.contains(RequestHandlerFlag.INIT)) { + } + if (handlerFlagSet.contains(RequestHandlerFlag.REQUEST)) { + OcResourceResponse ocResourceResponse = new OcResourceResponse(); + ocResourceResponse.setRequestHandle( + ocResourceRequest.getRequestHandle()); + ocResourceResponse.setResourceHandle( + ocResourceRequest.getResourceHandle()); + + switch (requestType) { + case GET: + assertTrue(false); + break; + case PUT: + assertTrue(false); + break; + case POST: + OcRepresentation rep = ocResourceRequest.getResourceRepresentation(); + try { + Log.i(TAG, "Post res. power: " + rep.getValue("power")); + } catch (OcException e) { + Log.e(TAG, e.toString()); + assertTrue(false); + } + Log.i(TAG, "URI: " + rep.getUri()); + + ocResourceResponse.setErrorCode(200); + ocResourceResponse.setResponseResult(EntityHandlerResult.OK); + ocResourceResponse.setResourceRepresentation( + getRepresentation(44)); + + break; + case DELETE: + assertTrue(false); + break; + } + + try { + OcPlatform.sendResponse(ocResourceResponse); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + return EntityHandlerResult.ERROR; + } + } + if (handlerFlagSet.contains(RequestHandlerFlag.OBSERVER)) { + } + return EntityHandlerResult.OK; + } + }, + EnumSet.of(ResourceProperty.DISCOVERABLE) + ); + + //client + OcPlatform.findResource("", + OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType, + OcConnectivityType.WIFI, + resourceFoundListener); + + //wait for onResourceFound event + assertTrue(signal1.await(60, TimeUnit.SECONDS)); + + //wait for onPostCompleted event + assertTrue(signal2.await(60, TimeUnit.SECONDS)); + + //server + OcPlatform.unregisterResource(resourceHandle); + + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + assertTrue(false); + } + + } + + public void testHandleDeleteRequest() throws InterruptedException { + final String resourceType = "unit.test.resource" + new Date().getTime(); + final CountDownLatch signal1 = new CountDownLatch(1); + final CountDownLatch signal2 = new CountDownLatch(1); + final List ocResourceList = new LinkedList(); + + final OcResource.OnDeleteListener onDeleteListener = new OcResource.OnDeleteListener() { + @Override + public void onDeleteCompleted(List headerOptionList) { + signal2.countDown(); + } + + @Override + public void onDeleteFailed(Throwable ex) { + if (ex instanceof OcException) { + OcException ocEx = (OcException) ex; + ErrorCode errCode = ocEx.getErrorCode(); + } + Log.e(TAG, ex.toString()); + assertTrue(false); + } + }; + + final OcPlatform.OnResourceFoundListener resourceFoundListener = + new OcPlatform.OnResourceFoundListener() { + @Override + public void onResourceFound(OcResource resource) { + ocResourceList.add(resource); + try { + resource.deleteResource(onDeleteListener); + } catch (OcException e) { + assertTrue(false); + } + signal1.countDown(); + } + }; + + try { + //server + OcResourceHandle resourceHandle = OcPlatform.registerResource( + "/a/unittest", + resourceType, + OcPlatform.DEFAULT_INTERFACE, + new OcPlatform.EntityHandler() { + @Override + public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) { + EnumSet handlerFlagSet = + ocResourceRequest.getRequestHandlerFlagSet(); + RequestType requestType = ocResourceRequest.getRequestType(); + + if (handlerFlagSet.contains(RequestHandlerFlag.INIT)) { + } + if (handlerFlagSet.contains(RequestHandlerFlag.REQUEST)) { + OcResourceResponse ocResourceResponse = new OcResourceResponse(); + ocResourceResponse.setRequestHandle( + ocResourceRequest.getRequestHandle()); + ocResourceResponse.setResourceHandle( + ocResourceRequest.getResourceHandle()); + + switch (requestType) { + case DELETE: + ocResourceResponse.setErrorCode(200); + ocResourceResponse.setResponseResult( + EntityHandlerResult.RESOURCE_DELETED); + break; + } + + try { + OcPlatform.sendResponse(ocResourceResponse); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + return EntityHandlerResult.ERROR; + } + } + if (handlerFlagSet.contains(RequestHandlerFlag.OBSERVER)) { + } + return EntityHandlerResult.OK; + } + }, + EnumSet.of(ResourceProperty.DISCOVERABLE) + ); + + //client + OcPlatform.findResource("", + OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType, + OcConnectivityType.WIFI, + resourceFoundListener); + + //wait for onResourceFound event + assertTrue(signal1.await(60, TimeUnit.SECONDS)); + + //wait for onDeleteCompleted event + assertTrue(signal2.await(60, TimeUnit.SECONDS)); + + //server + OcPlatform.unregisterResource(resourceHandle); + + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + assertTrue(false); + } + } + + public void testHandleGetPutPostDeleteFailures() throws InterruptedException { + final String resourceType = "unit.test.resource" + new Date().getTime(); + final CountDownLatch signal1 = new CountDownLatch(1); + final CountDownLatch signal2 = new CountDownLatch(1); + final CountDownLatch signal3 = new CountDownLatch(1); + final CountDownLatch signal4 = new CountDownLatch(1); + final CountDownLatch signal5 = new CountDownLatch(1); + + final List ocResourceList = new LinkedList(); + final OcResource.OnGetListener onGetListener = new OcResource.OnGetListener() { + @Override + public void onGetCompleted(List headerOptionList, + OcRepresentation ocRepresentation) { + assertTrue(false); + } + + @Override + public void onGetFailed(Throwable ex) { + if (ex instanceof OcException) { + OcException ocEx = (OcException) ex; + ErrorCode errCode = ocEx.getErrorCode(); + } + Log.i(TAG, ex.toString()); + signal2.countDown(); + } + }; + + final OcResource.OnPutListener onPutListener = new OcResource.OnPutListener() { + @Override + public void onPutCompleted(List headerOptionList, + OcRepresentation ocRepresentation) { + assertTrue(false); + } + + @Override + public void onPutFailed(Throwable ex) { + if (ex instanceof OcException) { + OcException ocEx = (OcException) ex; + ErrorCode errCode = ocEx.getErrorCode(); + } + Log.i(TAG, ex.toString()); + signal3.countDown(); + } + }; + final OcResource.OnPostListener onPostListener = new OcResource.OnPostListener() { + @Override + public void onPostCompleted(List headerOptionList, + OcRepresentation ocRepresentation) { + assertTrue(false); + } + + @Override + public void onPostFailed(Throwable ex) { + if (ex instanceof OcException) { + OcException ocEx = (OcException) ex; + ErrorCode errCode = ocEx.getErrorCode(); + } + Log.i(TAG, ex.toString()); + signal4.countDown(); + } + }; + + final OcResource.OnDeleteListener onDeleteListener = new OcResource.OnDeleteListener() { + @Override + public void onDeleteCompleted(List headerOptionList) { + assertTrue(false); + } + + @Override + public void onDeleteFailed(Throwable ex) { + if (ex instanceof OcException) { + OcException ocEx = (OcException) ex; + ErrorCode errCode = ocEx.getErrorCode(); + } + Log.i(TAG, ex.toString()); + signal5.countDown(); + } + }; + + final OcPlatform.OnResourceFoundListener resourceFoundListener = + new OcPlatform.OnResourceFoundListener() { + @Override + public void onResourceFound(OcResource resource) { + ocResourceList.add(resource); + try { + resource.get(new HashMap(), onGetListener); + resource.put(new OcRepresentation(), new HashMap(), + onPutListener); + resource.post(new OcRepresentation(), new HashMap(), + onPostListener); + resource.deleteResource(onDeleteListener); + } catch (OcException e) { + assertTrue(false); + } + signal1.countDown(); + } + }; + + try { + //server + OcResourceHandle resourceHandle = OcPlatform.registerResource( + "/a/unittest", + resourceType, + OcPlatform.DEFAULT_INTERFACE, + new OcPlatform.EntityHandler() { + @Override + public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) { + EnumSet handlerFlagSet = + ocResourceRequest.getRequestHandlerFlagSet(); + RequestType requestType = ocResourceRequest.getRequestType(); + + if (handlerFlagSet.contains(RequestHandlerFlag.INIT)) { + } + if (handlerFlagSet.contains(RequestHandlerFlag.REQUEST)) { + OcResourceResponse ocResourceResponse = new OcResourceResponse(); + ocResourceResponse.setRequestHandle( + ocResourceRequest.getRequestHandle()); + ocResourceResponse.setResourceHandle( + ocResourceRequest.getResourceHandle()); + + switch (requestType) { + case GET: + ocResourceResponse.setErrorCode(200); + ocResourceResponse.setResponseResult( + EntityHandlerResult.ERROR); + break; + case PUT: + ocResourceResponse.setErrorCode(200); + ocResourceResponse.setResponseResult( + EntityHandlerResult.ERROR); + break; + case POST: + ocResourceResponse.setErrorCode(200); + ocResourceResponse.setResponseResult( + EntityHandlerResult.ERROR); + break; + case DELETE: + ocResourceResponse.setErrorCode(200); + ocResourceResponse.setResponseResult( + EntityHandlerResult.ERROR); + break; + } + try { + OcPlatform.sendResponse(ocResourceResponse); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + return EntityHandlerResult.ERROR; + } + } + if (handlerFlagSet.contains(RequestHandlerFlag.OBSERVER)) { + } + return EntityHandlerResult.OK; + } + }, + EnumSet.of(ResourceProperty.DISCOVERABLE) + ); + + //client + OcPlatform.findResource("", + OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType, + OcConnectivityType.WIFI, + resourceFoundListener); + + //wait for onResourceFound event + assertTrue(signal1.await(60, TimeUnit.SECONDS)); + //wait for onGetCompleted event + assertTrue(signal2.await(60, TimeUnit.SECONDS)); + //wait for onPutCompleted event + assertTrue(signal3.await(60, TimeUnit.SECONDS)); + //wait for onPostCompleted event + assertTrue(signal4.await(60, TimeUnit.SECONDS)); + //wait for onDeleteCompleted event + assertTrue(signal5.await(60, TimeUnit.SECONDS)); + + //server + OcPlatform.unregisterResource(resourceHandle); + + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + assertTrue(false); + } + } + + public void testRegisterDeviceInfoGetDeviceInfo() throws InterruptedException { + final String resourceType = "unit.test.resource" + new Date().getTime(); + final CountDownLatch signal = new CountDownLatch(1); + + OcPlatform.OnDeviceFoundListener deviceFoundListener = new OcPlatform.OnDeviceFoundListener() { + @Override + public void onDeviceFound(OcRepresentation ocRepresentation) { + try { + Log.i(TAG, "Device Name: " + ocRepresentation.getValue("dn")); + } catch (OcException e) { + Log.e(TAG, e.toString()); + assertTrue(false); + } + boolean hasDeviceNameAtr = ocRepresentation.hasAttribute("dn"); + assertTrue(hasDeviceNameAtr); + boolean hasNonExistingAtr = ocRepresentation.hasAttribute("NonExisting"); + assertFalse(hasNonExistingAtr); + Log.i(TAG, "URI: " + ocRepresentation.getUri()); + signal.countDown(); + } + }; + + OcDeviceInfo devInfo = new OcDeviceInfo(); + + devInfo.setContentType("myContentType"); + devInfo.setDateOfManufacture("myDateOfManufacture"); + devInfo.setDeviceName("myDeviceName"); + devInfo.setDeviceUuid("myDeviceUUID"); + devInfo.setFirmwareVersion("myFirmwareVersion"); + devInfo.setHostName("myHostName"); + devInfo.setManufacturerName("myManufacturerNa"); + devInfo.setManufacturerUrl("myManufacturerUrl"); + devInfo.setModelNumber("myModelNumber"); + devInfo.setPlatformVersion("myPlatformVersion"); + devInfo.setSupportUrl("mySupportUrl"); + devInfo.setVersion("myVersion"); + + try { + //server + OcPlatform.registerDeviceInfo(devInfo); + + //client + OcPlatform.getDeviceInfo( + "", + OcPlatform.WELL_KNOWN_QUERY + "/d", + OcConnectivityType.WIFI, + deviceFoundListener); + + //wait for onDeviceFound event + assertTrue(signal.await(60, TimeUnit.SECONDS)); + + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + assertTrue(false); + } + } + + public void testBindUnbindResources() throws InterruptedException { + final String resourceType = "unit.test.resource" + new Date().getTime(); + final CountDownLatch signal1 = new CountDownLatch(3); + final CountDownLatch signal2 = new CountDownLatch(2); + final CountDownLatch signal3 = new CountDownLatch(1); + final CountDownLatch signal4 = new CountDownLatch(3); + final CountDownLatch signal5 = new CountDownLatch(3); + final CountDownLatch signal6 = new CountDownLatch(1); + + OcPlatform.EntityHandler entityHandler = new OcPlatform.EntityHandler() { + @Override + public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) { + return EntityHandlerResult.OK; + } + }; + + OcPlatform.OnResourceFoundListener resourceFoundListener1 = new OcPlatform.OnResourceFoundListener() { + @Override + public void onResourceFound(OcResource resource) { + signal1.countDown(); + } + }; + + OcPlatform.OnResourceFoundListener resourceFoundListener2 = new OcPlatform.OnResourceFoundListener() { + @Override + public void onResourceFound(OcResource resource) { + signal2.countDown(); + } + }; + + OcPlatform.OnResourceFoundListener resourceFoundListener3 = new OcPlatform.OnResourceFoundListener() { + @Override + public void onResourceFound(OcResource resource) { + signal3.countDown(); + } + }; + + OcPlatform.OnResourceFoundListener resourceFoundListener4 = new OcPlatform.OnResourceFoundListener() { + @Override + public void onResourceFound(OcResource resource) { + signal4.countDown(); + } + }; + + OcPlatform.OnResourceFoundListener resourceFoundListener5 = new OcPlatform.OnResourceFoundListener() { + @Override + public void onResourceFound(OcResource resource) { + signal5.countDown(); + } + }; + + OcPlatform.OnResourceFoundListener resourceFoundListener6 = new OcPlatform.OnResourceFoundListener() { + @Override + public void onResourceFound(OcResource resource) { + signal6.countDown(); + } + }; + + try { + + //server + OcResourceHandle resourceHandleCollection = OcPlatform.registerResource( + "/a/unittest1", + resourceType, + OcPlatform.DEFAULT_INTERFACE, + entityHandler, + EnumSet.of(ResourceProperty.DISCOVERABLE) + ); + + OcResourceHandle resourceHandle1 = OcPlatform.registerResource( + "/a/unittest2", + resourceType, + OcPlatform.DEFAULT_INTERFACE, + entityHandler, + EnumSet.of(ResourceProperty.DISCOVERABLE) + ); + + OcResourceHandle resourceHandle2 = OcPlatform.registerResource( + "/a/unittest3", + resourceType, + OcPlatform.DEFAULT_INTERFACE, + entityHandler, + EnumSet.of(ResourceProperty.DISCOVERABLE) + ); + + //client + OcPlatform.findResource("", + OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType, + OcConnectivityType.WIFI, + resourceFoundListener1); + + //wait for onResourceFound event to find 3 registered resources + assertTrue(signal1.await(60, TimeUnit.SECONDS)); + + //server + OcPlatform.bindResource(resourceHandleCollection, resourceHandle1); + OcPlatform.bindResource(resourceHandleCollection, resourceHandle2); + + //client + OcPlatform.findResource("", + OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType, + OcConnectivityType.WIFI, + resourceFoundListener3); + + //wait for onResourceFound event to find 1 collection resources + assertTrue(signal3.await(60, TimeUnit.SECONDS)); + + //server + OcPlatform.unbindResource(resourceHandleCollection, resourceHandle1); + + //client + OcPlatform.findResource("", + OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType, + OcConnectivityType.WIFI, + resourceFoundListener2); + + //wait for onResourceFound event to find 2 resources + assertTrue(signal2.await(60, TimeUnit.SECONDS)); + + //server + OcPlatform.unbindResource(resourceHandleCollection, resourceHandle2); + + //client + OcPlatform.findResource("", + OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType, + OcConnectivityType.WIFI, + resourceFoundListener4); + + //wait for onResourceFound event to find 3 registered resources + assertTrue(signal4.await(60, TimeUnit.SECONDS)); + + //Bind/unbind a list of resource handles + List resourceHandleList = new LinkedList(); + resourceHandleList.add(resourceHandle1); + resourceHandleList.add(resourceHandle2); + OcPlatform.bindResources(resourceHandleCollection, resourceHandleList); + + //client + OcPlatform.findResource("", + OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType, + OcConnectivityType.WIFI, + resourceFoundListener6); + + //wait for onResourceFound event to find 1 collection resources + assertTrue(signal6.await(60, TimeUnit.SECONDS)); + + OcPlatform.unbindResources(resourceHandleCollection, resourceHandleList); + + //client + OcPlatform.findResource("", + OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType, + OcConnectivityType.WIFI, + resourceFoundListener5); + + //wait for onResourceFound event to find 1 collection resources + assertTrue(signal5.await(60, TimeUnit.SECONDS)); + + //server + OcPlatform.unregisterResource(resourceHandleCollection); + OcPlatform.unregisterResource(resourceHandle1); + OcPlatform.unregisterResource(resourceHandle2); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + assertTrue(false); + } + } + + public void testResourceMethods() throws InterruptedException { + final String resourceType1 = "unit.test.resource" + new Date().getTime(); + final String resourceType2 = "unit.test.resource" + new Date().getTime(); + + final CountDownLatch signal = new CountDownLatch(2); + final List resourceList = new LinkedList(); + + OcPlatform.EntityHandler entityHandler = new OcPlatform.EntityHandler() { + @Override + public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) { + return EntityHandlerResult.OK; + } + }; + + OcPlatform.OnResourceFoundListener resourceFoundListener = + new OcPlatform.OnResourceFoundListener() { + @Override + public void onResourceFound(OcResource resource) { + resourceList.add(resource); + Log.i(TAG, "Host: " + resource.getHost()); + Log.i(TAG, "Uri: " + resource.getUri()); + Log.i(TAG, "Observable: " + resource.isObservable()); + + for (String resourceType : resource.getResourceTypes()) { + Log.i(TAG, "Type: " + resourceType); + } + + for (String resourceInterface : resource.getResourceInterfaces()) { + Log.i(TAG, "Interface: " + resourceInterface); + } + + List headerOptionList = new LinkedList(); + headerOptionList.add(new OcHeaderOption(2885, "OptionData1")); + headerOptionList.add(new OcHeaderOption(2886, "OptionData2")); + resource.setHeaderOptions(headerOptionList); + + resource.setHeaderOptions(headerOptionList); + resource.unsetHeaderOptions(); + + OcResourceIdentifier resourceIdentifier = resource.getUniqueIdentifier(); + OcResourceIdentifier resourceIdentifier2 = resource.getUniqueIdentifier(); + assertTrue(resourceIdentifier.equals(resourceIdentifier2)); + + signal.countDown(); + } + }; + + try { + //server + OcResourceHandle resourceHandle1 = OcPlatform.registerResource( + "/a/unittest1", + resourceType1, + OcPlatform.DEFAULT_INTERFACE, + entityHandler, + EnumSet.of(ResourceProperty.DISCOVERABLE) + ); + + OcResourceHandle resourceHandle2 = OcPlatform.registerResource( + "/a/unittest2", + resourceType2, + OcPlatform.DEFAULT_INTERFACE, + entityHandler, + EnumSet.of(ResourceProperty.DISCOVERABLE) + ); + + //client + OcPlatform.findResource("", + OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType1, + OcConnectivityType.WIFI, + resourceFoundListener); + + OcPlatform.findResource("", + OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType2, + OcConnectivityType.WIFI, + resourceFoundListener); + + //wait for onResourceFound event + assertTrue(signal.await(60, TimeUnit.SECONDS)); + + assertTrue(2 == resourceList.size()); + + OcResource res0 = resourceList.get(0); + OcResource res1 = resourceList.get(1); + assertFalse(res0.getUniqueIdentifier().equals(res1.getUniqueIdentifier())); + assertTrue(res0.getUniqueIdentifier().equals(res0.getUniqueIdentifier())); + + //server + OcPlatform.unregisterResource(resourceHandle1); + OcPlatform.unregisterResource(resourceHandle2); + + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + assertTrue(false); + } + } + + public void testCreateResourceProxy() throws InterruptedException { + final String resourceType = "unit.test.resource" + new Date().getTime(); + final CountDownLatch signal = new CountDownLatch(1); + + OcPlatform.EntityHandler entityHandler = new OcPlatform.EntityHandler() { + @Override + public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) { + return EntityHandlerResult.OK; + } + }; + + OcPlatform.OnResourceFoundListener resourceFoundListener = + new OcPlatform.OnResourceFoundListener() { + @Override + public void onResourceFound(OcResource resource) { + + try { + //client: construct resource proxy + OcResource resourceProxy = OcPlatform.constructResourceObject( + resource.getHost(), + resource.getUri(), + OcConnectivityType.WIFI, + resource.isObservable(), + resource.getResourceTypes(), + resource.getResourceInterfaces()); + + //client: register resource proxy + OcResourceHandle resourceProxyHandle = + OcPlatform.registerResource(resourceProxy); + + OcPlatform.unregisterResource(resourceProxyHandle); + } catch (OcException e) { + assertTrue(false); + } + signal.countDown(); + } + }; + + try { + //server + OcResourceHandle resourceHandle = OcPlatform.registerResource( + "/a/unittest", + resourceType, + OcPlatform.DEFAULT_INTERFACE, + entityHandler, + EnumSet.of(ResourceProperty.DISCOVERABLE) + ); + + //client + OcPlatform.findResource("", + OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType, + OcConnectivityType.WIFI, + resourceFoundListener); + + //wait for onResourceFound event + assertTrue(signal.await(60, TimeUnit.SECONDS)); + + //server + OcPlatform.unregisterResource(resourceHandle); + + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + assertTrue(false); + } + + try { + //server + OcResourceHandle resourceHandle = OcPlatform.registerResource( + "/a/unittest", + resourceType, + OcPlatform.DEFAULT_INTERFACE, + entityHandler, + EnumSet.of(ResourceProperty.DISCOVERABLE) + ); + + //client + OcPlatform.findResource("", + OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType, + OcConnectivityType.WIFI, + resourceFoundListener); + + //wait for onResourceFound event + assertTrue(signal.await(60, TimeUnit.SECONDS)); + + //server + OcPlatform.unregisterResource(resourceHandle); + + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + assertTrue(false); + } + } + + public void testObserveClientServer() throws InterruptedException { + final int NUM_OBSERVES = 20; + final Timer timer = new Timer(); + final List resourceList = new LinkedList(); + final List resourceHandleList = new LinkedList(); + final CountDownLatch signal1 = new CountDownLatch(1); + final CountDownLatch signal2 = new CountDownLatch(NUM_OBSERVES); + final CountDownLatch signal3 = new CountDownLatch(1); + + final String resourceType = "unit.test.resource" + new Date().getTime(); + + final OcResource.OnObserveListener observeListener = new OcResource.OnObserveListener() { + @Override + public void onObserveCompleted( + List headerOptionList, + OcRepresentation ocRepresentation, + int sequenceNumber) { + + try { + Log.i(TAG, "Observe #" + sequenceNumber + " power: " + + ocRepresentation.getValue("power")); + } catch (OcException e) { + Log.e(TAG, e.toString()); + assertTrue(false); + } + signal2.countDown(); + } + + @Override + public void onObserveFailed(Throwable ex) { + if (ex instanceof OcException) { + OcException ocEx = (OcException) ex; + ErrorCode errCode = ocEx.getErrorCode(); + } + Log.e(TAG, ex.toString()); + assertTrue(false); + } + }; + + final List observationIdList = new LinkedList(); + OcPlatform.EntityHandler entityHandler = new OcPlatform.EntityHandler() { + @Override + public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) { + EnumSet handlerFlagSet = ocResourceRequest.getRequestHandlerFlagSet(); + RequestType requestType = ocResourceRequest.getRequestType(); + + if (handlerFlagSet.contains(RequestHandlerFlag.INIT)) { + + } + if (handlerFlagSet.contains(RequestHandlerFlag.REQUEST)) { + OcResourceResponse ocResourceResponse = new OcResourceResponse(); + ocResourceResponse.setRequestHandle(ocResourceRequest.getRequestHandle()); + ocResourceResponse.setResourceHandle(ocResourceRequest.getResourceHandle()); + + switch (requestType) { + case GET: + ocResourceResponse.setErrorCode(200); + ocResourceResponse.setResponseResult(EntityHandlerResult.OK); + ocResourceResponse.setResourceRepresentation( + getRepresentation( + rnd.nextInt(100))); + try { + OcPlatform.sendResponse(ocResourceResponse); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + return EntityHandlerResult.ERROR; + } + break; + } + } + + if (handlerFlagSet.contains(RequestHandlerFlag.OBSERVER)) { + ObservationInfo observationInfo = ocResourceRequest.getObservationInfo(); + + switch (observationInfo.getObserveAction()) { + case REGISTER: + synchronized (observationIdList) { + observationIdList.add(observationInfo.getOcObservationId()); + timer.schedule(new TimerTask() { + int numNotified = 1; + + @Override + public void run() { + if (0 < resourceHandleList.size()) { + synchronized (observationIdList) { + if (numNotified > NUM_OBSERVES) { + timer.cancel(); + timer.purge(); + signal3.countDown(); + } else { + try { + OcPlatform.notifyAllObservers( + resourceHandleList.get(0)); + } catch (OcException e) { + if (ErrorCode.NO_OBSERVERS == e.getErrorCode()) { + timer.cancel(); + timer.purge(); + signal3.countDown(); + } + Log.e(TAG, e.getMessage()); + } + numNotified++; + } + } + } + + } + }, 0, 100); + } + break; + case UNREGISTER: + //TODO unregister isn't implemented in C++ API, yet + synchronized (observationIdList) { + timer.cancel(); + break; + } + } + } + return EntityHandlerResult.OK; + } + }; + + OcPlatform.OnResourceFoundListener resourceFoundListener = + new OcPlatform.OnResourceFoundListener() { + @Override + public void onResourceFound(OcResource resource) { + resourceList.add(resource); + if (resource.isObservable()) { + try { + resource.observe( + ObserveType.OBSERVE, + new HashMap(), + observeListener); + + signal1.countDown(); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + assertTrue(false); + } + } + } + }; + try { + //server + OcResourceHandle resourceHandle = OcPlatform.registerResource( + "/a/unittest", + resourceType, + OcPlatform.DEFAULT_INTERFACE, + entityHandler, + EnumSet.of(ResourceProperty.DISCOVERABLE, ResourceProperty.OBSERVABLE) + ); + + resourceHandleList.add(resourceHandle); + + //client + OcPlatform.findResource("", + OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType, + OcConnectivityType.WIFI, + resourceFoundListener); + + //wait for onResourceFound event + assertTrue(signal1.await(60, TimeUnit.SECONDS)); + + //wait for OnObserveListener event to observe 20 values + assertTrue(signal2.await(60, TimeUnit.SECONDS)); + + if (resourceList.size() > 0) { + OcResource resource = resourceList.get(0); + if (resource.isObservable()) { + resource.cancelObserve(); + } + } + + //wait for server to finish + assertTrue(signal3.await(60, TimeUnit.SECONDS)); + + //server + OcPlatform.unregisterResource(resourceHandle); + + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + assertTrue(false); + } + } + + private OcRepresentation getRepresentation(int value) { + OcRepresentation rep = new OcRepresentation(); + try { + rep.setValue("power", value); + } catch (OcException e) { + Log.e(TAG, e.toString()); + assertTrue(false); + } + return rep; + } + + private OcRepresentation getRepresentation() { + return getRepresentation(74); + } +} \ No newline at end of file diff --git a/android/android_api/base/src/main/AndroidManifest.xml b/android/android_api/base/src/main/AndroidManifest.xml new file mode 100755 index 0000000..183e674 --- /dev/null +++ b/android/android_api/base/src/main/AndroidManifest.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + diff --git a/android/android_api/base/src/main/java/org/iotivity/base/EntityHandlerResult.java b/android/android_api/base/src/main/java/org/iotivity/base/EntityHandlerResult.java new file mode 100755 index 0000000..d8ed2fb --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/base/EntityHandlerResult.java @@ -0,0 +1,42 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base; + +public enum EntityHandlerResult { + OK(0), + ERROR(1), + RESOURCE_CREATED(2), + RESOURCE_DELETED(3), + SLOW(4), + FORBIDDEN(5); + + private int value; + + private EntityHandlerResult(int value) { + this.value = value; + } + + public int getValue() { + return this.value; + } +} diff --git a/android/android_api/base/src/main/java/org/iotivity/base/ErrorCode.java b/android/android_api/base/src/main/java/org/iotivity/base/ErrorCode.java new file mode 100755 index 0000000..d1862e0 --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/base/ErrorCode.java @@ -0,0 +1,95 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base; + +public enum ErrorCode { + /* Success status code - START HERE */ + OK("OK", ""), + RESOURCE_CREATED("RESOURCE_CREATED", ""), + RESOURCE_DELETED("RESOURCE_DELETED", ""), + CONTINUE("CONTINUE", ""), + /* Success status code - END HERE */ + /* Error status code - START HERE */ + INVALID_URI("INVALID_URI", ""), + INVALID_QUERY("INVALID_QUERY", ""), + INVALID_IP("INVALID_IP", ""), + INVALID_PORT("INVALID_PORT", ""), + INVALID_CALLBACK("INVALID_CALLBACK", ""), + INVALID_METHOD("INVALID_METHOD", ""), + INVALID_PARAM("INVALID_PARAM", ""), + INVALID_OBSERVE_PARAM("INVALID_OBSERVE_PARAM", ""), + NO_MEMORY("NO_MEMORY", ""), + COMM_ERROR("COMM_ERROR", ""), + NOT_IMPL("NOTIMPL", ""), + NO_RESOURCE("NO_RESOURCE", "Resource not found"), + RESOURCE_ERROR("RESOURCE_ERROR", "Not supported method or interface"), + SLOW_RESOURCE("SLOW_RESOURCE", ""), + NO_OBSERVERS("NO_OBSERVERS", "Resource has no registered observers"), + OBSERVER_NOT_FOUND("OBSERVER_NOT_FOUND", ""), + PRESENCE_STOPPED("PRESENCE_STOPPED", ""), + PRESENCE_TIMEOUT("PRESENCE_TIMEOUT", ""), + PRESENCE_DO_NOT_HANDLE("PRESENCE_DO_NOT_HANDLE", ""), + VIRTUAL_DO_NOT_HANDLE("VIRTUAL_DO_NOT_HANDLE", ""), + INVALID_OPTION("INVALID_OPTION", ""), + MALFORMED_RESPONSE("MALFORMED_RESPONSE", "Remote reply contained malformed data"), + PERSISTENT_BUFFER_REQUIRED("PERSISTENT_BUFFER_REQUIRED", ""), + INVALID_REQUEST_HANDLE("INVALID_REQUEST_HANDLE", ""), + INVALID_DEVICE_INFO("INVALID_DEVICE_INFO", ""), + ERROR("ERROR", "Generic error"), + + JNI_EXCEPTION("JNI_EXCEPTION", "Generic Java binder error"), + JNI_NO_NATIVE_OBJECT("JNI_NO_NATIVE_OBJECT", ""), + JNI_INVALID_VALUE("JNI_INVALID_VALUE", ""), + + INVALID_CLASS_CAST("INVALID_CLASS_CAST", ""),; + + private String error; + private String description; + + private ErrorCode(String error, String description) { + this.error = error; + this.description = description; + } + + public String getError() { + return error; + } + + public String getDescription() { + return description; + } + + public static ErrorCode get(String errorCode) { + for (ErrorCode eCode : ErrorCode.values()) { + if (eCode.getError().equals(errorCode)) { + return eCode; + } + } + throw new IllegalArgumentException("Unexpected ErrorCode value"); + } + + @Override + public String toString() { + return error + (description.isEmpty() ? "" : " : " + description); + } +} diff --git a/android/android_api/base/src/main/java/org/iotivity/base/ModeType.java b/android/android_api/base/src/main/java/org/iotivity/base/ModeType.java new file mode 100755 index 0000000..81ea7c7 --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/base/ModeType.java @@ -0,0 +1,39 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base; + +public enum ModeType { + SERVER(0), + CLIENT(1), + CLIENT_SERVER(2),; + + private int value; + + private ModeType(int value) { + this.value = value; + } + + public int getValue() { + return this.value; + } +} diff --git a/android/android_api/base/src/main/java/org/iotivity/base/ObservationInfo.java b/android/android_api/base/src/main/java/org/iotivity/base/ObservationInfo.java new file mode 100755 index 0000000..483d4cb --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/base/ObservationInfo.java @@ -0,0 +1,55 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base; + +public class ObservationInfo { + + private ObserveAction mObserveAction; + private byte mOcObservationId; + + private ObservationInfo(int observationAction, byte observationId) { + this.mObserveAction = ObserveAction.get(observationAction); + this.mOcObservationId = observationId; + } + + public ObservationInfo(ObserveAction observeAction, byte observationId) { + this.mObserveAction = observeAction; + this.mOcObservationId = observationId; + } + + public ObserveAction getObserveAction() { + return mObserveAction; + } + + public void setObserveAction(ObserveAction observeAction) { + this.mObserveAction = observeAction; + } + + public byte getOcObservationId() { + return mOcObservationId; + } + + public void setOcObservationId(byte ocObservationId) { + this.mOcObservationId = ocObservationId; + } +} diff --git a/android/android_api/base/src/main/java/org/iotivity/base/ObserveAction.java b/android/android_api/base/src/main/java/org/iotivity/base/ObserveAction.java new file mode 100755 index 0000000..3e7c5ec --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/base/ObserveAction.java @@ -0,0 +1,47 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base; + +public enum ObserveAction { + REGISTER(0), + UNREGISTER(1),; + + private int value; + + private ObserveAction(int value) { + this.value = value; + } + + public int getValue() { + return this.value; + } + + public static ObserveAction get(int val) { + for (ObserveAction observeAction : ObserveAction.values()) { + if (observeAction.getValue() == val) + return observeAction; + } + + throw new IllegalArgumentException("Unexpected ObserveAction value"); + } +} diff --git a/android/android_api/base/src/main/java/org/iotivity/base/ObserveType.java b/android/android_api/base/src/main/java/org/iotivity/base/ObserveType.java new file mode 100755 index 0000000..3432a47 --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/base/ObserveType.java @@ -0,0 +1,38 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base; + +public enum ObserveType { + OBSERVE(0), + OBSERVE_ALL(1),; + + private int value; + + private ObserveType(int value) { + this.value = value; + } + + public int getValue() { + return this.value; + } +} diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcConnectivityType.java b/android/android_api/base/src/main/java/org/iotivity/base/OcConnectivityType.java new file mode 100755 index 0000000..e405790 --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/base/OcConnectivityType.java @@ -0,0 +1,52 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base; + +import java.security.InvalidParameterException; + +public enum OcConnectivityType { + ETHERNET(0), + WIFI (1), + EDR (2), + LE (3), + ALL (4), + ; + + private int value; + + private OcConnectivityType(int value) { + this.value = value; + } + + public int getValue() { + return this.value; + } + + public static OcConnectivityType get(int val) { + for (OcConnectivityType v : OcConnectivityType.values()) { + if (v.getValue() == val) + return v; + } + throw new InvalidParameterException("Unexpected OcConnectivityType value:" + val); + } +} diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcDeviceInfo.java b/android/android_api/base/src/main/java/org/iotivity/base/OcDeviceInfo.java new file mode 100755 index 0000000..65e1497 --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/base/OcDeviceInfo.java @@ -0,0 +1,177 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base; + +public class OcDeviceInfo { + + private String deviceName; + private String hostName; + private String deviceUuid; + private String contentType; + private String version; + private String manufacturerName; + private String manufacturerUrl; + private String modelNumber; + private String dateOfManufacture; + private String platformVersion; + private String firmwareVersion; + private String supportUrl; + + public OcDeviceInfo() { + deviceName = ""; + hostName = ""; + deviceUuid = ""; + contentType = ""; + version = ""; + manufacturerName = ""; + manufacturerUrl = ""; + modelNumber = ""; + dateOfManufacture = ""; + platformVersion = ""; + firmwareVersion = ""; + supportUrl = ""; + } + + public OcDeviceInfo( + String deviceName, + String hostName, + String deviceUuid, + String contentType, + String version, + String manufacturerName, + String manufacturerUrl, + String modelNumber, + String dateOfManufacture, + String platformVersion, + String firmwareVersion, + String supportUrl) { + this.deviceName = deviceName; + this.hostName = hostName; + this.deviceUuid = deviceUuid; + this.contentType = contentType; + this.version = version; + this.manufacturerName = manufacturerName; + this.manufacturerUrl = manufacturerUrl; + this.modelNumber = modelNumber; + this.dateOfManufacture = dateOfManufacture; + this.platformVersion = platformVersion; + this.firmwareVersion = firmwareVersion; + this.supportUrl = supportUrl; + } + + public String getDeviceName() { + return deviceName; + } + + public void setDeviceName(String deviceName) { + this.deviceName = deviceName; + } + + public String getHostName() { + return hostName; + } + + public void setHostName(String hostName) { + this.hostName = hostName; + } + + public String getDeviceUuid() { + return deviceUuid; + } + + public void setDeviceUuid(String deviceUuid) { + this.deviceUuid = deviceUuid; + } + + public String getContentType() { + return contentType; + } + + public void setContentType(String contentType) { + this.contentType = contentType; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getManufacturerName() { + return manufacturerName; + } + + public void setManufacturerName(String manufacturerName) { + this.manufacturerName = manufacturerName; + } + + public String getManufacturerUrl() { + return manufacturerUrl; + } + + public void setManufacturerUrl(String manufacturerUrl) { + this.manufacturerUrl = manufacturerUrl; + } + + public String getModelNumber() { + return modelNumber; + } + + public void setModelNumber(String modelNumber) { + this.modelNumber = modelNumber; + } + + public String getDateOfManufacture() { + return dateOfManufacture; + } + + public void setDateOfManufacture(String dateOfManufacture) { + this.dateOfManufacture = dateOfManufacture; + } + + public String getPlatformVersion() { + return platformVersion; + } + + public void setPlatformVersion(String platformVersion) { + this.platformVersion = platformVersion; + } + + public String getFirmwareVersion() { + return firmwareVersion; + } + + public void setFirmwareVersion(String firmwareVersion) { + this.firmwareVersion = firmwareVersion; + } + + public String getSupportUrl() { + return supportUrl; + } + + public void setSupportUrl(String supportUrl) { + this.supportUrl = supportUrl; + } +} diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcException.java b/android/android_api/base/src/main/java/org/iotivity/base/OcException.java new file mode 100755 index 0000000..f83bf6c --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/base/OcException.java @@ -0,0 +1,58 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base; + +public class OcException extends Exception { + + private ErrorCode errorCode; + + public OcException(ErrorCode errorCode, String errMessage) { + super(errMessage + " " + errorCode.toString()); + this.errorCode = errorCode; + } + + private OcException(String error, String errMessage) { + super(errMessage + " " + error); + this.errorCode = ErrorCode.get(error); + } + + public ErrorCode getErrorCode() { + return errorCode; + } + + private static void addStackTrace(Throwable throwable, + String file, + String functionName, + int line) { + StackTraceElement[] stack = throwable.getStackTrace(); + StackTraceElement[] newStack = new StackTraceElement[stack.length + 1]; + + System.arraycopy(stack, 0, newStack, 1, stack.length); + newStack[0] = new StackTraceElement("", functionName, file, line); + throwable.setStackTrace(newStack); + } + + private void setNativeExceptionLocation(String file, String functionName, int line) { + OcException.addStackTrace(this, file, functionName, line); + } +} diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcHeaderOption.java b/android/android_api/base/src/main/java/org/iotivity/base/OcHeaderOption.java new file mode 100755 index 0000000..984bc27 --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/base/OcHeaderOption.java @@ -0,0 +1,70 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base; + +import java.security.InvalidParameterException; + +/** + * OcHeaderOption class allows to create instances which comprises optionId + * and optionData as members. These are used in setting Header options. + * After creating instances of OcHeaderOptions, use setHeaderOptions API + * (in OcResource) to set header Options. + * NOTE: optionId is an integer value which MUST be within + * range of 2048 to 3000 inclusive of lower and upper bound. + * HeaderOption instance creation fails if above condition is not satisfied. + */ +public class OcHeaderOption { + + public static final int MIN_HEADER_OPTION_ID = 2048; + public static final int MAX_HEADER_OPTION_ID = 3000; + + private int mOptionId; + private String mOptionData; + + public OcHeaderOption(int optionId, String optionData) { + if (!(optionId >= MIN_HEADER_OPTION_ID && optionId <= MAX_HEADER_OPTION_ID)) { + throw new InvalidParameterException("Option ID range is invalid"); + } + + this.mOptionId = optionId; + this.mOptionData = optionData; + } + + /** + * API to get Option ID + * + * @return option ID + */ + public int getOptionId() { + return mOptionId; + } + + /** + * API to get Option data + * + * @return option data + */ + public String getOptionData() { + return mOptionData; + } +} diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcPlatform.java b/android/android_api/base/src/main/java/org/iotivity/base/OcPlatform.java new file mode 100755 index 0000000..fe71268 --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/base/OcPlatform.java @@ -0,0 +1,777 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base; + +import org.iotivity.ca.CaInterface; + +import java.util.EnumSet; +import java.util.Iterator; +import java.util.List; + +/** + * Contains the main entrance/functionality of the product. To set a custom configuration, the + * implementer must make a call to OcPlatform.Configure before the first usage of a function in this + * class. + */ +public final class OcPlatform { + + static { + System.loadLibrary("oc_logger"); + System.loadLibrary("octbstack"); + System.loadLibrary("connectivity_abstraction"); + System.loadLibrary("oc"); + System.loadLibrary("ocstack-jni"); + } + + /** + * Default interface + */ + public static final String DEFAULT_INTERFACE = "oc.mi.def"; + + /** + * Used in discovering (GET) links to other resources of a collection + */ + public static final String LINK_INTERFACE = "oc.mi.ll"; + + /** + * Used in GET, PUT, POST, DELETE methods on links to other resources of a collection + */ + public static final String BATCH_INTERFACE = "oc.mi.b"; + + /** + * Used in GET, PUT, POST methods on links to other remote resources of a group + */ + public static final String GROUP_INTERFACE = "oc.mi.grp"; + + public static final String WELL_KNOWN_QUERY = "224.0.1.187:5683/oc/core"; + public static final String MULTICAST_PREFIX = "224.0.1.187:5683"; + public static final String MULTICAST_IP = "224.0.1.187"; + public static final int MULTICAST_PORT = 5683; + public static final int DEFAULT_PRESENCE_TTL = 60; + public static final String PRESENCE_URI = "/oc/presence"; + + private static volatile boolean sIsPlatformInitialized = false; + + private OcPlatform() { + } + + /** + * API for setting the configuration of the OcPlatform. + * Note: Any calls made to this AFTER the first call to OcPlatform.Configure will have no affect + * + * @param platformConfig platform configuration + */ + public synchronized static void Configure(PlatformConfig platformConfig) { + if (!sIsPlatformInitialized) { + CaInterface.initialize(platformConfig.getContext()); + + OcPlatform.configure( + platformConfig.getServiceType().getValue(), + platformConfig.getModeType().getValue(), + platformConfig.getIpAddress(), + platformConfig.getPort(), + platformConfig.getQualityOfService().getValue() + ); + + sIsPlatformInitialized = true; + } + } + + private static native void configure(int serviceType, + int modeType, + String ipAddress, + int port, + int qualityOfService); + + /** + * API for notifying base that resource's attributes have changed. + * + * @param ocResourceHandle resource handle of the resource + * @throws OcException + */ + public static void notifyAllObservers( + OcResourceHandle ocResourceHandle) throws OcException { + OcPlatform.initCheck(); + OcPlatform.notifyAllObservers0(ocResourceHandle); + } + + private static native void notifyAllObservers0( + OcResourceHandle ocResourceHandle) throws OcException; + + /** + * API for notifying base that resource's attributes have changed. + * + * @param ocResourceHandle resource handle of the resource + * @param qualityOfService the quality of communication + * @throws OcException + */ + public static void notifyAllObservers( + OcResourceHandle ocResourceHandle, + QualityOfService qualityOfService) throws OcException { + OcPlatform.initCheck(); + OcPlatform.notifyAllObservers1(ocResourceHandle, qualityOfService.getValue()); + } + + private static native void notifyAllObservers1( + OcResourceHandle ocResourceHandle, + int qualityOfService) throws OcException; + + /** + * API for notifying only specific clients that resource's attributes have changed. + * + * @param ocResourceHandle resource handle of the resource + * @param ocObservationIdList These set of ids are ones which which will be notified upon + * resource change. + * @param ocResourceResponse OcResourceResponse object used by app to fill the response for + * this resource change + * @throws OcException + */ + public static void notifyListOfObservers( + OcResourceHandle ocResourceHandle, + List ocObservationIdList, + OcResourceResponse ocResourceResponse) throws OcException { + OcPlatform.initCheck(); + + byte[] idArr = new byte[ocObservationIdList.size()]; + Iterator it = ocObservationIdList.iterator(); + int i = 0; + while (it.hasNext()) { + idArr[i++] = (byte) it.next(); + } + + OcPlatform.notifyListOfObservers2( + ocResourceHandle, + idArr, + ocResourceResponse); + } + + private static native void notifyListOfObservers2( + OcResourceHandle ocResourceHandle, + byte[] ocObservationIdArray, + OcResourceResponse ocResourceResponse) throws OcException; + + /** + * API for notifying only specific clients that resource's attributes have changed. + * + * @param ocResourceHandle resource handle of the resource + * @param ocObservationIdList These set of ids are ones which which will be notified upon + * resource change. + * @param ocResourceResponse OcResourceResponse object used by app to fill the response for + * this resource change + * @param qualityOfService the quality of communication + * @throws OcException + */ + public static void notifyListOfObservers( + OcResourceHandle ocResourceHandle, + List ocObservationIdList, + OcResourceResponse ocResourceResponse, + QualityOfService qualityOfService) throws OcException { + OcPlatform.initCheck(); + + byte[] idArr = new byte[ocObservationIdList.size()]; + Iterator it = ocObservationIdList.iterator(); + int i = 0; + while (it.hasNext()) { + idArr[i++] = (byte) it.next(); + } + + OcPlatform.notifyListOfObservers3( + ocResourceHandle, + idArr, + ocResourceResponse, + qualityOfService.getValue() + ); + } + + private static native void notifyListOfObservers3( + OcResourceHandle ocResourceHandle, + byte[] ocObservationIdArray, + OcResourceResponse ocResourceResponse, + int qualityOfService) throws OcException; + + /** + * API for Service and Resource Discovery. NOTE: This API applies to client side only + * + * @param host Host IP Address of a service to direct resource discovery query. + * If empty, performs multicast resource discovery query + * @param resourceUri name of the resource. If null or empty, performs search for all + * resource names + * @param connectivityType a type of connectivity indicating the interface. Example: WIFI, + * ETHERNET, ALL + * @param onResourceFoundListener Handles events, success states and failure states. + * @throws OcException + */ + public static void findResource( + String host, + String resourceUri, + OcConnectivityType connectivityType, + OnResourceFoundListener onResourceFoundListener) throws OcException { + OcPlatform.initCheck(); + OcPlatform.findResource0( + host, + resourceUri, + connectivityType.getValue(), + onResourceFoundListener + ); + } + + private static native void findResource0( + String host, + String resourceUri, + int connectivityType, + OnResourceFoundListener onResourceFoundListener) throws OcException; + + /** + * API for Service and Resource Discovery. NOTE: This API applies to client side only + * + * @param host Host IP Address of a service to direct resource discovery query. + * If empty, performs multicast resource discovery query + * @param resourceUri name of the resource. If null or empty, performs search for all + * resource names + * @param connectivityType a type of connectivity indicating the interface. Example: WIFI, + * ETHERNET, ALL + * @param onResourceFoundListener Handles events, success states and failure states. + * @param qualityOfService the quality of communication + * @throws OcException + */ + public static void findResource( + String host, + String resourceUri, + OcConnectivityType connectivityType, + OnResourceFoundListener onResourceFoundListener, + QualityOfService qualityOfService) throws OcException { + OcPlatform.initCheck(); + OcPlatform.findResource1(host, + resourceUri, + connectivityType.getValue(), + onResourceFoundListener, + qualityOfService.getValue() + ); + } + + private static native void findResource1( + String host, + String resourceUri, + int connectivityType, + OnResourceFoundListener onResourceFoundListener, + int qualityOfService) throws OcException; + + /** + * API for Device Discovery + * + * @param host Host IP Address. If null or empty, Multicast is performed. + * @param deviceUri Uri containing address to the virtual device + * @param connectivityType a type of connectivity indicating the interface. Example: WIFI, + * ETHERNET, ALL + * @param onDeviceFoundListener Handles events, success states and failure states. + * @throws OcException + */ + public static void getDeviceInfo( + String host, + String deviceUri, + OcConnectivityType connectivityType, + OnDeviceFoundListener onDeviceFoundListener) throws OcException { + OcPlatform.initCheck(); + OcPlatform.getDeviceInfo0( + host, + deviceUri, + connectivityType.getValue(), + onDeviceFoundListener + ); + } + + private static native void getDeviceInfo0( + String host, + String deviceUri, + int connectivityType, + OnDeviceFoundListener onDeviceFoundListener) throws OcException; + + /** + * API for Device Discovery + * + * @param host Host IP Address. If null or empty, Multicast is performed. + * @param deviceUri Uri containing address to the virtual device + * @param connectivityType a type of connectivity indicating the interface. Example: WIFI, + * ETHERNET, ALL + * @param onDeviceFoundListener Handles events, success states and failure states. + * @param qualityOfService the quality of communication + * @throws OcException + */ + public static void getDeviceInfo( + String host, + String deviceUri, + OcConnectivityType connectivityType, + OnDeviceFoundListener onDeviceFoundListener, + QualityOfService qualityOfService) throws OcException { + OcPlatform.initCheck(); + OcPlatform.getDeviceInfo1( + host, + deviceUri, + connectivityType.getValue(), + onDeviceFoundListener, + qualityOfService.getValue() + ); + } + + private static native void getDeviceInfo1( + String host, + String deviceUri, + int connectivityType, + OnDeviceFoundListener onDeviceFoundListener, + int qualityOfService) throws OcException; + + /** + * This API registers a resource with the server NOTE: This API applies to server side only. + * + * @param ocResource The instance of OcResource with all data filled + * @return resource handle + * @throws OcException + */ + public static OcResourceHandle registerResource( + OcResource ocResource) throws OcException { + OcPlatform.initCheck(); + return OcPlatform.registerResource0(ocResource); + } + + private static native OcResourceHandle registerResource0( + OcResource ocResource) throws OcException; + + /** + * This API registers a resource with the server NOTE: This API applies to server side only. + * + * @param resourceUri The URI of the resource. Example: "a/light" + * @param resourceTypeName The resource type. Example: "light" + * @param resourceInterface The resource interface (whether it is collection etc). + * @param entityHandler entity handler. + * @param resourcePropertySet indicates the property of the resource + * @return resource handle + * @throws OcException + */ + public static OcResourceHandle registerResource( + String resourceUri, + String resourceTypeName, + String resourceInterface, + EntityHandler entityHandler, + EnumSet resourcePropertySet) throws OcException { + OcPlatform.initCheck(); + + int resProperty = 0; + + for (ResourceProperty prop : ResourceProperty.values()) { + if (resourcePropertySet.contains(prop)) + resProperty |= prop.getValue(); + } + + return OcPlatform.registerResource1(resourceUri, + resourceTypeName, + resourceInterface, + entityHandler, + resProperty); + } + + private static native OcResourceHandle registerResource1( + String resourceUri, + String resourceTypeName, + String resourceInterface, + EntityHandler entityHandler, + int resourceProperty) throws OcException; + + /** + * Register Device Info + * + * @param ocDeviceInfo object containing all the device specific information + * @throws OcException + */ + public static void registerDeviceInfo( + OcDeviceInfo ocDeviceInfo) throws OcException { + OcPlatform.initCheck(); + OcPlatform.registerDeviceInfo0( + ocDeviceInfo.getDeviceName(), + ocDeviceInfo.getHostName(), + ocDeviceInfo.getDeviceUuid(), + ocDeviceInfo.getContentType(), + ocDeviceInfo.getVersion(), + ocDeviceInfo.getManufacturerName(), + ocDeviceInfo.getManufacturerUrl(), + ocDeviceInfo.getModelNumber(), + ocDeviceInfo.getDateOfManufacture(), + ocDeviceInfo.getPlatformVersion(), + ocDeviceInfo.getFirmwareVersion(), + ocDeviceInfo.getSupportUrl() + ); + } + + private static native void registerDeviceInfo0( + String deviceName, + String hostName, + String deviceUUID, + String contentType, + String version, + String manufacturerName, + String manufacturerUrl, + String modelNumber, + String dateOfManufacture, + String platformVersion, + String firmwareVersion, + String supportUrl) throws OcException; + + /** + * This API unregisters a resource with the server NOTE: This API applies to server side only. + * + * @param ocResourceHandle This is the resource handle which we which to unregister from the + * server + * @throws OcException + */ + public static void unregisterResource( + OcResourceHandle ocResourceHandle) throws OcException { + OcPlatform.initCheck(); + OcPlatform.unregisterResource0(ocResourceHandle); + } + + private static native void unregisterResource0( + OcResourceHandle ocResourceHandle) throws OcException; + + + /** + * Add a resource to a collection resource + * + * @param ocResourceCollectionHandle handle to the collection resource + * @param ocResourceHandle handle to resource to be added to the collection resource + * @throws OcException + */ + public static void bindResource( + OcResourceHandle ocResourceCollectionHandle, + OcResourceHandle ocResourceHandle) throws OcException { + OcPlatform.initCheck(); + OcPlatform.bindResource0(ocResourceCollectionHandle, ocResourceHandle); + } + + private static native void bindResource0( + OcResourceHandle ocResourceCollectionHandle, + OcResourceHandle ocResourceHandle) throws OcException; + + /** + * Add multiple resources to a collection resource. + * + * @param ocResourceCollectionHandle handle to the collection resource + * @param ocResourceHandleList reference to list of resource handles to be added to the + * collection resource + * @throws OcException + */ + public static void bindResources( + OcResourceHandle ocResourceCollectionHandle, + List ocResourceHandleList) throws OcException { + OcPlatform.initCheck(); + OcPlatform.bindResources0( + ocResourceCollectionHandle, + ocResourceHandleList.toArray( + new OcResourceHandle[ocResourceHandleList.size()]) + ); + } + + private static native void bindResources0( + OcResourceHandle ocResourceCollectionHandle, + OcResourceHandle[] ocResourceHandleArray) throws OcException; + + /** + * Unbind a resource from a collection resource. + * + * @param ocResourceCollectionHandle handle to the collection resource + * @param ocResourceHandle resource handle to be unbound from the collection resource + * @throws OcException + */ + public static void unbindResource( + OcResourceHandle ocResourceCollectionHandle, + OcResourceHandle ocResourceHandle) throws OcException { + OcPlatform.initCheck(); + OcPlatform.unbindResource0(ocResourceCollectionHandle, ocResourceHandle); + } + + private static native void unbindResource0( + OcResourceHandle ocResourceCollectionHandle, + OcResourceHandle ocResourceHandle) throws OcException; + + /** + * Unbind resources from a collection resource. + * + * @param ocResourceCollectionHandle Handle to the collection resource + * @param ocResourceHandleList List of resource handles to be unbound from the collection + * resource + * @throws OcException + */ + public static void unbindResources( + OcResourceHandle ocResourceCollectionHandle, + List ocResourceHandleList) throws OcException { + OcPlatform.initCheck(); + OcPlatform.unbindResources0( + ocResourceCollectionHandle, + ocResourceHandleList.toArray( + new OcResourceHandle[ocResourceHandleList.size()]) + ); + } + + private static native void unbindResources0( + OcResourceHandle ocResourceCollectionHandle, + OcResourceHandle[] ocResourceHandleArray) throws OcException; + + /** + * Binds a type to a particular resource + * + * @param ocResourceHandle handle to the resource + * @param resourceTypeName new typename to bind to the resource + * @throws OcException + */ + public static void bindTypeToResource( + OcResourceHandle ocResourceHandle, + String resourceTypeName) throws OcException { + OcPlatform.initCheck(); + OcPlatform.bindTypeToResource0(ocResourceHandle, resourceTypeName); + } + + private static native void bindTypeToResource0( + OcResourceHandle ocResourceHandle, + String resourceTypeName) throws OcException; + + /** + * Binds an interface to a particular resource + * + * @param ocResourceHandle handle to the resource + * @param resourceInterfaceName new interface to bind to the resource + * @throws OcException + */ + public static void bindInterfaceToResource( + OcResourceHandle ocResourceHandle, + String resourceInterfaceName) throws OcException { + OcPlatform.initCheck(); + OcPlatform.bindInterfaceToResource0(ocResourceHandle, resourceInterfaceName); + } + + private static native void bindInterfaceToResource0( + OcResourceHandle ocResourceHandle, + String resourceInterfaceName) throws OcException; + + /** + * Start Presence announcements. + * + * @param ttl time to live in seconds + * @throws OcException + */ + public static void startPresence(int ttl) throws OcException { + OcPlatform.initCheck(); + OcPlatform.startPresence0(ttl); + } + + private static native void startPresence0(int ttl) throws OcException; + + /** + * Stop Presence announcements. + * + * @throws OcException + */ + public static void stopPresence() throws OcException { + OcPlatform.initCheck(); + OcPlatform.stopPresence0(); + } + + private static native void stopPresence0() throws OcException; + + /** + * Subscribes to a server's presence change events. By making this subscription, every time a + * server adds/removes/alters a resource, starts or is intentionally stopped + * + * @param host The IP address/addressable name of the server to subscribe to + * @param connectivityType a type of connectivity indicating the interface. Example: WIFI, + * ETHERNET, ALL + * @param onPresenceListener listener that will receive notifications/subscription events + * @return a handle object that can be used to identify this subscription request. It can be + * used to unsubscribe from these events in the future + * @throws OcException + */ + public static OcPresenceHandle subscribePresence( + String host, + OcConnectivityType connectivityType, + OnPresenceListener onPresenceListener) throws OcException { + OcPlatform.initCheck(); + return OcPlatform.subscribePresence0( + host, + connectivityType.getValue(), + onPresenceListener + ); + } + + private static native OcPresenceHandle subscribePresence0( + String host, + int connectivityType, + OnPresenceListener onPresenceListener) throws OcException; + + /** + * Subscribes to a server's presence change events. By making this subscription, every time a + * server adds/removes/alters a resource, starts or is intentionally stopped + * + * @param host The IP address/addressable name of the server to subscribe to + * @param resourceType a resource type specified as a filter for subscription events. + * @param connectivityType a type of connectivity indicating the interface. Example: WIFI, + * ETHERNET, ALL + * @param onPresenceListener listener that will receive notifications/subscription events + * @return a handle object that can be used to identify this subscription request. It can be + * used to unsubscribe from these events in the future + * @throws OcException + */ + public static OcPresenceHandle subscribePresence( + String host, + String resourceType, + OcConnectivityType connectivityType, + OnPresenceListener onPresenceListener) throws OcException { + OcPlatform.initCheck(); + return OcPlatform.subscribePresence1( + host, + resourceType, + connectivityType.getValue(), + onPresenceListener); + } + + private static native OcPresenceHandle subscribePresence1( + String host, + String resourceType, + int connectivityType, + OnPresenceListener onPresenceListener) throws OcException; + + /** + * Unsubscribes from a previously subscribed server's presence events. Note that you may for + * a short time still receive events from the server since it may take time for the + * unsubscribe to take effect. + * + * @param ocPresenceHandle the handle object provided by the subscribePresence call that + * identifies this subscription + * @throws OcException + */ + public static void unsubscribePresence( + OcPresenceHandle ocPresenceHandle) throws OcException { + OcPlatform.initCheck(); + OcPlatform.unsubscribePresence0(ocPresenceHandle); + } + + private static native void unsubscribePresence0( + OcPresenceHandle ocPresenceHandle) throws OcException; + + /** + * Creates a resource proxy object so that get/put/observe functionality can be used without + * discovering the object in advance. Note that the consumer of this method needs to provide + * all of the details required to correctly contact and observe the object. If the consumer + * lacks any of this information, they should discover the resource object normally. + * Additionally, you can only create this object if OcPlatform was initialized to be a Client + * or Client/Server. + * + * @param host a string containing a resolvable host address of the server holding + * the resource + * @param uri the rest of the resource's URI that will permit messages to be + * properly routed. + * Example: /a/light + * @param connectivityType a type of connectivity indicating the interface. Example: WIFI, + * ETHERNET, ALL + * @param isObservable a boolean containing whether the resource supports observation + * @param resourceTypeList a collection of resource types implemented by the resource + * @param interfaceList a collection of interfaces that the resource supports/implements + * @return new resource object + * @throws OcException + */ + public static OcResource constructResourceObject( + String host, + String uri, + OcConnectivityType connectivityType, + boolean isObservable, + List resourceTypeList, + List interfaceList) throws OcException { + OcPlatform.initCheck(); + return OcPlatform.constructResourceObject0( + host, + uri, + connectivityType.getValue(), + isObservable, + resourceTypeList.toArray(new String[resourceTypeList.size()]), + interfaceList.toArray(new String[interfaceList.size()]) + ); + } + + private static native OcResource constructResourceObject0( + String host, + String uri, + int connectivityType, + boolean isObservable, + String[] resourceTypes, + String[] interfaces) throws OcException; + + /** + * Allows application entity handler to send response to an incoming request. + * + * @param ocResourceResponse resource response + * @throws OcException + */ + public static void sendResponse(OcResourceResponse ocResourceResponse) + throws OcException { + OcPlatform.initCheck(); + OcPlatform.sendResponse0(ocResourceResponse); + } + + private static native void sendResponse0(OcResourceResponse ocResourceResponse) + throws OcException; + + /** + * An OnResourceFoundListener can be registered via the OcPlatform.findResource call. + * Event listeners are notified asynchronously + */ + public interface OnResourceFoundListener { + public void onResourceFound(OcResource resource); + } + + /** + * An OnDeviceFoundListener can be registered via the OcPlatform.getDeviceInfo call. + * Event listeners are notified asynchronously + */ + public interface OnDeviceFoundListener { + public void onDeviceFound(OcRepresentation ocRepresentation); + } + + /** + * An OnPresenceListener can be registered via the OcPlatform.subscribePresence call. + * Event listeners are notified asynchronously + */ + public interface OnPresenceListener { + public void onPresence(OcPresenceStatus ocPresenceStatus, int nonce, String hostAddress); + } + + /** + * An EntityHandler can be registered via the OcPlatform.registerResource call. + * Event listeners are notified asynchronously + */ + public interface EntityHandler { + public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest); + } + + private static void initCheck() { + if (!sIsPlatformInitialized) { + throw new IllegalStateException("OcPlatform must be configured by making a call to " + + "OcPlatform.Configure before any other API calls are permitted"); + } + } +} \ No newline at end of file diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcPlatformStatus.java b/android/android_api/base/src/main/java/org/iotivity/base/OcPlatformStatus.java new file mode 100755 index 0000000..4ef76da --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/base/OcPlatformStatus.java @@ -0,0 +1,39 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base; + + +public enum OcPlatformStatus { + UP(0), + DOWN(1),; + + private int value; + + private OcPlatformStatus(int value) { + this.value = value; + } + + public int getValue() { + return this.value; + } +} diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcPresenceHandle.java b/android/android_api/base/src/main/java/org/iotivity/base/OcPresenceHandle.java new file mode 100755 index 0000000..184be8f --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/base/OcPresenceHandle.java @@ -0,0 +1,41 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base; + +public class OcPresenceHandle { + + private OcPresenceHandle(long nativeHandle) { + this.mNativeHandle = nativeHandle; + } + + @Override + protected void finalize() throws Throwable { + super.finalize(); + + dispose(); + } + + private native void dispose(); + + private long mNativeHandle; +} diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcPresenceStatus.java b/android/android_api/base/src/main/java/org/iotivity/base/OcPresenceStatus.java new file mode 100755 index 0000000..ff2c7dc --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/base/OcPresenceStatus.java @@ -0,0 +1,50 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base; + +import java.security.InvalidParameterException; + +public enum OcPresenceStatus { + OK("OK"), + STOPPED("PRESENCE_STOPPED"), + TIMEOUT("PRESENCE_TIMEOUT"), + DO_NOT_HANDLE("PRESENCE_DO_NOT_HANDLE"); + + private String value; + + private OcPresenceStatus(String value) { + this.value = value; + } + + public static OcPresenceStatus get(String val) { + for (OcPresenceStatus v : OcPresenceStatus.values()) { + if (v.getValue().equals(val)) + return v; + } + throw new InvalidParameterException("Unexpected OcPresenceStatus value"); + } + + public String getValue() { + return this.value; + } +} diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcRepresentation.java b/android/android_api/base/src/main/java/org/iotivity/base/OcRepresentation.java new file mode 100755 index 0000000..98ec0bc --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/base/OcRepresentation.java @@ -0,0 +1,358 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base; + +import java.security.InvalidParameterException; +import java.util.Arrays; +import java.util.List; + +/** + * + */ +public class OcRepresentation { + + static { + System.loadLibrary("oc"); + System.loadLibrary("ocstack-jni"); + } + + public OcRepresentation() { + create(); + //Native OCRepresentation object was created using "new" and needs to be deleted + this.mNativeNeedsDelete = true; + } + + private OcRepresentation(long nativeHandle) { + this.mNativeHandle = nativeHandle; + this.mNativeNeedsDelete = false; + } + + private OcRepresentation(long nativeHandle, boolean nativeNeedsDelete) { + this.mNativeHandle = nativeHandle; + this.mNativeNeedsDelete = nativeNeedsDelete; + } + + public T getValue(String key) throws OcException { + Object obj = this.getValueN(key); + @SuppressWarnings("unchecked") + T t = (T) obj; + return t; + } + + private native Object getValueN(String key); + + public void setValue(String key, int value) throws OcException { + this.setValueInteger(key, value); + } + + public void setValue(String key, double value) throws OcException { + this.setValueDouble(key, value); + } + + public void setValue(String key, boolean value) throws OcException { + this.setValueBoolean(key, value); + } + + public void setValue(String key, String value) throws OcException { + this.setValueStringN(key, value); + } + + public void setValue(String key, OcRepresentation value) throws OcException { + this.setValueRepresentation(key, value); + } + + public void setValue(String key, int[] value) throws OcException { + this.setValueIntegerArray(key, value); + } + + public void setValue(String key, int[][] value) throws OcException { + this.setValueInteger2DArray(key, value); + } + + public void setValue(String key, int[][][] value) throws OcException { + this.setValueInteger3DArray(key, value); + } + + public void setValue(String key, double[] value) throws OcException { + this.setValueDoubleArray(key, value); + } + + public void setValue(String key, double[][] value) throws OcException { + this.setValueDouble2DArray(key, value); + } + + public void setValue(String key, double[][][] value) throws OcException { + this.setValueDouble3DArray(key, value); + } + + public void setValue(String key, boolean[] value) throws OcException { + this.setValueBooleanArray(key, value); + } + + public void setValue(String key, boolean[][] value) throws OcException { + this.setValueBoolean2DArray(key, value); + } + + public void setValue(String key, boolean[][][] value) throws OcException { + this.setValueBoolean3DArray(key, value); + } + + public void setValue(String key, String[] value) throws OcException { + this.setValueStringArray(key, value); + } + + public void setValue(String key, String[][] value) throws OcException { + this.setValueString2DArray(key, value); + } + + public void setValue(String key, String[][][] value) throws OcException { + this.setValueString3DArray(key, value); + } + + public void setValue(String key, OcRepresentation[] value) throws OcException { + this.setValueRepresentationArray(key, value); + } + + public void setValue(String key, OcRepresentation[][] value) throws OcException { + this.setValueRepresentation2DArray(key, value); + } + + public void setValue(String key, OcRepresentation[][][] value) throws OcException { + this.setValueRepresentation3DArray(key, value); + } + + private native void setValueInteger(String key, int value) throws OcException; + + private native void setValueDouble(String key, double value) throws OcException; + + private native void setValueBoolean(String key, boolean value) throws OcException; + + private native void setValueStringN(String key, String value) throws OcException; + + private native void setValueRepresentation(String key, OcRepresentation value) throws OcException; + + private native void setValueIntegerArray(String key, int[] value) throws OcException; + + private native void setValueInteger2DArray(String key, int[][] value) throws OcException; + + private native void setValueInteger3DArray(String key, int[][][] value) throws OcException; + + private native void setValueDoubleArray(String key, double[] value) throws OcException; + + private native void setValueDouble2DArray(String key, double[][] value) throws OcException; + + private native void setValueDouble3DArray(String key, double[][][] value) throws OcException; + + private native void setValueBooleanArray(String key, boolean[] value) throws OcException; + + private native void setValueBoolean2DArray(String key, boolean[][] value) throws OcException; + + private native void setValueBoolean3DArray(String key, boolean[][][] value) throws OcException; + + private native void setValueStringArray(String key, String[] value) throws OcException; + + private native void setValueString2DArray(String key, String[][] value) throws OcException; + + private native void setValueString3DArray(String key, String[][][] value) throws OcException; + + private native void setValueRepresentationArray(String key, OcRepresentation[] value) throws OcException; + + private native void setValueRepresentation2DArray(String key, OcRepresentation[][] value) throws OcException; + + private native void setValueRepresentation3DArray(String key, OcRepresentation[][][] value) throws OcException; + + /** + * @deprecated use {@link #getValue(String key)} instead. + */ + @Deprecated + public int getValueInt(String key) { + int value = 0; + try { + value = this.getValue(key); + } catch (OcException e) { + //simply catching here for the deprecated APIs, so the older usages don't have to handle + //it in the code + } + return value; + } + + /** + * @deprecated use {@link #getValue(String key)} instead. + */ + @Deprecated + public boolean getValueBool(String key) { + boolean value = false; + try { + value = this.getValue(key); + } catch (OcException e) { + //simply catching here for the deprecated APIs, so the older usages don't have to handle + //it in the code + } + return value; + } + + /** + * @deprecated use {@link #getValue(String key)} instead. + */ + @Deprecated + public String getValueString(String key) { + String value = ""; + try { + value = this.getValue(key); + } catch (OcException e) { + //simply catching here for the deprecated APIs, so the older usages don't have to handle + //it in the code + } + return value; + } + + /** + * @deprecated use {@link #setValue(String key, int value)} instead. + */ + @Deprecated + public void setValueInt(String key, int value) { + try { + this.setValue(key, value); + } catch (OcException e) { + //simply catching here for the deprecated APIs, so the older usages don't have to handle + //it in the code + } + } + + /** + * @deprecated use {@link #setValue(String key, boolean value)} instead. + */ + @Deprecated + public void setValueBool(String key, boolean value) { + try { + this.setValue(key, value); + } catch (OcException e) { + //simply catching here for the deprecated APIs, so the older usages don't have to handle + //it in the code + } + } + + /** + * @deprecated use {@link #setValue(String key, String value)} instead. + */ + @Deprecated + public void setValueString(String key, String value) { + try { + this.setValue(key, value); + } catch (OcException e) { + //simply catching here for the deprecated APIs, so the older usages don't have to handle + //it in the code + } + } + + public native String getJSONRepresentation(); + + public native void addChild(OcRepresentation representation); + + public native void clearChildren(); + + public List getChildren() { + return Arrays.asList( + getChildrenArray()); + } + + private native OcRepresentation[] getChildrenArray(); + + public native String getUri(); + + public native void setUri(String uri); + + /** + * Method to get the list of resource types + * + * @return List of resource types + */ + public native List getResourceTypes(); + + /** + * Method to set the list of resource types + * + * @param resourceTypeList list of resources + */ + public void setResourceTypes(List resourceTypeList) { + if (null == resourceTypeList) { + throw new InvalidParameterException("resourceTypeList cannot be null"); + } + + this.setResourceTypeArray( + resourceTypeList.toArray( + new String[resourceTypeList.size()])); + } + + private native void setResourceTypeArray(String[] resourceTypeArray); + + /** + * Method to get the list of resource interfaces + * + * @return List of resource interface + */ + public native List getResourceInterfaces(); + + /** + * Method to set the list of resource interfaces + * + * @param resourceInterfaceList list of interfaces + */ + public void setResourceInterfaces(List resourceInterfaceList) { + if (null == resourceInterfaceList) { + throw new InvalidParameterException("resourceInterfaceList cannot be null"); + } + + this.setResourceInterfaceArray( + resourceInterfaceList.toArray( + new String[resourceInterfaceList.size()])); + } + + private native void setResourceInterfaceArray(String[] resourceInterfaceArray); + + public native boolean isEmpty(); + + public native int size(); + + public native boolean remove(String key); + + public native boolean hasAttribute(String key); + + public native void setNull(String key); + + public native boolean isNull(String key); + + @Override + protected void finalize() throws Throwable { + super.finalize(); + + dispose(this.mNativeNeedsDelete); + } + + private native void create(); + + private native void dispose(boolean needsDelete); + + private long mNativeHandle; + private boolean mNativeNeedsDelete; +} \ No newline at end of file diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcRequestHandle.java b/android/android_api/base/src/main/java/org/iotivity/base/OcRequestHandle.java new file mode 100755 index 0000000..73cd14b --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/base/OcRequestHandle.java @@ -0,0 +1,41 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base; + +public class OcRequestHandle { + + private OcRequestHandle(long nativeHandle) { + this.mNativeHandle = nativeHandle; + } + + @Override + protected void finalize() throws Throwable { + super.finalize(); + + dispose(); + } + + private native void dispose(); + + private long mNativeHandle; +} diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcResource.java b/android/android_api/base/src/main/java/org/iotivity/base/OcResource.java new file mode 100755 index 0000000..b3f4b08 --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/base/OcResource.java @@ -0,0 +1,575 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base; + +import java.util.List; +import java.util.Map; + +/** + * OcResource represents an OC resource. A resource could be a light controller, temperature sensor, + * smoke detector, etc. A resource comes with a well-defined contract or interface onto which you + * can perform different operations, such as turning on the light, getting the current temperature + * or subscribing for event notifications from the smoke detector. A resource can be composed of + * one or more resources. + */ +public class OcResource { + + private OcResource(long nativeHandle) { + this.mNativeHandle = nativeHandle; + } + + /** + * Method to get the attributes of a resource. + * + * @param queryParamsMap map which can have the query parameter name and value + * @param onGetListener The event handler will be invoked with a map of attribute name and + * values. The event handler will also have the result from this Get + * operation This will have error codes + * @throws OcException + */ + public native void get(Map queryParamsMap, + OnGetListener onGetListener) throws OcException; + + /** + * Method to get the attributes of a resource. + * + * @param queryParamsMap map which can have the query parameter name and value + * @param onGetListener The event handler will be invoked with a map of attribute name and + * values. The event handler will also have the result from this Get + * operation This will have error codes + * @param qualityOfService the quality of communication + * @throws OcException + */ + public void get(Map queryParamsMap, + OnGetListener onGetListener, + QualityOfService qualityOfService) throws OcException { + this.get1(queryParamsMap, onGetListener, qualityOfService.getValue()); + } + + private native void get1(Map queryParamsMap, + OnGetListener onGetListener, + int qualityOfService) throws OcException; + + /** + * Method to get the attributes of a resource. + * + * @param resourceType resourceType of the resource to operate on + * @param resourceInterface interface type of the resource to operate on + * @param queryParamsMap map which can have the query parameter name and value + * @param onGetListener The event handler will be invoked with a map of attribute name and + * values. The event handler will also have the result from this Get + * operation This will have error codes + * @throws OcException + */ + public void get(String resourceType, + String resourceInterface, + Map queryParamsMap, + OnGetListener onGetListener) throws OcException { + this.get2( + resourceType, + resourceInterface, + queryParamsMap, + onGetListener); + } + + private native void get2(String resourceType, + String resourceInterface, + Map queryParamsMap, + OnGetListener onGetListener) throws OcException; + + /** + * Method to get the attributes of a resource. + * + * @param resourceType resourceType of the resource to operate on + * @param resourceInterface interface type of the resource to operate on + * @param queryParamsMap map which can have the query parameter name and value + * @param onGetListener The event handler will be invoked with a map of attribute name and + * values. The event handler will also have the result from this Get + * operation This will have error codes + * @param qualityOfService the quality of communication + * @throws OcException + */ + public void get(String resourceType, + String resourceInterface, + Map queryParamsMap, + OnGetListener onGetListener, + QualityOfService qualityOfService) throws OcException { + this.get3( + resourceType, + resourceInterface, + queryParamsMap, + onGetListener, + qualityOfService.getValue()); + } + + private native void get3(String resourceType, + String resourceInterface, + Map queryParamsMap, + OnGetListener onGetListener, + int qualityOfService) throws OcException; + + /** + * Method to set the representation of a resource (via PUT) + * + * @param representation representation of the resource + * @param queryParamsMap Map which can have the query parameter name and value + * @param onPutListener event handler The event handler will be invoked with a map of attribute + * name and values. + * @throws OcException + */ + public native void put(OcRepresentation representation, + Map queryParamsMap, + OnPutListener onPutListener) throws OcException; + + /** + * Method to set the representation of a resource (via PUT) + * + * @param ocRepresentation representation of the resource + * @param queryParamsMap Map which can have the query parameter name and value + * @param onPutListener event handler The event handler will be invoked with a map of + * attribute name and values. + * @param qualityOfService the quality of communication + * @throws OcException + */ + public void put(OcRepresentation ocRepresentation, + Map queryParamsMap, + OnPutListener onPutListener, + QualityOfService qualityOfService) throws OcException { + this.put1( + ocRepresentation, + queryParamsMap, + onPutListener, + qualityOfService.getValue()); + } + + private native void put1(OcRepresentation ocRepresentation, + Map queryParamsMap, + OnPutListener onPutListener, + int qualityOfService) throws OcException; + + /** + * Method to set the representation of a resource (via PUT) + * + * @param resourceType resource type of the resource to operate on + * @param resourceInterface interface type of the resource to operate on + * @param ocRepresentation representation of the resource + * @param queryParamsMap Map which can have the query parameter name and value + * @param onPutListener event handler The event handler will be invoked with a map of + * attribute name and values. + * @throws OcException + */ + public void put(String resourceType, + String resourceInterface, + OcRepresentation ocRepresentation, + Map queryParamsMap, + OnPutListener onPutListener) throws OcException { + this.put2( + resourceType, + resourceInterface, + ocRepresentation, + queryParamsMap, + onPutListener); + } + + private native void put2(String resourceType, + String resourceInterface, + OcRepresentation ocRepresentation, + Map queryParamsMap, + OnPutListener onPutListener) throws OcException; + + /** + * Method to set the representation of a resource (via PUT) + * + * @param resourceType resource type of the resource to operate on + * @param resourceInterface interface type of the resource to operate on + * @param ocRepresentation representation of the resource + * @param queryParamsMap Map which can have the query parameter name and value + * @param onPutListener event handler The event handler will be invoked with a map of + * attribute name and values. + * @param qualityOfService the quality of communication + * @throws OcException + */ + public void put(String resourceType, + String resourceInterface, + OcRepresentation ocRepresentation, + Map queryParamsMap, + OnPutListener onPutListener, + QualityOfService qualityOfService) throws OcException { + this.put3( + resourceType, + resourceInterface, + ocRepresentation, + queryParamsMap, + onPutListener, + qualityOfService.getValue()); + } + + private native void put3(String resourceType, + String resourceInterface, + OcRepresentation ocRepresentation, + Map queryParamsMap, + OnPutListener onPutListener, + int qualityOfService) throws OcException; + + /** + * Method to POST on a resource + * + * @param ocRepresentation representation of the resource + * @param queryParamsMap Map which can have the query parameter name and value + * @param onPostListener event handler The event handler will be invoked with a map of + * attribute name and values. + * @throws OcException + */ + public native void post(OcRepresentation ocRepresentation, + Map queryParamsMap, + OnPostListener onPostListener) throws OcException; + + /** + * Method to POST on a resource + * + * @param ocRepresentation representation of the resource + * @param queryParamsMap Map which can have the query parameter name and value + * @param onPostListener event handler The event handler will be invoked with a map of + * attribute name and values. + * @param qualityOfService the quality of communication + * @throws OcException + */ + public void post(OcRepresentation ocRepresentation, + Map queryParamsMap, + OnPostListener onPostListener, + QualityOfService qualityOfService) throws OcException { + this.post1( + ocRepresentation, + queryParamsMap, + onPostListener, + qualityOfService.getValue()); + } + + private native void post1(OcRepresentation ocRepresentation, + Map queryParamsMap, + OnPostListener onPostListener, + int qualityOfService) throws OcException; + + /** + * Method to POST on a resource + * + * @param resourceType resource type of the resource to operate on + * @param resourceInterface interface type of the resource to operate on + * @param ocRepresentation representation of the resource + * @param queryParamsMap Map which can have the query parameter name and value + * @param onPostListener event handler The event handler will be invoked with a map of + * attribute name and values. + * @throws OcException + */ + public void post(String resourceType, + String resourceInterface, + OcRepresentation ocRepresentation, + Map queryParamsMap, + OnPostListener onPostListener) throws OcException { + this.post2( + resourceType, + resourceInterface, + ocRepresentation, + queryParamsMap, + onPostListener); + } + + private native void post2(String resourceType, + String resourceInterface, + OcRepresentation ocRepresentation, + Map queryParamsMap, + OnPostListener onPostListener) throws OcException; + + /** + * Method to POST on a resource + * + * @param resourceType resource type of the resource to operate on + * @param resourceInterface interface type of the resource to operate on + * @param ocRepresentation representation of the resource + * @param queryParamsMap Map which can have the query parameter name and value + * @param onPostListener event handler The event handler will be invoked with a map of + * attribute name and values. + * @param qualityOfService the quality of communication + * @throws OcException + */ + public void post(String resourceType, + String resourceInterface, + OcRepresentation ocRepresentation, + Map queryParamsMap, + OnPostListener onPostListener, + QualityOfService qualityOfService) throws OcException { + this.post3( + resourceType, + resourceInterface, + ocRepresentation, + queryParamsMap, + onPostListener, + qualityOfService.getValue()); + } + + private native void post3(String resourceType, + String resourceInterface, + OcRepresentation ocRepresentation, + Map queryParamsMap, + OnPostListener onPostListener, + int qualityOfService) throws OcException; + + /** + * Method to perform DELETE operation + * + * @param onDeleteListener event handler The event handler will have headerOptionList + */ + public native void deleteResource(OnDeleteListener onDeleteListener) throws OcException; + + /** + * Method to perform DELETE operation + * + * @param onDeleteListener event handler The event handler will have headerOptionList + * @param qualityOfService the quality of communication + */ + public void deleteResource(OnDeleteListener onDeleteListener, + QualityOfService qualityOfService) throws OcException { + this.deleteResource1(onDeleteListener, + qualityOfService.getValue()); + } + + private native void deleteResource1(OnDeleteListener onDeleteListener, + int qualityOfService) throws OcException; + + /** + * Method to set observation on the resource + * + * @param observeType allows the client to specify how it wants to observe + * @param queryParamsMap map which can have the query parameter name and value + * @param onObserveListener event handler The handler method will be invoked with a map + * of attribute name and values. + * @throws OcException + */ + public void observe(ObserveType observeType, + Map queryParamsMap, + OnObserveListener onObserveListener) throws OcException { + this.observe( + observeType.getValue(), + queryParamsMap, + onObserveListener); + } + + private synchronized native void observe(int observeType, + Map queryParamsMap, + OnObserveListener onObserveListener) throws OcException; + + /** + * Method to set observation on the resource + * + * @param observeType allows the client to specify how it wants to observe + * @param queryParamsMap map which can have the query parameter name and value + * @param onObserveListener event handler The handler method will be invoked with a map + * of attribute name and values. + * @param qualityOfService the quality of communication + * @throws OcException + */ + public void observe(ObserveType observeType, + Map queryParamsMap, + OnObserveListener onObserveListener, + QualityOfService qualityOfService) throws OcException { + this.observe1( + observeType.getValue(), + queryParamsMap, + onObserveListener, + qualityOfService.getValue()); + } + + private synchronized native void observe1(int observeType, + Map queryParamsMap, + OnObserveListener onObserveListener, + int qualityOfService) throws OcException; + + /** + * Method to cancel the observation on the resource + * + * @throws OcException + */ + public native void cancelObserve() throws OcException; + + /** + * Method to cancel the observation on the resource + * + * @param qualityOfService the quality of communication + * @throws OcException + */ + public void cancelObserve(QualityOfService qualityOfService) throws OcException { + this.cancelObserve1(qualityOfService.getValue()); + } + + private native void cancelObserve1(int qualityOfService) throws OcException; + + /** + * Method to set header options + * + * @param headerOptionList List where header information(header optionID and + * optionData is passed + */ + public void setHeaderOptions(List headerOptionList) { + this.setHeaderOptions(headerOptionList.toArray( + new OcHeaderOption[headerOptionList.size()]) + ); + } + + private native void setHeaderOptions(OcHeaderOption[] headerOptionList); + + /** + * Method to unset header options + */ + public native void unsetHeaderOptions(); + + /** + * Method to get the host address of this resource + * + * @return host address NOTE: This might or might not be exposed in future due to + * security concerns + */ + public native String getHost(); + + /** + * Method to get the URI for this resource + * + * @return resource URI + */ + public native String getUri(); + + /** + * Method to get the connectivity type of this resource + * + * @return OcConnectivityType connectivity type + */ + public OcConnectivityType getConnectivityType() { + return OcConnectivityType.get( + this.getConnectivityTypeN() + ); + } + + private native int getConnectivityTypeN(); + + /** + * Method to provide ability to check if this resource is observable or not + * + * @return true indicates resource is observable; false indicates resource is not observable + */ + public native boolean isObservable(); + + /** + * Method to get the list of resource types + * + * @return List of resource types + */ + public native List getResourceTypes(); + + /** + * Method to get the list of resource interfaces + * + * @return List of resource interface + */ + public native List getResourceInterfaces(); + + /** + * Method to get a unique identifier for this resource across network interfaces. This will + * be guaranteed unique for every resource-per-server independent of how this was discovered. + * + * @return OcResourceIdentifier object, which can be used for all comparison and hashing + */ + public native OcResourceIdentifier getUniqueIdentifier(); + + /** + * Method to get a string representation of the resource's server ID. + * * This is unique per- server independent on how it was discovered. + * + * @return server ID + */ + public native String getServerId(); + + /** + * An OnGetListener can be registered via the resource get call. + * Event listeners are notified asynchronously + */ + public interface OnGetListener { + public void onGetCompleted(List headerOptionList, + OcRepresentation ocRepresentation); + + public void onGetFailed(Throwable ex); + } + + /** + * An OnPutListener can be registered via the resource put call. + * Event listeners are notified asynchronously + */ + public interface OnPutListener { + public void onPutCompleted(List headerOptionList, + OcRepresentation ocRepresentation); + + public void onPutFailed(Throwable ex); + } + + /** + * An OnPostListener can be registered via the resource post call. + * Event listeners are notified asynchronously + */ + public interface OnPostListener { + public void onPostCompleted(List headerOptionList, + OcRepresentation ocRepresentation); + + public void onPostFailed(Throwable ex); + } + + /** + * An OnDeleteListener can be registered via the resource delete call. + * Event listeners are notified asynchronously + */ + public interface OnDeleteListener { + public void onDeleteCompleted(List headerOptionList); + + public void onDeleteFailed(Throwable ex); + } + + /** + * An OnObserveListener can be registered via the resource observe call. + * Event listeners are notified asynchronously + */ + public interface OnObserveListener { + public void onObserveCompleted(List headerOptionList, + OcRepresentation ocRepresentation, + int sequenceNumber); + + public void onObserveFailed(Throwable ex); + } + + @Override + protected void finalize() throws Throwable { + super.finalize(); + + dispose(); + } + + private native void dispose(); + + private long mNativeHandle; +} diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcResourceHandle.java b/android/android_api/base/src/main/java/org/iotivity/base/OcResourceHandle.java new file mode 100755 index 0000000..3bab82f --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/base/OcResourceHandle.java @@ -0,0 +1,41 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base; + +public class OcResourceHandle { + + private OcResourceHandle(long nativeHandle) { + this.mNativeHandle = nativeHandle; + } + + @Override + protected void finalize() throws Throwable { + super.finalize(); + + dispose(); + } + + private native void dispose(); + + private long mNativeHandle; +} diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcResourceIdentifier.java b/android/android_api/base/src/main/java/org/iotivity/base/OcResourceIdentifier.java new file mode 100755 index 0000000..a1de037 --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/base/OcResourceIdentifier.java @@ -0,0 +1,51 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base; + +public class OcResourceIdentifier { + private OcResourceIdentifier(long nativeHandle) { + this.mNativeHandle = nativeHandle; + } + + @Override + protected void finalize() throws Throwable { + super.finalize(); + + dispose(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof OcResourceIdentifier)) { + return false; + } + OcResourceIdentifier other = (OcResourceIdentifier) obj; + return equalsN(other); + } + + private native boolean equalsN(OcResourceIdentifier other); + + private native void dispose(); + + private long mNativeHandle; +} diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcResourceRequest.java b/android/android_api/base/src/main/java/org/iotivity/base/OcResourceRequest.java new file mode 100755 index 0000000..5a24b02 --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/base/OcResourceRequest.java @@ -0,0 +1,135 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base; + +import java.util.EnumSet; +import java.util.List; +import java.util.Map; + +/** + * OcResourceRequest provides APIs to extract details from a request + */ +public class OcResourceRequest { + + private OcResourceRequest(long nativeHandle) { + this.mNativeHandle = nativeHandle; + } + + /** + * Retrieves the type of request for the entity handler function to operate + * + * @return request type. This could be 'GET'/'PUT'/'POST'/'DELETE' + */ + public RequestType getRequestType() { + return RequestType.get(getRequestTypeNative()); + } + + private native String getRequestTypeNative(); + + /** + * Retrieves the query parameters from the request + * + * @return parameters in the request + */ + public native Map getQueryParameters(); + + /** + * Retrieves the request handler flag set. This can be INIT flag and/or REQUEST flag and/or + * OBSERVE flag. + * NOTE: + * INIT indicates that the vendor's entity handler should go and perform + * initialization operations + * REQUEST indicates that it is a request of certain type (GET/PUT/POST/DELETE) and entity + * handler needs to perform corresponding operations + * OBSERVE indicates that the request is of type Observe and entity handler needs to perform + * corresponding operations + * + * @return Set of handler flags + */ + public EnumSet getRequestHandlerFlagSet() { + return RequestHandlerFlag.convertToEnumSet(getRequestHandlerFlagNative()); + } + + private native int getRequestHandlerFlagNative(); + + /** + * Provides the entire resource attribute representation + * + * @return OcRepresentation object containing the name value pairs representing + * the resource's attributes + */ + public native OcRepresentation getResourceRepresentation(); + + /** + * Object provides observation information + * + * @return observation information + */ + public native ObservationInfo getObservationInfo(); + + /** + * Specifies the resource uri + * + * @param resourceUri resource uri + */ + public native void setResourceUri(String resourceUri); + + /** + * Gets the resource URI + * + * @return resource URI + */ + public native String getResourceUri(); + + /** + * This API retrieves a list of headerOptions which was sent from a client + * + * @return List of header options + */ + public native List getHeaderOptions(); + + /** + * This API retrieves the request handle + * + * @return request handle + */ + public native OcRequestHandle getRequestHandle(); + + /** + * This API retrieves the resource handle + * + * @return resource handle + */ + public native OcResourceHandle getResourceHandle(); + + @Override + protected void finalize() throws Throwable { + super.finalize(); + + dispose(); + } + + private native void dispose(); + + private long mNativeHandle; +} diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcResourceResponse.java b/android/android_api/base/src/main/java/org/iotivity/base/OcResourceResponse.java new file mode 100755 index 0000000..263de42 --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/base/OcResourceResponse.java @@ -0,0 +1,139 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base; + +import java.util.List; + +/** + * OcResourceResponse provides APIs to set the response details + */ +public class OcResourceResponse { + + static { + System.loadLibrary("oc"); + System.loadLibrary("ocstack-jni"); + } + + public OcResourceResponse() { + super(); + + create(); + } + + private OcResourceResponse(long nativeHandle) { + this.mNativeHandle = nativeHandle; + } + + /** + * This API sets the error code for this response + * + * @param eCode error code to set + */ + public native void setErrorCode(int eCode); + + /** + * Gets new resource uri + * + * @return new resource uri + */ + public native String getNewResourceUri(); + + /** + * Sets new resource uri + * + * @param newResourceUri new resource uri + */ + public native void setNewResourceUri(String newResourceUri); + + /** + * This API allows to set headerOptions in the response + * + * @param headerOptionList List of HeaderOption entries + */ + public void setHeaderOptions(List headerOptionList) { + this.setHeaderOptions(headerOptionList.toArray( + new OcHeaderOption[headerOptionList.size()]) + ); + } + + private native void setHeaderOptions(OcHeaderOption[] headerOptionList); + + /** + * This API allows to set request handle + * + * @param ocRequestHandle request handle + */ + public native void setRequestHandle(OcRequestHandle ocRequestHandle); + + /** + * This API allows to set the resource handle + * + * @param ocResourceHandle resource handle + */ + public native void setResourceHandle(OcResourceHandle ocResourceHandle); + + /** + * This API allows to set the EntityHandler response result + * + * @param responseResult OcEntityHandlerResult type to set the result value + */ + public void setResponseResult(EntityHandlerResult responseResult) { + this.setResponseResult(responseResult.getValue()); + } + + private native void setResponseResult(int responseResult); + + /** + * API to set the entire resource attribute representation + * + * @param ocRepresentation the name value pairs representing the resource's attributes + * @param interfaceStr specifies the interface + */ + public native void setResourceRepresentation(OcRepresentation ocRepresentation, + String interfaceStr); + + /** + * API to set the entire resource attribute representation + * + * @param representation object containing the name value pairs representing the + * resource's attributes + */ + public void setResourceRepresentation(OcRepresentation representation) { + this.setResourceRepresentation1(representation); + } + + private native void setResourceRepresentation1(OcRepresentation representation); + + @Override + protected void finalize() throws Throwable { + super.finalize(); + + dispose(); + } + + private native void create(); + + private native void dispose(); + + private long mNativeHandle; +} diff --git a/android/android_api/base/src/main/java/org/iotivity/base/PlatformConfig.java b/android/android_api/base/src/main/java/org/iotivity/base/PlatformConfig.java new file mode 100755 index 0000000..7fd9ac0 --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/base/PlatformConfig.java @@ -0,0 +1,88 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base; + +import android.content.Context; + +/** + * Data structure to provide the configuration. + */ +public class PlatformConfig { + + private Context mContext; + private ServiceType mServiceType; + private ModeType mModeType; + private String mIpAddress; + private int mPort; + private QualityOfService mQualityOfService; + + /** + * @param context app context + * @param serviceType indicate IN_PROC or OUT_OF_PROC + * @param modeType indicate whether we want to do server, client or both + * @param ipAddress ip address of server + * if you specify 0.0.0.0 : it listens on any interface + * @param port port of server + * if you specifiy 0 : next available random port is used + * if you specify 5683 : client discovery can work even if they don't + * specify port + * @param qualityOfService quality of service + */ + public PlatformConfig(Context context, + ServiceType serviceType, + ModeType modeType, + String ipAddress, + int port, + QualityOfService qualityOfService) { + this.mContext = context; + this.mServiceType = serviceType; + this.mModeType = modeType; + this.mIpAddress = ipAddress; + this.mPort = port; + this.mQualityOfService = qualityOfService; + } + + public Context getContext() { + return mContext; + } + + public ServiceType getServiceType() { + return mServiceType; + } + + public ModeType getModeType() { + return mModeType; + } + + public String getIpAddress() { + return mIpAddress; + } + + public int getPort() { + return mPort; + } + + public QualityOfService getQualityOfService() { + return mQualityOfService; + } +} diff --git a/android/android_api/base/src/main/java/org/iotivity/base/QualityOfService.java b/android/android_api/base/src/main/java/org/iotivity/base/QualityOfService.java new file mode 100755 index 0000000..4c85981 --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/base/QualityOfService.java @@ -0,0 +1,42 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base; + +/** + */ +public enum QualityOfService { + LOW(0), + MEDIUM(1), + HIGH(2), + NA(3); + + private int value; + + private QualityOfService(int value) { + this.value = value; + } + + public int getValue() { + return this.value; + } +} diff --git a/android/android_api/base/src/main/java/org/iotivity/base/RequestHandlerFlag.java b/android/android_api/base/src/main/java/org/iotivity/base/RequestHandlerFlag.java new file mode 100755 index 0000000..5e1f5ee --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/base/RequestHandlerFlag.java @@ -0,0 +1,61 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base; + +import java.util.EnumSet; + +public enum RequestHandlerFlag { + INIT(1 << 0), + REQUEST(1 << 1), + OBSERVER(1 << 2),; + + private int value; + + private RequestHandlerFlag(int value) { + this.value = value; + } + + public int getValue() { + return this.value; + } + + public static EnumSet convertToEnumSet(int value) { + EnumSet flagSet = null; + + for (RequestHandlerFlag v : values()) { + if (0 != (value & v.getValue())) { + if (flagSet == null) { + flagSet = EnumSet.of(v); + } else { + flagSet.add(v); + } + } + } + + if (null == flagSet || flagSet.isEmpty()) { + throw new IllegalArgumentException("Unexpected RequestHandlerFlag value"); + } + + return flagSet; + } +} diff --git a/android/android_api/base/src/main/java/org/iotivity/base/RequestType.java b/android/android_api/base/src/main/java/org/iotivity/base/RequestType.java new file mode 100755 index 0000000..894429d --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/base/RequestType.java @@ -0,0 +1,48 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base; + +public enum RequestType { + GET("GET"), + PUT("PUT"), + POST("POST"), + DELETE("DELETE"),; + private String value; + + private RequestType(String value) { + this.value = value; + } + + public String getValue() { + return this.value; + } + + public static RequestType get(String value) { + for (RequestType v : values()) { + if (v.getValue().equals(value)) { + return v; + } + } + throw new IllegalArgumentException("Unexpected RequestType value"); + } +} diff --git a/android/android_api/base/src/main/java/org/iotivity/base/ResourceProperty.java b/android/android_api/base/src/main/java/org/iotivity/base/ResourceProperty.java new file mode 100755 index 0000000..64345db --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/base/ResourceProperty.java @@ -0,0 +1,41 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base; + +public enum ResourceProperty { + ACTIVE(1 << 0), + DISCOVERABLE(1 << 1), + OBSERVABLE(1 << 2), + SLOW(1 << 3), + SECURE(1 << 4); + + private int value; + + private ResourceProperty(int value) { + this.value = value; + } + + public int getValue() { + return this.value; + } +} diff --git a/android/android_api/base/src/main/java/org/iotivity/base/ServiceType.java b/android/android_api/base/src/main/java/org/iotivity/base/ServiceType.java new file mode 100755 index 0000000..6dc65a7 --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/base/ServiceType.java @@ -0,0 +1,38 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base; + +public enum ServiceType { + IN_PROC(0), + OUT_OF_PROC(1),; + + private int value; + + private ServiceType(int value) { + this.value = value; + } + + public int getValue() { + return this.value; + } +} diff --git a/android/android_api/base/src/main/java/org/iotivity/ca/CaInterface.java b/android/android_api/base/src/main/java/org/iotivity/ca/CaInterface.java new file mode 100755 index 0000000..81c457c --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/ca/CaInterface.java @@ -0,0 +1,34 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.ca; + +import android.content.Context; + +public class CaInterface { + static { + System.loadLibrary("connectivity_abstraction"); + System.loadLibrary("ca-interface"); + } + + public static native void initialize(Context context); +} \ No newline at end of file diff --git a/android/android_api/base/src/main/java/org/iotivity/ca/CaIpInterface.java b/android/android_api/base/src/main/java/org/iotivity/ca/CaIpInterface.java new file mode 100755 index 0000000..43d0ace --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/ca/CaIpInterface.java @@ -0,0 +1,70 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.ca; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; +import android.net.wifi.WifiManager; + +public class CaIpInterface { + private static Context mContext; + + private CaIpInterface(Context context) { + mContext = context; + registerIpStateReceiver(); + } + + private void registerIpStateReceiver() { + IntentFilter intentFilter = new IntentFilter(); + intentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION); + intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); + + mContext.registerReceiver(mReceiver, intentFilter); + } + + private static BroadcastReceiver mReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + if (intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, + WifiManager.WIFI_STATE_UNKNOWN) == WifiManager.WIFI_STATE_DISABLED) { + stateDisabled(); + } else if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) { + ConnectivityManager manager = (ConnectivityManager) + mContext.getSystemService(Context.CONNECTIVITY_SERVICE); + NetworkInfo nwInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); + + if(nwInfo.isConnected()) { + stateEnabled(); + } + } + } + }; + + private native static void stateEnabled(); + + private native static void stateDisabled(); +} \ No newline at end of file diff --git a/android/android_api/base/src/main/java/org/iotivity/ca/CaWiFiInterface.java b/android/android_api/base/src/main/java/org/iotivity/ca/CaWiFiInterface.java new file mode 100755 index 0000000..15cac58 --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/ca/CaWiFiInterface.java @@ -0,0 +1,72 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.ca; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; +import android.net.wifi.WifiManager; + +public class CaWiFiInterface { + + private static Context mContext; + + private CaWiFiInterface(Context context) { + mContext = context; + registerWiFiStateReceiver(); + } + + private void registerWiFiStateReceiver() { + IntentFilter intentFilter = new IntentFilter(); + intentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION); + intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); + + mContext.registerReceiver(mReceiver, intentFilter); + } + + private static BroadcastReceiver mReceiver = new BroadcastReceiver() { + + @Override + public void onReceive(Context context, Intent intent) { + if (intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, + WifiManager.WIFI_STATE_UNKNOWN) == WifiManager.WIFI_STATE_DISABLED) { + CAWiFiStateDisabled(); + } else if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) { + ConnectivityManager manager = (ConnectivityManager) + mContext.getSystemService(Context.CONNECTIVITY_SERVICE); + NetworkInfo nwInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); + + if (nwInfo.isConnected()) { + CAWiFiStateEnabled(); + } + } + } + }; + + private native static void CAWiFiStateEnabled(); + + private native static void CAWiFiStateDisabled(); +} \ No newline at end of file diff --git a/android/android_api/build.gradle b/android/android_api/build.gradle new file mode 100755 index 0000000..478166f --- /dev/null +++ b/android/android_api/build.gradle @@ -0,0 +1,41 @@ +/* + * //****************************************************************** + * // + * // Copyright 2014 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:1.0.0' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + jcenter() + } +} diff --git a/android/android_api/gradle.properties b/android/android_api/gradle.properties new file mode 100755 index 0000000..42a55d5 --- /dev/null +++ b/android/android_api/gradle.properties @@ -0,0 +1,40 @@ +# +# //****************************************************************** +# // +# // Copyright 2015 Intel Corporation. +# // +# //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +# // +# // 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. +# // +# //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +# + +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +# Default value: -Xmx10248m -XX:MaxPermSize=256m +# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true diff --git a/android/android_api/gradle/wrapper/gradle-wrapper.jar b/android/android_api/gradle/wrapper/gradle-wrapper.jar new file mode 100755 index 0000000000000000000000000000000000000000..8c0fb64a8698b08ecc4158d828ca593c4928e9dd GIT binary patch literal 49896 zcmagFb986H(k`5d^NVfUwr$(C?M#x1ZQHiZiEVpg+jrjgoQrerx!>1o_ul)D>ebz~ zs=Mmxr&>W81QY-S1PKWQ%N-;H^tS;2*XwVA`dej1RRn1z<;3VgfE4~kaG`A%QSPsR z#ovnZe+tS9%1MfeDyz`RirvdjPRK~p(#^q2(^5@O&NM19EHdvN-A&StN>0g6QA^VN z0Gx%Gq#PD$QMRFzmK+utjS^Y1F0e8&u&^=w5K<;4Rz|i3A=o|IKLY+g`iK6vfr9?+ z-`>gmU&i?FGSL5&F?TXFu`&Js6h;15QFkXp2M1H9|Eq~bpov-GU(uz%mH0n55wUl- zv#~ccAz`F5wlQ>e_KlJS3@{)B?^v*EQM=IxLa&76^y51a((wq|2-`qON>+4dLc{Oo z51}}o^Zen(oAjxDK7b++9_Yg`67p$bPo3~BCpGM7uAWmvIhWc5Gi+gQZ|Pwa-Gll@<1xmcPy z|NZmu6m)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E@N`2ropeHP)E}o?qJkyVEI;K$!)bWY zt9>4WmDVJh7U~m$|K`T#hF!v|znj^=M;69uXrFys#51XT;DbMr4H)>7UQ1e2(cuQf z4kr~Tt1tpBB2GaJ(|j~lHgW40EgMMVqR6eJoJig1SBg|2=$~4I3P0eP$q%_`sS&4~ z26=&a&tLjQbch1`cVXa-2fTl1y8}->|Nqu?uVrNTov!=VKh)g89wUPTgAzkSKZ57_ zr=B^mcldE3K04t4{;RaG53&9yovq;@aR#VHx+R1^^*kr-vEEd!uea68Z<{R%_DD6fn&T4 zu;fDj07L-(_fLSJGdkeh&c&7A(ZLj`7iwnkAcqUexU;WjUkqeg1m1-IUZTIZA(4dtr2Gr`e{BIejlCgS<33MB=1!8?a74!F%=Uo7N`F@k} ze+1C_eU4Y_$mvdjci zwEtCIphA2PBzBhng5=M#e4r%)RW5rVD|_`PvY$7BK`}w~d>%0O9sY#*LUAq=^OjMF^PY5m<7!=s5jyRfosCQAo#hL`h5vN-M}6Q z0Li}){5?wi8)GVHNkF|U9*8V5ej)nhb^TLw1KqiPK(@{P1^L&P=`ZNt?_+}&0(8Uh zfyyZFPgMV7ECt;Jdw|`|{}b$w4&x77VxR>8wUs|GQ5FBf1UlvasqX$qfk5rI4>Wfr zztH>y`=daAef**C12yJ7;LDf&3;h3X+5@dGPy@vS(RSs3CWimbTp=g \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- -APP_HOME="`pwd -P`" -cd "$SAVED" >&- - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" - -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# For Cygwin, ensure paths are in UNIX format before anything is touched. +if $cygwin ; then + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/android/SimpleClient/gradlew.bat b/android/android_api/gradlew.bat old mode 100644 new mode 100755 similarity index 100% rename from android/SimpleClient/gradlew.bat rename to android/android_api/gradlew.bat diff --git a/android/android_api/settings.gradle b/android/android_api/settings.gradle new file mode 100755 index 0000000..d1bcc8a --- /dev/null +++ b/android/android_api/settings.gradle @@ -0,0 +1,23 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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 ':base' diff --git a/android/Base/build.gradle b/android/examples/build.gradle old mode 100644 new mode 100755 similarity index 83% rename from android/Base/build.gradle rename to android/examples/build.gradle index 9b8abe4..50e899c --- a/android/Base/build.gradle +++ b/android/examples/build.gradle @@ -1,19 +1,19 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - -buildscript { - repositories { - jcenter() - } - dependencies { - classpath 'com.android.tools.build:gradle:0.12.2' - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -allprojects { - repositories { - jcenter() - } -} +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:1.0.0' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + jcenter() + } +} diff --git a/android/examples/examples.iml b/android/examples/examples.iml new file mode 100755 index 0000000..8d49284 --- /dev/null +++ b/android/examples/examples.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + diff --git a/android/examples/fridgeclient/.gitignore b/android/examples/fridgeclient/.gitignore new file mode 100755 index 0000000..3543521 --- /dev/null +++ b/android/examples/fridgeclient/.gitignore @@ -0,0 +1 @@ +/build diff --git a/android/examples/fridgeclient/build.gradle b/android/examples/fridgeclient/build.gradle new file mode 100755 index 0000000..975453f --- /dev/null +++ b/android/examples/fridgeclient/build.gradle @@ -0,0 +1,26 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 21 + buildToolsVersion "21.1.2" + + defaultConfig { + applicationId "org.iotivity.base.examples.fridgeclient" + minSdkVersion 19 + targetSdkVersion 21 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + compile 'com.android.support:appcompat-v7:21.0.3' + compile project(':message') +} diff --git a/android/examples/fridgeclient/fridgeclient.iml b/android/examples/fridgeclient/fridgeclient.iml new file mode 100755 index 0000000..ea17290 --- /dev/null +++ b/android/examples/fridgeclient/fridgeclient.iml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/examples/fridgeclient/src/main/AndroidManifest.xml b/android/examples/fridgeclient/src/main/AndroidManifest.xml new file mode 100755 index 0000000..d560e70 --- /dev/null +++ b/android/examples/fridgeclient/src/main/AndroidManifest.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + diff --git a/android/examples/fridgeclient/src/main/java/org/iotivity/base/examples/fridgeclient/FridgeClient.java b/android/examples/fridgeclient/src/main/java/org/iotivity/base/examples/fridgeclient/FridgeClient.java new file mode 100755 index 0000000..a004c87 --- /dev/null +++ b/android/examples/fridgeclient/src/main/java/org/iotivity/base/examples/fridgeclient/FridgeClient.java @@ -0,0 +1,362 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base.examples.fridgeclient; + +import android.app.Activity; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.os.Bundle; +import android.os.Message; +import android.support.v4.content.LocalBroadcastManager; +import android.text.method.ScrollingMovementMethod; +import android.util.Log; +import android.view.Menu; +import android.view.MenuItem; +import android.widget.LinearLayout; +import android.widget.TextView; + +import org.iotivity.base.ErrorCode; +import org.iotivity.base.ModeType; +import org.iotivity.base.OcConnectivityType; +import org.iotivity.base.OcException; +import org.iotivity.base.OcHeaderOption; +import org.iotivity.base.OcPlatform; +import org.iotivity.base.OcRepresentation; +import org.iotivity.base.OcResource; +import org.iotivity.base.PlatformConfig; +import org.iotivity.base.QualityOfService; +import org.iotivity.base.ServiceType; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; + +import base.iotivity.org.examples.message.IMessageLogger; + +/** + * FridgeClient + *

+ * FridgeClient is a sample client app which should be started after the fridgeServer is started. + * It creates DeviceResource, DoorResource, LightResource and performs a get operation on them. + * This implements IMessageLogger to display messages on the screen + */ +public class FridgeClient extends Activity implements + OcPlatform.OnResourceFoundListener, IMessageLogger { + private static String TAG = "FridgeClient: "; + + private MessageReceiver mMessageReceiver = new MessageReceiver(); + private TextView mEventsTextView; + private String mDeviceName; + private int mDeviceCode; + private List ifaces; + private final List resourceList = new LinkedList(); + + /** + * configure OIC platform and call findResource + */ + private void initOICStack() { + PlatformConfig cfg = new PlatformConfig( + this, + ServiceType.IN_PROC, + ModeType.CLIENT, + "0.0.0.0", // bind to all available interfaces + 0, + QualityOfService.LOW); + + OcPlatform.Configure(cfg); + try { + OcPlatform.findResource("", OcPlatform.WELL_KNOWN_QUERY + "?rt=" + "intel.fridge", + OcConnectivityType.WIFI, this); + } catch (OcException e) { + logMessage(TAG + " init Error. " + e.getMessage()); + Log.e(TAG, e.getMessage()); + } + } + + /** + * prints out the appropriate messages depending on the device code + * + * @param representation representation of the OcResource + * @param value clientDeviceCode + */ + private void getResponse(OcRepresentation representation, int value) { + switch (value) { + case 0: + // Get on device + try { + logMessage(TAG + "Name of device: " + + representation.getValue(StringConstants.DEVICE_NAME)); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + break; + case 1: + // get on fridge light + try { + boolean lightOn = representation.getValue(StringConstants.ON); + logMessage(TAG + "The fridge light is " + + (lightOn ? "" : "not " + "on")); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + break; + case 2: + case 3: + // get on fridge door(s) + try { + boolean doorOpen = representation.getValue(StringConstants.OPEN); + logMessage(TAG + "Door is " + (doorOpen ? + "open" : "not open") + " and is on the " + + representation.getValue(StringConstants.SIDE) + " side"); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + break; + case 4: + // get on fridge random door + try { + logMessage("Name of fridge: " + + representation.getValue(StringConstants.DEVICE_NAME)); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + break; + default: + logMessage("Unexpected State"); + break; + } + } + + /** + * this method is used to wait for 1 second between calls to different resources. + * It is added for better readability + */ + private void doWait() { + try { + Thread.sleep(StringConstants.WAIT_TIME); + } catch (InterruptedException e) { + logMessage(TAG + "doWait exception: " + e.getMessage()); + Log.e(TAG, e.getMessage()); + } + } + + @Override + /** + * callback when a resource is found. This method calls getResponse with the correct code + */ + synchronized public void onResourceFound(OcResource ocResource) { + // eventHandler for onGetListener + resourceList.add(ocResource); + OcResource.OnGetListener onGetListener = new OcResource.OnGetListener() { + @Override + public void onGetCompleted(List headerOptionList, OcRepresentation rep) { + logMessage(TAG + " Got a response from " + getClientDeviceName()); + getResponse(rep, getClientDeviceCode()); + } + + @Override + public void onGetFailed(Throwable throwable) { + if (throwable instanceof OcException) { + OcException ocEx = (OcException) throwable; + ErrorCode errCode = ocEx.getErrorCode(); + //do something based on errorCode + } + Log.e(TAG, throwable.toString()); + } + }; + + if (ocResource.getUri().equals(StringConstants.RESOURCE_URI)) { + logMessage(TAG + "Discovered a device with \nHost: " + ocResource.getHost() + + ", Uri: " + ocResource.getUri()); + } + List lightTypes = new LinkedList<>(); + lightTypes.add("intel.fridge.light"); + try { + OcResource light = OcPlatform.constructResourceObject(ocResource.getHost(), + StringConstants.LIGHT, OcConnectivityType.WIFI, false, lightTypes, ifaces); + + List doorTypes = new LinkedList<>(); + doorTypes.add("intel.fridge.door"); + OcResource leftDoor = OcPlatform.constructResourceObject(ocResource.getHost(), + StringConstants.LEFT_DOOR, OcConnectivityType.WIFI, false, doorTypes, ifaces); + + OcResource rightDoor = OcPlatform.constructResourceObject(ocResource.getHost(), + StringConstants.RIGHT_DOOR, OcConnectivityType.WIFI, false, doorTypes, ifaces); + + OcResource randomDoor = OcPlatform.constructResourceObject(ocResource.getHost(), + StringConstants.RANDOM_DOOR, OcConnectivityType.WIFI, false, doorTypes, ifaces); + + List headerOptions = new LinkedList<>(); + OcHeaderOption apiVersion = new OcHeaderOption(StringConstants.API_VERSION_KEY, + StringConstants.API_VERSION); + OcHeaderOption clientToken = new OcHeaderOption(StringConstants.CLIENT_VERSION_KEY, + StringConstants.CLIENT_TOKEN); + headerOptions.add(apiVersion); + headerOptions.add(clientToken); + ocResource.setHeaderOptions(headerOptions); + /** + * wait for 1 second before calling get on different resources. + * It is done for better readability. + * doWait() is called before each call to get + */ + doWait(); + + setupClientOptions("Device", 0); + ocResource.get(new HashMap(), onGetListener); + doWait(); + + setupClientOptions("Fridge Light", 1); + light.get(new HashMap(), onGetListener); + doWait(); + + setupClientOptions("Left Door", 2); + leftDoor.get(new HashMap(), onGetListener); + doWait(); + + setupClientOptions("Right Door", 3); + rightDoor.get(new HashMap(), onGetListener); + doWait(); + + setupClientOptions("Random Door", 4); + randomDoor.get(new HashMap(), onGetListener); + doWait(); + + resourceList.add(leftDoor); + leftDoor.deleteResource(new OcResource.OnDeleteListener() { + @Override + public void onDeleteCompleted(List ocHeaderOptions) { + logMessage(TAG + "Delete resource successful"); + } + + @Override + public void onDeleteFailed(Throwable throwable) { + if (throwable instanceof OcException) { + OcException ocEx = (OcException) throwable; + ErrorCode errCode = ocEx.getErrorCode(); + //do something based on errorCode + } + Log.e(TAG, throwable.toString()); + } + }); + } catch (OcException e) { + logMessage(TAG + "onResourceFound Error. " + e.getMessage()); + Log.e(TAG, e.getMessage()); + } + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_fridge_client); + registerReceiver(mMessageReceiver, new IntentFilter(StringConstants.INTENT)); + + mEventsTextView = new TextView(this); + mEventsTextView.setMovementMethod(new ScrollingMovementMethod()); + LinearLayout layout = (LinearLayout) findViewById(R.id.linearLayout); + layout.addView(mEventsTextView, new LinearLayout.LayoutParams + (LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f)); + ifaces = new LinkedList<>(); + ifaces.add(StringConstants.RESOURCE_INTERFACE); + mDeviceCode = -1; + mDeviceName = ""; + + initOICStack(); + } + + public class MessageReceiver extends BroadcastReceiver { + @Override + public void onReceive(Context context, Intent intent) { + final String message = intent.getStringExtra(StringConstants.MESSAGE); + logMessage(message); + } + } + + @Override + public void logMessage(final String text) { + if (StringConstants.ENABLE_PRINTING) { + runOnUiThread(new Runnable() { + public void run() { + final Message msg = new Message(); + msg.obj = text; + mEventsTextView.append("\n"); + mEventsTextView.append(text); + } + }); + Log.i(TAG, text); + } + } + + + private void setupClientOptions(String name, int value) { + mDeviceName = name; + mDeviceCode = value; + } + + private String getClientDeviceName() { + return mDeviceName; + } + + private int getClientDeviceCode() { + return mDeviceCode; + } + + + //method to print the headerOptions received from the server + void printHeaderOptions(List headerOptions) { + for (OcHeaderOption headerOption : headerOptions) { + if (StringConstants.API_VERSION_KEY == headerOption.getOptionId()) { + logMessage(TAG + "Server API version in GET response: " + + headerOption.getOptionData()); + } + } + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.menu_fridge_client, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + int id = item.getItemId(); + if (id == R.id.action_settings) { + return true; + } + return super.onOptionsItemSelected(item); + } + + @Override + public void onDestroy() { + super.onDestroy(); + onStop(); + } + + @Override + protected void onStop() { + LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver); + super.onStop(); + } +} diff --git a/android/examples/fridgeclient/src/main/java/org/iotivity/base/examples/fridgeclient/StringConstants.java b/android/examples/fridgeclient/src/main/java/org/iotivity/base/examples/fridgeclient/StringConstants.java new file mode 100755 index 0000000..da88e4d --- /dev/null +++ b/android/examples/fridgeclient/src/main/java/org/iotivity/base/examples/fridgeclient/StringConstants.java @@ -0,0 +1,33 @@ +package org.iotivity.base.examples.fridgeclient; + +import org.iotivity.base.OcPlatform; + +/** + * StringConstant contains the fridgeclient specific constant values. To add another supported + * Resource or Interface type to this app, begin by adding the new strings here, and then + * find the places throughout the app where Resource-specific case switches occur, and add + * the newly-supported type there. + */ +public interface StringConstants { + public static final String RESOURCE_URI = "/device"; + public static final String DEVICE_NAME = "device_name"; + public static final String LIGHT = "/light"; + public static final String LEFT_DOOR = "/door/left"; + public static final String RIGHT_DOOR = "/door/right"; + public static final String RANDOM_DOOR = "/door/random"; + public static final String MESSAGE = "message"; + public static final String API_VERSION = "v.1.2"; + public static final String CLIENT_TOKEN = "AaBbYyZz"; + public static final String ON = "on"; + public static final String OPEN = "open"; + public static final String SIDE = "side"; + public static final String INTENT = "org.iotivity.base.examples.fridgeclient"; + public static final String RESOURCE_INTERFACE = OcPlatform.DEFAULT_INTERFACE; + + public static final int WAIT_TIME = 1000; + public static final int API_VERSION_KEY = 2048; + public static final int CLIENT_VERSION_KEY = 3000; + + public static final boolean ENABLE_PRINTING = true; // change to false to disable printing + // of messages on the console and the screen +} diff --git a/android/SimpleClient/app/src/main/res/drawable-hdpi/ic_launcher.png b/android/examples/fridgeclient/src/main/res/drawable-hdpi/ic_launcher.png old mode 100644 new mode 100755 similarity index 100% rename from android/SimpleClient/app/src/main/res/drawable-hdpi/ic_launcher.png rename to android/examples/fridgeclient/src/main/res/drawable-hdpi/ic_launcher.png diff --git a/android/SimpleClient/app/src/main/res/drawable-mdpi/ic_launcher.png b/android/examples/fridgeclient/src/main/res/drawable-mdpi/ic_launcher.png old mode 100644 new mode 100755 similarity index 100% rename from android/SimpleClient/app/src/main/res/drawable-mdpi/ic_launcher.png rename to android/examples/fridgeclient/src/main/res/drawable-mdpi/ic_launcher.png diff --git a/android/SimpleClient/app/src/main/res/drawable-xhdpi/ic_launcher.png b/android/examples/fridgeclient/src/main/res/drawable-xhdpi/ic_launcher.png old mode 100644 new mode 100755 similarity index 100% rename from android/SimpleClient/app/src/main/res/drawable-xhdpi/ic_launcher.png rename to android/examples/fridgeclient/src/main/res/drawable-xhdpi/ic_launcher.png diff --git a/android/SimpleClient/app/src/main/res/drawable-xxhdpi/ic_launcher.png b/android/examples/fridgeclient/src/main/res/drawable-xxhdpi/ic_launcher.png old mode 100644 new mode 100755 similarity index 100% rename from android/SimpleClient/app/src/main/res/drawable-xxhdpi/ic_launcher.png rename to android/examples/fridgeclient/src/main/res/drawable-xxhdpi/ic_launcher.png diff --git a/android/examples/fridgeclient/src/main/res/layout/activity_fridge_client.xml b/android/examples/fridgeclient/src/main/res/layout/activity_fridge_client.xml new file mode 100755 index 0000000..d813c8a --- /dev/null +++ b/android/examples/fridgeclient/src/main/res/layout/activity_fridge_client.xml @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/android/examples/fridgeclient/src/main/res/menu/menu_fridge_client.xml b/android/examples/fridgeclient/src/main/res/menu/menu_fridge_client.xml new file mode 100755 index 0000000..f812805 --- /dev/null +++ b/android/examples/fridgeclient/src/main/res/menu/menu_fridge_client.xml @@ -0,0 +1,6 @@ +

+ + diff --git a/android/SimpleClient/app/src/main/res/values-w820dp/dimens.xml b/android/examples/fridgeclient/src/main/res/values-w820dp/dimens.xml old mode 100644 new mode 100755 similarity index 98% rename from android/SimpleClient/app/src/main/res/values-w820dp/dimens.xml rename to android/examples/fridgeclient/src/main/res/values-w820dp/dimens.xml index 63fc816..62df187 --- a/android/SimpleClient/app/src/main/res/values-w820dp/dimens.xml +++ b/android/examples/fridgeclient/src/main/res/values-w820dp/dimens.xml @@ -1,6 +1,6 @@ - - - 64dp - + + + 64dp + diff --git a/android/SimpleClient/app/src/main/res/values/dimens.xml b/android/examples/fridgeclient/src/main/res/values/dimens.xml old mode 100644 new mode 100755 similarity index 97% rename from android/SimpleClient/app/src/main/res/values/dimens.xml rename to android/examples/fridgeclient/src/main/res/values/dimens.xml index 47c8224..295b5a9 --- a/android/SimpleClient/app/src/main/res/values/dimens.xml +++ b/android/examples/fridgeclient/src/main/res/values/dimens.xml @@ -1,5 +1,5 @@ - - - 16dp - 16dp - + + + 16dp + 16dp + diff --git a/android/SimpleClient/app/src/main/res/values/strings.xml b/android/examples/fridgeclient/src/main/res/values/strings.xml old mode 100644 new mode 100755 similarity index 74% rename from android/SimpleClient/app/src/main/res/values/strings.xml rename to android/examples/fridgeclient/src/main/res/values/strings.xml index 532e40d..152e2c9 --- a/android/SimpleClient/app/src/main/res/values/strings.xml +++ b/android/examples/fridgeclient/src/main/res/values/strings.xml @@ -1,8 +1,8 @@ - - - - SimpleClient - Hello world! - Settings - - + + + + FridgeClient + Hello world! + Settings + + diff --git a/android/Base/app/src/main/res/values/styles.xml b/android/examples/fridgeclient/src/main/res/values/styles.xml old mode 100644 new mode 100755 similarity index 59% rename from android/Base/app/src/main/res/values/styles.xml rename to android/examples/fridgeclient/src/main/res/values/styles.xml index ff6c9d2..084b42b --- a/android/Base/app/src/main/res/values/styles.xml +++ b/android/examples/fridgeclient/src/main/res/values/styles.xml @@ -1,8 +1,8 @@ - - - - - - + + + + + + diff --git a/android/examples/fridgeserver/.gitignore b/android/examples/fridgeserver/.gitignore new file mode 100755 index 0000000..3543521 --- /dev/null +++ b/android/examples/fridgeserver/.gitignore @@ -0,0 +1 @@ +/build diff --git a/android/examples/fridgeserver/build.gradle b/android/examples/fridgeserver/build.gradle new file mode 100755 index 0000000..b7327b6 --- /dev/null +++ b/android/examples/fridgeserver/build.gradle @@ -0,0 +1,26 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 21 + buildToolsVersion "21.1.2" + + defaultConfig { + applicationId "org.iotivity.base.examples.fridgeserver" + minSdkVersion 19 + targetSdkVersion 21 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + compile 'com.android.support:appcompat-v7:21.0.3' + compile project(':message') +} diff --git a/android/examples/fridgeserver/fridgeserver.iml b/android/examples/fridgeserver/fridgeserver.iml new file mode 100755 index 0000000..65d2947 --- /dev/null +++ b/android/examples/fridgeserver/fridgeserver.iml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/examples/fridgeserver/src/main/AndroidManifest.xml b/android/examples/fridgeserver/src/main/AndroidManifest.xml new file mode 100755 index 0000000..cbcffd9 --- /dev/null +++ b/android/examples/fridgeserver/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + diff --git a/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DeviceResource.java b/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DeviceResource.java new file mode 100755 index 0000000..fc33258 --- /dev/null +++ b/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DeviceResource.java @@ -0,0 +1,189 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base.examples.fridgeserver; + +import android.content.Context; +import android.content.Intent; +import android.util.Log; + +import org.iotivity.base.EntityHandlerResult; +import org.iotivity.base.OcException; +import org.iotivity.base.OcHeaderOption; +import org.iotivity.base.OcPlatform; +import org.iotivity.base.OcResourceRequest; +import org.iotivity.base.OcResourceResponse; +import org.iotivity.base.RequestHandlerFlag; +import org.iotivity.base.ResourceProperty; + +import java.util.EnumSet; +import java.util.LinkedList; +import java.util.List; + +import base.iotivity.org.examples.message.IMessageLogger; + +/** + * DeviceResource + *

+ * Creates a device resource and performs action based on client requests + */ +public class DeviceResource extends Resource implements IMessageLogger { + private Context mContext; + + private static String TAG = "DeviceResource: "; + + /** + * constructor + * + * @param context to enable sending of broadcast messages to be displayed on the user screen + */ + DeviceResource(Context context) { + mContext = context; + + // eventHandler for register deviceResource + OcPlatform.EntityHandler eh = new OcPlatform.EntityHandler() { + @Override + public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) { + // this is where the main logic of DeviceResource is handled + return entityHandler(ocResourceRequest); + } + }; + + try { + logMessage(TAG + "RegisterDeviceResource " + StringConstants.DEVICE_URI + " : " + + StringConstants.RESOURCE_TYPENAME + " : " + StringConstants.RESOURCE_INTERFACE); + mResourceHandle = OcPlatform.registerResource(StringConstants.DEVICE_URI, + StringConstants.RESOURCE_TYPENAME, StringConstants.RESOURCE_INTERFACE, + eh, EnumSet.of(ResourceProperty.DISCOVERABLE)); + } catch (OcException e) { + logMessage(TAG + "registerResource error: " + e.getMessage()); + Log.e(TAG, e.getMessage()); + } + } + + /** + * update current state of device + * + * @return device representation + */ + private void updateRepresentationValues() { + try { + mRepresentation.setValue(StringConstants.DEVICE_NAME, + "Intel Powered 2 door, 1 light refrigerator"); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + } + + /** + * unregister the resource + */ + private void deleteDeviceResource() { + try { + OcPlatform.unregisterResource(mResourceHandle); + logMessage(TAG + "Unregister DeviceResource successful"); + } catch (OcException e) { + logMessage(TAG + e.getMessage()); + Log.e(TAG, e.getMessage()); + } + } + + /** + * this is the main method which handles different incoming requests appropriately. + * + * @param request OcResourceRequest from the client + * @return EntityHandlerResult depending on whether the request was handled successfully or not + */ + private EntityHandlerResult entityHandler(OcResourceRequest request) { + EntityHandlerResult result = EntityHandlerResult.ERROR; + if (null != request) { + List headerOptions = request.getHeaderOptions(); + String clientAPIVersion = ""; + String clientToken = ""; + + // search for header options map and look for API version and client token + for (OcHeaderOption headerOption : headerOptions) { + int optionId = headerOption.getOptionId(); + if (StringConstants.API_VERSION_KEY == optionId) { + clientAPIVersion = headerOption.getOptionData(); + logMessage(TAG + " Client API Version: " + clientAPIVersion); + } else if (StringConstants.CLIENT_VERSION_KEY == optionId) { + clientToken = headerOption.getOptionData(); + logMessage(TAG + " Client Token: " + clientToken); + } + } + if (clientAPIVersion.equals(StringConstants.API_VERSION) && + clientToken.equals(StringConstants.CLIENT_TOKEN)) { + List serverHeaderOptions = new LinkedList<>(); + OcHeaderOption apiVersion = new OcHeaderOption(StringConstants.API_VERSION_KEY, + StringConstants.API_VERSION); + serverHeaderOptions.add(apiVersion); + try { + if (request.getRequestHandlerFlagSet().contains(RequestHandlerFlag.REQUEST)) { + OcResourceResponse response = new OcResourceResponse(); + response.setRequestHandle(request.getRequestHandle()); + response.setResourceHandle(request.getResourceHandle()); + response.setHeaderOptions(serverHeaderOptions); + + switch (request.getRequestType()) { + case GET: + response.setErrorCode(StringConstants.OK); + response.setResponseResult(EntityHandlerResult.OK); + updateRepresentationValues(); + response.setResourceRepresentation(mRepresentation); + OcPlatform.sendResponse(response); + break; + case DELETE: + deleteDeviceResource(); + response.setErrorCode(StringConstants.OK); + response.setResponseResult(EntityHandlerResult.OK); + break; + case POST: + response.setResponseResult(EntityHandlerResult.ERROR); + OcPlatform.sendResponse(response); + break; + } + result = EntityHandlerResult.OK; + } + } catch (OcException e) { + logMessage(TAG + e.getMessage()); + Log.e(TAG, e.getMessage()); + } + } + } + return result; + } + + @Override + public void logMessage(String msg) { + logMsg(msg); + if (StringConstants.ENABLE_PRINTING) { + Log.i(TAG, msg); + } + } + + public void logMsg(final String text) { + Intent intent = new Intent(StringConstants.INTENT); + intent.putExtra("message", text); + mContext.sendBroadcast(intent); + } +} diff --git a/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DoorResource.java b/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DoorResource.java new file mode 100755 index 0000000..438022b --- /dev/null +++ b/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DoorResource.java @@ -0,0 +1,178 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base.examples.fridgeserver; + +import android.content.Context; +import android.content.Intent; +import android.util.Log; + +import org.iotivity.base.EntityHandlerResult; +import org.iotivity.base.OcException; +import org.iotivity.base.OcPlatform; +import org.iotivity.base.OcRepresentation; +import org.iotivity.base.OcResourceRequest; +import org.iotivity.base.OcResourceResponse; +import org.iotivity.base.RequestHandlerFlag; +import org.iotivity.base.ResourceProperty; + +import java.util.EnumSet; + +import base.iotivity.org.examples.message.IMessageLogger; + +/** + * DoorResource + *

+ * Creates a door resource and performs action based on client requests + */ +public class DoorResource extends Resource implements IMessageLogger { + private Context mContext; + + private static String TAG = "DoorResource: "; + private String mSide = StringConstants.LEFT; + private boolean mOpen; + private String resourceURI; + + /** + * Constructor + * + * @param side left or right side of the door + * @param context to enable sending of broadcast messages to be displayed on the user screen + */ + DoorResource(String side, Context context) { + mContext = context; + mSide = side; + + resourceURI = StringConstants.DOOR_URI + mSide; + + // eventHandler for register doorResource + OcPlatform.EntityHandler eh = new OcPlatform.EntityHandler() { + @Override + public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) { + // this is where the main logic of DoorResource is handled + return entityHandler(ocResourceRequest); + } + }; + try { + logMessage(TAG + "RegisterDoorResource " + resourceURI + " : " + + StringConstants.RESOURCE_TYPEDOOR + " : " + StringConstants.RESOURCE_INTERFACE); + mResourceHandle = OcPlatform.registerResource(resourceURI, + StringConstants.RESOURCE_TYPEDOOR, StringConstants.RESOURCE_INTERFACE, + eh, EnumSet.of(ResourceProperty.DISCOVERABLE)); + } catch (OcException e) { + logMessage(TAG + "DoorResource registerResource error: " + e.getMessage()); + Log.e(TAG, e.getMessage()); + } + } + + /** + * updates the current value of the door resource + * + * @return door representation + */ + private void updateRepresentationValues() { + try { + mRepresentation.setValue(StringConstants.SIDE, mSide); + mRepresentation.setValue(StringConstants.OPEN, mOpen); + mRepresentation.setValue(StringConstants.DEVICE_NAME, + "Intel Powered 2 door, 1 light refrigerator"); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + } + + /** + * update the OPEN value of doorResource (door is open/ closed) + * + * @param representation get current state of door + */ + private void put(OcRepresentation representation) { + try { + mOpen = representation.getValue(StringConstants.OPEN); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + // Note, we won't let the user change the door side! + } + + /** + * this is the main method which handles different incoming requests appropriately. + * + * @param request OcResourceRequest from the client + * @return EntityHandlerResult depending on whether the request was handled successfully or not + */ + private EntityHandlerResult entityHandler(OcResourceRequest request) { + EntityHandlerResult result = EntityHandlerResult.ERROR; + if (null != request) { + try { + if (request.getRequestHandlerFlagSet().contains(RequestHandlerFlag.REQUEST)) { + OcResourceResponse response = new OcResourceResponse(); + response.setRequestHandle(request.getRequestHandle()); + response.setResourceHandle(request.getResourceHandle()); + + switch (request.getRequestType()) { + case GET: + response.setErrorCode(StringConstants.OK); + updateRepresentationValues(); + response.setResourceRepresentation(mRepresentation); + response.setResponseResult(EntityHandlerResult.OK); + OcPlatform.sendResponse(response); + break; + case PUT: + response.setErrorCode(StringConstants.OK); + put(request.getResourceRepresentation()); + updateRepresentationValues(); + response.setResourceRepresentation(mRepresentation); + response.setResponseResult(EntityHandlerResult.OK); + OcPlatform.sendResponse(response); + break; + case DELETE: + response.setResponseResult(EntityHandlerResult.RESOURCE_DELETED); + response.setErrorCode(204); + OcPlatform.sendResponse(response); + break; + } + result = EntityHandlerResult.OK; + } + } catch (OcException e) { + logMessage(TAG + e.getMessage()); + Log.e(TAG, e.getMessage()); + return EntityHandlerResult.ERROR; + } + } + return result; + } + + @Override + public void logMessage(String msg) { + logMsg(msg); + if (StringConstants.ENABLE_PRINTING) { + Log.i(TAG, msg); + } + } + + public void logMsg(final String text) { + Intent intent = new Intent(StringConstants.INTENT); + intent.putExtra(StringConstants.MESSAGE, text); + mContext.sendBroadcast(intent); + } +} diff --git a/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/FridgeServer.java b/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/FridgeServer.java new file mode 100755 index 0000000..45971f7 --- /dev/null +++ b/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/FridgeServer.java @@ -0,0 +1,145 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base.examples.fridgeserver; + +import android.app.Activity; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.os.Bundle; +import android.os.Message; +import android.support.v4.content.LocalBroadcastManager; +import android.text.method.ScrollingMovementMethod; +import android.util.Log; +import android.view.Menu; +import android.view.MenuItem; +import android.widget.LinearLayout; +import android.widget.TextView; + +import org.iotivity.base.ModeType; +import org.iotivity.base.OcPlatform; +import org.iotivity.base.PlatformConfig; +import org.iotivity.base.QualityOfService; +import org.iotivity.base.ServiceType; + +import base.iotivity.org.examples.message.IMessageLogger; + +/** + * FridgeServer + *

+ * This is the main fridgeServer class. This instantiates Refrigerator object + * which has different resources (DeviceResource, LightResource, DoorResource). + */ +public class FridgeServer extends Activity implements IMessageLogger { + private Context mContext; + private static String TAG = "FridgeServer: "; + private TextView mEventsTextView; + private MessageReceiver mMessageReceiver = new MessageReceiver(); + private Refrigerator refrigerator; + + /** + * configure OIC platform and call findResource + */ + private void initOICStack() { + //create platform config + PlatformConfig cfg = new PlatformConfig( + this, + ServiceType.IN_PROC, + ModeType.SERVER, + "0.0.0.0", // bind to all available interfaces + 0, + QualityOfService.LOW); + OcPlatform.Configure(cfg); + logMessage(TAG + "Creating refrigerator resources"); + + refrigerator = new Refrigerator(mContext); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_fridge_server); + registerReceiver(mMessageReceiver, new IntentFilter(StringConstants.INTENT)); + + mEventsTextView = new TextView(this); + mEventsTextView.setMovementMethod(new ScrollingMovementMethod()); + LinearLayout layout = (LinearLayout) findViewById(R.id.linearLayout); + layout.addView(mEventsTextView, new LinearLayout.LayoutParams + (LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f)); + mContext = this; + + initOICStack(); + } + + public class MessageReceiver extends BroadcastReceiver { + @Override + public void onReceive(Context context, Intent intent) { + final String message = intent.getStringExtra(StringConstants.MESSAGE); + logMessage(message); + } + } + + @Override + public void logMessage(final String text) { + if (StringConstants.ENABLE_PRINTING) { + runOnUiThread(new Runnable() { + public void run() { + final Message msg = new Message(); + msg.obj = text; + mEventsTextView.append("\n"); + mEventsTextView.append(text); + } + }); + Log.i(TAG, text); + } + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_fridge_server, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + int id = item.getItemId(); + if (id == R.id.action_settings) { + return true; + } + return super.onOptionsItemSelected(item); + } + + @Override + public void onDestroy() { + super.onDestroy(); + onStop(); + } + + @Override + protected void onStop() { + LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver); + super.onStop(); + } +} diff --git a/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/LightResource.java b/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/LightResource.java new file mode 100755 index 0000000..09b7f43 --- /dev/null +++ b/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/LightResource.java @@ -0,0 +1,164 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base.examples.fridgeserver; + +import android.content.Context; +import android.content.Intent; +import android.util.Log; + +import org.iotivity.base.EntityHandlerResult; +import org.iotivity.base.OcException; +import org.iotivity.base.OcPlatform; +import org.iotivity.base.OcRepresentation; +import org.iotivity.base.OcResourceRequest; +import org.iotivity.base.OcResourceResponse; +import org.iotivity.base.RequestHandlerFlag; +import org.iotivity.base.ResourceProperty; + +import java.util.EnumSet; + +import base.iotivity.org.examples.message.IMessageLogger; + +/** + * LightResource + *

+ * Creates a light resource and performs action based on client requests + */ +public class LightResource extends Resource implements IMessageLogger { + private Context mContext; + + private static String TAG = "LightResource: "; + + private boolean mIsOn = false; + + /** + * constructor + * + * @param context to enable sending of broadcast messages to be displayed on the user screen + */ + LightResource(Context context) { + mContext = context; + //eventHandler for register lightResource + OcPlatform.EntityHandler eh = new OcPlatform.EntityHandler() { + @Override + public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) { + // this is where the main logic of LightResource is handled + return entityHandler(ocResourceRequest); + } + }; + try { + logMessage(TAG + "RegisterLightResource " + StringConstants.LIGHT_URI + " : " + + StringConstants.RESOURCE_TYPELIGHT + " : " + StringConstants.RESOURCE_INTERFACE); + mResourceHandle = OcPlatform.registerResource(StringConstants.LIGHT_URI, + StringConstants.RESOURCE_TYPELIGHT, StringConstants.RESOURCE_INTERFACE, + eh, EnumSet.of(ResourceProperty.DISCOVERABLE)); + } catch (OcException e) { + logMessage(TAG + "LightResource registerResource error: " + e.getMessage()); + Log.e(TAG, e.getMessage()); + } + } + + /** + * updates the current state of the light (on/ off) + * + * @return light is on or off + */ + private void updateRepresentationValues() { + try { + mRepresentation.setValue(StringConstants.ON, mIsOn); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + } + + /** + * update the value of mIsOn from the representation + * + * @param representation get current state of light + */ + private void put(OcRepresentation representation) { + try { + mIsOn = representation.getValue(StringConstants.ON); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + } + + /** + * this is the main method which handles different incoming requests appropriately. + * + * @param request OcResourceRequest from the client + * @return EntityHandlerResult depending on whether the request was handled successfully or not + */ + private EntityHandlerResult entityHandler(OcResourceRequest request) { + EntityHandlerResult result = EntityHandlerResult.ERROR; + if (null != request) { + try { + if (request.getRequestHandlerFlagSet().contains(RequestHandlerFlag.REQUEST)) { + OcResourceResponse response = new OcResourceResponse(); + response.setRequestHandle(request.getRequestHandle()); + response.setResourceHandle(request.getResourceHandle()); + + switch (request.getRequestType()) { + case GET: + response.setErrorCode(StringConstants.OK); + updateRepresentationValues(); + response.setResourceRepresentation(mRepresentation); + response.setResponseResult(EntityHandlerResult.OK); + OcPlatform.sendResponse(response); + result = EntityHandlerResult.OK; + break; + case PUT: + response.setErrorCode(StringConstants.OK); + put(request.getResourceRepresentation()); + updateRepresentationValues(); + response.setResourceRepresentation(mRepresentation); + response.setResponseResult(EntityHandlerResult.OK); + OcPlatform.sendResponse(response); + result = EntityHandlerResult.OK; + break; + } + } + } catch (OcException e) { + logMessage(TAG + e.getMessage()); + Log.e(TAG, e.getMessage()); + return EntityHandlerResult.ERROR; + } + } + return result; + } + + @Override + public void logMessage(String msg) { + logMsg(msg); + if (StringConstants.ENABLE_PRINTING) { + Log.i(TAG, msg); + } + } + + public void logMsg(final String text) { + Intent intent = new Intent(StringConstants.INTENT); + intent.putExtra(StringConstants.MESSAGE, text); + mContext.sendBroadcast(intent); + } +} diff --git a/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Refrigerator.java b/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Refrigerator.java new file mode 100755 index 0000000..4432755 --- /dev/null +++ b/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Refrigerator.java @@ -0,0 +1,57 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base.examples.fridgeserver; + +import android.content.Context; + +/** + * Refrigerator + *

+ * Refrigerator class has different objects (resources) which are instantiated when a + * Refrigerator object is created. Operations are performed on each of the individual resources. + */ +public class Refrigerator { + private Context mContext; + + private LightResource mLight; + private DeviceResource mDevice; + private DoorResource mLeftDoor; + private DoorResource mRightDoor; + private DoorResource mRandomDoor; + + /** + * constructor + * + * @param context needed by individual resources to be able to send broadcast + * messages to be displayed on the user screen + */ + Refrigerator(Context context) { + mContext = context; + mLight = new LightResource(context); + mDevice = new DeviceResource(context); + mLeftDoor = new DoorResource(StringConstants.LEFT, context); + mRightDoor = new DoorResource(StringConstants.RIGHT, context); + mRandomDoor = new DoorResource(StringConstants.RANDOM, context); + } + +} diff --git a/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Resource.java b/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Resource.java new file mode 100755 index 0000000..350cee0 --- /dev/null +++ b/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Resource.java @@ -0,0 +1,41 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base.examples.fridgeserver; + +import org.iotivity.base.OcRepresentation; +import org.iotivity.base.OcResourceHandle; + +/** + * Resource + *

+ * Each of the other resource classes (DeviceResource, DoorResource and LightResource extend Resource + */ +public class Resource { + protected OcResourceHandle mResourceHandle; + protected OcRepresentation mRepresentation; + + Resource() { + mResourceHandle = null; + mRepresentation = new OcRepresentation(); + } +} \ No newline at end of file diff --git a/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/StringConstants.java b/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/StringConstants.java new file mode 100755 index 0000000..1afe25b --- /dev/null +++ b/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/StringConstants.java @@ -0,0 +1,37 @@ +package org.iotivity.base.examples.fridgeserver; + +import org.iotivity.base.OcPlatform; + +/** + * StringConstant contains the fridgeserver specific constant values. To add another supported + * Resource or Interface type to this app, begin by adding the new strings here, and then + * find the places throughout the app where Resource-specific case switches occur, and add + * the newly-supported type there. + */ +public interface StringConstants { + public static final String DEVICE_URI = "/device"; + public static final String LIGHT_URI = "/light"; + public static final String DOOR_URI = "/door/"; + public static final String DEVICE_NAME = "device_name"; + public static final String RESOURCE_TYPENAME = "intel.fridge"; + public static final String RESOURCE_TYPEDOOR = "intel.fridge.door"; + public static final String RESOURCE_TYPELIGHT = "intel.fridge.light"; + public static final String API_VERSION = "v.1.2"; + public static final String CLIENT_TOKEN = "AaBbYyZz"; + public static final String SIDE = "side"; + public static final String OPEN = "open"; + public static final String MESSAGE = "message"; + public static final String LEFT = "left"; + public static final String RIGHT = "right"; + public static final String RANDOM = "random"; + public static final String ON = "on"; + public static final String INTENT = "org.iotivity.base.examples.fridgeserver"; + public static final String RESOURCE_INTERFACE = OcPlatform.DEFAULT_INTERFACE; + + public static final int API_VERSION_KEY = 2048; + public static final int CLIENT_VERSION_KEY = 3000; + public static final int OK = 200; + + public static final boolean ENABLE_PRINTING = true; // change to false to disable printing + // of messages on the console and the screen +} diff --git a/android/Base/app/src/main/res/drawable-hdpi/ic_launcher.png b/android/examples/fridgeserver/src/main/res/drawable-hdpi/ic_launcher.png old mode 100644 new mode 100755 similarity index 100% rename from android/Base/app/src/main/res/drawable-hdpi/ic_launcher.png rename to android/examples/fridgeserver/src/main/res/drawable-hdpi/ic_launcher.png diff --git a/android/Base/app/src/main/res/drawable-mdpi/ic_launcher.png b/android/examples/fridgeserver/src/main/res/drawable-mdpi/ic_launcher.png old mode 100644 new mode 100755 similarity index 100% rename from android/Base/app/src/main/res/drawable-mdpi/ic_launcher.png rename to android/examples/fridgeserver/src/main/res/drawable-mdpi/ic_launcher.png diff --git a/android/Base/app/src/main/res/drawable-xhdpi/ic_launcher.png b/android/examples/fridgeserver/src/main/res/drawable-xhdpi/ic_launcher.png old mode 100644 new mode 100755 similarity index 100% rename from android/Base/app/src/main/res/drawable-xhdpi/ic_launcher.png rename to android/examples/fridgeserver/src/main/res/drawable-xhdpi/ic_launcher.png diff --git a/android/Base/app/src/main/res/drawable-xxhdpi/ic_launcher.png b/android/examples/fridgeserver/src/main/res/drawable-xxhdpi/ic_launcher.png old mode 100644 new mode 100755 similarity index 100% rename from android/Base/app/src/main/res/drawable-xxhdpi/ic_launcher.png rename to android/examples/fridgeserver/src/main/res/drawable-xxhdpi/ic_launcher.png diff --git a/android/examples/fridgeserver/src/main/res/layout/activity_fridge_server.xml b/android/examples/fridgeserver/src/main/res/layout/activity_fridge_server.xml new file mode 100755 index 0000000..39362b3 --- /dev/null +++ b/android/examples/fridgeserver/src/main/res/layout/activity_fridge_server.xml @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/android/examples/fridgeserver/src/main/res/menu/menu_fridge_server.xml b/android/examples/fridgeserver/src/main/res/menu/menu_fridge_server.xml new file mode 100755 index 0000000..2895144 --- /dev/null +++ b/android/examples/fridgeserver/src/main/res/menu/menu_fridge_server.xml @@ -0,0 +1,6 @@ +

+ + diff --git a/android/examples/fridgeserver/src/main/res/values-w820dp/dimens.xml b/android/examples/fridgeserver/src/main/res/values-w820dp/dimens.xml new file mode 100755 index 0000000..62df187 --- /dev/null +++ b/android/examples/fridgeserver/src/main/res/values-w820dp/dimens.xml @@ -0,0 +1,6 @@ + + + 64dp + diff --git a/android/examples/fridgeserver/src/main/res/values/dimens.xml b/android/examples/fridgeserver/src/main/res/values/dimens.xml new file mode 100755 index 0000000..295b5a9 --- /dev/null +++ b/android/examples/fridgeserver/src/main/res/values/dimens.xml @@ -0,0 +1,5 @@ + + + 16dp + 16dp + diff --git a/android/examples/fridgeserver/src/main/res/values/strings.xml b/android/examples/fridgeserver/src/main/res/values/strings.xml new file mode 100755 index 0000000..3e317da --- /dev/null +++ b/android/examples/fridgeserver/src/main/res/values/strings.xml @@ -0,0 +1,8 @@ + + + + FridgeServer + Hello world! + Settings + + diff --git a/android/SimpleClient/app/src/main/res/values/styles.xml b/android/examples/fridgeserver/src/main/res/values/styles.xml old mode 100644 new mode 100755 similarity index 59% rename from android/SimpleClient/app/src/main/res/values/styles.xml rename to android/examples/fridgeserver/src/main/res/values/styles.xml index ff6c9d2..084b42b --- a/android/SimpleClient/app/src/main/res/values/styles.xml +++ b/android/examples/fridgeserver/src/main/res/values/styles.xml @@ -1,8 +1,8 @@ - - - - - - + + + + + + diff --git a/android/examples/gradle/wrapper/gradle-wrapper.jar b/android/examples/gradle/wrapper/gradle-wrapper.jar new file mode 100755 index 0000000000000000000000000000000000000000..8c0fb64a8698b08ecc4158d828ca593c4928e9dd GIT binary patch literal 49896 zcmagFb986H(k`5d^NVfUwr$(C?M#x1ZQHiZiEVpg+jrjgoQrerx!>1o_ul)D>ebz~ zs=Mmxr&>W81QY-S1PKWQ%N-;H^tS;2*XwVA`dej1RRn1z<;3VgfE4~kaG`A%QSPsR z#ovnZe+tS9%1MfeDyz`RirvdjPRK~p(#^q2(^5@O&NM19EHdvN-A&StN>0g6QA^VN z0Gx%Gq#PD$QMRFzmK+utjS^Y1F0e8&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"`dirname \"$PRG\"`/" >&- -APP_HOME="`pwd -P`" -cd "$SAVED" >&- - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" - -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# For Cygwin, ensure paths are in UNIX format before anything is touched. +if $cygwin ; then + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/android/Base/gradlew.bat b/android/examples/gradlew.bat old mode 100644 new mode 100755 similarity index 100% rename from android/Base/gradlew.bat rename to android/examples/gradlew.bat diff --git a/android/examples/message/.gitignore b/android/examples/message/.gitignore new file mode 100755 index 0000000..1a94a02 --- /dev/null +++ b/android/examples/message/.gitignore @@ -0,0 +1,3 @@ +/build + +src/main/res \ No newline at end of file diff --git a/android/examples/message/build.gradle b/android/examples/message/build.gradle new file mode 100755 index 0000000..1ed1a39 --- /dev/null +++ b/android/examples/message/build.gradle @@ -0,0 +1,24 @@ +apply plugin: 'com.android.library' + +android { + compileSdkVersion 21 + buildToolsVersion "21.1.2" + + defaultConfig { + minSdkVersion 19 + targetSdkVersion 21 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + compile 'com.android.support:appcompat-v7:21.0.3' +} diff --git a/android/examples/message/message.iml b/android/examples/message/message.iml new file mode 100755 index 0000000..e9cabc1 --- /dev/null +++ b/android/examples/message/message.iml @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/examples/message/src/main/AndroidManifest.xml b/android/examples/message/src/main/AndroidManifest.xml new file mode 100755 index 0000000..9922f58 --- /dev/null +++ b/android/examples/message/src/main/AndroidManifest.xml @@ -0,0 +1,9 @@ + + + + + + + diff --git a/android/examples/message/src/main/java/base/iotivity/org/examples/message/IMessageLogger.java b/android/examples/message/src/main/java/base/iotivity/org/examples/message/IMessageLogger.java new file mode 100755 index 0000000..7ecd6b3 --- /dev/null +++ b/android/examples/message/src/main/java/base/iotivity/org/examples/message/IMessageLogger.java @@ -0,0 +1,27 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package base.iotivity.org.examples.message; + +public interface IMessageLogger { + public void logMessage(String msg); +} diff --git a/android/examples/settings.gradle b/android/examples/settings.gradle new file mode 100755 index 0000000..bf2b78b --- /dev/null +++ b/android/examples/settings.gradle @@ -0,0 +1 @@ +include ':simpleserver', ':simpleclient', ':message', ':fridgeserver', ':fridgeclient' \ No newline at end of file diff --git a/android/examples/simpleclient/.gitignore b/android/examples/simpleclient/.gitignore new file mode 100755 index 0000000..3543521 --- /dev/null +++ b/android/examples/simpleclient/.gitignore @@ -0,0 +1 @@ +/build diff --git a/android/examples/simpleclient/build.gradle b/android/examples/simpleclient/build.gradle new file mode 100755 index 0000000..07cc15b --- /dev/null +++ b/android/examples/simpleclient/build.gradle @@ -0,0 +1,25 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 21 + buildToolsVersion "21.1.2" + + defaultConfig { + applicationId "org.iotivity.base.examples.simpleclient" + minSdkVersion 19 + targetSdkVersion 21 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile project(':message') + compile 'com.android.support:appcompat-v7:21.0.3' +} diff --git a/android/examples/simpleclient/simpleclient.iml b/android/examples/simpleclient/simpleclient.iml new file mode 100755 index 0000000..4ba5a36 --- /dev/null +++ b/android/examples/simpleclient/simpleclient.iml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/SimpleClient/app/src/main/AndroidManifest.xml b/android/examples/simpleclient/src/main/AndroidManifest.xml old mode 100644 new mode 100755 similarity index 76% rename from android/SimpleClient/app/src/main/AndroidManifest.xml rename to android/examples/simpleclient/src/main/AndroidManifest.xml index 08329da..0345054 --- a/android/SimpleClient/app/src/main/AndroidManifest.xml +++ b/android/examples/simpleclient/src/main/AndroidManifest.xml @@ -1,23 +1,24 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/android/examples/simpleclient/src/main/java/org/iotivity/base/examples/simpleclient/Light.java b/android/examples/simpleclient/src/main/java/org/iotivity/base/examples/simpleclient/Light.java new file mode 100755 index 0000000..2f981b3 --- /dev/null +++ b/android/examples/simpleclient/src/main/java/org/iotivity/base/examples/simpleclient/Light.java @@ -0,0 +1,65 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base.examples.simpleclient; + +/** + * Light + * + * This class is used by simpleclient to create an object and update the values depending on the server response + */ +public class Light { + private boolean mState; + private int mPower; + private String mName; + + // constructor + Light() { + mState = false; + mPower = 0; + mName = ""; + } + + // accessor methods + public boolean getState() { + return mState; + } + void setState(boolean state) { + mState = state; + } + int getPower() { + return mPower; + } + void setPower(int power) { + mPower = power; + } + String getName() { + return mName; + } + void setName(String name) { + mName = name; + } +} + + + + diff --git a/android/examples/simpleclient/src/main/java/org/iotivity/base/examples/simpleclient/SimpleClient.java b/android/examples/simpleclient/src/main/java/org/iotivity/base/examples/simpleclient/SimpleClient.java new file mode 100755 index 0000000..b747c5a --- /dev/null +++ b/android/examples/simpleclient/src/main/java/org/iotivity/base/examples/simpleclient/SimpleClient.java @@ -0,0 +1,443 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base.examples.simpleclient; + +import android.app.Activity; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.os.Message; +import android.text.method.ScrollingMovementMethod; +import android.util.Log; +import android.widget.LinearLayout; +import android.widget.TextView; + +import org.iotivity.base.ErrorCode; +import org.iotivity.base.ModeType; +import org.iotivity.base.ObserveType; +import org.iotivity.base.OcConnectivityType; +import org.iotivity.base.OcException; +import org.iotivity.base.OcHeaderOption; +import org.iotivity.base.OcPlatform; +import org.iotivity.base.OcRepresentation; +import org.iotivity.base.OcResource; +import org.iotivity.base.PlatformConfig; +import org.iotivity.base.QualityOfService; +import org.iotivity.base.ServiceType; + +import java.util.HashMap; +import java.util.List; + +import base.iotivity.org.examples.message.IMessageLogger; + +/** + * SimpleClient + *

+ * SimpleClient is a sample client app which should be started after the simpleServer is started. + * It finds resources advertised by the server and calls different operations on it (GET, PUT, + * POST and OBSERVE). + * This implements IMessageLogger to display messages on the screen + */ +public class SimpleClient extends Activity implements OcPlatform.OnResourceFoundListener, + IMessageLogger { + private static final String TAG = "SimpleClient: "; + + private Light myLight; + private OcResource curResource; + + //for display + private TextView mEventsTextView; + private static boolean printOnce = true; + + /** + * configure OIC platform and call findResource + */ + private void initOICStack() { + //create platform config + PlatformConfig cfg = new PlatformConfig( + this, + ServiceType.IN_PROC, + ModeType.CLIENT, + "0.0.0.0", // bind to all available interfaces + 0, + QualityOfService.LOW); + OcPlatform.Configure(cfg); + try { + /** + * find all resources + */ + OcPlatform.findResource("", OcPlatform.WELL_KNOWN_QUERY + "?rt=" + "core.light", + OcConnectivityType.WIFI, this); + } catch (OcException e) { + logMessage(TAG + "findResource error: " + e.getMessage()); + Log.e(TAG, e.getMessage()); + } + } + + @Override + /** + * callback when a resource is found. This method calls doGetLightRepresentation to get the + * current values of myLight + */ + synchronized public void onResourceFound(OcResource ocResource) { + /** + * this may potentially be called by multiple threads at the same time + */ + synchronized (this) { + String resourceUri; + String hostAddress; + resourceUri = ocResource.getUri(); + hostAddress = ocResource.getHost(); + logMessage(TAG + "Discovered Resource\nUri: " + resourceUri + " \n Host: " + hostAddress); + // get the resource types + if (resourceUri.equals(StringConstants.RESOURCE_URI0)) { + curResource = ocResource; + doGetLightRepresentation(); + } + } + } + + /** + * get myLight values after observe + */ + private void doObserveLightRepresentation() { + // eventhandler for observe() + OcResource.OnObserveListener onObserveListener = new OcResource.OnObserveListener() { + @Override + public void onObserveCompleted(List ocHeaderOptions, + OcRepresentation ocRepresentation, int seqNum) { + if (printOnce) { + logMessage(TAG + "OBSERVE request was successful"); + printOnce = false; + } + try { + boolean state = ocRepresentation.getValue(StringConstants.STATE); + int power = ocRepresentation.getValue(StringConstants.POWER); + String name = ocRepresentation.getValue(StringConstants.NAME); + myLight.setState(state); + myLight.setPower(power); + myLight.setName(name); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + logMessage(TAG + "onObserve: Power: " + myLight.getPower()); + if (seqNum > 20) { + try { + curResource.cancelObserve(); + logMessage(TAG + "Successfully cancelled observe"); + } catch (OcException e) { + logMessage(TAG + "cancelObserve error. " + e.getMessage()); + Log.e(TAG, e.getMessage()); + } + } + + } + + @Override + public void onObserveFailed(Throwable throwable) { + if (throwable instanceof OcException) { + OcException ocEx = (OcException) throwable; + ErrorCode errCode = ocEx.getErrorCode(); + //do something based on errorCode + } + Log.e(TAG, throwable.toString()); + } + }; + try { + curResource.observe(ObserveType.OBSERVE, new HashMap(), onObserveListener); + } catch (OcException e) { + logMessage(TAG + e.getMessage()); + Log.e(TAG, e.getMessage()); + } + } + + /** + * get the current value of myLight after POST and call doObserveLightRepresentation + * + * @param ocRepresentation needed to invoke post() + */ + private void doOnPost2(OcRepresentation ocRepresentation) { + // eventhandler for post() + OcResource.OnPostListener onPostListener2 = new OcResource.OnPostListener() { + @Override + public void onPostCompleted(List ocHeaderOptions, OcRepresentation rep) { + logMessage(TAG + "POST request was successful"); + String createdUri = rep.getUri(); + if (createdUri.equals(StringConstants.RESOURCE_URI1)) { + logMessage(TAG + "Uri of the created resource: " + createdUri); + } else { + try { + boolean state = rep.getValue(StringConstants.STATE); + int power = rep.getValue(StringConstants.POWER); + String name = rep.getValue(StringConstants.NAME); + myLight.setState(state); + myLight.setPower(power); + myLight.setName(name); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + logMessage(TAG + "onPost\nState: " + myLight.getState() + "\nPower: " + + myLight.getPower() + "\nName: " + myLight.getName()); + } + doObserveLightRepresentation(); + } + + @Override + public void onPostFailed(Throwable throwable) { + if (throwable instanceof OcException) { + OcException ocEx = (OcException) throwable; + ErrorCode errCode = ocEx.getErrorCode(); + //do something based on errorCode + } + Log.e(TAG, throwable.toString()); + } + }; + try { + curResource.post(ocRepresentation, new HashMap(), onPostListener2); + } catch (OcException e) { + logMessage(TAG + e.getMessage()); + Log.e(TAG, e.getMessage()); + } + } + + /** + * create a new resource and update its value. + */ + private void doPostLightRepresentation() { + // eventhandler for post() + OcResource.OnPostListener onPostListener = new OcResource.OnPostListener() { + @Override + public void onPostCompleted(List ocHeaderOptions, + OcRepresentation ocRepresentation) { + String createdUri = ""; + try { + createdUri = ocRepresentation.getValue(StringConstants.CREATED_URI); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + if (createdUri.equals(StringConstants.RESOURCE_URI1)) { + logMessage(TAG + "Uri of the created resource: " + createdUri); + } else { + boolean state = false; + try { + state = ocRepresentation.getValue(StringConstants.STATE); + int power = ocRepresentation.getValue(StringConstants.POWER); + String name = ocRepresentation.getValue(StringConstants.NAME); + myLight.setState(state); + myLight.setPower(power); + myLight.setName(name); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + } + OcRepresentation rep = new OcRepresentation(); + myLight.setState(true); + myLight.setPower(55); + try { + rep.setValue(StringConstants.POWER, myLight.getPower()); + rep.setValue(StringConstants.STATE, myLight.getState()); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + doOnPost2(rep); + } + + @Override + public void onPostFailed(Throwable throwable) { + if (throwable instanceof OcException) { + OcException ocEx = (OcException) throwable; + ErrorCode errCode = ocEx.getErrorCode(); + //do something based on errorCode + } + Log.e(TAG, throwable.toString()); + } + }; + + OcRepresentation rep = new OcRepresentation(); + myLight.setState(false); + myLight.setPower(105); + try { + rep.setValue(StringConstants.STATE, myLight.getState()); + rep.setValue(StringConstants.POWER, myLight.getPower()); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + try { + curResource.post(rep, new HashMap(), onPostListener); + } catch (OcException e) { + logMessage(TAG + e.getMessage()); + Log.e(TAG, e.getMessage()); + } + } + + /** + * modify the current value of myLight and call doPostLightRepresentation + */ + private void doPutLightRepresentation() { + // eventhandler for put() + OcResource.OnPutListener onPutListener = new OcResource.OnPutListener() { + @Override + public void onPutCompleted(List ocHeaderOptions, + OcRepresentation ocRepresentation) { + logMessage(TAG + "PUT resource was successful"); + try { + boolean state = ocRepresentation.getValue(StringConstants.STATE); + int power = ocRepresentation.getValue(StringConstants.POWER); + String name = ocRepresentation.getValue(StringConstants.NAME); + myLight.setState(state); + myLight.setPower(power); + myLight.setName(name); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + + logMessage(TAG + "onPutCompleted:\nState:" + myLight.getState() + "\nPower: " + + myLight.getPower() + "\nName: " + myLight.getName()); + doPostLightRepresentation(); + } + + @Override + public void onPutFailed(Throwable throwable) { + + if (throwable instanceof OcException) { + OcException ocEx = (OcException) throwable; + ErrorCode errCode = ocEx.getErrorCode(); + //do something based on errorCode + } + Log.e(TAG, throwable.toString()); + } + }; + + OcRepresentation rep = new OcRepresentation(); + Log.d(TAG, "myLight settings: power = 15"); + myLight.setState(true); + myLight.setPower(15); + try { + rep.setValue(StringConstants.STATE, myLight.getState()); + rep.setValue(StringConstants.POWER, myLight.getPower()); + rep.setValue(StringConstants.NAME, myLight.getName()); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + try { + Log.d(TAG, "before calling put"); + curResource.put(rep, new HashMap(), onPutListener); + } catch (OcException e) { + logMessage(TAG + e.getMessage()); + Log.e(TAG, e.getMessage()); + } + Log.d(TAG, "end of put call"); + } + + /** + * get the existing value of myLight and call doPutLightRepresentation() to modify the current values + */ + private void doGetLightRepresentation() { + // eventhandler for get() + OcResource.OnGetListener onGetListener = new OcResource.OnGetListener() { + @Override + public void onGetCompleted(List headerOptionList, + OcRepresentation ocRepresentation) { + logMessage(TAG + "GET resource was successful " + StringConstants.STATE); + try { + boolean state = ocRepresentation.getValue(StringConstants.STATE); + int power = ocRepresentation.getValue(StringConstants.POWER); + String name = ocRepresentation.getValue(StringConstants.NAME); + myLight.setState(state); + myLight.setPower(power); + myLight.setName(name); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + logMessage(TAG + "onGetCompleted\nState: " + myLight.getState() + "\nPower: " + + myLight.getPower() + "\nName: " + myLight.getName()); + doPutLightRepresentation(); + } + + @Override + public void onGetFailed(Throwable throwable) { + if (throwable instanceof OcException) { + OcException ocEx = (OcException) throwable; + ErrorCode errCode = ocEx.getErrorCode(); + //do something based on errorCode + } + Log.e(TAG, throwable.toString()); + } + }; + + try { + curResource.get(new HashMap(), onGetListener); + } catch (OcException e) { + logMessage(TAG + e.getMessage()); + Log.e(TAG, e.getMessage()); + } + } + + /** + * to display on SimpleClient screen + */ + public class MessageReceiver extends BroadcastReceiver { + @Override + public void onReceive(Context context, Intent intent) { + final String message = intent.getStringExtra(StringConstants.MESSAGE); + logMessage(message); + } + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + mEventsTextView = new TextView(this); + mEventsTextView.setMovementMethod(new ScrollingMovementMethod()); + LinearLayout layout = (LinearLayout) findViewById(R.id.linearLayout); + layout.addView(mEventsTextView, new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f) + ); + myLight = new Light(); + + initOICStack(); + } + + @Override + public void logMessage(String text) { + logMsg(text); + } + + public void logMsg(final String text) { + runOnUiThread(new Runnable() { + public void run() { + Message msg = new Message(); + msg.obj = text; + mEventsTextView.append("\n"); + mEventsTextView.append(text); + } + }); + Log.i(TAG, text); + //to print on SimpleServer screen + Intent intent = new Intent("org.iotivity.base.examples.simpleclient"); + intent.putExtra(StringConstants.MESSAGE, text); + sendBroadcast(intent); + } +} diff --git a/android/examples/simpleclient/src/main/java/org/iotivity/base/examples/simpleclient/StringConstants.java b/android/examples/simpleclient/src/main/java/org/iotivity/base/examples/simpleclient/StringConstants.java new file mode 100755 index 0000000..f87c387 --- /dev/null +++ b/android/examples/simpleclient/src/main/java/org/iotivity/base/examples/simpleclient/StringConstants.java @@ -0,0 +1,17 @@ +package org.iotivity.base.examples.simpleclient; + +/** + * StringConstant contains the simpleclient specific constant values. To add another supported + * Resource or Interface type to this app, begin by adding the new strings here, and then + * find the places throughout the app where Resource-specific case switches occur, and add + * the newly-supported type there. + */ +public interface StringConstants { + public static final String RESOURCE_URI0 = "/light0"; + public static final String RESOURCE_URI1 = "/light1"; + public static final String CREATED_URI = "createduri"; + public static final String STATE = "state"; + public static final String NAME = "name"; + public static final String POWER = "power"; + public static final String MESSAGE = "message"; +} diff --git a/android/examples/simpleclient/src/main/res/drawable-hdpi/ic_launcher.png b/android/examples/simpleclient/src/main/res/drawable-hdpi/ic_launcher.png new file mode 100755 index 0000000000000000000000000000000000000000..96a442e5b8e9394ccf50bab9988cb2316026245d GIT binary patch literal 9397 zcmV;mBud+fP)L`9r|n3#ts(U@pVoQ)(ZPc(6i z8k}N`MvWQ78F(rhG(?6FnFXYo>28{yZ}%O}TvdDT_5P?j=iW=V`8=UNc_}`JbG!ST zs@lK(TWkH+P**sB$A`cEY%Y53cQ}1&6`x-M$Cz&{o9bLU^M-%^mY?+vedlvt$RT-^ zu|w7}IaWaljBq#|I%Mpo!Wc2bbZF3KF9|D%wZe{YFM=hJAv$>j>nhx`=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sN001R)MObuXVRU6WZEs|0 vW_bWIFflPLFgYzTHdHV-Ix;spGd3+SH##sdcWUue00000NkvXXu0mjfB?gph literal 0 HcmV?d00001 diff --git a/android/examples/simpleclient/src/main/res/drawable-xhdpi/ic_launcher.png b/android/examples/simpleclient/src/main/res/drawable-xhdpi/ic_launcher.png new file mode 100755 index 0000000000000000000000000000000000000000..71c6d760f05183ef8a47c614d8d13380c8528499 GIT binary patch literal 14383 zcmV+~IMBz5P)>IR{Zx9EA~4K?jU8DyU!%BVu|c#=(H1 zIAFva(2=Yn8AKWhO=@Vm>As!A%_mpwu-+fLs?Ir051^0kZ=Q9(`cB=t=bYMm<@H-@ z?@QQC#}7(lHuiOKOg-hI-&yJQ@X z>38Dx`mgcs{{O@!m2+^EdNUPDF+a6!8!8*d@!BI^jeED=gH;btqEI5d{e*jVDP7bq z{q~MSBE(fsoQg6}7k95+Ji!s3$poDp-qlOkXAwnM{3JB1P1P!!MLkm@C24>Si7~v(J@mNzG-t<6(_#~IP~Z}QN`;~#%u^^ zBv=E1KsZ>EXwWhEA%MjWSj+&p1YiKMScFGKjPH_0g9QS9!hVpahud$BNHq6km8f&$y)VmTQ`qJPd+?0zVd*nDN_N;fDC>PCKgkkd- zF&a`~zS4LCy*S)Om}M0r157c%Vz&|}g=6?|;XWKwAQT*MxQ#H?lrYWC!I5q;pTUZZ zoF|S^mMxt;_qPCIXf(txX5a0Ww;uk~=vd{jwJXPI%UbvK`FqRT9{O`bUiO)BJM_2% z(XOY!tbcIB+EHv;)4J*BV9|&y5&#Sa0{{$SB&foHK?p!lAcP=9mJn^Q zEdF4f`u+CiwmYVjr%WuN^Du#n`yU&B^3IJzBL_Zu-$?zTyBfz|`{R*^-t)z|a`kd+ z3q1~f(k6y5Nm3x1Yb_kKdg+KYV*sjIe!V z{5>Bz^<6`n@li*u;}T2+4lyJ`2oxNk906cBFdVfoiU|zCpa} z1i&zeF@X)3#Clk0*p&E|Ev$2}*1}l_W2{Z$7(q~!&ar*`feE?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4tjB}?}cebXhMwDcWVH#C7;ezj${GGLd((VfRt zk9-#Q-SPlV*!Ln_bI+U5)Z1lTW81Xb3Xz(2VlkR}Tp{XTq+}==Zd0OL_f1xZZYqaM z$80m8n72X(f|FK)sZ-~pS{cEdh5fK@9HXNXsMa@O!Mwwz3}Rcbi!oxB&F?QSIIdWj zx>(6VaVGmk*5<(bg6N3tnEv$EiVjmlm zKuU#5Wh;L1&Bp-%AN|S+IN+dtu>8SW;MiEQQXoi>G#VR3kNlOA0hCa%=}ubL{Rw#g z8>O^z*aor(V1b*ij4|}&n%zkb0KoqRbb1&ct<2Ko0000bbVXQnWMOn=I%9HWVRU5x zGB7bQEigGPGBQ*!IXW{kIx{jYFgH3dFsPDZ%m4rYC3HntbYx+4WjbwdWNBu305UK! pF)c7TEipD!FgH3fH###mEigAaFfey&@l*f+002ovPDHLkV1iQC3p)S+ literal 0 HcmV?d00001 diff --git a/android/examples/simpleclient/src/main/res/drawable-xxhdpi/ic_launcher.png b/android/examples/simpleclient/src/main/res/drawable-xxhdpi/ic_launcher.png new file mode 100755 index 0000000000000000000000000000000000000000..4df18946442ed763bd52cf3adca31617848656fa GIT binary patch literal 19388 zcmV)wK$O3UP)Px#AY({UO#lFTCIA3{ga82g0001h=l}q9FaQARU;qF* zm;eA5aGbhPJOBUy24YJ`L;wH)0002_L%V+f000SaNLh0L02dMf02dMgXP?qi002pU zNkl|h&1u(8czNZ4@#f$#wV0)!Ag z0v`kdaZJA80Etb`em&5Y!E zUqa2Vr|;XhZ+9(EpYxohs)2tf|4`1N(7CR_lTdd#*A@G}sSVM&uD}@-3icHIEogT9 zb{>Rw-DkC7JJ-J|`dnAwG>h+a4T1&`?>~PbW?^0Atb+3d+gG~!HYm6UI6D8r#W>H6 zwno(1UHZ#kb`pT9jweMCgp$4I_j^Yl9Tqx59L1_@ipE2`9YIt*07QrZBrAJ*y<Z$tDT`3MX%djE2uvg_2DFw!uERrrpiu}Kng&7(Pi`f z%{4psj+%BfOWY=!RJ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%(08A%}IcAuTTyxnQqMv4LU>Ix&M7aTDfYh0*a#y1y5MrT4nW3|7AvG3|{#op5JB zZI&qN>r<4>f!N;berv<2ms@HsBoR_^iGPn@fxq7P^G8not6xh=Ye_t&x%!FL9>GS> zr@MC_UbJZb<3X42quWNGPSke#Ud{_<9+s`?1JLBvPKmrU`#Y>;-|WyIGzYzl z;bzz6w(l5Tms|MrlW3O)Q&#VcK^Fqn(D{_wZ&wHb#@$ zCbd+T$M~v5g4Xbf?>C!;f?T)T9V(l@?3&GAu71)SY}jfbs~m7x9)s>yDpS^6YMoyv zXoY=t*$C?!neh<+TJvI2HBycBQ9gCPk^Pixp?98{Pw@sOP}kfO$DZ<2#eX`eH-s&< z7qqCaL#PJo-Zexx~6xkH{GZw zCc!5lphQbH2*&madGEpUZ|CTwUK>rjR96lPv&e-DaW<|`ZT@urL0eCP-AWd80b26& zcAyI%rM_P2Msh+;9WHW$A)Z|y|6q_iYn(pql!xBlIKSIcYd?`+))d(>R4u{5w9Y;4 z&Bt2fIA@#Y2*7aTLFjCb4jC7^TU4m2} zv>h1UNRQ)v7kg>x-1p5lBi+X@nfG(4jPESBs~Apa(7&aNT%}Bkyik2o34dHIUH{YL z**g{8V;Hxi7PUs+j-F~we5@_#o5rAEz21K|$-6koV00aV*BgQynhM)C;qCV0UO0|P;7pn4D+rcyuzmRw(k`H+26EglR%2C_dcS5K7~}*L_rV_*p^v<@IGuq07)S5&#aC>Abr0Kbg?0k fedym91iL@%p^iY2K86jjF~HQs0{hVDO4NS<0ONux literal 0 HcmV?d00001 diff --git a/android/examples/simpleclient/src/main/res/layout/activity_main.xml b/android/examples/simpleclient/src/main/res/layout/activity_main.xml new file mode 100755 index 0000000..9aecf74 --- /dev/null +++ b/android/examples/simpleclient/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/android/examples/simpleclient/src/main/res/menu/menu_main.xml b/android/examples/simpleclient/src/main/res/menu/menu_main.xml new file mode 100755 index 0000000..a1045e9 --- /dev/null +++ b/android/examples/simpleclient/src/main/res/menu/menu_main.xml @@ -0,0 +1,6 @@ +

+ + diff --git a/android/examples/simpleclient/src/main/res/values-w820dp/dimens.xml b/android/examples/simpleclient/src/main/res/values-w820dp/dimens.xml new file mode 100755 index 0000000..62df187 --- /dev/null +++ b/android/examples/simpleclient/src/main/res/values-w820dp/dimens.xml @@ -0,0 +1,6 @@ + + + 64dp + diff --git a/android/examples/simpleclient/src/main/res/values/dimens.xml b/android/examples/simpleclient/src/main/res/values/dimens.xml new file mode 100755 index 0000000..295b5a9 --- /dev/null +++ b/android/examples/simpleclient/src/main/res/values/dimens.xml @@ -0,0 +1,5 @@ + + + 16dp + 16dp + diff --git a/android/examples/simpleclient/src/main/res/values/strings.xml b/android/examples/simpleclient/src/main/res/values/strings.xml new file mode 100755 index 0000000..575b3e0 --- /dev/null +++ b/android/examples/simpleclient/src/main/res/values/strings.xml @@ -0,0 +1,8 @@ + + + + Starting Simple Client + Hello world! + Settings + + diff --git a/android/examples/simpleclient/src/main/res/values/styles.xml b/android/examples/simpleclient/src/main/res/values/styles.xml new file mode 100755 index 0000000..084b42b --- /dev/null +++ b/android/examples/simpleclient/src/main/res/values/styles.xml @@ -0,0 +1,8 @@ + + + + + + diff --git a/android/examples/simpleserver/.gitignore b/android/examples/simpleserver/.gitignore new file mode 100755 index 0000000..3543521 --- /dev/null +++ b/android/examples/simpleserver/.gitignore @@ -0,0 +1 @@ +/build diff --git a/android/examples/simpleserver/build.gradle b/android/examples/simpleserver/build.gradle new file mode 100755 index 0000000..3ecd031 --- /dev/null +++ b/android/examples/simpleserver/build.gradle @@ -0,0 +1,27 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 21 + buildToolsVersion "21.1.2" + + defaultConfig { + applicationId "org.iotivity.base.examples.simpleserver" + minSdkVersion 19 + targetSdkVersion 21 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + +} + +dependencies { + //compile fileTree(dir: 'libs', include: ['*.so']) + compile project(':message') + compile 'com.android.support:appcompat-v7:21.0.3' +} diff --git a/android/examples/simpleserver/simpleserver.iml b/android/examples/simpleserver/simpleserver.iml new file mode 100755 index 0000000..c668fa1 --- /dev/null +++ b/android/examples/simpleserver/simpleserver.iml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/examples/simpleserver/src/main/AndroidManifest.xml b/android/examples/simpleserver/src/main/AndroidManifest.xml new file mode 100755 index 0000000..43352f4 --- /dev/null +++ b/android/examples/simpleserver/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + diff --git a/android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/LightRepThread.java b/android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/LightRepThread.java new file mode 100755 index 0000000..0993995 --- /dev/null +++ b/android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/LightRepThread.java @@ -0,0 +1,86 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +/* + * // Starts a new thread for OBSERVE. It increments the value of mPower by 10 every 3 seconds + */ +package org.iotivity.base.examples.simpleserver; + +import android.util.Log; + +import org.iotivity.base.EntityHandlerResult; +import org.iotivity.base.OcException; +import org.iotivity.base.OcPlatform; +import org.iotivity.base.OcRepresentation; +import org.iotivity.base.OcResourceResponse; + +import java.util.List; + +/** + * LightRepThread + * + * Spawn a thread for OBSERVE. This increments the resource's power value by 10 every 3 seconds. + * If there is an observationList, call notifyListOfObservers(). Otherwise, call notifyAllObservers() + */ +public class LightRepThread extends Thread { + private static String TAG = "LightRepThread: "; + + private LightResource mLightResource; + private List mObservationList; + private static int count = 0; + + LightRepThread(Object lr, List observationList) { + mLightResource = (LightResource)lr; + mObservationList = observationList; + } + + public void run() { + while(count < 20) { + try { + sleep(3000); + } catch (InterruptedException e) { + Log.e(TAG, e.getMessage()); + } + + // increment current power value by 10 every 3 seconds + mLightResource.setPower(mLightResource.getPower() + 10); + try { + // if observationList is not empty, call notifyListOfObservers + if (mObservationList.size() > 0) { + OcResourceResponse ocResourceResponse = new OcResourceResponse(); + ocResourceResponse.setErrorCode(StringConstants.ERROR_CODE); + ocResourceResponse.setResponseResult(EntityHandlerResult.OK); + OcRepresentation r = mLightResource.get(); + ocResourceResponse.setResourceRepresentation + (mLightResource.get(), OcPlatform.DEFAULT_INTERFACE); + OcPlatform.notifyListOfObservers(mLightResource.getHandle(), mObservationList, ocResourceResponse); + } else { + // notify all observers if mObservationList is empty + OcPlatform.notifyAllObservers(mLightResource.getHandle()); + } + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + ++count; + } + } +} diff --git a/android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/LightResource.java b/android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/LightResource.java new file mode 100755 index 0000000..e8414a0 --- /dev/null +++ b/android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/LightResource.java @@ -0,0 +1,308 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base.examples.simpleserver; + +import android.content.Context; +import android.content.Intent; +import android.util.Log; + +import org.iotivity.base.EntityHandlerResult; +import org.iotivity.base.ObservationInfo; +import org.iotivity.base.OcException; +import org.iotivity.base.OcPlatform; +import org.iotivity.base.OcRepresentation; +import org.iotivity.base.OcResourceHandle; +import org.iotivity.base.OcResourceRequest; +import org.iotivity.base.OcResourceResponse; +import org.iotivity.base.RequestHandlerFlag; +import org.iotivity.base.RequestType; +import org.iotivity.base.ResourceProperty; + +import java.util.EnumSet; +import java.util.LinkedList; +import java.util.List; + +import base.iotivity.org.examples.message.IMessageLogger; + +/** + * LightResource + * + * class LightResource is the main class of the simpleServer. This creates resources and handles incoming requests from the client. + */ +public class LightResource implements IMessageLogger { + private Context mContext; + private static String TAG = "SimpleServer: "; + + private String mName; + private Boolean mState; + private Integer mPower; + private OcRepresentation mLightRep; + private OcResourceHandle mResourceHandle; + private List mObservationIds; + private static boolean doOnce; // used in POST + LightRepThread lightRepThread; + + // constructor + LightResource(Context context) { + mContext = context; + mName = "John's light"; + mState = false; + mPower = 0; + mObservationIds = new LinkedList<>(); + mLightRep = new OcRepresentation(); + try { + mLightRep.setValue(StringConstants.STATE, mState); + mLightRep.setValue(StringConstants.POWER, mPower); + mLightRep.setValue(StringConstants.NAME, mName); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + doOnce = true; // used in post + lightRepThread = null; + } + + //accessor methods + protected int getPower() { + return mPower; + } + protected void setPower(int power) { + mPower = power; + } + protected OcResourceHandle getHandle() { + return mResourceHandle; + } + + /** + * creates a resource. this method internally calls registerResource + * @return returns the OcResourceHandle after creating and registering the resource + */ + protected OcResourceHandle createResource0() { + // entityhandler for registerResource + OcPlatform.EntityHandler eh = new OcPlatform.EntityHandler() { + @Override + public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) { + // this is where the main logic of simpleserver is handled as different requests (GET, PUT, POST, OBSERVE, DELETE) are handled + return entityHandler(ocResourceRequest); + } + }; + + try { + mResourceHandle = OcPlatform.registerResource(StringConstants.RESOURCE_URI0, StringConstants.RESOURCE_TYPENAME, + StringConstants.RESOURCE_INTERFACE, eh, + EnumSet.of(ResourceProperty.DISCOVERABLE, ResourceProperty.OBSERVABLE)); + } catch (OcException e) { + logMessage(TAG + "RegisterResource error. " + e.getMessage()); + Log.e(TAG, e.getMessage()); + } + logMessage(TAG + "Successfully registered resource"); + return mResourceHandle; + } + + /** + * create another resource. this method internally calls registerResource + */ + private void createResource1() { + // entityhandler for registerResource + OcPlatform.EntityHandler eh = new OcPlatform.EntityHandler() { + @Override + public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) { + // this is where the main logic of simpleserver is handled as different requests (GET, PUT, POST, OBSERVE, DELETE) are handled + return entityHandler(ocResourceRequest); + } + }; + + try { + OcPlatform.registerResource(StringConstants.RESOURCE_URI1, StringConstants.RESOURCE_TYPENAME, + StringConstants.RESOURCE_INTERFACE, eh, + EnumSet.of(ResourceProperty.DISCOVERABLE, ResourceProperty.OBSERVABLE)); + } catch (OcException e) { + logMessage(TAG + "RegisterResource1 error: " + e.getMessage()); + Log.e(TAG, e.getMessage()); + } + logMessage(TAG + "Successfully registered resource1"); + } + + /** + * post representation . Post can act like put or can create a new resource. + * Gets value from the representation and updates the internal state + * @param rep current OcRepresentation of the object + * @return updated OcRepresentation + */ + private OcRepresentation post(OcRepresentation rep) { + //create a resource the first time + if (true == doOnce) { + createResource1(); + OcRepresentation representation = rep; + try { + representation.setValue(StringConstants.CREATED_URI, StringConstants.RESOURCE_URI1); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + doOnce = false; + return representation; + } + // from second time onwards, put + put(rep); + return get(); + } + + /** + * puts representation . Gets value from the representation and updates the internal state + * @param rep current OcRepresentation of the object + */ + private void put(OcRepresentation rep) { + try { + mState = rep.getValue(StringConstants.STATE); + mPower = rep.getValue(StringConstants.POWER); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + logMessage(TAG + "Put State: " + mState + " Name: " + mName + " Power: " + mPower); + } + + /** + * gets the updated representation. Updates the representation with internal state before sending out + * @return OcRepresentation after updating the values of the lightRepresentation + */ + protected OcRepresentation get() { + try { + mLightRep.setValue(StringConstants.STATE, mState); + mLightRep.setValue(StringConstants.POWER, mPower); + mLightRep.setValue(StringConstants.NAME, mName); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + return mLightRep; + } + + /** + * this is the main method which handles different incoming requests appropriately. + * Init is not supported currently. + * @param request OcResourceRequest from the client + * @return EntityHandlerResult depending on whether the request was handled successfully or not + */ + private EntityHandlerResult entityHandler(OcResourceRequest request) { + EntityHandlerResult result = EntityHandlerResult.ERROR; + if (null != request) { + RequestType requestType = request.getRequestType(); + EnumSet requestFlag = request.getRequestHandlerFlagSet(); + + if (requestFlag.contains(RequestHandlerFlag.INIT)) { + logMessage(TAG + "Init"); + } + if (requestFlag.contains(RequestHandlerFlag.REQUEST)) { + try { + logMessage(TAG + "Request"); + OcResourceResponse ocResourceResponse = new OcResourceResponse(); + ocResourceResponse.setRequestHandle(request.getRequestHandle()); + ocResourceResponse.setResourceHandle(request.getResourceHandle()); + + switch (requestType) { + // handle GET request + case GET: + logMessage("GET"); + ocResourceResponse.setResponseResult(EntityHandlerResult.OK); + ocResourceResponse.setErrorCode(StringConstants.ERROR_CODE); + ocResourceResponse.setResourceRepresentation(get()); + OcPlatform.sendResponse(ocResourceResponse); + break; + // handle PUT request + case PUT: + OcRepresentation rep = request.getResourceRepresentation(); + put(rep); + ocResourceResponse.setErrorCode(StringConstants.ERROR_CODE); + ocResourceResponse.setResponseResult(EntityHandlerResult.OK); + ocResourceResponse.setResourceRepresentation(get()); + OcPlatform.sendResponse(ocResourceResponse); + break; + // handle POST request + case POST: + rep = request.getResourceRepresentation(); + OcRepresentation rep_post = post(rep); + ocResourceResponse.setResourceRepresentation(rep_post); + ocResourceResponse.setErrorCode(StringConstants.ERROR_CODE); + if (rep_post.hasAttribute(StringConstants.CREATED_URI)) { + String createdUri = rep_post.getValue(StringConstants.CREATED_URI); + if (createdUri.equals(StringConstants.RESOURCE_URI1)) { + ocResourceResponse.setNewResourceUri(createdUri); + ocResourceResponse.setResponseResult + (EntityHandlerResult.RESOURCE_CREATED); + } else { + ocResourceResponse.setResponseResult(EntityHandlerResult.OK); + } + } + OcPlatform.sendResponse(ocResourceResponse); + break; + // handle DELETE request + case DELETE: + logMessage(TAG + "DELETE"); + OcPlatform.unregisterResource(getHandle()); + OcPlatform.unregisterResource(getHandle()); + break; + + } + + result = EntityHandlerResult.OK; + } catch(OcException e) { + logMessage(TAG + "Error in Request " + e.getMessage()); + Log.e(TAG, e.getMessage()); + } + } + // handle OBSERVER request + if (requestFlag.contains(RequestHandlerFlag.OBSERVER)) { + logMessage(TAG + "OBSERVER"); + ObservationInfo observationInfo = request.getObservationInfo(); + + switch (observationInfo.getObserveAction()) { + case REGISTER: + synchronized (mObservationIds) { + mObservationIds.add(observationInfo.getOcObservationId()); + } + break; + case UNREGISTER: + synchronized (mObservationIds) { + mObservationIds.remove(observationInfo.getOcObservationId()); + } + break; + } + if (null == lightRepThread) { + lightRepThread = new LightRepThread(this, mObservationIds); + lightRepThread.run(); + } + result = EntityHandlerResult.OK; + } + } + return result; + } + + @Override + public void logMessage(String msg) { + logMsg(msg); + } + + public void logMsg(final String text) { + Intent intent = new Intent("org.iotivity.base.examples.simpleserver"); + intent.putExtra(StringConstants.MESSAGE, text); + mContext.sendBroadcast(intent); + } +} \ No newline at end of file diff --git a/android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/SimpleServer.java b/android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/SimpleServer.java new file mode 100755 index 0000000..31b5c6a --- /dev/null +++ b/android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/SimpleServer.java @@ -0,0 +1,145 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base.examples.simpleserver; + +import android.app.Activity; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.os.Bundle; +import android.os.Message; +import android.support.v4.content.LocalBroadcastManager; +import android.text.method.ScrollingMovementMethod; +import android.util.Log; +import android.view.Menu; +import android.view.MenuItem; +import android.widget.LinearLayout; +import android.widget.TextView; + +import org.iotivity.base.ModeType; +import org.iotivity.base.OcPlatform; +import org.iotivity.base.OcRepresentation; +import org.iotivity.base.PlatformConfig; +import org.iotivity.base.QualityOfService; +import org.iotivity.base.ServiceType; + +import base.iotivity.org.examples.message.IMessageLogger; + +/** + * SimpleServer + * + * SimpleServer instantiates a TextView and creates and configures OICPlatform. + * It also creates a LightResource and waits for the incoming client requests to handle specific scenarios. + * This implements IMessageLogger to display messages on the screen + */ + +public class SimpleServer extends Activity implements IMessageLogger { + private final static String TAG = "SimpleServer: "; + private TextView mEventsTextView; + private MessageReceiver mMessageReceiver = new MessageReceiver(); + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + registerReceiver(mMessageReceiver, new IntentFilter("org.iotivity.base.examples.simpleserver")); + + mEventsTextView = new TextView(this); + mEventsTextView.setMovementMethod(new ScrollingMovementMethod()); + LinearLayout layout = (LinearLayout)findViewById(R.id.linearLayout); + layout.addView(mEventsTextView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f)); + + OcRepresentation rep = new OcRepresentation(); + rep.setValueBool("test", false); + boolean result = rep.getValueBool("test"); + + initOICStack(); + } + + /** + * configure OIC platform and call findResource + */ + private void initOICStack() { + //create platform config + PlatformConfig cfg = new PlatformConfig( + this, + ServiceType.IN_PROC, + ModeType.SERVER, + "0.0.0.0", // bind to all available interfaces + 0, + QualityOfService.LOW); + OcPlatform.Configure(cfg); + // Create instance of lightResource + LightResource myLight = new LightResource(this); + // create and register a resource + myLight.createResource0(); + } + + public class MessageReceiver extends BroadcastReceiver { + @Override + public void onReceive(Context context, Intent intent) { + final String message = intent.getStringExtra(StringConstants.MESSAGE); + logMessage(message); + } + } + + public void logMessage(final String text) { + runOnUiThread(new Runnable() { + public void run() { + final Message msg = new Message(); + msg.obj = text; + mEventsTextView.append("\n"); + mEventsTextView.append(text); + } + }); + Log.i(TAG, text); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.menu_main, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + int id = item.getItemId(); + if (id == R.id.action_settings) { + return true; + } + return super.onOptionsItemSelected(item); + } + + @Override + public void onDestroy() { + super.onDestroy(); + onStop(); + } + + @Override + protected void onStop() { + LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver); + super.onStop(); + } +} \ No newline at end of file diff --git a/android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/StringConstants.java b/android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/StringConstants.java new file mode 100755 index 0000000..98f33d0 --- /dev/null +++ b/android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/StringConstants.java @@ -0,0 +1,21 @@ +package org.iotivity.base.examples.simpleserver; + +import org.iotivity.base.OcPlatform; +/** + * StringConstants contains the simpleserver specific constant values. To add another supported + * Resource or Interface type to this app, begin by adding the new strings here, and then + * find the places throughout the app where Resource-specific case switches occur, and add + * the newly-supported type there. + */ +public interface StringConstants { + public static final String RESOURCE_URI0 = "/light0"; + public static final String RESOURCE_URI1 = "/light1"; + public static final String RESOURCE_TYPENAME = "core.light"; + public static final String RESOURCE_INTERFACE = OcPlatform.DEFAULT_INTERFACE; //resource interface + public static final String CREATED_URI = "createduri"; + public static final String STATE = "state"; + public static final String NAME = "name"; + public static final String POWER = "power"; + public static final String MESSAGE = "message"; + public static final int ERROR_CODE = 200; +} diff --git a/android/examples/simpleserver/src/main/res/drawable-hdpi/ic_launcher.png b/android/examples/simpleserver/src/main/res/drawable-hdpi/ic_launcher.png new file mode 100755 index 0000000000000000000000000000000000000000..96a442e5b8e9394ccf50bab9988cb2316026245d GIT binary patch literal 9397 zcmV;mBud+fP)L`9r|n3#ts(U@pVoQ)(ZPc(6i z8k}N`MvWQ78F(rhG(?6FnFXYo>28{yZ}%O}TvdDT_5P?j=iW=V`8=UNc_}`JbG!ST zs@lK(TWkH+P**sB$A`cEY%Y53cQ}1&6`x-M$Cz&{o9bLU^M-%^mY?+vedlvt$RT-^ zu|w7}IaWaljBq#|I%Mpo!Wc2bbZF3KF9|D%wZe{YFM=hJAv$>j>nhx`=Wis#KG!cJA5x!4)f) zezMz1?Vn$GnZNjbFXH(pK83nn!^3=+^*kTTs5rV9Dq^XS(IKO!mKt5!d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literal 0 HcmV?d00001 diff --git a/android/examples/simpleserver/src/main/res/drawable-xhdpi/ic_launcher.png b/android/examples/simpleserver/src/main/res/drawable-xhdpi/ic_launcher.png new file mode 100755 index 0000000000000000000000000000000000000000..71c6d760f05183ef8a47c614d8d13380c8528499 GIT binary patch literal 14383 zcmV+~IMBz5P)>IR{Zx9EA~4K?jU8DyU!%BVu|c#=(H1 zIAFva(2=Yn8AKWhO=@Vm>As!A%_mpwu-+fLs?Ir051^0kZ=Q9(`cB=t=bYMm<@H-@ z?@QQC#}7(lHuiOKOg-hI-&yJQ@X z>38Dx`mgcs{{O@!m2+^EdNUPDF+a6!8!8*d@!BI^jeED=gH;btqEI5d{e*jVDP7bq z{q~MSBE(fsoQg6}7k95+Ji!s3$poDp-qlOkXAwnM{3JB1P1P!!MLkm@C24>Si7~v(J@mNzG-t<6(_#~IP~Z}QN`;~#%u^^ zBv=E1KsZ>EXwWhEA%MjWSj+&p1YiKMScFGKjPH_0g9QS9!hVpahud$BNHq6km8f&$y)VmTQ`qJPd+?0zVd*nDN_N;fDC>PCKgkkd- zF&a`~zS4LCy*S)Om}M0r157c%Vz&|}g=6?|;XWKwAQT*MxQ#H?lrYWC!I5q;pTUZZ zoF|S^mMxt;_qPCIXf(txX5a0Ww;uk~=vd{jwJXPI%UbvK`FqRT9{O`bUiO)BJM_2% z(XOY!tbcIB+EHv;)4J*BV9|&y5&#Sa0{{$SB&foHK?p!lAcP=9mJn^Q zEdF4f`u+CiwmYVjr%WuN^Du#n`yU&B^3IJzBL_Zu-$?zTyBfz|`{R*^-t)z|a`kd+ z3q1~f(k6y5Nm3x1Yb_kKdg+KYV*sjIe!V z{5>Bz^<6`n@li*u;}T2+4lyJ`2oxNk906cBFdVfoiU|zCpa} z1i&zeF@X)3#Clk0*p&E|Ev$2}*1}l_W2{Z$7(q~!&ar*`feE?ciQuhsm(q`Gl}fN+ z@eJbtu1z-J9Kjlg^G?2Vm(yjpIN`_LzXAXv^r3($xF(p5y?b9P1*F-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2VlkR}Tp{XTq+}==Zd0OL_f1xZZYqaM z$80m8n72X(f|FK)sZ-~pS{cEdh5fK@9HXNXsMa@O!Mwwz3}Rcbi!oxB&F?QSIIdWj zx>(6VaVGmk*5<(bg6N3tnEv$EiVjmlm zKuU#5Wh;L1&Bp-%AN|S+IN+dtu>8SW;MiEQQXoi>G#VR3kNlOA0hCa%=}ubL{Rw#g z8>O^z*aor(V1b*ij4|}&n%zkb0KoqRbb1&ct<2Ko0000bbVXQnWMOn=I%9HWVRU5x zGB7bQEigGPGBQ*!IXW{kIx{jYFgH3dFsPDZ%m4rYC3HntbYx+4WjbwdWNBu305UK! pF)c7TEipD!FgH3fH###mEigAaFfey&@l*f+002ovPDHLkV1iQC3p)S+ literal 0 HcmV?d00001 diff --git a/android/examples/simpleserver/src/main/res/drawable-xxhdpi/ic_launcher.png b/android/examples/simpleserver/src/main/res/drawable-xxhdpi/ic_launcher.png new file mode 100755 index 0000000000000000000000000000000000000000..4df18946442ed763bd52cf3adca31617848656fa GIT binary patch literal 19388 zcmV)wK$O3UP)Px#AY({UO#lFTCIA3{ga82g0001h=l}q9FaQARU;qF* zm;eA5aGbhPJOBUy24YJ`L;wH)0002_L%V+f000SaNLh0L02dMf02dMgXP?qi002pU zNkl|h&1u(8czNZ4@#f$#wV0)!Ag z0v`kdaZJA80Etb`em&5Y!E zUqa2Vr|;XhZ+9(EpYxohs)2tf|4`1N(7CR_lTdd#*A@G}sSVM&uD}@-3icHIEogT9 zb{>Rw-DkC7JJ-J|`dnAwG>h+a4T1&`?>~PbW?^0Atb+3d+gG~!HYm6UI6D8r#W>H6 zwno(1UHZ#kb`pT9jweMCgp$4I_j^Yl9Tqx59L1_@ipE2`9YIt*07QrZBrAJ*y<Z$tDT`3MX%djE2uvg_2DFw!uERrrpiu}Kng&7(Pi`f z%{4psj+%BfOWY=!RJ}WRO`2o z1*lMUb-KNH?&zVBdgsT!`NuFndHUV=K5Xy1^CUJ_i+==wl8z4RzOBnn0#H>3{Umz- z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f!N;berv<2ms@HsBoR_^iGPn@fxq7P^G8not6xh=Ye_t&x%!FL9>GS> zr@MC_UbJZb<3X42quWNGPSke#Ud{_<9+s`?1JLBvPKmrU`#Y>;-|WyIGzYzl z;bzz6w(l5Tms|MrlW3O)Q&#VcK^Fqn(D{_wZ&wHb#@$ zCbd+T$M~v5g4Xbf?>C!;f?T)T9V(l@?3&GAu71)SY}jfbs~m7x9)s>yDpS^6YMoyv zXoY=t*$C?!neh<+TJvI2HBycBQ9gCPk^Pixp?98{Pw@sOP}kfO$DZ<2#eX`eH-s&< z7qqCaL#PJo-Zexx~6xkH{GZw zCc!5lphQbH2*&madGEpUZ|CTwUK>rjR96lPv&e-DaW<|`ZT@urL0eCP-AWd80b26& zcAyI%rM_P2Msh+;9WHW$A)Z|y|6q_iYn(pql!xBlIKSIcYd?`+))d(>R4u{5w9Y;4 z&Bt2fIA@#Y2*7aTLFjCb4jC7^TU4m2} zv>h1UNRQ)v7kg>x-1p5lBi+X@nfG(4jPESBs~Apa(7&aNT%}Bkyik2o34dHIUH{YL z**g{8V;Hxi7PUs+j-F~we5@_#o5rAEz21K|$-6koV00aV*BgQynhM)C;qCV0UO0|P;7pn4D+rcyuzmRw(k`H+26EglR%2C_dcS5K7~}*L_rV_*p^v<@IGuq07)S5&#aC>Abr0Kbg?0k fedym91iL@%p^iY2K86jjF~HQs0{hVDO4NS<0ONux literal 0 HcmV?d00001 diff --git a/android/examples/simpleserver/src/main/res/layout/activity_main.xml b/android/examples/simpleserver/src/main/res/layout/activity_main.xml new file mode 100755 index 0000000..ebe6ef7 --- /dev/null +++ b/android/examples/simpleserver/src/main/res/layout/activity_main.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + diff --git a/android/examples/simpleserver/src/main/res/menu/menu_main.xml b/android/examples/simpleserver/src/main/res/menu/menu_main.xml new file mode 100755 index 0000000..a1045e9 --- /dev/null +++ b/android/examples/simpleserver/src/main/res/menu/menu_main.xml @@ -0,0 +1,6 @@ + + + diff --git a/android/examples/simpleserver/src/main/res/values-w820dp/dimens.xml b/android/examples/simpleserver/src/main/res/values-w820dp/dimens.xml new file mode 100755 index 0000000..62df187 --- /dev/null +++ b/android/examples/simpleserver/src/main/res/values-w820dp/dimens.xml @@ -0,0 +1,6 @@ + + + 64dp + diff --git a/android/examples/simpleserver/src/main/res/values/dimens.xml b/android/examples/simpleserver/src/main/res/values/dimens.xml new file mode 100755 index 0000000..295b5a9 --- /dev/null +++ b/android/examples/simpleserver/src/main/res/values/dimens.xml @@ -0,0 +1,5 @@ + + + 16dp + 16dp + diff --git a/android/examples/simpleserver/src/main/res/values/strings.xml b/android/examples/simpleserver/src/main/res/values/strings.xml new file mode 100755 index 0000000..4414f1d --- /dev/null +++ b/android/examples/simpleserver/src/main/res/values/strings.xml @@ -0,0 +1,8 @@ + + + + SimpleServer + Starting Simple Server... + Settings + + diff --git a/android/examples/simpleserver/src/main/res/values/styles.xml b/android/examples/simpleserver/src/main/res/values/styles.xml new file mode 100755 index 0000000..084b42b --- /dev/null +++ b/android/examples/simpleserver/src/main/res/values/styles.xml @@ -0,0 +1,8 @@ + + + + + + diff --git a/auto_build.sh b/auto_build.sh index ea12dd6..19c3440 100755 --- a/auto_build.sh +++ b/auto_build.sh @@ -25,25 +25,18 @@ function build() # Note: for android, as oic-resource uses C++11 feature stoi and to_string, # it requires gcc-4.9, currently only android-ndk-r10(for linux) # and windows android-ndk-r10(64bit target version) support these features. - if [ "$BUILD_FOR_ANDROID" = "true" ] - then - echo "*********** Build Boost for android ***********" - pushd extlibs - .//buildDependencies.sh - popd + echo "*********** Build Boost for android ***********" + # disable parallel build for android as gradle depends on scons to finish first + export SCONSFLAGS="-Q" - echo "*********** Build for android x86 *************" - scons TARGET_OS=android TARGET_ARCH=x86 ANDROID_NDK=$1 RELEASE=$3 + echo "*********** Build for android x86 *************" + scons TARGET_OS=android TARGET_ARCH=x86 RELEASE=$3 TARGET_TRANSPORT=IP - echo "*********** Build for android armeabi *************" - scons TARGET_OS=android TARGET_ARCH=armeabi ANDROID_NDK=$1 RELEASE=$3 + echo "*********** Build for android armeabi *************" + scons TARGET_OS=android TARGET_ARCH=armeabi RELEASE=$3 TARGET_TRANSPORT=IP - echo "*********** Build for android armeabi-v7a *************" - scons TARGET_OS=android TARGET_ARCH=armeabi-v7a ANDROID_NDK=$1 RELEASE=$3 - - echo "*********** Build for android armeabi-v7a-hard *************" - scons TARGET_OS=android TARGET_ARCH=armeabi-v7a-hard ANDROID_NDK=$1 RELEASE=$3 - fi + # enable parallel build + export SCONSFLAGS="-Q -j 4" echo "*********** Build for arduino avr *************" scons resource TARGET_OS=arduino UPLOAD=false BOARD=mega TARGET_ARCH=avr TARGET_TRANSPORT=IP SHIELD=ETH RELEASE=$3 @@ -53,6 +46,7 @@ function build() scons resource TARGET_OS=arduino UPLOAD=false BOARD=arduino_due_x TARGET_ARCH=arm TARGET_TRANSPORT=IP SHIELD=ETH RELEASE=$3 scons resource TARGET_OS=arduino UPLOAD=false BOARD=arduino_due_x TARGET_ARCH=arm TARGET_TRANSPORT=IP SHIELD=WIFI RELEASE=$3 + if [ $(uname -s) = "Darwin" ] then echo "*********** Build for OSX *************" @@ -109,3 +103,4 @@ scons resource LOGGING=false RELEASE=false scons resource TEST=1 RELEASE=false echo "===================== done =====================" + diff --git a/build_common/android/SConscript b/build_common/android/SConscript index 7dfac8c..6a88107 100644 --- a/build_common/android/SConscript +++ b/build_common/android/SConscript @@ -6,22 +6,42 @@ import platform import subprocess Import('env') +SConscript('../external_libs.scons') +SConscript('../../extlibs/android/ndk/SConscript') +SConscript('../../extlibs/android/gradle/SConscript') +SConscript('../../extlibs/android/sdk/SConscript') help_vars = Variables() -help_vars.Add(PathVariable('ANDROID_NDK', 'Android NDK root directory', os.environ.get('ANDROID_NDK'))) -help_vars.Update(env) -Help(help_vars.GenerateHelpText(env)) +help_vars.Add(PathVariable('ANDROID_GRADLE', 'Android Gradle directory', os.path.join(env.get('SRC_DIR'), 'extlibs', 'android', 'gradle', 'gradle-2.2.1/bin/gradle'))) +help_vars.Add(PathVariable('ANDROID_NDK', 'Android NDK root directory', os.path.join(env.get('SRC_DIR'), 'extlibs', 'android', 'ndk', 'android-ndk-r10d'))) -android_ndk = env.get('ANDROID_NDK') -if not android_ndk: +if env.get('ANDROID_NDK'): + android_ndk = env.get('ANDROID_NDK') +else: print ''' -*************************************** Error ********************************* -* Android NDK path isn't set, you can set enviornment variable ANDROID_NDK * -* or add it in command line as: * +*************************************** Info ********************************** +* Android NDK path isn't set, the default will be used. You can set * +* environment variable ANDROID_NDK or add it in command line as: * * # scons ANDROID_NDK= ... * ******************************************************************************* ''' - Exit(1) + android_ndk = os.path.join(env.get('SRC_DIR'), 'extlibs', 'android', 'ndk', 'android-ndk-r10d') + +if env.get('ANDROID_GRADLE'): + android_gradle = env.get('ANDROID_GRADLE') +else: + print ''' +*************************************** Info ********************************** +* Android Gradle path isn't set, the default will be used. You can set * +* environment variable ANDROID_GRADLE or add it in command line as: * +* # scons ANDROID_GRADLE= ... * +******************************************************************************* +''' + android_gradle = os.path.join(env.get('SRC_DIR'), 'extlibs', 'android', 'gradle', 'gradle-2.2.1', 'bin', 'gradle') + +help_vars.Update(env) +Help(help_vars.GenerateHelpText(env)) +src_dir = env.get('SRC_DIR') # Overwrite suffixes and prefixes if env['HOST_OS'] == 'win32': @@ -66,15 +86,17 @@ if not os.path.isfile(ndk_build_cmd): ''' % android_ndk Exit(1) -ANDROID_HOME = os.environ.get('ANDROID_HOME') -if ANDROID_HOME is not None: - ANDROID_HOME = os.path.abspath(ANDROID_HOME) +# ANDROID_HOME build option +help_vars = Variables() +help_vars.Add(PathVariable('ANDROID_HOME', 'ANDROID SDK root directory', os.environ.get('ANDROID_HOME'))) +help_vars.Update(env) +Help(help_vars.GenerateHelpText(env)) -if ANDROID_HOME is None or not os.path.exists(ANDROID_HOME): - print ''' -*************************************** Warning ******************************* -* Enviornment variable ANDROID_HOME is not set properly. It should be the * -* root directory of android sdk. If you'd like build Java code, it's required.* +print ''' +*************************************** Info ********************************** +* Environment variable ANDROID_HOME will use default value. To override * +* root directory of android sdk, please specify ANDROID_HOME as follows: * +* scons ANDROID_HOME= * ******************************************************************************* ''' @@ -88,6 +110,7 @@ for tc_ver in ['4.7', '4.8', '4.9', '']: cmd = [ndk_build_cmd] cmd.append('APP_ABI=' + target_arch) +cmd.append('APP_PLATFORM=android-21') cmd.append('APP_STL=gnustl_shared') if env.get('RELEASE'): cmd.append('APP_OPTIM=release') @@ -151,6 +174,12 @@ for flags in p.stdout.readlines(): if not platform_ver.isdigit(): platform_ver = '' + + elif cmp(flags[0:9], 'PLATFORM=') == 0: # get target platform: android-x + platform_ver = flags[9+8:].strip() + if not platform_ver.isdigit(): + platform_ver = '' + # Determine dependency faux SYS_ROOT dep_sys_root = os.path.join(env.get('SRC_DIR'), 'dep', 'android', target_arch, 'usr') dep_src_dir = os.path.join(dep_sys_root, 'include') @@ -181,7 +210,6 @@ env.AppendUnique(CCFLAGS = ['-Wall', '-fPIC']) #env.AppendUnique(LINKFLAGS = ['-ldl', '-lpthread']) env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')]) -src_dir = env.get('SRC_DIR') env.AppendUnique(LIBPATH = [src_dir + '/resource/csdk/connectivity/lib/android']) env.AppendUnique(LIBS = ['log', 'coap']) diff --git a/extlibs/android/gradle/SConscript b/extlibs/android/gradle/SConscript new file mode 100644 index 0000000..9cece4b --- /dev/null +++ b/extlibs/android/gradle/SConscript @@ -0,0 +1,29 @@ +import os, sys, platform, subprocess + +Import('env') + +env = env.Clone() +ndk_env = env.Clone() +SConscript('../../../build_common/external_libs.scons') + +target_os = env.get('TARGET_OS') +host_os = sys.platform +print host_os +SConscript('../../../build_common/external_libs.scons') +###################################################################### +# Build flags +###################################################################### +src_dir = env.get('SRC_DIR') + +path = os.path.join(src_dir, 'extlibs', 'android', 'gradle', 'gradle-2.2.1') + +# check 'gradle' library, if it doesn't exits, ask user to download it +if not os.path.exists(path): + gradle_zip = env.Download('gradle2.2.1.zip', 'https://services.gradle.org/distributions/gradle-2.2.1-all.zip') + gradle_dir = env.UnpackAll('gradle-2.2.1', gradle_zip) + print ''' +*********************************************************************** +* Downloading gradle: * +******************************************************************************* +''' + diff --git a/extlibs/android/ndk/SConscript b/extlibs/android/ndk/SConscript new file mode 100644 index 0000000..cc36c4e --- /dev/null +++ b/extlibs/android/ndk/SConscript @@ -0,0 +1,37 @@ +import os, string, sys, subprocess, struct + +Import('env') + +env = env.Clone() +ndk_env = env.Clone() + +target_os = env.get('TARGET_OS') +target_arch = env.get('TARGET_ARCH') + +host_os = sys.platform + +###################################################################### +# Build flags +###################################################################### +src_dir = env.get('SRC_DIR') +path = os.path.join(src_dir, 'extlibs', 'android', 'ndk', 'android-ndk-r10d') + +# check 'ndk' library, if it doesn't exits, ask user to download it +if not os.path.exists(path): + ndk_env = Environment(ENV = os.environ) + if host_os == 'linux2' : + archType = 8 * struct.calcsize("P") + if archType == 64: + env.Download('android-ndk-r10d.bin', 'http://dl.google.com/android/ndk/android-ndk-r10d-linux-x86_64.bin') + else: + env.Download('android-ndk-r10d.bin', 'http://dl.google.com/android/ndk/android-ndk-r10d-linux-x86.bin') + + os.system("chmod a+x android-ndk-r10d.bin") + os.system("./android-ndk-r10d.bin") + else: + if target_arch in ['x86_64']: + env.Download('android-ndk-r10d', 'http://dl.google.com/android/ndk/android-ndk-r10d-windows-x86_64.exe') + if target_arch in ['x86']: + env.Download('android-ndk-r10d', 'http://dl.google.com/android/ndk/android-ndk-r10d-windows-x86.exe') + + diff --git a/extlibs/android/sdk/SConscript b/extlibs/android/sdk/SConscript new file mode 100644 index 0000000..aa268e6 --- /dev/null +++ b/extlibs/android/sdk/SConscript @@ -0,0 +1,58 @@ +## +# Script to install (if they do not exist) the Android SDK library (ie. Android JDK) +## + +import os, subprocess, struct +import urllib2, urlparse +import SCons.Errors +import shutil + +Import('env') + +target_os = env.get('TARGET_OS') +src_dir = env.get('SRC_DIR') + +SConscript(src_dir + '/build_common/tools/UnpackAll.py') +SConscript(src_dir + '/build_common/external_libs.scons') + +# Download +if target_os == 'android': + android_home = env.get('ANDROID_HOME') + if not android_home: + print 'Creating ANDROID_HOME for Android SDK' + + androidlib_dir = src_dir + '/extlibs/android/sdk/android-sdk_r24.2' + + if not os.path.exists(androidlib_dir): + from sys import platform as _platform + if _platform == "linux" or _platform == "linux2": + androidlib_zip_file = src_dir + '/extlibs/android/android-sdk_r24.2-linux.tgz' + androidlib_url = 'http://dl.google.com/android/android-sdk_r24.2-linux.tgz' + elif _platform == "darwin": + androidlib_zip_file = src_dir + '/extlibs/android/android-sdk_r24.2-macosx.zip' + androidlib_url = 'http://dl.google.com/android/android-sdk_r24.2-macosx.zip' + elif _platform == "win32": + androidlib_zip_file = src_dir + '/extlibs/android/android-sdk_r24.2-windows.zip' + androidlib_url = 'http://dl.google.com/android/android-sdk_r24.2-windows.zip' + + # If the zip file is not already present, download it + if not os.path.exists(androidlib_zip_file): + androidlib_zip = env.Download(androidlib_zip_file, androidlib_url) + else: + androidlib_zip = androidlib_zip_file + + # Unzip the lib + print 'Unzipping android lib...' + env.UnpackAll(androidlib_dir, androidlib_zip) + print 'Unzipping android lib complete' + + # Remove downloaded file +# os.remove(androidlib_zip_file) + else: + androidlib_dir = env.get('ANDROID_HOME') + +# Set the ANDROID_HOME +env.Replace(ANDROID_HOME = androidlib_dir) +print 'ANDROID_HOME = ' + env.get('ANDROID_HOME') + + diff --git a/extlibs/boost/SConscript b/extlibs/boost/SConscript index 1d8b47b..0fe0662 100644 --- a/extlibs/boost/SConscript +++ b/extlibs/boost/SConscript @@ -20,7 +20,7 @@ if 'android' == target_os : env.Tool('BoostBootstrap', toolpath=['../../tools/scons']) env.Tool('BoostBuild', toolpath=['../../tools/scons']) - boost_version = '1.57.0' + boost_version = '1.58.0' boost_base_name = 'boost_'+string.replace(boost_version,'.','_') boost_arch_name = boost_base_name+'.zip' boost_url = 'http://downloads.sourceforge.net/project/boost/boost/'+boost_version+'/'+boost_arch_name+'?r=&ts=1421801329&use_mirror=iweb' diff --git a/resource/SConscript b/resource/SConscript index e9cddf5..9f96e77 100644 --- a/resource/SConscript +++ b/resource/SConscript @@ -30,7 +30,7 @@ Import('env') target_os = env.get('TARGET_OS') src_dir = env.get('SRC_DIR') -if target_os not in ['arduino', 'darwin', 'ios']: +if target_os not in ['arduino', 'darwin', 'ios', 'android']: env.AppendUnique(LIBS=['rt']) # Build libcoap diff --git a/resource/csdk/connectivity/build/How_To_Build.txt b/resource/csdk/connectivity/build/How_To_Build.txt old mode 100644 new mode 100755 index 7a64501..5b2c5b0 --- a/resource/csdk/connectivity/build/How_To_Build.txt +++ b/resource/csdk/connectivity/build/How_To_Build.txt @@ -96,17 +96,18 @@ Note :- Currently Mega & Due build is supported. 3) Execute following command to start build : For Arduino Mega - $ scons TARGET_OS=arduino TARGET_TRANSPORT= SHIELD= TARGET_ARCH=avr BOARD=mega ARDUINO_HOME= + $ scons TARGET_OS=arduino TARGET_TRANSPORT= TARGET_ARCH=avr BOARD=mega ARDUINO_HOME= For Arduino Due - $ scons TARGET_OS=arduino TARGET_TRANSPORT= SHIELD= TARGET_ARCH=arm BOARD=arduino_due_x_dbg ARDUINO_HOME= + $ scons TARGET_OS=arduino TARGET_TRANSPORT= TARGET_ARCH=arm BOARD=arduino_due_x_dbg ARDUINO_HOME= NOTE: BOARD=arduino_due_x_dbg|arduino_due_x. Default is arduino_due_x_dbg. Possible values for are: - -> IP : - $ scons TARGET_OS=arduino TARGET_TRANSPORT=IP SHIELD=WIFI TARGET_ARCH=avr BOARD=mega ARDUINO_HOME= - $ scons TARGET_OS=arduino TARGET_TRANSPORT=IP SHIELD=ETH TARGET_ARCH=avr BOARD=mega ARDUINO_HOME= + -> ETHERNET : + $ scons TARGET_OS=arduino TARGET_TRANSPORT=ETHERNET TARGET_ARCH=avr BOARD=mega ARDUINO_HOME= + -> WIFI : + $ scons TARGET_OS=arduino TARGET_TRANSPORT=WIFI TARGET_ARCH=avr BOARD=mega ARDUINO_HOME= -> BLE : - $ scons TARGET_OS=arduino TARGET_TRANSPORT=BLE SHIELD=RBL_NRF8001 TARGET_ARCH=avr BOARD=mega ARDUINO_HOME= + $ scons TARGET_OS=arduino TARGET_TRANSPORT=BLE TARGET_ARCH=avr BOARD=mega ARDUINO_HOME= Note :- Only single transport can be built at a time for Arduino. @@ -114,11 +115,11 @@ For Arduino Due 5) After building sample, script will try to install on "/dev/ttyACM0" port in 'sudo' mode. To skip installation, set command line argument 'UPLOAD=false'. - "scons TARGET_OS=arduino TARGET_TRANSPORT=IP SHIELD=ETH TARGET_ARCH=avr BOARD=mega ARDUINO_HOME= UPLOAD=false" + "scons TARGET_OS=arduino TARGET_TRANSPORT=ETHERNET TARGET_ARCH=avr BOARD=mega ARDUINO_HOME= UPLOAD=false" 6) To set BLE Shield Name, include the option DEVICE_NAME during scons build. - -> $ scons TARGET_OS=arduino TARGET_TRANSPORT=BLE SHIELD=RBL_NRF8001 TARGET_ARCH=avr BOARD=mega ARDUINO_HOME= DEVICE_NAME=OIC + -> $ scons TARGET_OS=arduino TARGET_TRANSPORT=ETHERNET TARGET_ARCH=avr BOARD=mega ARDUINO_HOME= DEVICE_NAME=OIC Specified Device name length MUST be less than 10 characters. RBL Library has this limitation. By Default DEVICE_NAME=OIC-DEVICE, if device name option is not specified diff --git a/resource/csdk/connectivity/build/SConscript b/resource/csdk/connectivity/build/SConscript old mode 100644 new mode 100755 index b29c55a..b901f1a --- a/resource/csdk/connectivity/build/SConscript +++ b/resource/csdk/connectivity/build/SConscript @@ -267,4 +267,3 @@ if env.GetOption('clean'): Execute(Delete(dir + '/.sconf_temp')) Return('env') - diff --git a/resource/csdk/connectivity/build/android/Makefile b/resource/csdk/connectivity/build/android/Makefile new file mode 100755 index 0000000..038e36b --- /dev/null +++ b/resource/csdk/connectivity/build/android/Makefile @@ -0,0 +1,19 @@ +#Assumes ndk directory is at ~/ +#set ndk directory PATH in .bashrc and use the ndk-build directly +#change NDK_PATH to ${your_ndk_path} +NDK_PATH = ~/ndk +NDK_BUILD = $(NDK_PATH)/ndk-build + +BUILD_DIR = $(CURDIR) +APPLICATION_BUILD = $(BUILD_DIR) +ROOT_DIR = $(BUILD_DIR) + +#Clean files +LIBS_DIR = $(ROOT_DIR)/libs +OBJ_DIR = $(ROOT_DIR)/obj + +all: + $(NDK_BUILD) NDK_PROJECT_PATH=$(APPLICATION_BUILD) + +clean : + @$(RM) -rf $(LIBS_DIR) $(OBJ_DIR) diff --git a/resource/csdk/connectivity/build/android/README.txt b/resource/csdk/connectivity/build/android/README.txt old mode 100644 new mode 100755 diff --git a/resource/csdk/connectivity/build/android/SConscript b/resource/csdk/connectivity/build/android/SConscript old mode 100644 new mode 100755 diff --git a/resource/csdk/connectivity/build/android/jni/Android.mk b/resource/csdk/connectivity/build/android/jni/Android.mk old mode 100644 new mode 100755 diff --git a/resource/csdk/connectivity/build/android/jni/Application.mk b/resource/csdk/connectivity/build/android/jni/Application.mk old mode 100644 new mode 100755 diff --git a/resource/csdk/connectivity/build/arduino/Arduino_Setup_README.txt b/resource/csdk/connectivity/build/arduino/Arduino_Setup_README.txt old mode 100644 new mode 100755 diff --git a/resource/csdk/connectivity/build/arduino/Makefile b/resource/csdk/connectivity/build/arduino/Makefile new file mode 100755 index 0000000..7524a33 --- /dev/null +++ b/resource/csdk/connectivity/build/arduino/Makefile @@ -0,0 +1,75 @@ +# +# override with `make BUILD=debug` +# override with `make PLATFORM=arduinomega` or `make PLATFORM=arduinodue` +# TRANSPORT can be ETHERNET, WIFI, BT, BLE. Include Corresponding Transport during compilation. For Eg: `make PLATFORM=arduinomega TRANSPORT=BLE +# default to release build +# default to build for arduinomega +# default to build for BLE Transport +BUILD := release +PLATFORM := arduinomega +TRANSPORT := BLE +OBJ_DIR := ./bin +APP_NAME := casample +ARDUINO_PORT := ttyACM0 + +include ./local.properties +include ./$(PLATFORM).properties + +VPATH := $(SDIR_ARD_PLATFORM) + +#Include __ARDUINO_BLE__ flag for BLE Transport. Currently, BLE Sample APP is segregated with this MACRO +ifeq ($(TRANSPORT),BLE) +CFLAGS := -Os -Wall -c -DTB_LOG -DOIC_ARDUINODUE -DINTERFACESAMPLE_ARDUINO -DARDUINO -DOIC_ARDUINODUE -D__ARDUINO__ -DWITH_ARDUINO -D__ARDUINO_BLE__ -DLE_ADAPTER +else ifeq ($(TRANSPORT),WIFI) +CFLAGS := -Os -Wall -c -DTB_LOG -DOIC_ARDUINODUE -DINTERFACESAMPLE_ARDUINO -DARDUINO -DOIC_ARDUINODUE -D__ARDUINO__ -DWITH_ARDUINO -DWIFI_ADAPTER +else +CFLAGS := -Os -Wall -c -DTB_LOG -DOIC_ARDUINODUE -DINTERFACESAMPLE_ARDUINO -DARDUINO -DOIC_ARDUINODUE -D__ARDUINO__ -DWITH_ARDUINO -DETHERNET_ADAPTER +endif + +all: prep_dirs core.a $(APP_NAME).o $(APP_NAME).elf $(APP_NAME).hex + +$(info *********PLATFORM_OBJS!!**********) +core.a: $(PLATFORM_OBJS) + @cd $(OBJ_DIR) && $(AR) -x ../../../lib/libcoap-4.1.1/$(BUILD)/libcoap.a + $(AR) rcs $@ $(CORE_COBJ) $(CORE_CPPOBJ) $(PLATFORM_OBJS) $(OBJ_DIR)/*.o + $(RANLIB) $@ + +prep_dirs: + -mkdir $(OBJ_DIR) + +logger.c.o: logger.c + $(CCPLUS) $(CFLAGS) $(CFLAGS_PLATFORM) $(INC_DIR_PLATFORM) $< -o $@ + +%.c.o: %.c + $(CC) $(CFLAGS) $(CFLAGS_PLATFORM) $(INC_DIR_PLATFORM) $< -o $@ + +%.o: %.c + $(CC) $(CFLAGS) $(CFLAGS_PLATFORM) $(INC_DIR_PLATFORM) $< -o $@ + +%.o: %.cpp + $(CCPLUS) $(CFLAGS) $(CFLAGS_PLATFORM) $(INC_DIR_PLATFORM) $< -o $@ + +%.cpp.o: %.cpp + $(CCPLUS) $(CFLAGS) $(CFLAGS_PLATFORM) $(INC_DIR_PLATFORM) $< -o $@ + +# core.a and $(APP_NAME).cpp.o are combined to generate $(APP_NAME).elf. +# For Integration with Top Layer, we can link top layer with core.a +$(APP_NAME).elf: $(APP_NAME).cpp.o core.a + $(CC) -w -Os -Wl,--gc-sections,--relax -mmcu=atmega2560 -o $@ $^ -L$(ARDUINO_DIR)/libraries -lm + +$(APP_NAME).hex: $(APP_NAME).elf + $(AVR_OBJCOPY) -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 $< $(APP_NAME).eep + $(AVR_OBJCOPY) -O ihex -R .eeprom $< $@ + +install: all + $(AVR_PROGRAMMER) -C$(ARDUINO_DIR)/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega2560 -cstk500v2 -P/dev/$(ARDUINO_PORT) -b115200 -D -Uflash:w:$(APP_NAME).hex:i + + +.PHONY: clean +clean: + @rm -f *.o *.d *.elf *.eep core.a *.hex *.bin *.map *- + @rm -rf $(OBJ_DIR) + + + + diff --git a/resource/csdk/connectivity/build/arduino/README.txt b/resource/csdk/connectivity/build/arduino/README.txt old mode 100644 new mode 100755 diff --git a/resource/csdk/connectivity/build/arduino/SConscript b/resource/csdk/connectivity/build/arduino/SConscript old mode 100644 new mode 100755 diff --git a/resource/csdk/connectivity/build/arduino/arduino.scons b/resource/csdk/connectivity/build/arduino/arduino.scons old mode 100644 new mode 100755 index b6919e7..4c13ebd --- a/resource/csdk/connectivity/build/arduino/arduino.scons +++ b/resource/csdk/connectivity/build/arduino/arduino.scons @@ -26,3 +26,4 @@ env.ImportLib('Time/Time') env.AppendUnique(CPPDEFINES = ['WITH_ARDUINO', '__ARDUINO__']) if env.get('LOGGING'): env.AppendUnique(CPPDEFINES = ['TB_LOG']) + diff --git a/resource/csdk/connectivity/build/arduino/arduinomega.properties b/resource/csdk/connectivity/build/arduino/arduinomega.properties old mode 100644 new mode 100755 diff --git a/resource/csdk/connectivity/build/arduino/build.sh b/resource/csdk/connectivity/build/arduino/build.sh old mode 100644 new mode 100755 diff --git a/resource/csdk/connectivity/build/arduino/local.properties b/resource/csdk/connectivity/build/arduino/local.properties old mode 100644 new mode 100755 diff --git a/resource/csdk/connectivity/build/common.mk b/resource/csdk/connectivity/build/common.mk new file mode 100755 index 0000000..858dda1 --- /dev/null +++ b/resource/csdk/connectivity/build/common.mk @@ -0,0 +1,60 @@ +#/****************************************************************** +# * +# * Copyright 2014 Samsung Electronics All Rights Reserved. +# * +# * +# * +# * Licensed under the Apache License, Version 2.0 (the "License"); +# * you may not use this file except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.apache.org/licenses/LICENSE-2.0 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# * +#******************************************************************/ + +## +## Definitions +## +SHELL = /bin/bash +PROJECT_NAME = connectivity_abstraction +PROJECT_ROOT_PATH = .. +PROJECT_API_PATH = $(PROJECT_ROOT_PATH)/api +PROJECT_INC_PATH = $(PROJECT_ROOT_PATH)/inc +PROJECT_SRC_PATH = $(PROJECT_ROOT_PATH)/src +PROJECT_COMMON_INC_PATH = $(PROJECT_ROOT_PATH)/common/inc +PROJECT_COMMON_SRC_PATH = $(PROJECT_ROOT_PATH)/common/src +PROJECT_COMMON_PATH = $(PROJECT_ROOT_PATH)/common +PROJECT_OUT_PATH = $(PROJECT_ROOT_PATH)/build/out +PROJECT_LIB_PATH = $(PROJECT_ROOT_PATH)/lib + +## +## macro +## +define MAKE_PROJECT_OUT_PATH + @if [ ! -d $(PROJECT_OUT_PATH) ]; then \ + mkdir $(PROJECT_OUT_PATH); \ + fi +endef + + +## +## Commands +## +CC = gcc +CXX = g++ +RM = rm -rf +CP = cp +MV = mv +AR = ar +LD = ld +LN = ln +CD = cd +RANLIB = ranlib + + diff --git a/resource/csdk/connectivity/build/linux/SConscript b/resource/csdk/connectivity/build/linux/SConscript old mode 100644 new mode 100755 diff --git a/resource/csdk/connectivity/build/tizen/Makefile b/resource/csdk/connectivity/build/tizen/Makefile new file mode 100755 index 0000000..8e56590 --- /dev/null +++ b/resource/csdk/connectivity/build/tizen/Makefile @@ -0,0 +1,65 @@ +## +# override with `make BUILD=debug` +# override with `make PLATFORM=arduinomega` or `make PLATFORM=arduinodue` +# default to release build +# default to build for linux +BUILD := debug +PLATFORM := tizen +OBJ_DIR := ./bin +ROOT_DIR := . +VERSION_MAJOR := 0 +VERSION_MINOR := 1 +VERSION_PATCH := 0 +ADAPTER_MACRO := -DWIFI_ADAPTER + +$(info *******************tizen Build !!******************) + +CC=gcc +LIBCOAP=./lib/libcoap-4.1.1/ +LIBCOAP_OBJ_DIR=./lib/libcoap-4.1.1/obj + +TINYDTLS=./lib/extlibs/tinydtls +TINYDTLS_OBJ_DIR=./lib/extlibs/tinydtls/obj + +# TODO : Currently Hardcoded WIFI_ADAPTER. Change it to generic +CFLAGS.debug = -DWITH_POSIX -D__TIZEN__ -Wall -std=c99 -DSLP_SDK_LOG -g -D_GNU_SOURCE -DTIZEN_DEBUG_ENABLE -DTB_LOG $(ADAPTER_MACRO) +CFLAGS.release = -DWITH_POSIX -D__TIZEN__ -Wall -std=c99 -DSLP_SDK_LOG -D_GNU_SOURCE -DTIZEN_DEBUG_ENABLE -DTB_LOG $(ADAPTER_MACRO) +COMPILEFLAG = `pkg-config --cflags --libs capi-network-wifi dlog capi-network-bluetooth glib-2.0` + +# Include files will be copied into a single folder on gbsbuild. +# NO NEED to mention the path explicitly. + +CA_INC = $(ROOT_DIR)/ +DTLS_INC = $(ROOT_DIR)/dtls/ + +INC_DIRS := -I$(CA_INC) +INC_DIRS += -I$(DTLS_INC) + +SRC = $(wildcard *.c) +OBJECTS = $(patsubst %.c, %.o, $(SRC)) + +#Currently compiling libcoap objects. If it's provided by external party. +#Then don't compile, Instead directly extract objects and create liboicinterface.a +all: $(OBJECTS) + $(MAKE) -C $(LIBCOAP) clean + $(MAKE) -C $(LIBCOAP) + -mkdir $(LIBCOAP_OBJ_DIR) + @cd $(LIBCOAP_OBJ_DIR) && $(AR) -x ../libcoap.a + ar rcs liboicinterface.a $(OBJECTS) $(LIBCOAP_OBJ_DIR)/*.o + +%.o : %.c + $(CC) -c $(CFLAGS.$(BUILD)) $(COMPILEFLAG) $(INC_DIRS) $< -o $@ + + +pack: +#$(CC) $(CFLAGS) $(COMPILEFLAG) WiFiInterface.c bt_interface.c tc_interface.c sample_main.c -o sample /usr/lib/liboctbstack.a -lm -pthread + $(info **************************************TEST***************************) +install: +#cp -rf sample ./usr/apps/com.samsung.oicca/bin/sample + +clean: + rm -rf *.o sample + rm -f *.o *.d *.elf *.eep core.a *.hex *.bin *.map *- + rm -rf $(OBJ_DIR) + rm -rf $(LIBCOAP_OBJ_DIR) + diff --git a/resource/csdk/connectivity/build/tizen/SConscript b/resource/csdk/connectivity/build/tizen/SConscript new file mode 100755 index 0000000..3c72392 --- /dev/null +++ b/resource/csdk/connectivity/build/tizen/SConscript @@ -0,0 +1,241 @@ +## +# This script includes generic build options: +# release/debug, target os, target arch, cross toolchain, build environment etc +## +import os +import platform + +# 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', 'WIFI', 'ETHERNET', '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('BUILD_SAMPLE', 'Build with sample', 'ON', allowed_values=('ON', 'OFF'))) + +###################################################################### +# Platform(build target) specific options: SDK/NDK & toolchain +###################################################################### +targets_support_cc = ['linux', 'arduino', '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//// +# +# 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() + +Export('env') + +###################################################################### +# Link scons to Yocto cross-toolchain ONLY when target_os is yocto +###################################################################### +if target_os == "yocto": + ''' + This code injects Yocto cross-compilation tools+flags into scons' + build environment in order to invoke the relevant tools while + performing a build. + ''' + import os.path + try: + CC = os.environ['CC'] + target_prefix = CC.split()[0] + target_prefix = target_prefix[:len(target_prefix)-3] + tools = {"CC" : target_prefix+"gcc", + "CXX" : target_prefix+"g++", + "AS" : target_prefix+"as", + "LD" : target_prefix+"ld", + "GDB" : target_prefix+"gdb", + "STRIP" : target_prefix+"strip", + "RANLIB" : target_prefix+"ranlib", + "OBJCOPY" : target_prefix+"objcopy", + "OBJDUMP" : target_prefix+"objdump", + "AR" : target_prefix+"ar", + "NM" : target_prefix+"nm", + "M4" : "m4", + "STRINGS": target_prefix+"strings"} + PATH = os.environ['PATH'].split(os.pathsep) + for tool in tools: + if tool in os.environ: + for path in PATH: + if os.path.isfile(os.path.join(path, tools[tool])): + env[tool] = os.path.join(path, os.environ[tool]) + break + except: + print "ERROR in Yocto cross-toolchain environment" + Exit(1) + ''' + Now reset TARGET_OS to linux so that all linux specific build configurations + hereupon apply for the entirety of the build process. + ''' + env['TARGET_OS'] = 'linux' + ''' + We want to preserve debug symbols to allow BitBake to generate both DEBUG and + RELEASE packages for OIC. + ''' + env['CCFLAGS'].append('-g') + Export('env') +else: + ''' + If target_os is not Yocto, 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/resource/csdk/connectivity/build/tizen/SConstruct b/resource/csdk/connectivity/build/tizen/SConstruct old mode 100644 new mode 100755 diff --git a/resource/csdk/connectivity/build/tizen/com.oic.ca.manifest b/resource/csdk/connectivity/build/tizen/com.oic.ca.manifest old mode 100644 new mode 100755 diff --git a/resource/csdk/connectivity/build/tizen/com.oic.ca.pc b/resource/csdk/connectivity/build/tizen/com.oic.ca.pc old mode 100644 new mode 100755 diff --git a/resource/csdk/connectivity/build/tizen/gbsbuild.sh b/resource/csdk/connectivity/build/tizen/gbsbuild.sh old mode 100644 new mode 100755 index aed6145..385fe5b --- a/resource/csdk/connectivity/build/tizen/gbsbuild.sh +++ b/resource/csdk/connectivity/build/tizen/gbsbuild.sh @@ -1,8 +1,6 @@ #!/bin/sh -cur_dir="./resource/csdk/connectivity/" - -spec=`ls ./resource/csdk/connectivity/build/tizen/packaging/*.spec` +spec=`ls build/tizen/packaging/*.spec` version=`rpm --query --queryformat '%{version}\n' --specfile $spec` name=`echo $name|cut -d" " -f 1` @@ -28,24 +26,18 @@ echo `pwd` mkdir ./tmp mkdir ./tmp/con/ -cp -R $cur_dir/* $sourcedir/tmp/con -cp -R $cur_dir/SConscript $sourcedir/tmp/con -cp -R $cur_dir/src/ip_adapter/SConscript $sourcedir/tmp/con/src/ip_adapter/ -cp -R $cur_dir/src/bt_le_adapter/SConscript $sourcedir/tmp/con/src/bt_le_adapter/ -cp -R $cur_dir/src/bt_edr_adapter/SConscript $sourcedir/tmp/con/src/bt_edr_adapter/ -cp -R $cur_dir/common/SConscript $sourcedir/tmp/con/common/ -cp -R $cur_dir/lib/libcoap-4.1.1/SConscript $sourcedir/tmp/con/lib/libcoap-4.1.1/ -cp -R $cur_dir/samples/tizen/ $sourcedir/tmp/con/sample/ +cp -R ./* $sourcedir/tmp/con +cp -R ./SConscript $sourcedir/tmp/con +cp -R ./src/wifi_adapter/SConscript $sourcedir/tmp/con/src/wifi_adapter/ +cp -R ./src/bt_le_adapter/SConscript $sourcedir/tmp/con/src/bt_le_adapter/ +cp -R ./src/bt_edr_adapter/SConscript $sourcedir/tmp/con/src/bt_edr_adapter/ +cp -R ./common/SConscript $sourcedir/tmp/con/common/ +cp -R ./lib/libcoap-4.1.1/SConscript $sourcedir/tmp/con/lib/libcoap-4.1.1/ +cp -R ./samples/tizen/ $sourcedir/tmp/con/sample/ mkdir -p $sourcedir/tmp/con/sample/lib/tizen/ble/libs -cp -R $cur_dir/lib/tizen/ble/libs/* $sourcedir/tmp/con/sample/lib/tizen/ble/libs/ - -mkdir -p $sourcedir/tmp/iotivityconfig -cd $sourcedir/build_common/ -cp -R ./iotivityconfig/* $sourcedir/tmp/iotivityconfig/ -cp -R ./SConscript $sourcedir/tmp/ +cp -R ./lib/tizen/ble/libs/* $sourcedir/tmp/con/sample/lib/tizen/ble/libs/ -cd $sourcedir -cd $cur_dir/build/tizen +cd $sourcedir/build/tizen cp -R ./* $sourcedir/tmp/ cp SConscript $sourcedir/tmp/ diff --git a/resource/csdk/connectivity/build/tizen/packaging/com.oic.ca.spec b/resource/csdk/connectivity/build/tizen/packaging/com.oic.ca.spec old mode 100644 new mode 100755 index 6fedada..a8689a3 --- a/resource/csdk/connectivity/build/tizen/packaging/com.oic.ca.spec +++ b/resource/csdk/connectivity/build/tizen/packaging/com.oic.ca.spec @@ -40,12 +40,13 @@ scons TARGET_OS=tizen TARGET_TRANSPORT=%{TARGET_TRANSPORT} RELEASE=%{RELEASE} mkdir -p %{DEST_INC_DIR} mkdir -p %{DEST_LIB_DIR}/pkgconfig -cp -f %{ROOTDIR}/con/src/libconnectivity_abstraction.so %{buildroot}/%{_libdir} -cp -f %{ROOTDIR}/con/lib/libcoap-4.1.1/libcoap.so %{buildroot}/%{_libdir} +cp -f %{ROOTDIR}/con/src/libconnectivity_abstraction.a %{buildroot}/%{_libdir} +cp -f %{ROOTDIR}/con/lib/libcoap-4.1.1/libcoap.a %{buildroot}/%{_libdir} cp -rf %{ROOTDIR}/con/api/cacommon.h* %{DEST_INC_DIR}/ cp -rf %{ROOTDIR}/con/inc/caadapterinterface.h* %{DEST_INC_DIR}/ cp -rf %{ROOTDIR}/con/common/inc/cathreadpool.h* %{DEST_INC_DIR}/ -cp -rf %{ROOTDIR}/con/inc/caipadapter.h* %{DEST_INC_DIR}/ +cp -rf %{ROOTDIR}/con/inc/cawifiadapter.h* %{DEST_INC_DIR}/ +cp -rf %{ROOTDIR}/con/inc/caethernetadapter.h* %{DEST_INC_DIR}/ cp -rf %{ROOTDIR}/con/inc/caedradapter.h* %{DEST_INC_DIR}/ cp -rf %{ROOTDIR}/con/inc/caleadapter.h* %{DEST_INC_DIR}/ cp -rf %{ROOTDIR}/con/api/cainterface.h* %{DEST_INC_DIR}/ @@ -55,7 +56,7 @@ cp -rf %{ROOTDIR}/com.oic.ca.pc %{DEST_LIB_DIR}/pkgconfig/ %files %manifest com.oic.ca.manifest %defattr(-,root,root,-) -%{_libdir}/lib*.so* +%{_libdir}/lib*.a* %{_includedir}/OICHeaders/* %{_libdir}/pkgconfig/*.pc diff --git a/resource/csdk/connectivity/build/tizen/scons/SConscript b/resource/csdk/connectivity/build/tizen/scons/SConscript old mode 100644 new mode 100755 index f2d562f..318d954 --- a/resource/csdk/connectivity/build/tizen/scons/SConscript +++ b/resource/csdk/connectivity/build/tizen/scons/SConscript @@ -20,7 +20,7 @@ if env.get('LOGGING'): env.ParseConfig("pkg-config --cflags --libs capi-network-wifi dlog glib-2.0") if 'ALL' in transport: - env.AppendUnique(CPPDEFINES = ['NO_IP_ADAPTER','EDR_ADAPTER','LE_ADAPTER']) + env.AppendUnique(CPPDEFINES = ['WIFI_ADAPTER', 'NO_ETHERNET_ADAPTER','EDR_ADAPTER','LE_ADAPTER']) print "CA Transport is ALL" else: if 'BT' in transport: @@ -35,5 +35,12 @@ else: else: env.AppendUnique(CPPDEFINES = ['NO_LE_ADAPTER']) + if 'WIFI' in transport: + env.AppendUnique(CPPDEFINES = ['WIFI_ADAPTER']) + print "CA Transport is WIFI" + else: + env.AppendUnique(CPPDEFINES = ['NO_WIFI_ADAPTER']) + + env.SConscript(['../con/lib/libcoap-4.1.1/SConscript']) env.SConscript(['../con/SConscript']) diff --git a/resource/csdk/connectivity/lib/libcoap-4.1.1/SConscript b/resource/csdk/connectivity/lib/libcoap-4.1.1/SConscript index c8143a1..167613c 100644 --- a/resource/csdk/connectivity/lib/libcoap-4.1.1/SConscript +++ b/resource/csdk/connectivity/lib/libcoap-4.1.1/SConscript @@ -66,9 +66,6 @@ libcoap_src = [ 'block.c' ] -if target_os in ['android', 'tizen'] : - libcoap = libcoap_env.SharedLibrary('libcoap', libcoap_src, OBJPREFIX='libcoap_') -else : - libcoap = libcoap_env.StaticLibrary('libcoap', libcoap_src, OBJPREFIX='libcoap_') +libcoap = libcoap_env.StaticLibrary('libcoap', libcoap_src, OBJPREFIX='libcoap_') libcoap_env.InstallTarget([libcoap], 'libcoap') diff --git a/resource/csdk/connectivity/samples/android/sample_service/jni/Application.mk b/resource/csdk/connectivity/samples/android/sample_service/jni/Application.mk index 50d595b..a0e5d81 100644 --- a/resource/csdk/connectivity/samples/android/sample_service/jni/Application.mk +++ b/resource/csdk/connectivity/samples/android/sample_service/jni/Application.mk @@ -1,4 +1,4 @@ -APP_STL := gnustl_static +APP_STL := gnustl_shared APP_PLATFORM = android-21 APP_CPPFLAGS += -fexceptions diff --git a/resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/ca/CaIpInterface.java b/resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/ca/CaIpInterface.java new file mode 100644 index 0000000..43d0ace --- /dev/null +++ b/resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/ca/CaIpInterface.java @@ -0,0 +1,70 @@ +/* + * //****************************************************************** + * // + * // Copyright 2015 Intel Corporation. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * // + * // 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. + * // + * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.ca; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; +import android.net.wifi.WifiManager; + +public class CaIpInterface { + private static Context mContext; + + private CaIpInterface(Context context) { + mContext = context; + registerIpStateReceiver(); + } + + private void registerIpStateReceiver() { + IntentFilter intentFilter = new IntentFilter(); + intentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION); + intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); + + mContext.registerReceiver(mReceiver, intentFilter); + } + + private static BroadcastReceiver mReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + if (intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, + WifiManager.WIFI_STATE_UNKNOWN) == WifiManager.WIFI_STATE_DISABLED) { + stateDisabled(); + } else if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) { + ConnectivityManager manager = (ConnectivityManager) + mContext.getSystemService(Context.CONNECTIVITY_SERVICE); + NetworkInfo nwInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); + + if(nwInfo.isConnected()) { + stateEnabled(); + } + } + } + }; + + private native static void stateEnabled(); + + private native static void stateDisabled(); +} \ No newline at end of file diff --git a/resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c b/resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c index 2d408fd..987504d 100644 --- a/resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c +++ b/resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c @@ -33,7 +33,7 @@ #include "logger.h" #include "oic_malloc.h" #include "oic_string.h" -#include "org_iotivity_jar_caipinterface.h" +#include "org_iotivity_ca_CaIpInterface.h" #define IP_MONITOR_TAG "IP_MONITOR" #define MAX_INTERFACE_INFO_LENGTH (1024) @@ -176,7 +176,7 @@ CAResult_t CACreateIPJNIInterfaceObject(jobject context) } //Create caipinterface jni instance - jclass IPJniInterface = (*env)->FindClass(env, "org/iotivity/jar/caipinterface"); + jclass IPJniInterface = (*env)->FindClass(env, "org/iotivity/ca/CaIpInterface"); if (!IPJniInterface) { OIC_LOG(ERROR, IP_MONITOR_TAG, "Could not get caipinterface class"); @@ -471,7 +471,7 @@ static void CADestroyNetworkMonitorMutexes() CAResult_t CAIPInitializeNetworkMonitor(const ca_thread_pool_t threadPool) { - OIC_LOG(DEBUG, IP_MONITOR_TAG, "IN"); + OIC_LOG(DEBUG, IP_MONITOR_TAG, "CAIPInitializeNetworkMonitor IN"); VERIFY_NON_NULL(threadPool, IP_MONITOR_TAG, "threadPool is null"); @@ -763,6 +763,7 @@ void CAIPSendNetworkChangeCallback(CANetworkStatus_t currNetworkStatus) { OIC_LOG(DEBUG, IP_MONITOR_TAG, "IN"); ca_mutex_lock(g_stopNetworkMonitorMutex); + if (g_stopNetworkMonitor) { OIC_LOG(DEBUG, IP_MONITOR_TAG, "Stop Network Monitor Thread is called"); @@ -770,16 +771,22 @@ void CAIPSendNetworkChangeCallback(CANetworkStatus_t currNetworkStatus) return; } ca_mutex_unlock(g_stopNetworkMonitorMutex); - ca_mutex_lock(g_networkMonitorContextMutex); - if (!g_networkMonitorContext->networkChangeCb) + if(!g_networkMonitorContext) { - OIC_LOG(ERROR, IP_MONITOR_TAG, "g_networkChangeCb is NULL"); + OIC_LOG(DEBUG, IP_MONITOR_TAG, "g_networkChangeCb is NULL"); + ca_mutex_unlock(g_networkMonitorContextMutex); + return; + } + if (!g_networkMonitorContext->networkChangeCb) + { + OIC_LOG(ERROR, IP_MONITOR_TAG, "g_networkChangeCb->networkChangeCb is NULL"); ca_mutex_unlock(g_networkMonitorContextMutex); return; } - ca_mutex_unlock(g_networkMonitorContextMutex); + ca_mutex_unlock(g_networkMonitorContextMutex); + u_arraylist_t *netInterfaceList = u_arraylist_create(); VERIFY_NON_NULL_VOID(netInterfaceList, IP_MONITOR_TAG, @@ -855,13 +862,13 @@ void CAIPSendNetworkChangeCallback(CANetworkStatus_t currNetworkStatus) OIC_LOG(DEBUG, IP_MONITOR_TAG, "CACheckIsInterfaceInfoChanged true"); } } - CAClearNetInterfaceInfoList(netInterfaceList); + CAClearNetInterfaceInfoList(netInterfaceList); OIC_LOG(DEBUG, IP_MONITOR_TAG, "OUT"); } -JNIEXPORT void JNICALL -Java_org_iotivity_jar_caipinterface_CAIPStateEnabled(JNIEnv *env, jclass class) +JNIEXPORT void JNICALL Java_org_iotivity_ca_CaIpInterface_stateEnabled + (JNIEnv *env, jclass clazz) { CANetworkStatus_t currNetworkStatus = CA_INTERFACE_UP; OIC_LOG(DEBUG, IP_MONITOR_TAG, "CAIPStateEnabled"); @@ -869,8 +876,8 @@ Java_org_iotivity_jar_caipinterface_CAIPStateEnabled(JNIEnv *env, jclass class) CAIPSendNetworkChangeCallback(currNetworkStatus); } -JNIEXPORT void JNICALL -Java_org_iotivity_jar_caipinterface_CAIPStateDisabled(JNIEnv *env, jclass class) +JNIEXPORT void JNICALL Java_org_iotivity_ca_CaIpInterface_stateDisabled + (JNIEnv *env, jclass clazz) { CANetworkStatus_t currNetworkStatus = CA_INTERFACE_DOWN; OIC_LOG(DEBUG, IP_MONITOR_TAG, "CAIPStateDisabled"); diff --git a/resource/csdk/connectivity/src/ip_adapter/android/org_iotivity_ca_CaIpInterface.h b/resource/csdk/connectivity/src/ip_adapter/android/org_iotivity_ca_CaIpInterface.h new file mode 100644 index 0000000..1d66553 --- /dev/null +++ b/resource/csdk/connectivity/src/ip_adapter/android/org_iotivity_ca_CaIpInterface.h @@ -0,0 +1,29 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class org_iotivity_ca_CaIpInterface */ + +#ifndef _Included_org_iotivity_ca_CaIpInterface +#define _Included_org_iotivity_ca_CaIpInterface +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: org_iotivity_ca_CaIpInterface + * Method: stateEnabled + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_iotivity_ca_CaIpInterface_stateEnabled + (JNIEnv *, jclass); + +/* + * Class: org_iotivity_ca_CaIpInterface + * Method: stateDisabled + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_iotivity_ca_CaIpInterface_stateDisabled + (JNIEnv *, jclass); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/resource/csdk/connectivity/src/ip_adapter/android/org_iotivity_jar_caipinterface.h b/resource/csdk/connectivity/src/ip_adapter/android/org_iotivity_jar_caipinterface.h deleted file mode 100644 index b66bad4..0000000 --- a/resource/csdk/connectivity/src/ip_adapter/android/org_iotivity_jar_caipinterface.h +++ /dev/null @@ -1,30 +0,0 @@ -#include -/* Header for class org_iotivity_jar_caipinterface */ - -#ifndef _Included_org_iotivity_jar_caipinterface -#define _Included_org_iotivity_jar_caipinterface -#ifdef __cplusplus -extern "C" -{ -#endif -/* - * Class: org_iotivity_jar_caipinterface - * Method: CAIPStateEnabled - * Signature: ()V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_jar_caipinterface_CAIPStateEnabled(JNIEnv *, jclass); - -/* - * Class: org_iotivity_jar_caipinterface - * Method: CAIPStateDisabled - * Signature: ()V - */ -JNIEXPORT -void JNICALL Java_org_iotivity_jar_caipinterface_CAIPStateDisabled -(JNIEnv *, jclass); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/resource/csdk/stack/samples/linux/secure/SConscript b/resource/csdk/stack/samples/linux/secure/SConscript index 82a298d..71e298f 100644 --- a/resource/csdk/stack/samples/linux/secure/SConscript +++ b/resource/csdk/stack/samples/linux/secure/SConscript @@ -49,7 +49,7 @@ samples_env.Append(LINKFLAGS = ['-Wl,--no-as-needed']) if target_os == 'android': samples_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions']) - samples_env.AppendUnique(LIBS = ['gnustl_static']) + samples_env.AppendUnique(LIBS = ['gnustl_shared']) samples_env.AppendUnique(CPPDEFINES = ['_GLIBCXX_USE_C99=1', '_GLIBCXX_HAVE_WCSTOF=1']) if not env.get('RELEASE'): diff --git a/resource/examples/SConscript b/resource/examples/SConscript index 115f424..914a5ee 100644 --- a/resource/examples/SConscript +++ b/resource/examples/SConscript @@ -56,7 +56,7 @@ if env.get('SECURED') == '1': if target_os == 'android': examples_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions']) - examples_env.AppendUnique(LIBS = ['gnustl_static']) + examples_env.AppendUnique(LIBS = ['gnustl_shared']) if not env.get('RELEASE'): examples_env.AppendUnique(LIBS = ['log']) diff --git a/resource/include/OCRepresentation.h b/resource/include/OCRepresentation.h index 63fbd62..534bb5a 100644 --- a/resource/include/OCRepresentation.h +++ b/resource/include/OCRepresentation.h @@ -198,6 +198,29 @@ namespace OC return val; } + /** + * Retrieve the attributevalue structure associated with the supplied name + * + * @param str Name of the attribute + * @param attrValue Attribute Value structure + * @return The getAttributeValue method returns true if the attribute was + * found in the representation. Otherwise it returns false. + */ + bool getAttributeValue(const std::string& str, AttributeValue& attrValue) const + { + auto x = m_values.find(str); + + if (x != m_values.end()) + { + attrValue = x->second; + return true; + } + else + { + return false; + } + } + std::string getValueToString(const std::string& key) const; bool hasAttribute(const std::string& str) const; diff --git a/resource/oc_logger/SConscript b/resource/oc_logger/SConscript index 761d401..8bd1edc 100644 --- a/resource/oc_logger/SConscript +++ b/resource/oc_logger/SConscript @@ -36,7 +36,7 @@ liboc_logger_env.PrependUnique(CPPPATH = ['include']) target_os = env.get('TARGET_OS') if target_os == 'android': liboc_logger_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions']) - liboc_logger_env.AppendUnique(LIBS = ['gnustl_static', 'log']) + liboc_logger_env.AppendUnique(LIBS = ['gnustl_shared', 'log']) if target_os not in ['arduino', 'windows', 'winrt']: liboc_logger_env.AppendUnique(CFLAGS = ['-Wall', '-std=c99', '-fPIC']) diff --git a/resource/oc_logger/examples/SConscript b/resource/oc_logger/examples/SConscript index 644ec78..a3a4c91 100644 --- a/resource/oc_logger/examples/SConscript +++ b/resource/oc_logger/examples/SConscript @@ -38,7 +38,7 @@ examples_env.AppendUnique(LIBS = ['oc_logger', 'stdc++']) target_os = env.get('TARGET_OS') if target_os == 'android': examples_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions']) - examples_env.AppendUnique(LIBS = ['gnustl_static']) + examples_env.AppendUnique(LIBS = ['gnustl_shared']) if target_os not in ['arduino', 'windows', 'winrt']: examples_env.AppendUnique(CFLAGS = Split('-Wall -std=c99 -Werror')) diff --git a/resource/src/SConscript b/resource/src/SConscript index 2966a60..2e2c94f 100644 --- a/resource/src/SConscript +++ b/resource/src/SConscript @@ -48,7 +48,7 @@ if target_os not in ['windows', 'winrt']: if target_os == 'android': oclib_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions']) oclib_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')]) - oclib_env.AppendUnique(LIBS = ['octbstack', 'oc_logger', 'boost_thread', 'gnustl_static', 'log']) + oclib_env.AppendUnique(LIBS = ['octbstack', 'oc_logger', 'boost_thread', 'gnustl_shared', 'log']) if target_os in ['darwin', 'ios']: oclib_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')]) -- 2.7.4