From 4db16ede72d261191df17c72e0e78e624126b688 Mon Sep 17 00:00:00 2001 From: Petre Eftime Date: Wed, 6 Apr 2016 19:06:18 +0300 Subject: [PATCH] [IOT-1089] Change Android build system to accomodate both Android and Generic Java bindings Remove android folder and create java folder containing: common/ # contains base classes examples-android/ # examples for android examples-java/ # examples for generic java iotivity-android/ # contains ca classes for android iotivity-linux/ # contains ca classes for linux jni/ # native bindings, now builds with scons Generic Java bindings work on Linux, with IP transport only. Port simpleclient and simpleserver examples to java to test functionality. Add __JAVA__ define flag to diferentiate from Android Bindings. scons will take BUILDJAVA parameter to allow building Java for other platforms. Change-Id: I8b733b3a70214658c39c5147906fd462e04d54a2 Signed-off-by: Petre Eftime Reviewed-on: https://gerrit.iotivity.org/gerrit/7895 Tested-by: jenkins-iotivity Reviewed-by: George Nash Reviewed-by: Rick Bell --- SConstruct | 7 +- android/android_api/.gitignore | 10 - android/android_api/android_api.iml | 29 - android/android_api/base/.gitignore | 5 - android/android_api/base/base.iml | 90 -- android/android_api/base/jni/Android.mk | 114 --- android/android_api/base/jni/Application.mk | 2 - auto_build.sh | 22 + build_common/SConscript | 3 + build_common/external_libs.scons | 18 +- build_common/linux/SConscript | 24 + {android/android_api => java}/SConscript | 43 +- {android/android_api => java}/build.gradle | 6 - .../src/main/java/org/iotivity/base/CredType.java | 0 .../main/java/org/iotivity/base/DeviceStatus.java | 0 .../org/iotivity/base/EntityHandlerResult.java | 0 .../src/main/java/org/iotivity/base/ErrorCode.java | 0 .../src/main/java/org/iotivity/base/KeySize.java | 0 .../src/main/java/org/iotivity/base/ModeType.java | 0 .../java/org/iotivity/base/ObservationInfo.java | 0 .../main/java/org/iotivity/base/ObserveAction.java | 0 .../main/java/org/iotivity/base/ObserveType.java | 0 .../java/org/iotivity/base/OcConnectivityType.java | 0 .../main/java/org/iotivity/base/OcDeviceInfo.java | 0 .../main/java/org/iotivity/base/OcException.java | 0 .../java/org/iotivity/base/OcHeaderOption.java | 0 .../java/org/iotivity/base/OcPlatformInfo.java | 0 .../java/org/iotivity/base/OcPlatformStatus.java | 0 .../java/org/iotivity/base/OcPresenceHandle.java | 0 .../java/org/iotivity/base/OcPresenceStatus.java | 0 .../java/org/iotivity/base/OcProvisioning.java | 0 .../java/org/iotivity/base/OcRepresentation.java | 0 .../java/org/iotivity/base/OcRequestHandle.java | 0 .../main/java/org/iotivity/base/OcResource.java | 0 .../java/org/iotivity/base/OcResourceHandle.java | 0 .../org/iotivity/base/OcResourceIdentifier.java | 0 .../java/org/iotivity/base/OcResourceRequest.java | 0 .../java/org/iotivity/base/OcResourceResponse.java | 0 .../java/org/iotivity/base/OcSecureResource.java | 0 .../src/main/java/org/iotivity/base/OicSecAcl.java | 0 .../main/java/org/iotivity/base/OwnedStatus.java | 0 .../src/main/java/org/iotivity/base/OxmType.java | 0 .../java/org/iotivity/base/ProvisionResult.java | 0 .../java/org/iotivity/base/QualityOfService.java | 0 .../java/org/iotivity/base/RequestHandlerFlag.java | 0 .../main/java/org/iotivity/base/RequestType.java | 0 .../java/org/iotivity/base/ResourceProperty.java | 0 .../main/java/org/iotivity/base/ServiceType.java | 0 .../examples-android}/build.gradle | 0 .../devicediscoveryclient}/.gitignore | 0 .../devicediscoveryclient/build.gradle | 37 + .../devicediscoveryclient.iml | 0 .../devicediscoveryclient}/proguard-rules.pro | 0 .../src/main/AndroidManifest.xml | 0 .../base/examples/DeviceDiscoveryClient.java | 0 .../src/main/res/drawable}/iotivityicon.png | Bin .../src/main/res/drawable/iotivitylogo.png | Bin .../layout/activity_device_discovery_client.xml | 0 .../src/main/res/mipmap-hdpi}/iotivityicon.png | Bin .../src/main/res/mipmap-mdpi/iotivityicon.png | Bin .../src/main/res/mipmap-xhdpi/iotivityicon.png | Bin .../src/main/res/mipmap-xxhdpi/iotivityicon.png | Bin .../src/main/res/values-v21/styles.xml | 0 .../src/main/res/values-w820dp/dimens.xml | 0 .../src/main/res/values/dimens.xml | 0 .../src/main/res/values/strings.xml | 0 .../src/main/res/values/styles.xml | 0 .../devicediscoveryserver}/.gitignore | 0 .../devicediscoveryserver/build.gradle | 37 + .../devicediscoveryserver.iml | 0 .../devicediscoveryserver}/proguard-rules.pro | 0 .../src/main/AndroidManifest.xml | 0 .../base/examples/DeviceDiscoveryServer.java | 0 .../src/main/res/drawable}/iotivityicon.png | Bin .../src/main/res/drawable/iotivitylogo.png | Bin .../layout/activity_device_discovery_server.xml | 0 .../src/main/res/mipmap-hdpi}/iotivityicon.png | Bin .../src/main/res/mipmap-mdpi/iotivityicon.png | Bin .../src/main/res/mipmap-xhdpi/iotivityicon.png | Bin .../src/main/res/mipmap-xxhdpi/iotivityicon.png | Bin .../src/main/res/values-v21/styles.xml | 0 .../src/main/res/values-w820dp/dimens.xml | 0 .../src/main/res/values/dimens.xml | 0 .../src/main/res/values/strings.xml | 0 .../src/main/res/values/styles.xml | 0 .../examples-android}/examples.iml | 0 .../examples-android/fridgeclient}/.gitignore | 0 java/examples-android/fridgeclient/build.gradle | 35 + .../fridgeclient/fridgeclient.iml | 0 .../fridgeclient/src/main/AndroidManifest.xml | 0 .../org/iotivity/base/examples/FridgeClient.java | 0 .../src/main/res/drawable-hdpi}/iotivityicon.png | Bin .../src/main/res/drawable-hdpi}/iotivitylogo.png | Bin .../src/main/res/drawable-mdpi}/iotivityicon.png | Bin .../src/main/res/drawable-mdpi}/iotivitylogo.png | Bin .../src/main/res/drawable-xhdpi}/iotivityicon.png | Bin .../src/main/res/drawable-xhdpi}/iotivitylogo.png | Bin .../src/main/res/drawable-xxhdpi}/iotivityicon.png | Bin .../src/main/res/drawable-xxhdpi}/iotivitylogo.png | Bin .../src/main/res/layout/activity_fridge_client.xml | 0 .../src/main/res/menu/menu_fridge_client.xml | 0 .../src/main/res/values-w820dp/dimens.xml | 0 .../fridgeclient}/src/main/res/values/dimens.xml | 0 .../fridgeclient/src/main/res/values/strings.xml | 0 .../fridgeclient}/src/main/res/values/styles.xml | 0 .../examples-android/fridgegroupclient}/.gitignore | 0 .../fridgegroupclient/build.gradle | 35 + .../fridgegroupclient/src/main/AndroidManifest.xml | 0 .../iotivity/base/examples/FridgeGroupClient.java | 0 .../src/main/res/drawable-hdpi}/iotivityicon.png | Bin .../src/main/res/drawable-hdpi}/iotivitylogo.png | Bin .../src/main/res/drawable-mdpi}/iotivityicon.png | Bin .../src/main/res/drawable-mdpi}/iotivitylogo.png | Bin .../src/main/res/drawable-xhdpi}/iotivityicon.png | Bin .../src/main/res/drawable-xhdpi/iotivitylogo.png | Bin .../src/main/res/drawable-xxhdpi}/iotivityicon.png | Bin .../src/main/res/drawable-xxhdpi}/iotivitylogo.png | Bin .../src/main/res/layout/activity_fridge_client.xml | 0 .../src/main/res/values-w820dp/dimens.xml | 0 .../src/main/res/values/assets.xml | 0 .../src/main/res/values/dimens.xml | 0 .../src/main/res/values/strings.xml | 0 .../src/main/res/values/styles.xml | 0 .../examples-android/fridgegroupserver}/.gitignore | 0 .../fridgegroupserver/build.gradle | 35 + .../fridgegroupserver/src/main/AndroidManifest.xml | 0 .../org/iotivity/base/examples/DoorResource.java | 0 .../iotivity/base/examples/FridgeGroupServer.java | 0 .../org/iotivity/base/examples/FridgeResource.java | 0 .../org/iotivity/base/examples/LightResource.java | 0 .../org/iotivity/base/examples/Refrigerator.java | 0 .../java/org/iotivity/base/examples/Resource.java | 0 .../src/main/res/drawable-hdpi/ic_launcher.png | Bin .../src/main/res/drawable-hdpi}/iotivityicon.png | Bin .../src/main/res/drawable-hdpi/iotivitylogo.png | Bin .../src/main/res/drawable-mdpi/ic_launcher.png | Bin .../src/main/res/drawable-mdpi}/iotivityicon.png | Bin .../src/main/res/drawable-mdpi}/iotivitylogo.png | Bin .../src/main/res/drawable-xhdpi/ic_launcher.png | Bin .../src/main/res/drawable-xhdpi}/iotivityicon.png | Bin .../src/main/res/drawable-xhdpi/iotivitylogo.png | Bin .../src/main/res/drawable-xxhdpi/ic_launcher.png | Bin .../src/main/res/drawable-xxhdpi}/iotivityicon.png | Bin .../src/main/res/drawable-xxhdpi}/iotivitylogo.png | Bin .../src/main/res/layout/activity_fridge_server.xml | 0 .../src/main/res/values-w820dp/dimens.xml | 0 .../src/main/res/values/dimens.xml | 0 .../src/main/res/values/strings.xml | 0 .../src/main/res/values/styles.xml | 0 .../examples-android}/fridgeserver/.gitignore | 0 java/examples-android/fridgeserver/build.gradle | 35 + .../fridgeserver/fridgeserver.iml | 0 .../fridgeserver/src/main/AndroidManifest.xml | 0 .../base/examples/fridgeserver/DeviceResource.java | 0 .../base/examples/fridgeserver/DoorResource.java | 0 .../base/examples/fridgeserver/FridgeServer.java | 0 .../base/examples/fridgeserver/LightResource.java | 0 .../base/examples/fridgeserver/Refrigerator.java | 0 .../base/examples/fridgeserver/Resource.java | 0 .../src/main/res/drawable-hdpi}/iotivityicon.png | Bin .../src/main/res/drawable-hdpi/iotivitylogo.png | Bin .../src/main/res/drawable-mdpi}/iotivityicon.png | Bin .../src/main/res/drawable-mdpi}/iotivitylogo.png | Bin .../src/main/res/drawable-xhdpi}/iotivityicon.png | Bin .../src/main/res/drawable-xhdpi/iotivitylogo.png | Bin .../src/main/res/drawable-xxhdpi}/iotivityicon.png | Bin .../src/main/res/drawable-xxhdpi}/iotivitylogo.png | Bin .../src/main/res/layout/activity_fridge_server.xml | 0 .../src/main/res/values-w820dp/dimens.xml | 0 .../fridgeserver}/src/main/res/values/dimens.xml | 0 .../fridgeserver/src/main/res/values/strings.xml | 0 .../fridgeserver}/src/main/res/values/styles.xml | 0 .../examples-android}/gradle.properties | 0 .../gradle/wrapper/gradle-wrapper.jar | Bin .../gradle/wrapper/gradle-wrapper.properties | 0 .../examples => java/examples-android}/gradlew | 0 .../examples => java/examples-android}/gradlew.bat | 0 .../examples-android/groupclient}/.gitignore | 0 java/examples-android/groupclient/build.gradle | 37 + .../examples-android}/groupclient/groupclient.iml | 0 .../groupclient}/proguard-rules.pro | 0 .../groupclient/src/main/AndroidManifest.xml | 0 .../org/iotivity/base/examples/GroupClient.java | 0 .../src/main/res/drawable}/iotivityicon.png | Bin .../src/main/res/drawable}/iotivitylogo.png | Bin .../src/main/res/layout/activity_group_client.xml | 0 .../src/main/res/mipmap-hdpi}/iotivityicon.png | Bin .../src/main/res/mipmap-mdpi/iotivityicon.png | Bin .../src/main/res/mipmap-xhdpi/iotivityicon.png | Bin .../src/main/res/mipmap-xxhdpi/iotivityicon.png | Bin .../src/main/res/values-v21/styles.xml | 0 .../src/main/res/values-w820dp/dimens.xml | 0 .../groupclient/src/main/res/values/dimens.xml | 0 .../groupclient/src/main/res/values/strings.xml | 0 .../groupclient}/src/main/res/values/styles.xml | 0 .../examples-android/groupserver}/.gitignore | 0 java/examples-android/groupserver/build.gradle | 37 + .../examples-android}/groupserver/groupserver.iml | 0 .../groupserver}/proguard-rules.pro | 0 .../groupserver/src/main/AndroidManifest.xml | 0 .../org/iotivity/base/examples/GroupServer.java | 0 .../src/main/res/drawable}/iotivityicon.png | Bin .../src/main/res/drawable}/iotivitylogo.png | Bin .../src/main/res/layout/activity_group_server.xml | 0 .../src/main/res/mipmap-hdpi}/iotivityicon.png | Bin .../src/main/res/mipmap-mdpi/iotivityicon.png | Bin .../src/main/res/mipmap-xhdpi/iotivityicon.png | Bin .../src/main/res/mipmap-xxhdpi/iotivityicon.png | Bin .../src/main/res/values-v21/styles.xml | 0 .../src/main/res/values-w820dp/dimens.xml | 0 .../groupserver}/src/main/res/values/dimens.xml | 0 .../groupserver/src/main/res/values/strings.xml | 0 .../groupserver}/src/main/res/values/styles.xml | 0 .../examples-android}/guiclient/.gitignore | 0 .../examples-android}/guiclient/build.gradle | 0 .../examples-android}/guiclient/guiclient.iml | 0 .../examples-android}/guiclient/proguard-rules.pro | 0 .../guiclient/src/main/AndroidManifest.xml | 0 .../guiclient/ExpandableResourceListAdapter.java | 0 .../java/org/iotivity/guiclient/MainActivity.java | 0 .../org/iotivity/guiclient/OcAttributeInfo.java | 0 .../org/iotivity/guiclient/OcProtocolStrings.java | 0 .../org/iotivity/guiclient/OcResourceInfo.java | 0 .../main/java/org/iotivity/guiclient/OcWorker.java | 0 .../org/iotivity/guiclient/OcWorkerListener.java | 0 .../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 .../main/res/drawable/android_resource_icon.png | Bin .../src/main/res/drawable/attribute_icon.png | Bin .../src/main/res/drawable/ic_action_discard.png | Bin .../main/res/drawable/ic_action_discard_dark.png | Bin .../src/main/res/drawable/ic_action_refresh.png | Bin .../src/main/res/drawable/iotivity_hex_icon.png | Bin .../guiclient/src/main/res/drawable/led_icon.png | Bin .../guiclient/src/main/res/drawable/light_icon.png | Bin .../src/main/res/drawable/thermometer_icon.png | Bin .../layout/actionbar_indeterminate_progress.xml | 0 .../src/main/res/layout/activity_main.xml | 0 .../res/layout/attribute_layout_on_off_switch.xml | 0 .../res/layout/attribute_layout_progress_bar.xml | 0 .../main/res/layout/attribute_layout_slider.xml | 0 .../main/res/layout/resource_list_item_layout.xml | 0 .../guiclient/src/main/res/menu/menu_main.xml | 0 .../guiclient/src/main/res/values-large}/refs.xml | 0 .../guiclient/src/main/res/values-sw600dp/refs.xml | 0 .../src/main/res/values-w820dp/dimens.xml | 0 .../guiclient/src/main/res/values/dimens.xml | 0 .../guiclient/src/main/res/values}/refs.xml | 0 .../guiclient/src/main/res/values/strings.xml | 0 .../guiclient/src/main/res/values/styles.xml | 0 .../examples-android/presenceclient}/.gitignore | 0 java/examples-android/presenceclient/build.gradle | 37 + .../presenceclient/presenceclient.iml | 0 .../presenceclient/src/main/AndroidManifest.xml | 0 .../org/iotivity/base/examples/PresenceClient.java | 0 .../src/main/res/drawable}/iotivityicon.png | Bin .../src/main/res/drawable}/iotivitylogo.png | Bin .../main/res/layout/activity_presence_client.xml | 0 .../src/main/res/mipmap-hdpi}/iotivityicon.png | Bin .../src/main/res/mipmap-mdpi/iotivityicon.png | Bin .../src/main/res/mipmap-xhdpi/iotivityicon.png | Bin .../src/main/res/mipmap-xxhdpi/iotivityicon.png | Bin .../src/main/res/values-v21/styles.xml | 0 .../src/main/res/values-w820dp/dimens.xml | 0 .../presenceclient}/src/main/res/values/dimens.xml | 0 .../presenceclient/src/main/res/values/strings.xml | 0 .../presenceclient}/src/main/res/values/styles.xml | 0 .../examples-android/presenceserver}/.gitignore | 0 java/examples-android/presenceserver/build.gradle | 37 + .../presenceserver/presenceserver.iml | 0 .../presenceserver/src/main/AndroidManifest.xml | 0 .../org/iotivity/base/examples/PresenceServer.java | 0 .../src/main/res/drawable}/iotivityicon.png | Bin .../src/main/res/drawable}/iotivitylogo.png | Bin .../main/res/layout/activity_presence_server.xml | 0 .../src/main/res/mipmap-hdpi}/iotivityicon.png | Bin .../src/main/res/mipmap-mdpi/iotivityicon.png | Bin .../src/main/res/mipmap-xhdpi/iotivityicon.png | Bin .../src/main/res/mipmap-xxhdpi/iotivityicon.png | Bin .../src/main/res/values-v21/styles.xml | 0 .../src/main/res/values-w820dp/dimens.xml | 0 .../presenceserver}/src/main/res/values/dimens.xml | 0 .../presenceserver/src/main/res/values/strings.xml | 0 .../presenceserver}/src/main/res/values/styles.xml | 0 .../provisioningclient/build.gradle | 38 + .../provisioningclient/proguard-rules.pro | 0 .../provisioningclient/provisioningclient.iml | 0 .../src/main/AndroidManifest.xml | 0 .../src/main/assets/oic_svr_db_client.json | 0 .../provisioningclient/ProvisioningClient.java | 0 .../provisioningclient/StringConstants.java | 0 .../layout/activity_secure_provision_client.xml | 0 .../main/res/menu/menu_secure_provision_client.xml | 0 .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin .../src/main/res/mipmap-xxhdpi/ic_launcher.png | Bin .../src/main/res/values-v21/styles.xml | 0 .../src/main/res/values-w820dp/dimens.xml | 0 .../src/main/res/values/dimens.xml | 0 .../src/main/res/values/strings.xml | 0 .../src/main/res/values/styles.xml | 0 .../examples-android}/settings.gradle | 0 .../examples-android/simplebase}/.gitignore | 0 .../examples-android}/simplebase/build.gradle | 2 +- .../simplebase/libs/android-support-v4.jar | Bin .../simplebase/proguard-rules.pro | 0 .../examples-android}/simplebase/simplebase.iml | 0 .../simplebase/src/main/AndroidManifest.xml | 0 .../iotivity/base/examples/BluetoothFragment.java | 0 .../java/org/iotivity/base/examples/Common.java | 0 .../org/iotivity/base/examples/DrawerFragment.java | 0 .../iotivity/base/examples/MessageFragment.java | 0 .../org/iotivity/base/examples/SimpleBase.java | 0 .../iotivity/base/examples/TemplateFragment.java | 0 .../src/main/res/drawable-hdpi/drawer_shadow.9.png | Bin .../src/main/res/drawable-hdpi/ic_drawer.png | Bin .../src/main/res/drawable-mdpi/drawer_shadow.9.png | Bin .../src/main/res/drawable-mdpi/ic_drawer.png | Bin .../main/res/drawable-xhdpi/drawer_shadow.9.png | Bin .../src/main/res/drawable-xhdpi/ic_drawer.png | Bin .../main/res/drawable-xxhdpi/drawer_shadow.9.png | Bin .../src/main/res/drawable-xxhdpi/ic_drawer.png | Bin .../src/main/res/drawable}/iotivityicon.png | Bin .../src/main/res/drawable}/iotivitylogo.png | Bin .../src/main/res/layout/activity_simplebase.xml | 0 .../src/main/res/layout/fragment_bluetooth.xml | 0 .../src/main/res/layout/fragment_drawer.xml | 0 .../src/main/res/layout/fragment_message.xml | 0 .../src/main/res/layout/fragment_template.xml | 0 .../simplebase/src/main/res/layout/tcp_input.xml | 0 .../src/main/res/mipmap-hdpi}/iotivityicon.png | Bin .../src/main/res/mipmap-mdpi/iotivityicon.png | Bin .../src/main/res/mipmap-xhdpi/iotivityicon.png | Bin .../src/main/res/mipmap-xxhdpi/iotivityicon.png | Bin .../simplebase}/src/main/res/values-v21/styles.xml | 0 .../src/main/res/values-w820dp/dimens.xml | 0 .../simplebase/src/main/res/values/dimens.xml | 0 .../simplebase/src/main/res/values/strings.xml | 0 .../simplebase}/src/main/res/values/styles.xml | 0 .../examples-android/simpleclient}/.gitignore | 0 .../examples-android}/simpleclient/build.gradle | 2 +- .../simpleclient}/proguard-rules.pro | 0 .../simpleclient/simpleclient.iml | 0 .../simpleclient/src/main/AndroidManifest.xml | 0 .../src/main/assets/oic_svr_db_client.json | 0 .../java/org/iotivity/base/examples/Light.java | 0 .../org/iotivity/base/examples/SimpleClient.java | 0 .../src/main/res/drawable}/iotivityicon.png | Bin .../src/main/res/drawable/iotivitylogo.png | Bin .../src/main/res/layout/activity_simple_client.xml | 0 .../src/main/res/mipmap-hdpi}/iotivityicon.png | Bin .../src/main/res/mipmap-mdpi/iotivityicon.png | Bin .../src/main/res/mipmap-xhdpi/iotivityicon.png | Bin .../src/main/res/mipmap-xxhdpi/iotivityicon.png | Bin .../src/main/res/values-v21/styles.xml | 0 .../src/main/res/values-w820dp/dimens.xml | 0 .../simpleclient}/src/main/res/values/dimens.xml | 0 .../simpleclient/src/main/res/values/strings.xml | 0 .../simpleclient}/src/main/res/values/styles.xml | 0 .../examples-android/simpleserver}/.gitignore | 0 .../examples-android}/simpleserver/build.gradle | 2 +- .../simpleserver}/proguard-rules.pro | 0 .../simpleserver/simpleserver.iml | 0 .../simpleserver/src/main/AndroidManifest.xml | 0 .../src/main/assets/oic_svr_db_server.json | 0 .../java/org/iotivity/base/examples/Light.java | 0 .../org/iotivity/base/examples/SimpleServer.java | 0 .../src/main/res/drawable}/iotivityicon.png | Bin .../src/main/res/drawable/iotivitylogo.png | Bin .../src/main/res/layout/activity_simple_server.xml | 0 .../src/main/res/mipmap-hdpi}/iotivityicon.png | Bin .../src/main/res/mipmap-mdpi/iotivityicon.png | Bin .../src/main/res/mipmap-xhdpi/iotivityicon.png | Bin .../src/main/res/mipmap-xxhdpi/iotivityicon.png | Bin .../src/main/res/values-v21/styles.xml | 0 .../src/main/res/values-w820dp/dimens.xml | 0 .../simpleserver}/src/main/res/values/dimens.xml | 0 .../simpleserver/src/main/res/values/strings.xml | 0 .../simpleserver}/src/main/res/values/styles.xml | 0 java/examples-java/build.gradle | 22 + .../examples-java/devicediscoveryclient/.gitignore | 1 + .../devicediscoveryclient/build.gradle | 0 .../base/examples/DeviceDiscoveryClient.java | 233 +++++ .../examples-java/devicediscoveryserver/.gitignore | 1 + .../devicediscoveryserver/build.gradle | 0 .../base/examples/DeviceDiscoveryServer.java | 163 ++++ java/examples-java/fridgeclient/.gitignore | 1 + .../examples-java}/fridgeclient/build.gradle | 0 .../org/iotivity/base/examples/FridgeClient.java | 248 ++++++ java/examples-java/fridgegroupclient/.gitignore | 1 + .../examples-java}/fridgegroupclient/build.gradle | 0 .../iotivity/base/examples/FridgeGroupClient.java | 258 ++++++ java/examples-java/fridgegroupserver/.gitignore | 1 + .../examples-java}/fridgegroupserver/build.gradle | 0 .../org/iotivity/base/examples/DoorResource.java | 172 ++++ .../iotivity/base/examples/FridgeGroupServer.java | 143 ++++ .../org/iotivity/base/examples/FridgeResource.java | 82 ++ .../org/iotivity/base/examples/LightResource.java | 161 ++++ .../org/iotivity/base/examples/Refrigerator.java | 62 ++ .../java/org/iotivity/base/examples/Resource.java | 59 ++ java/examples-java/fridgeserver/.gitignore | 1 + .../examples-java}/fridgeserver/build.gradle | 0 .../base/examples/fridgeserver/DeviceResource.java | 165 ++++ .../base/examples/fridgeserver/DoorResource.java | 169 ++++ .../base/examples/fridgeserver/FridgeServer.java | 132 +++ .../base/examples/fridgeserver/LightResource.java | 159 ++++ .../base/examples/fridgeserver/Refrigerator.java | 62 ++ .../base/examples/fridgeserver/Resource.java | 61 ++ java/examples-java/gradle.properties | 47 + .../gradle/wrapper/gradle-wrapper.jar | Bin .../gradle/wrapper/gradle-wrapper.properties | 6 + .../android_api => java/examples-java}/gradlew | 0 .../android_api => java/examples-java}/gradlew.bat | 0 java/examples-java/groupclient/.gitignore | 1 + .../examples-java}/groupclient/build.gradle | 0 .../org/iotivity/base/examples/GroupClient.java | 295 +++++++ java/examples-java/groupserver/.gitignore | 1 + .../examples-java}/groupserver/build.gradle | 0 .../org/iotivity/base/examples/GroupServer.java | 333 ++++++++ java/examples-java/guiclient/.gitignore | 1 + java/examples-java/guiclient/build.gradle | 25 + .../guiclient/ExpandableResourceListAdapter.java | 382 +++++++++ .../java/org/iotivity/guiclient/MainActivity.java | 336 ++++++++ .../org/iotivity/guiclient/OcAttributeInfo.java | 176 ++++ .../org/iotivity/guiclient/OcProtocolStrings.java | 50 ++ .../org/iotivity/guiclient/OcResourceInfo.java | 375 ++++++++ .../main/java/org/iotivity/guiclient/OcWorker.java | 524 ++++++++++++ .../org/iotivity/guiclient/OcWorkerListener.java | 56 ++ java/examples-java/presenceclient/.gitignore | 1 + .../examples-java}/presenceclient/build.gradle | 0 .../org/iotivity/base/examples/PresenceClient.java | 240 ++++++ java/examples-java/presenceserver/.gitignore | 1 + .../examples-java}/presenceserver/build.gradle | 0 .../org/iotivity/base/examples/PresenceServer.java | 219 +++++ .../examples-java}/provisioningclient/build.gradle | 0 .../src/main/assets/oic_svr_db_client.json | 43 + .../provisioningclient/ProvisioningClient.java | 593 +++++++++++++ .../provisioningclient/StringConstants.java | 14 + java/examples-java/settings.gradle | 1 + java/examples-java/simpleclient/.gitignore | 1 + java/examples-java/simpleclient/build.gradle | 0 .../src/main/assets/oic_svr_db_client.json | 50 ++ .../java/org/iotivity/base/examples/Light.java | 92 ++ .../org/iotivity/base/examples/SimpleClient.java | 555 ++++++++++++ java/examples-java/simpleserver/.gitignore | 1 + java/examples-java/simpleserver/build.gradle | 1 + .../src/main/assets/oic_svr_db_server.json | 56 ++ .../java/org/iotivity/base/examples/Light.java | 372 ++++++++ .../org/iotivity/base/examples/SimpleServer.java | 138 +++ {android/android_api => java}/gradle.properties | 0 java/gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 49896 bytes .../gradle/wrapper/gradle-wrapper.properties | 0 java/gradlew | 164 ++++ java/gradlew.bat | 90 ++ .../base => java/iotivity-android}/build.gradle | 86 +- .../iotivity-android}/proguard-rules.pro | 0 .../src/androidTest}/AndroidManifest.xml | 0 .../org/iotivity/base/OcRepresentationTest.java | 0 .../java/org/iotivity/base/SmokeTest.java | 0 .../iotivity-android/src/main}/AndroidManifest.xml | 0 .../main/java/org/iotivity/base/OcPlatform.java | 0 .../java/org/iotivity/base/PlatformConfig.java | 0 .../java/org/iotivity/ca/CaBtPairingInterface.java | 0 .../main/java/org/iotivity/ca/CaEdrInterface.java | 0 .../src/main/java/org/iotivity/ca/CaInterface.java | 0 .../main/java/org/iotivity/ca/CaIpInterface.java | 0 .../java/org/iotivity/ca/CaLeClientInterface.java | 0 .../java/org/iotivity/ca/CaLeServerInterface.java | 0 .../main/java/org/iotivity/ca/CaNfcInterface.java | 0 java/iotivity-linux/build.gradle | 37 + .../main/java/org/iotivity/base/OcPlatform.java | 949 +++++++++++++++++++++ .../java/org/iotivity/base/PlatformConfig.java | 108 +++ .../src/main/java/org/iotivity/ca/CaInterface.java | 178 ++++ .../main/java/org/iotivity/ca/CaIpInterface.java | 58 ++ .../android_api/base => java}/jni/JniCaInterface.c | 44 +- .../android_api/base => java}/jni/JniCaInterface.h | 31 + .../base => java}/jni/JniDisplayPinListener.cpp | 0 .../base => java}/jni/JniDisplayPinListener.h | 0 .../base => java}/jni/JniEntityHandler.cpp | 0 .../base => java}/jni/JniEntityHandler.h | 0 .../base => java}/jni/JniListenerManager.h | 0 .../base => java}/jni/JniOcPlatform.cpp | 2 - .../android_api/base => java}/jni/JniOcPlatform.h | 0 .../base => java}/jni/JniOcPresenceHandle.cpp | 0 .../base => java}/jni/JniOcPresenceHandle.h | 0 .../base => java}/jni/JniOcProvisioning.cpp | 0 .../base => java}/jni/JniOcProvisioning.h | 0 .../base => java}/jni/JniOcRepresentation.cpp | 0 .../base => java}/jni/JniOcRepresentation.h | 0 .../base => java}/jni/JniOcRequestHandle.cpp | 0 .../base => java}/jni/JniOcRequestHandle.h | 0 .../base => java}/jni/JniOcResource.cpp | 0 .../android_api/base => java}/jni/JniOcResource.h | 0 .../base => java}/jni/JniOcResourceHandle.cpp | 0 .../base => java}/jni/JniOcResourceHandle.h | 0 .../base => java}/jni/JniOcResourceIdentifier.cpp | 0 .../base => java}/jni/JniOcResourceIdentifier.h | 0 .../base => java}/jni/JniOcResourceRequest.cpp | 0 .../base => java}/jni/JniOcResourceRequest.h | 0 .../base => java}/jni/JniOcResourceResponse.cpp | 0 .../base => java}/jni/JniOcResourceResponse.h | 0 .../base => java}/jni/JniOcSecureResource.cpp | 0 .../base => java}/jni/JniOcSecureResource.h | 0 .../base => java}/jni/JniOcSecurity.cpp | 0 .../android_api/base => java}/jni/JniOcSecurity.h | 0 .../android_api/base => java}/jni/JniOcStack.cpp | 0 .../android_api/base => java}/jni/JniOcStack.h | 14 +- .../base => java}/jni/JniOnDeleteListener.cpp | 0 .../base => java}/jni/JniOnDeleteListener.h | 0 .../base => java}/jni/JniOnDeviceInfoListener.cpp | 0 .../base => java}/jni/JniOnDeviceInfoListener.h | 0 .../base => java}/jni/JniOnGetListener.cpp | 0 .../base => java}/jni/JniOnGetListener.h | 0 .../base => java}/jni/JniOnObserveListener.cpp | 0 .../base => java}/jni/JniOnObserveListener.h | 0 .../jni/JniOnPlatformInfoListener.cpp | 0 .../base => java}/jni/JniOnPlatformInfoListener.h | 0 .../base => java}/jni/JniOnPostListener.cpp | 0 .../base => java}/jni/JniOnPostListener.h | 0 .../base => java}/jni/JniOnPresenceListener.cpp | 0 .../base => java}/jni/JniOnPresenceListener.h | 0 .../base => java}/jni/JniOnPutListener.cpp | 0 .../base => java}/jni/JniOnPutListener.h | 0 .../jni/JniOnResourceFoundListener.cpp | 0 .../base => java}/jni/JniOnResourceFoundListener.h | 0 .../base => java}/jni/JniPinCheckListener.cpp | 0 .../base => java}/jni/JniPinCheckListener.h | 0 .../jni/JniProvisionResultListner.cpp | 0 .../base => java}/jni/JniProvisionResultListner.h | 0 .../base => java}/jni/JniSecureUtils.cpp | 0 .../android_api/base => java}/jni/JniSecureUtils.h | 0 .../android_api/base => java}/jni/JniUtils.cpp | 0 {android/android_api/base => java}/jni/JniUtils.h | 0 java/jni/SConscript | 125 +++ {android/android_api => java}/settings.gradle | 2 - resource/csdk/connectivity/api/cautilinterface.h | 14 +- resource/csdk/connectivity/inc/caadapterutils.h | 65 +- .../connectivity/src/adapter_util/caadapterutils.c | 114 +-- .../csdk/connectivity/util/src/cautilinterface.c | 31 + 542 files changed, 9813 insertions(+), 421 deletions(-) delete mode 100644 android/android_api/.gitignore delete mode 100644 android/android_api/android_api.iml delete mode 100644 android/android_api/base/.gitignore delete mode 100755 android/android_api/base/base.iml delete mode 100644 android/android_api/base/jni/Android.mk delete mode 100644 android/android_api/base/jni/Application.mk rename {android/android_api => java}/SConscript (58%) rename {android/android_api => java}/build.gradle (80%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/CredType.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/DeviceStatus.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/EntityHandlerResult.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/ErrorCode.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/KeySize.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/ModeType.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/ObservationInfo.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/ObserveAction.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/ObserveType.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/OcConnectivityType.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/OcDeviceInfo.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/OcException.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/OcHeaderOption.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/OcPlatformInfo.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/OcPlatformStatus.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/OcPresenceHandle.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/OcPresenceStatus.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/OcProvisioning.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/OcRepresentation.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/OcRequestHandle.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/OcResource.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/OcResourceHandle.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/OcResourceIdentifier.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/OcResourceRequest.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/OcResourceResponse.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/OcSecureResource.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/OicSecAcl.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/OwnedStatus.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/OxmType.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/ProvisionResult.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/QualityOfService.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/RequestHandlerFlag.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/RequestType.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/ResourceProperty.java (100%) rename {android/android_api/base => java/common}/src/main/java/org/iotivity/base/ServiceType.java (100%) rename {android/examples => java/examples-android}/build.gradle (100%) rename {android/examples/presenceserver => java/examples-android/devicediscoveryclient}/.gitignore (100%) create mode 100644 java/examples-android/devicediscoveryclient/build.gradle rename {android/examples => java/examples-android}/devicediscoveryclient/devicediscoveryclient.iml (100%) rename {android/examples/simpleserver => java/examples-android/devicediscoveryclient}/proguard-rules.pro (100%) rename {android/examples => java/examples-android}/devicediscoveryclient/src/main/AndroidManifest.xml (100%) rename {android/examples => java/examples-android}/devicediscoveryclient/src/main/java/org/iotivity/base/examples/DeviceDiscoveryClient.java (100%) rename {android/examples/simpleserver/src/main/res/mipmap-hdpi => java/examples-android/devicediscoveryclient/src/main/res/drawable}/iotivityicon.png (100%) rename {android/examples/simpleserver => java/examples-android/devicediscoveryclient}/src/main/res/drawable/iotivitylogo.png (100%) rename {android/examples => java/examples-android}/devicediscoveryclient/src/main/res/layout/activity_device_discovery_client.xml (100%) rename {android/examples/simpleserver/src/main/res/drawable => java/examples-android/devicediscoveryclient/src/main/res/mipmap-hdpi}/iotivityicon.png (100%) rename {android/examples/simpleserver => java/examples-android/devicediscoveryclient}/src/main/res/mipmap-mdpi/iotivityicon.png (100%) rename {android/examples/simpleserver => java/examples-android/devicediscoveryclient}/src/main/res/mipmap-xhdpi/iotivityicon.png (100%) rename {android/examples/simpleserver => java/examples-android/devicediscoveryclient}/src/main/res/mipmap-xxhdpi/iotivityicon.png (100%) rename {android/examples/simpleserver => java/examples-android/devicediscoveryclient}/src/main/res/values-v21/styles.xml (100%) rename {android/examples/simpleserver => java/examples-android/devicediscoveryclient}/src/main/res/values-w820dp/dimens.xml (100%) rename {android/examples/simpleserver => java/examples-android/devicediscoveryclient}/src/main/res/values/dimens.xml (100%) rename {android/examples => java/examples-android}/devicediscoveryclient/src/main/res/values/strings.xml (100%) rename {android/examples/simpleserver => java/examples-android/devicediscoveryclient}/src/main/res/values/styles.xml (100%) rename {android/examples/presenceclient => java/examples-android/devicediscoveryserver}/.gitignore (100%) create mode 100644 java/examples-android/devicediscoveryserver/build.gradle rename {android/examples => java/examples-android}/devicediscoveryserver/devicediscoveryserver.iml (100%) rename {android/examples/simpleclient => java/examples-android/devicediscoveryserver}/proguard-rules.pro (100%) rename {android/examples => java/examples-android}/devicediscoveryserver/src/main/AndroidManifest.xml (100%) rename {android/examples => java/examples-android}/devicediscoveryserver/src/main/java/org/iotivity/base/examples/DeviceDiscoveryServer.java (100%) rename {android/examples/simpleclient/src/main/res/mipmap-hdpi => java/examples-android/devicediscoveryserver/src/main/res/drawable}/iotivityicon.png (100%) rename {android/examples/simpleclient => java/examples-android/devicediscoveryserver}/src/main/res/drawable/iotivitylogo.png (100%) rename {android/examples => java/examples-android}/devicediscoveryserver/src/main/res/layout/activity_device_discovery_server.xml (100%) rename {android/examples/simpleclient/src/main/res/drawable => java/examples-android/devicediscoveryserver/src/main/res/mipmap-hdpi}/iotivityicon.png (100%) rename {android/examples/simpleclient => java/examples-android/devicediscoveryserver}/src/main/res/mipmap-mdpi/iotivityicon.png (100%) rename {android/examples/simpleclient => java/examples-android/devicediscoveryserver}/src/main/res/mipmap-xhdpi/iotivityicon.png (100%) rename {android/examples/simpleclient => java/examples-android/devicediscoveryserver}/src/main/res/mipmap-xxhdpi/iotivityicon.png (100%) rename {android/examples/simpleclient => java/examples-android/devicediscoveryserver}/src/main/res/values-v21/styles.xml (100%) rename {android/examples/simpleclient => java/examples-android/devicediscoveryserver}/src/main/res/values-w820dp/dimens.xml (100%) rename {android/examples/simpleclient => java/examples-android/devicediscoveryserver}/src/main/res/values/dimens.xml (100%) rename {android/examples => java/examples-android}/devicediscoveryserver/src/main/res/values/strings.xml (100%) rename {android/examples/simpleclient => java/examples-android/devicediscoveryserver}/src/main/res/values/styles.xml (100%) rename {android/examples => java/examples-android}/examples.iml (100%) rename {android/examples/simpleserver => java/examples-android/fridgeclient}/.gitignore (100%) mode change 100644 => 100755 create mode 100755 java/examples-android/fridgeclient/build.gradle rename {android/examples => java/examples-android}/fridgeclient/fridgeclient.iml (100%) rename {android/examples => java/examples-android}/fridgeclient/src/main/AndroidManifest.xml (100%) rename {android/examples => java/examples-android}/fridgeclient/src/main/java/org/iotivity/base/examples/FridgeClient.java (100%) rename {android/examples/simplebase/src/main/res/mipmap-hdpi => java/examples-android/fridgeclient/src/main/res/drawable-hdpi}/iotivityicon.png (100%) mode change 100644 => 100755 rename {android/examples/simplebase/src/main/res/drawable => java/examples-android/fridgeclient/src/main/res/drawable-hdpi}/iotivitylogo.png (100%) mode change 100644 => 100755 rename {android/examples/simplebase/src/main/res/drawable => java/examples-android/fridgeclient/src/main/res/drawable-mdpi}/iotivityicon.png (100%) mode change 100644 => 100755 rename {android/examples/presenceserver/src/main/res/drawable => java/examples-android/fridgeclient/src/main/res/drawable-mdpi}/iotivitylogo.png (100%) mode change 100644 => 100755 rename {android/examples/presenceserver/src/main/res/mipmap-hdpi => java/examples-android/fridgeclient/src/main/res/drawable-xhdpi}/iotivityicon.png (100%) mode change 100644 => 100755 rename {android/examples/presenceclient/src/main/res/drawable => java/examples-android/fridgeclient/src/main/res/drawable-xhdpi}/iotivitylogo.png (100%) mode change 100644 => 100755 rename {android/examples/presenceserver/src/main/res/drawable => java/examples-android/fridgeclient/src/main/res/drawable-xxhdpi}/iotivityicon.png (100%) mode change 100644 => 100755 rename {android/examples/groupserver/src/main/res/drawable => java/examples-android/fridgeclient/src/main/res/drawable-xxhdpi}/iotivitylogo.png (100%) mode change 100644 => 100755 rename {android/examples => java/examples-android}/fridgeclient/src/main/res/layout/activity_fridge_client.xml (100%) rename {android/examples => java/examples-android}/fridgeclient/src/main/res/menu/menu_fridge_client.xml (100%) rename {android/examples/simplebase => java/examples-android/fridgeclient}/src/main/res/values-w820dp/dimens.xml (100%) mode change 100644 => 100755 rename {android/examples/provisioningclient => java/examples-android/fridgeclient}/src/main/res/values/dimens.xml (100%) mode change 100644 => 100755 rename {android/examples => java/examples-android}/fridgeclient/src/main/res/values/strings.xml (100%) rename {android/examples/simplebase => java/examples-android/fridgeclient}/src/main/res/values/styles.xml (100%) mode change 100644 => 100755 rename {android/examples/simpleclient => java/examples-android/fridgegroupclient}/.gitignore (100%) mode change 100644 => 100755 create mode 100755 java/examples-android/fridgegroupclient/build.gradle rename {android/examples => java/examples-android}/fridgegroupclient/src/main/AndroidManifest.xml (100%) rename {android/examples => java/examples-android}/fridgegroupclient/src/main/java/org/iotivity/base/examples/FridgeGroupClient.java (100%) rename {android/examples/presenceclient/src/main/res/mipmap-hdpi => java/examples-android/fridgegroupclient/src/main/res/drawable-hdpi}/iotivityicon.png (100%) mode change 100644 => 100755 rename {android/examples/groupclient/src/main/res/drawable => java/examples-android/fridgegroupclient/src/main/res/drawable-hdpi}/iotivitylogo.png (100%) mode change 100644 => 100755 rename {android/examples/presenceclient/src/main/res/drawable => java/examples-android/fridgegroupclient/src/main/res/drawable-mdpi}/iotivityicon.png (100%) mode change 100644 => 100755 rename {android/examples/fridgeserver/src/main/res/drawable-xxhdpi => java/examples-android/fridgegroupclient/src/main/res/drawable-mdpi}/iotivitylogo.png (100%) rename {android/examples/groupserver/src/main/res/mipmap-hdpi => java/examples-android/fridgegroupclient/src/main/res/drawable-xhdpi}/iotivityicon.png (100%) mode change 100644 => 100755 rename {android/examples/fridgeserver => java/examples-android/fridgegroupclient}/src/main/res/drawable-xhdpi/iotivitylogo.png (100%) rename {android/examples/groupserver/src/main/res/drawable => java/examples-android/fridgegroupclient/src/main/res/drawable-xxhdpi}/iotivityicon.png (100%) mode change 100644 => 100755 rename {android/examples/fridgeserver/src/main/res/drawable-mdpi => java/examples-android/fridgegroupclient/src/main/res/drawable-xxhdpi}/iotivitylogo.png (100%) rename {android/examples => java/examples-android}/fridgegroupclient/src/main/res/layout/activity_fridge_client.xml (100%) rename {android/examples/provisioningclient => java/examples-android/fridgegroupclient}/src/main/res/values-w820dp/dimens.xml (100%) mode change 100644 => 100755 rename {android/examples => java/examples-android}/fridgegroupclient/src/main/res/values/assets.xml (100%) rename {android/examples/presenceserver => java/examples-android/fridgegroupclient}/src/main/res/values/dimens.xml (100%) mode change 100644 => 100755 rename {android/examples => java/examples-android}/fridgegroupclient/src/main/res/values/strings.xml (100%) rename {android/examples/provisioningclient => java/examples-android/fridgegroupclient}/src/main/res/values/styles.xml (100%) mode change 100644 => 100755 rename {android/examples/simplebase => java/examples-android/fridgegroupserver}/.gitignore (100%) mode change 100644 => 100755 create mode 100755 java/examples-android/fridgegroupserver/build.gradle rename {android/examples => java/examples-android}/fridgegroupserver/src/main/AndroidManifest.xml (100%) rename {android/examples => java/examples-android}/fridgegroupserver/src/main/java/org/iotivity/base/examples/DoorResource.java (100%) rename {android/examples => java/examples-android}/fridgegroupserver/src/main/java/org/iotivity/base/examples/FridgeGroupServer.java (100%) rename {android/examples => java/examples-android}/fridgegroupserver/src/main/java/org/iotivity/base/examples/FridgeResource.java (100%) rename {android/examples => java/examples-android}/fridgegroupserver/src/main/java/org/iotivity/base/examples/LightResource.java (100%) rename {android/examples => java/examples-android}/fridgegroupserver/src/main/java/org/iotivity/base/examples/Refrigerator.java (100%) rename {android/examples => java/examples-android}/fridgegroupserver/src/main/java/org/iotivity/base/examples/Resource.java (100%) rename {android/examples/guiclient => java/examples-android/fridgegroupserver}/src/main/res/drawable-hdpi/ic_launcher.png (100%) mode change 100644 => 100755 rename {android/examples/groupclient/src/main/res/mipmap-hdpi => java/examples-android/fridgegroupserver/src/main/res/drawable-hdpi}/iotivityicon.png (100%) mode change 100644 => 100755 rename {android/examples/fridgeserver => java/examples-android/fridgegroupserver}/src/main/res/drawable-hdpi/iotivitylogo.png (100%) rename {android/examples/guiclient => java/examples-android/fridgegroupserver}/src/main/res/drawable-mdpi/ic_launcher.png (100%) mode change 100644 => 100755 rename {android/examples/groupclient/src/main/res/drawable => java/examples-android/fridgegroupserver/src/main/res/drawable-mdpi}/iotivityicon.png (100%) mode change 100644 => 100755 rename {android/examples/fridgegroupserver/src/main/res/drawable-xxhdpi => java/examples-android/fridgegroupserver/src/main/res/drawable-mdpi}/iotivitylogo.png (100%) rename {android/examples/guiclient => java/examples-android/fridgegroupserver}/src/main/res/drawable-xhdpi/ic_launcher.png (100%) mode change 100644 => 100755 rename {android/examples/fridgeserver/src/main/res/drawable-xxhdpi => java/examples-android/fridgegroupserver/src/main/res/drawable-xhdpi}/iotivityicon.png (100%) rename {android/examples => java/examples-android}/fridgegroupserver/src/main/res/drawable-xhdpi/iotivitylogo.png (100%) rename {android/examples/guiclient => java/examples-android/fridgegroupserver}/src/main/res/drawable-xxhdpi/ic_launcher.png (100%) mode change 100644 => 100755 rename {android/examples/fridgeserver/src/main/res/drawable-xhdpi => java/examples-android/fridgegroupserver/src/main/res/drawable-xxhdpi}/iotivityicon.png (100%) rename {android/examples/fridgegroupserver/src/main/res/drawable-mdpi => java/examples-android/fridgegroupserver/src/main/res/drawable-xxhdpi}/iotivitylogo.png (100%) rename {android/examples => java/examples-android}/fridgegroupserver/src/main/res/layout/activity_fridge_server.xml (100%) rename {android/examples/presenceserver => java/examples-android/fridgegroupserver}/src/main/res/values-w820dp/dimens.xml (100%) mode change 100644 => 100755 rename {android/examples/presenceclient => java/examples-android/fridgegroupserver}/src/main/res/values/dimens.xml (100%) mode change 100644 => 100755 rename {android/examples => java/examples-android}/fridgegroupserver/src/main/res/values/strings.xml (100%) rename {android/examples/presenceserver => java/examples-android/fridgegroupserver}/src/main/res/values/styles.xml (100%) mode change 100644 => 100755 rename {android/examples => java/examples-android}/fridgeserver/.gitignore (100%) create mode 100755 java/examples-android/fridgeserver/build.gradle rename {android/examples => java/examples-android}/fridgeserver/fridgeserver.iml (100%) rename {android/examples => java/examples-android}/fridgeserver/src/main/AndroidManifest.xml (100%) rename {android/examples => java/examples-android}/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DeviceResource.java (100%) rename {android/examples => java/examples-android}/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DoorResource.java (100%) rename {android/examples => java/examples-android}/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/FridgeServer.java (100%) rename {android/examples => java/examples-android}/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/LightResource.java (100%) rename {android/examples => java/examples-android}/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Refrigerator.java (100%) rename {android/examples => java/examples-android}/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Resource.java (100%) rename {android/examples/fridgeserver/src/main/res/drawable-mdpi => java/examples-android/fridgeserver/src/main/res/drawable-hdpi}/iotivityicon.png (100%) rename {android/examples/fridgegroupserver => java/examples-android/fridgeserver}/src/main/res/drawable-hdpi/iotivitylogo.png (100%) rename {android/examples/fridgeserver/src/main/res/drawable-hdpi => java/examples-android/fridgeserver/src/main/res/drawable-mdpi}/iotivityicon.png (100%) rename {android/examples/fridgegroupclient/src/main/res/drawable-xxhdpi => java/examples-android/fridgeserver/src/main/res/drawable-mdpi}/iotivitylogo.png (100%) rename {android/examples/fridgegroupserver/src/main/res/drawable-xxhdpi => java/examples-android/fridgeserver/src/main/res/drawable-xhdpi}/iotivityicon.png (100%) rename {android/examples/fridgegroupclient => java/examples-android/fridgeserver}/src/main/res/drawable-xhdpi/iotivitylogo.png (100%) rename {android/examples/fridgegroupserver/src/main/res/drawable-xhdpi => java/examples-android/fridgeserver/src/main/res/drawable-xxhdpi}/iotivityicon.png (100%) rename {android/examples/fridgegroupclient/src/main/res/drawable-mdpi => java/examples-android/fridgeserver/src/main/res/drawable-xxhdpi}/iotivitylogo.png (100%) rename {android/examples => java/examples-android}/fridgeserver/src/main/res/layout/activity_fridge_server.xml (100%) rename {android/examples/presenceclient => java/examples-android/fridgeserver}/src/main/res/values-w820dp/dimens.xml (100%) mode change 100644 => 100755 rename {android/examples/groupserver => java/examples-android/fridgeserver}/src/main/res/values/dimens.xml (100%) mode change 100644 => 100755 rename {android/examples => java/examples-android}/fridgeserver/src/main/res/values/strings.xml (100%) rename {android/examples/presenceclient => java/examples-android/fridgeserver}/src/main/res/values/styles.xml (100%) mode change 100644 => 100755 rename {android/examples => java/examples-android}/gradle.properties (100%) rename {android/examples => java/examples-android}/gradle/wrapper/gradle-wrapper.jar (100%) rename {android/examples => java/examples-android}/gradle/wrapper/gradle-wrapper.properties (100%) rename {android/examples => java/examples-android}/gradlew (100%) rename {android/examples => java/examples-android}/gradlew.bat (100%) rename {android/examples/groupserver => java/examples-android/groupclient}/.gitignore (100%) create mode 100644 java/examples-android/groupclient/build.gradle rename {android/examples => java/examples-android}/groupclient/groupclient.iml (100%) rename {android/examples/groupserver => java/examples-android/groupclient}/proguard-rules.pro (100%) rename {android/examples => java/examples-android}/groupclient/src/main/AndroidManifest.xml (100%) rename {android/examples => java/examples-android}/groupclient/src/main/java/org/iotivity/base/examples/GroupClient.java (100%) rename {android/examples/fridgegroupserver/src/main/res/drawable-mdpi => java/examples-android/groupclient/src/main/res/drawable}/iotivityicon.png (100%) mode change 100755 => 100644 rename {android/examples/fridgegroupclient/src/main/res/drawable-hdpi => java/examples-android/groupclient/src/main/res/drawable}/iotivitylogo.png (100%) mode change 100755 => 100644 rename {android/examples => java/examples-android}/groupclient/src/main/res/layout/activity_group_client.xml (100%) rename {android/examples/fridgegroupserver/src/main/res/drawable-hdpi => java/examples-android/groupclient/src/main/res/mipmap-hdpi}/iotivityicon.png (100%) mode change 100755 => 100644 rename {android/examples/simplebase => java/examples-android/groupclient}/src/main/res/mipmap-mdpi/iotivityicon.png (100%) rename {android/examples/simplebase => java/examples-android/groupclient}/src/main/res/mipmap-xhdpi/iotivityicon.png (100%) rename {android/examples/simplebase => java/examples-android/groupclient}/src/main/res/mipmap-xxhdpi/iotivityicon.png (100%) rename {android/examples/simplebase => java/examples-android/groupclient}/src/main/res/values-v21/styles.xml (100%) rename {android/examples/guiclient => java/examples-android/groupclient}/src/main/res/values-w820dp/dimens.xml (100%) rename {android/examples => java/examples-android}/groupclient/src/main/res/values/dimens.xml (100%) rename {android/examples => java/examples-android}/groupclient/src/main/res/values/strings.xml (100%) rename {android/examples/groupserver => java/examples-android/groupclient}/src/main/res/values/styles.xml (100%) rename {android/examples/groupclient => java/examples-android/groupserver}/.gitignore (100%) create mode 100644 java/examples-android/groupserver/build.gradle rename {android/examples => java/examples-android}/groupserver/groupserver.iml (100%) rename {android/examples/groupclient => java/examples-android/groupserver}/proguard-rules.pro (100%) rename {android/examples => java/examples-android}/groupserver/src/main/AndroidManifest.xml (100%) rename {android/examples => java/examples-android}/groupserver/src/main/java/org/iotivity/base/examples/GroupServer.java (100%) rename {android/examples/fridgegroupclient/src/main/res/drawable-xxhdpi => java/examples-android/groupserver/src/main/res/drawable}/iotivityicon.png (100%) mode change 100755 => 100644 rename {android/examples/fridgeclient/src/main/res/drawable-xxhdpi => java/examples-android/groupserver/src/main/res/drawable}/iotivitylogo.png (100%) mode change 100755 => 100644 rename {android/examples => java/examples-android}/groupserver/src/main/res/layout/activity_group_server.xml (100%) rename {android/examples/fridgegroupclient/src/main/res/drawable-xhdpi => java/examples-android/groupserver/src/main/res/mipmap-hdpi}/iotivityicon.png (100%) mode change 100755 => 100644 rename {android/examples/presenceserver => java/examples-android/groupserver}/src/main/res/mipmap-mdpi/iotivityicon.png (100%) rename {android/examples/presenceserver => java/examples-android/groupserver}/src/main/res/mipmap-xhdpi/iotivityicon.png (100%) rename {android/examples/presenceserver => java/examples-android/groupserver}/src/main/res/mipmap-xxhdpi/iotivityicon.png (100%) rename {android/examples/provisioningclient => java/examples-android/groupserver}/src/main/res/values-v21/styles.xml (100%) rename {android/examples => java/examples-android}/groupserver/src/main/res/values-w820dp/dimens.xml (100%) rename {android/examples/fridgeserver => java/examples-android/groupserver}/src/main/res/values/dimens.xml (100%) mode change 100755 => 100644 rename {android/examples => java/examples-android}/groupserver/src/main/res/values/strings.xml (100%) rename {android/examples/groupclient => java/examples-android/groupserver}/src/main/res/values/styles.xml (100%) rename {android/examples => java/examples-android}/guiclient/.gitignore (100%) rename {android/examples => java/examples-android}/guiclient/build.gradle (100%) rename {android/examples => java/examples-android}/guiclient/guiclient.iml (100%) rename {android/examples => java/examples-android}/guiclient/proguard-rules.pro (100%) rename {android/examples => java/examples-android}/guiclient/src/main/AndroidManifest.xml (100%) rename {android/examples => java/examples-android}/guiclient/src/main/java/org/iotivity/guiclient/ExpandableResourceListAdapter.java (100%) rename {android/examples => java/examples-android}/guiclient/src/main/java/org/iotivity/guiclient/MainActivity.java (100%) rename {android/examples => java/examples-android}/guiclient/src/main/java/org/iotivity/guiclient/OcAttributeInfo.java (100%) rename {android/examples => java/examples-android}/guiclient/src/main/java/org/iotivity/guiclient/OcProtocolStrings.java (100%) rename {android/examples => java/examples-android}/guiclient/src/main/java/org/iotivity/guiclient/OcResourceInfo.java (100%) rename {android/examples => java/examples-android}/guiclient/src/main/java/org/iotivity/guiclient/OcWorker.java (100%) rename {android/examples => java/examples-android}/guiclient/src/main/java/org/iotivity/guiclient/OcWorkerListener.java (100%) rename {android/examples/fridgegroupserver => java/examples-android/guiclient}/src/main/res/drawable-hdpi/ic_launcher.png (100%) mode change 100755 => 100644 rename {android/examples/fridgegroupserver => java/examples-android/guiclient}/src/main/res/drawable-mdpi/ic_launcher.png (100%) mode change 100755 => 100644 rename {android/examples/fridgegroupserver => java/examples-android/guiclient}/src/main/res/drawable-xhdpi/ic_launcher.png (100%) mode change 100755 => 100644 rename {android/examples/fridgegroupserver => java/examples-android/guiclient}/src/main/res/drawable-xxhdpi/ic_launcher.png (100%) mode change 100755 => 100644 rename {android/examples => java/examples-android}/guiclient/src/main/res/drawable/android_resource_icon.png (100%) rename {android/examples => java/examples-android}/guiclient/src/main/res/drawable/attribute_icon.png (100%) rename {android/examples => java/examples-android}/guiclient/src/main/res/drawable/ic_action_discard.png (100%) rename {android/examples => java/examples-android}/guiclient/src/main/res/drawable/ic_action_discard_dark.png (100%) rename {android/examples => java/examples-android}/guiclient/src/main/res/drawable/ic_action_refresh.png (100%) rename {android/examples => java/examples-android}/guiclient/src/main/res/drawable/iotivity_hex_icon.png (100%) rename {android/examples => java/examples-android}/guiclient/src/main/res/drawable/led_icon.png (100%) rename {android/examples => java/examples-android}/guiclient/src/main/res/drawable/light_icon.png (100%) rename {android/examples => java/examples-android}/guiclient/src/main/res/drawable/thermometer_icon.png (100%) rename {android/examples => java/examples-android}/guiclient/src/main/res/layout/actionbar_indeterminate_progress.xml (100%) rename {android/examples => java/examples-android}/guiclient/src/main/res/layout/activity_main.xml (100%) rename {android/examples => java/examples-android}/guiclient/src/main/res/layout/attribute_layout_on_off_switch.xml (100%) rename {android/examples => java/examples-android}/guiclient/src/main/res/layout/attribute_layout_progress_bar.xml (100%) rename {android/examples => java/examples-android}/guiclient/src/main/res/layout/attribute_layout_slider.xml (100%) rename {android/examples => java/examples-android}/guiclient/src/main/res/layout/resource_list_item_layout.xml (100%) rename {android/examples => java/examples-android}/guiclient/src/main/res/menu/menu_main.xml (100%) rename {android/examples/guiclient/src/main/res/values => java/examples-android/guiclient/src/main/res/values-large}/refs.xml (100%) rename {android/examples => java/examples-android}/guiclient/src/main/res/values-sw600dp/refs.xml (100%) rename {android/examples/groupclient => java/examples-android/guiclient}/src/main/res/values-w820dp/dimens.xml (100%) rename {android/examples => java/examples-android}/guiclient/src/main/res/values/dimens.xml (100%) rename {android/examples/guiclient/src/main/res/values-large => java/examples-android/guiclient/src/main/res/values}/refs.xml (100%) rename {android/examples => java/examples-android}/guiclient/src/main/res/values/strings.xml (100%) rename {android/examples => java/examples-android}/guiclient/src/main/res/values/styles.xml (100%) rename {android/examples/devicediscoveryserver => java/examples-android/presenceclient}/.gitignore (100%) create mode 100644 java/examples-android/presenceclient/build.gradle rename {android/examples => java/examples-android}/presenceclient/presenceclient.iml (100%) rename {android/examples => java/examples-android}/presenceclient/src/main/AndroidManifest.xml (100%) rename {android/examples => java/examples-android}/presenceclient/src/main/java/org/iotivity/base/examples/PresenceClient.java (100%) rename {android/examples/fridgegroupclient/src/main/res/drawable-mdpi => java/examples-android/presenceclient/src/main/res/drawable}/iotivityicon.png (100%) mode change 100755 => 100644 rename {android/examples/fridgeclient/src/main/res/drawable-xhdpi => java/examples-android/presenceclient/src/main/res/drawable}/iotivitylogo.png (100%) mode change 100755 => 100644 rename {android/examples => java/examples-android}/presenceclient/src/main/res/layout/activity_presence_client.xml (100%) rename {android/examples/fridgegroupclient/src/main/res/drawable-hdpi => java/examples-android/presenceclient/src/main/res/mipmap-hdpi}/iotivityicon.png (100%) mode change 100755 => 100644 rename {android/examples => java/examples-android}/presenceclient/src/main/res/mipmap-mdpi/iotivityicon.png (100%) rename {android/examples => java/examples-android}/presenceclient/src/main/res/mipmap-xhdpi/iotivityicon.png (100%) rename {android/examples => java/examples-android}/presenceclient/src/main/res/mipmap-xxhdpi/iotivityicon.png (100%) rename {android/examples => java/examples-android}/presenceclient/src/main/res/values-v21/styles.xml (100%) rename {android/examples/fridgeserver => java/examples-android/presenceclient}/src/main/res/values-w820dp/dimens.xml (100%) mode change 100755 => 100644 rename {android/examples/fridgegroupserver => java/examples-android/presenceclient}/src/main/res/values/dimens.xml (100%) mode change 100755 => 100644 rename {android/examples => java/examples-android}/presenceclient/src/main/res/values/strings.xml (100%) rename {android/examples/fridgeserver => java/examples-android/presenceclient}/src/main/res/values/styles.xml (100%) mode change 100755 => 100644 rename {android/examples/devicediscoveryclient => java/examples-android/presenceserver}/.gitignore (100%) create mode 100644 java/examples-android/presenceserver/build.gradle rename {android/examples => java/examples-android}/presenceserver/presenceserver.iml (100%) rename {android/examples => java/examples-android}/presenceserver/src/main/AndroidManifest.xml (100%) rename {android/examples => java/examples-android}/presenceserver/src/main/java/org/iotivity/base/examples/PresenceServer.java (100%) rename {android/examples/fridgeclient/src/main/res/drawable-xxhdpi => java/examples-android/presenceserver/src/main/res/drawable}/iotivityicon.png (100%) mode change 100755 => 100644 rename {android/examples/fridgeclient/src/main/res/drawable-mdpi => java/examples-android/presenceserver/src/main/res/drawable}/iotivitylogo.png (100%) mode change 100755 => 100644 rename {android/examples => java/examples-android}/presenceserver/src/main/res/layout/activity_presence_server.xml (100%) rename {android/examples/fridgeclient/src/main/res/drawable-xhdpi => java/examples-android/presenceserver/src/main/res/mipmap-hdpi}/iotivityicon.png (100%) mode change 100755 => 100644 rename {android/examples/groupserver => java/examples-android/presenceserver}/src/main/res/mipmap-mdpi/iotivityicon.png (100%) rename {android/examples/groupserver => java/examples-android/presenceserver}/src/main/res/mipmap-xhdpi/iotivityicon.png (100%) rename {android/examples/groupserver => java/examples-android/presenceserver}/src/main/res/mipmap-xxhdpi/iotivityicon.png (100%) rename {android/examples => java/examples-android}/presenceserver/src/main/res/values-v21/styles.xml (100%) rename {android/examples/fridgegroupserver => java/examples-android/presenceserver}/src/main/res/values-w820dp/dimens.xml (100%) mode change 100755 => 100644 rename {android/examples/fridgegroupclient => java/examples-android/presenceserver}/src/main/res/values/dimens.xml (100%) mode change 100755 => 100644 rename {android/examples => java/examples-android}/presenceserver/src/main/res/values/strings.xml (100%) rename {android/examples/fridgegroupserver => java/examples-android/presenceserver}/src/main/res/values/styles.xml (100%) mode change 100755 => 100644 create mode 100644 java/examples-android/provisioningclient/build.gradle rename {android/examples => java/examples-android}/provisioningclient/proguard-rules.pro (100%) rename {android/examples => java/examples-android}/provisioningclient/provisioningclient.iml (100%) rename {android/examples => java/examples-android}/provisioningclient/src/main/AndroidManifest.xml (100%) rename {android/examples => java/examples-android}/provisioningclient/src/main/assets/oic_svr_db_client.json (100%) rename {android/examples => java/examples-android}/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/ProvisioningClient.java (100%) rename {android/examples => java/examples-android}/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/StringConstants.java (100%) rename {android/examples => java/examples-android}/provisioningclient/src/main/res/layout/activity_secure_provision_client.xml (100%) rename {android/examples => java/examples-android}/provisioningclient/src/main/res/menu/menu_secure_provision_client.xml (100%) rename {android/examples => java/examples-android}/provisioningclient/src/main/res/mipmap-hdpi/ic_launcher.png (100%) rename {android/examples => java/examples-android}/provisioningclient/src/main/res/mipmap-mdpi/ic_launcher.png (100%) rename {android/examples => java/examples-android}/provisioningclient/src/main/res/mipmap-xhdpi/ic_launcher.png (100%) rename {android/examples => java/examples-android}/provisioningclient/src/main/res/mipmap-xxhdpi/ic_launcher.png (100%) rename {android/examples/groupserver => java/examples-android/provisioningclient}/src/main/res/values-v21/styles.xml (100%) rename {android/examples/fridgegroupclient => java/examples-android/provisioningclient}/src/main/res/values-w820dp/dimens.xml (100%) mode change 100755 => 100644 rename {android/examples/fridgeclient => java/examples-android/provisioningclient}/src/main/res/values/dimens.xml (100%) mode change 100755 => 100644 rename {android/examples => java/examples-android}/provisioningclient/src/main/res/values/strings.xml (100%) rename {android/examples/fridgegroupclient => java/examples-android/provisioningclient}/src/main/res/values/styles.xml (100%) mode change 100755 => 100644 rename {android/examples => java/examples-android}/settings.gradle (100%) rename {android/examples/fridgegroupserver => java/examples-android/simplebase}/.gitignore (100%) mode change 100755 => 100644 rename {android/examples => java/examples-android}/simplebase/build.gradle (93%) rename {android/examples => java/examples-android}/simplebase/libs/android-support-v4.jar (100%) rename {android/examples => java/examples-android}/simplebase/proguard-rules.pro (100%) rename {android/examples => java/examples-android}/simplebase/simplebase.iml (100%) rename {android/examples => java/examples-android}/simplebase/src/main/AndroidManifest.xml (100%) rename {android/examples => java/examples-android}/simplebase/src/main/java/org/iotivity/base/examples/BluetoothFragment.java (100%) rename {android/examples => java/examples-android}/simplebase/src/main/java/org/iotivity/base/examples/Common.java (100%) rename {android/examples => java/examples-android}/simplebase/src/main/java/org/iotivity/base/examples/DrawerFragment.java (100%) rename {android/examples => java/examples-android}/simplebase/src/main/java/org/iotivity/base/examples/MessageFragment.java (100%) rename {android/examples => java/examples-android}/simplebase/src/main/java/org/iotivity/base/examples/SimpleBase.java (100%) rename {android/examples => java/examples-android}/simplebase/src/main/java/org/iotivity/base/examples/TemplateFragment.java (100%) rename {android/examples => java/examples-android}/simplebase/src/main/res/drawable-hdpi/drawer_shadow.9.png (100%) rename {android/examples => java/examples-android}/simplebase/src/main/res/drawable-hdpi/ic_drawer.png (100%) rename {android/examples => java/examples-android}/simplebase/src/main/res/drawable-mdpi/drawer_shadow.9.png (100%) rename {android/examples => java/examples-android}/simplebase/src/main/res/drawable-mdpi/ic_drawer.png (100%) rename {android/examples => java/examples-android}/simplebase/src/main/res/drawable-xhdpi/drawer_shadow.9.png (100%) rename {android/examples => java/examples-android}/simplebase/src/main/res/drawable-xhdpi/ic_drawer.png (100%) rename {android/examples => java/examples-android}/simplebase/src/main/res/drawable-xxhdpi/drawer_shadow.9.png (100%) rename {android/examples => java/examples-android}/simplebase/src/main/res/drawable-xxhdpi/ic_drawer.png (100%) rename {android/examples/fridgeclient/src/main/res/drawable-mdpi => java/examples-android/simplebase/src/main/res/drawable}/iotivityicon.png (100%) mode change 100755 => 100644 rename {android/examples/fridgeclient/src/main/res/drawable-hdpi => java/examples-android/simplebase/src/main/res/drawable}/iotivitylogo.png (100%) mode change 100755 => 100644 rename {android/examples => java/examples-android}/simplebase/src/main/res/layout/activity_simplebase.xml (100%) rename {android/examples => java/examples-android}/simplebase/src/main/res/layout/fragment_bluetooth.xml (100%) rename {android/examples => java/examples-android}/simplebase/src/main/res/layout/fragment_drawer.xml (100%) rename {android/examples => java/examples-android}/simplebase/src/main/res/layout/fragment_message.xml (100%) rename {android/examples => java/examples-android}/simplebase/src/main/res/layout/fragment_template.xml (100%) rename {android/examples => java/examples-android}/simplebase/src/main/res/layout/tcp_input.xml (100%) rename {android/examples/fridgeclient/src/main/res/drawable-hdpi => java/examples-android/simplebase/src/main/res/mipmap-hdpi}/iotivityicon.png (100%) mode change 100755 => 100644 rename {android/examples/groupclient => java/examples-android/simplebase}/src/main/res/mipmap-mdpi/iotivityicon.png (100%) rename {android/examples/groupclient => java/examples-android/simplebase}/src/main/res/mipmap-xhdpi/iotivityicon.png (100%) rename {android/examples/groupclient => java/examples-android/simplebase}/src/main/res/mipmap-xxhdpi/iotivityicon.png (100%) rename {android/examples/groupclient => java/examples-android/simplebase}/src/main/res/values-v21/styles.xml (100%) rename {android/examples/fridgeclient => java/examples-android/simplebase}/src/main/res/values-w820dp/dimens.xml (100%) mode change 100755 => 100644 rename {android/examples => java/examples-android}/simplebase/src/main/res/values/dimens.xml (100%) rename {android/examples => java/examples-android}/simplebase/src/main/res/values/strings.xml (100%) rename {android/examples/fridgeclient => java/examples-android/simplebase}/src/main/res/values/styles.xml (100%) mode change 100755 => 100644 rename {android/examples/fridgegroupclient => java/examples-android/simpleclient}/.gitignore (100%) mode change 100755 => 100644 rename {android/examples => java/examples-android}/simpleclient/build.gradle (92%) rename {android/examples/devicediscoveryserver => java/examples-android/simpleclient}/proguard-rules.pro (100%) rename {android/examples => java/examples-android}/simpleclient/simpleclient.iml (100%) rename {android/examples => java/examples-android}/simpleclient/src/main/AndroidManifest.xml (100%) rename {android/examples => java/examples-android}/simpleclient/src/main/assets/oic_svr_db_client.json (100%) rename {android/examples => java/examples-android}/simpleclient/src/main/java/org/iotivity/base/examples/Light.java (100%) rename {android/examples => java/examples-android}/simpleclient/src/main/java/org/iotivity/base/examples/SimpleClient.java (100%) rename {android/examples/devicediscoveryserver/src/main/res/mipmap-hdpi => java/examples-android/simpleclient/src/main/res/drawable}/iotivityicon.png (100%) rename {android/examples/devicediscoveryserver => java/examples-android/simpleclient}/src/main/res/drawable/iotivitylogo.png (100%) rename {android/examples => java/examples-android}/simpleclient/src/main/res/layout/activity_simple_client.xml (100%) rename {android/examples/devicediscoveryserver/src/main/res/drawable => java/examples-android/simpleclient/src/main/res/mipmap-hdpi}/iotivityicon.png (100%) rename {android/examples/devicediscoveryserver => java/examples-android/simpleclient}/src/main/res/mipmap-mdpi/iotivityicon.png (100%) rename {android/examples/devicediscoveryserver => java/examples-android/simpleclient}/src/main/res/mipmap-xhdpi/iotivityicon.png (100%) rename {android/examples/devicediscoveryserver => java/examples-android/simpleclient}/src/main/res/mipmap-xxhdpi/iotivityicon.png (100%) rename {android/examples/devicediscoveryserver => java/examples-android/simpleclient}/src/main/res/values-v21/styles.xml (100%) rename {android/examples/devicediscoveryserver => java/examples-android/simpleclient}/src/main/res/values-w820dp/dimens.xml (100%) rename {android/examples/devicediscoveryserver => java/examples-android/simpleclient}/src/main/res/values/dimens.xml (100%) rename {android/examples => java/examples-android}/simpleclient/src/main/res/values/strings.xml (100%) rename {android/examples/devicediscoveryserver => java/examples-android/simpleclient}/src/main/res/values/styles.xml (100%) rename {android/examples/fridgeclient => java/examples-android/simpleserver}/.gitignore (100%) mode change 100755 => 100644 rename {android/examples => java/examples-android}/simpleserver/build.gradle (92%) rename {android/examples/devicediscoveryclient => java/examples-android/simpleserver}/proguard-rules.pro (100%) rename {android/examples => java/examples-android}/simpleserver/simpleserver.iml (100%) rename {android/examples => java/examples-android}/simpleserver/src/main/AndroidManifest.xml (100%) rename {android/examples => java/examples-android}/simpleserver/src/main/assets/oic_svr_db_server.json (100%) rename {android/examples => java/examples-android}/simpleserver/src/main/java/org/iotivity/base/examples/Light.java (100%) rename {android/examples => java/examples-android}/simpleserver/src/main/java/org/iotivity/base/examples/SimpleServer.java (100%) rename {android/examples/devicediscoveryclient/src/main/res/mipmap-hdpi => java/examples-android/simpleserver/src/main/res/drawable}/iotivityicon.png (100%) rename {android/examples/devicediscoveryclient => java/examples-android/simpleserver}/src/main/res/drawable/iotivitylogo.png (100%) rename {android/examples => java/examples-android}/simpleserver/src/main/res/layout/activity_simple_server.xml (100%) rename {android/examples/devicediscoveryclient/src/main/res/drawable => java/examples-android/simpleserver/src/main/res/mipmap-hdpi}/iotivityicon.png (100%) rename {android/examples/devicediscoveryclient => java/examples-android/simpleserver}/src/main/res/mipmap-mdpi/iotivityicon.png (100%) rename {android/examples/devicediscoveryclient => java/examples-android/simpleserver}/src/main/res/mipmap-xhdpi/iotivityicon.png (100%) rename {android/examples/devicediscoveryclient => java/examples-android/simpleserver}/src/main/res/mipmap-xxhdpi/iotivityicon.png (100%) rename {android/examples/devicediscoveryclient => java/examples-android/simpleserver}/src/main/res/values-v21/styles.xml (100%) rename {android/examples/devicediscoveryclient => java/examples-android/simpleserver}/src/main/res/values-w820dp/dimens.xml (100%) rename {android/examples/devicediscoveryclient => java/examples-android/simpleserver}/src/main/res/values/dimens.xml (100%) rename {android/examples => java/examples-android}/simpleserver/src/main/res/values/strings.xml (100%) rename {android/examples/devicediscoveryclient => java/examples-android/simpleserver}/src/main/res/values/styles.xml (100%) create mode 100755 java/examples-java/build.gradle create mode 100644 java/examples-java/devicediscoveryclient/.gitignore rename {android/examples => java/examples-java}/devicediscoveryclient/build.gradle (100%) create mode 100644 java/examples-java/devicediscoveryclient/src/main/java/org/iotivity/base/examples/DeviceDiscoveryClient.java create mode 100644 java/examples-java/devicediscoveryserver/.gitignore rename {android/examples => java/examples-java}/devicediscoveryserver/build.gradle (100%) create mode 100644 java/examples-java/devicediscoveryserver/src/main/java/org/iotivity/base/examples/DeviceDiscoveryServer.java create mode 100755 java/examples-java/fridgeclient/.gitignore rename {android/examples => java/examples-java}/fridgeclient/build.gradle (100%) create mode 100755 java/examples-java/fridgeclient/src/main/java/org/iotivity/base/examples/FridgeClient.java create mode 100755 java/examples-java/fridgegroupclient/.gitignore rename {android/examples => java/examples-java}/fridgegroupclient/build.gradle (100%) create mode 100755 java/examples-java/fridgegroupclient/src/main/java/org/iotivity/base/examples/FridgeGroupClient.java create mode 100755 java/examples-java/fridgegroupserver/.gitignore rename {android/examples => java/examples-java}/fridgegroupserver/build.gradle (100%) create mode 100755 java/examples-java/fridgegroupserver/src/main/java/org/iotivity/base/examples/DoorResource.java create mode 100755 java/examples-java/fridgegroupserver/src/main/java/org/iotivity/base/examples/FridgeGroupServer.java create mode 100755 java/examples-java/fridgegroupserver/src/main/java/org/iotivity/base/examples/FridgeResource.java create mode 100755 java/examples-java/fridgegroupserver/src/main/java/org/iotivity/base/examples/LightResource.java create mode 100755 java/examples-java/fridgegroupserver/src/main/java/org/iotivity/base/examples/Refrigerator.java create mode 100755 java/examples-java/fridgegroupserver/src/main/java/org/iotivity/base/examples/Resource.java create mode 100755 java/examples-java/fridgeserver/.gitignore rename {android/examples => java/examples-java}/fridgeserver/build.gradle (100%) create mode 100755 java/examples-java/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DeviceResource.java create mode 100755 java/examples-java/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DoorResource.java create mode 100755 java/examples-java/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/FridgeServer.java create mode 100755 java/examples-java/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/LightResource.java create mode 100755 java/examples-java/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Refrigerator.java create mode 100755 java/examples-java/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Resource.java create mode 100644 java/examples-java/gradle.properties rename {android/android_api => java/examples-java}/gradle/wrapper/gradle-wrapper.jar (100%) create mode 100755 java/examples-java/gradle/wrapper/gradle-wrapper.properties rename {android/android_api => java/examples-java}/gradlew (100%) rename {android/android_api => java/examples-java}/gradlew.bat (100%) create mode 100644 java/examples-java/groupclient/.gitignore rename {android/examples => java/examples-java}/groupclient/build.gradle (100%) create mode 100644 java/examples-java/groupclient/src/main/java/org/iotivity/base/examples/GroupClient.java create mode 100644 java/examples-java/groupserver/.gitignore rename {android/examples => java/examples-java}/groupserver/build.gradle (100%) create mode 100644 java/examples-java/groupserver/src/main/java/org/iotivity/base/examples/GroupServer.java create mode 100644 java/examples-java/guiclient/.gitignore create mode 100644 java/examples-java/guiclient/build.gradle create mode 100644 java/examples-java/guiclient/src/main/java/org/iotivity/guiclient/ExpandableResourceListAdapter.java create mode 100644 java/examples-java/guiclient/src/main/java/org/iotivity/guiclient/MainActivity.java create mode 100644 java/examples-java/guiclient/src/main/java/org/iotivity/guiclient/OcAttributeInfo.java create mode 100644 java/examples-java/guiclient/src/main/java/org/iotivity/guiclient/OcProtocolStrings.java create mode 100644 java/examples-java/guiclient/src/main/java/org/iotivity/guiclient/OcResourceInfo.java create mode 100644 java/examples-java/guiclient/src/main/java/org/iotivity/guiclient/OcWorker.java create mode 100644 java/examples-java/guiclient/src/main/java/org/iotivity/guiclient/OcWorkerListener.java create mode 100644 java/examples-java/presenceclient/.gitignore rename {android/examples => java/examples-java}/presenceclient/build.gradle (100%) create mode 100644 java/examples-java/presenceclient/src/main/java/org/iotivity/base/examples/PresenceClient.java create mode 100644 java/examples-java/presenceserver/.gitignore rename {android/examples => java/examples-java}/presenceserver/build.gradle (100%) create mode 100644 java/examples-java/presenceserver/src/main/java/org/iotivity/base/examples/PresenceServer.java rename {android/examples => java/examples-java}/provisioningclient/build.gradle (100%) create mode 100644 java/examples-java/provisioningclient/src/main/assets/oic_svr_db_client.json create mode 100644 java/examples-java/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/ProvisioningClient.java create mode 100644 java/examples-java/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/StringConstants.java create mode 100755 java/examples-java/settings.gradle create mode 100644 java/examples-java/simpleclient/.gitignore create mode 100644 java/examples-java/simpleclient/build.gradle create mode 100644 java/examples-java/simpleclient/src/main/assets/oic_svr_db_client.json create mode 100644 java/examples-java/simpleclient/src/main/java/org/iotivity/base/examples/Light.java create mode 100644 java/examples-java/simpleclient/src/main/java/org/iotivity/base/examples/SimpleClient.java create mode 100644 java/examples-java/simpleserver/.gitignore create mode 100644 java/examples-java/simpleserver/build.gradle create mode 100755 java/examples-java/simpleserver/src/main/assets/oic_svr_db_server.json create mode 100644 java/examples-java/simpleserver/src/main/java/org/iotivity/base/examples/Light.java create mode 100644 java/examples-java/simpleserver/src/main/java/org/iotivity/base/examples/SimpleServer.java rename {android/android_api => java}/gradle.properties (100%) create mode 100755 java/gradle/wrapper/gradle-wrapper.jar rename {android/android_api => java}/gradle/wrapper/gradle-wrapper.properties (100%) create mode 100755 java/gradlew create mode 100755 java/gradlew.bat rename {android/android_api/base => java/iotivity-android}/build.gradle (63%) rename {android/android_api/base => java/iotivity-android}/proguard-rules.pro (100%) rename {android/android_api/base/src/main => java/iotivity-android/src/androidTest}/AndroidManifest.xml (100%) rename {android/android_api/base => java/iotivity-android}/src/androidTest/java/org/iotivity/base/OcRepresentationTest.java (100%) rename {android/android_api/base => java/iotivity-android}/src/androidTest/java/org/iotivity/base/SmokeTest.java (100%) rename {android/android_api/base/src/androidTest => java/iotivity-android/src/main}/AndroidManifest.xml (100%) rename {android/android_api/base => java/iotivity-android}/src/main/java/org/iotivity/base/OcPlatform.java (100%) rename {android/android_api/base => java/iotivity-android}/src/main/java/org/iotivity/base/PlatformConfig.java (100%) rename {android/android_api/base => java/iotivity-android}/src/main/java/org/iotivity/ca/CaBtPairingInterface.java (100%) rename {android/android_api/base => java/iotivity-android}/src/main/java/org/iotivity/ca/CaEdrInterface.java (100%) rename {android/android_api/base => java/iotivity-android}/src/main/java/org/iotivity/ca/CaInterface.java (100%) rename {android/android_api/base => java/iotivity-android}/src/main/java/org/iotivity/ca/CaIpInterface.java (100%) rename {android/android_api/base => java/iotivity-android}/src/main/java/org/iotivity/ca/CaLeClientInterface.java (100%) rename {android/android_api/base => java/iotivity-android}/src/main/java/org/iotivity/ca/CaLeServerInterface.java (100%) rename {android/android_api/base => java/iotivity-android}/src/main/java/org/iotivity/ca/CaNfcInterface.java (100%) create mode 100755 java/iotivity-linux/build.gradle create mode 100644 java/iotivity-linux/src/main/java/org/iotivity/base/OcPlatform.java create mode 100644 java/iotivity-linux/src/main/java/org/iotivity/base/PlatformConfig.java create mode 100644 java/iotivity-linux/src/main/java/org/iotivity/ca/CaInterface.java create mode 100644 java/iotivity-linux/src/main/java/org/iotivity/ca/CaIpInterface.java rename {android/android_api/base => java}/jni/JniCaInterface.c (89%) rename {android/android_api/base => java}/jni/JniCaInterface.h (83%) rename {android/android_api/base => java}/jni/JniDisplayPinListener.cpp (100%) rename {android/android_api/base => java}/jni/JniDisplayPinListener.h (100%) rename {android/android_api/base => java}/jni/JniEntityHandler.cpp (100%) rename {android/android_api/base => java}/jni/JniEntityHandler.h (100%) rename {android/android_api/base => java}/jni/JniListenerManager.h (100%) rename {android/android_api/base => java}/jni/JniOcPlatform.cpp (99%) rename {android/android_api/base => java}/jni/JniOcPlatform.h (100%) rename {android/android_api/base => java}/jni/JniOcPresenceHandle.cpp (100%) rename {android/android_api/base => java}/jni/JniOcPresenceHandle.h (100%) rename {android/android_api/base => java}/jni/JniOcProvisioning.cpp (100%) rename {android/android_api/base => java}/jni/JniOcProvisioning.h (100%) rename {android/android_api/base => java}/jni/JniOcRepresentation.cpp (100%) rename {android/android_api/base => java}/jni/JniOcRepresentation.h (100%) rename {android/android_api/base => java}/jni/JniOcRequestHandle.cpp (100%) rename {android/android_api/base => java}/jni/JniOcRequestHandle.h (100%) rename {android/android_api/base => java}/jni/JniOcResource.cpp (100%) rename {android/android_api/base => java}/jni/JniOcResource.h (100%) rename {android/android_api/base => java}/jni/JniOcResourceHandle.cpp (100%) rename {android/android_api/base => java}/jni/JniOcResourceHandle.h (100%) rename {android/android_api/base => java}/jni/JniOcResourceIdentifier.cpp (100%) rename {android/android_api/base => java}/jni/JniOcResourceIdentifier.h (100%) rename {android/android_api/base => java}/jni/JniOcResourceRequest.cpp (100%) rename {android/android_api/base => java}/jni/JniOcResourceRequest.h (100%) rename {android/android_api/base => java}/jni/JniOcResourceResponse.cpp (100%) rename {android/android_api/base => java}/jni/JniOcResourceResponse.h (100%) rename {android/android_api/base => java}/jni/JniOcSecureResource.cpp (100%) rename {android/android_api/base => java}/jni/JniOcSecureResource.h (100%) rename {android/android_api/base => java}/jni/JniOcSecurity.cpp (100%) rename {android/android_api/base => java}/jni/JniOcSecurity.h (100%) rename {android/android_api/base => java}/jni/JniOcStack.cpp (100%) rename {android/android_api/base => java}/jni/JniOcStack.h (93%) rename {android/android_api/base => java}/jni/JniOnDeleteListener.cpp (100%) rename {android/android_api/base => java}/jni/JniOnDeleteListener.h (100%) rename {android/android_api/base => java}/jni/JniOnDeviceInfoListener.cpp (100%) rename {android/android_api/base => java}/jni/JniOnDeviceInfoListener.h (100%) rename {android/android_api/base => java}/jni/JniOnGetListener.cpp (100%) rename {android/android_api/base => java}/jni/JniOnGetListener.h (100%) rename {android/android_api/base => java}/jni/JniOnObserveListener.cpp (100%) rename {android/android_api/base => java}/jni/JniOnObserveListener.h (100%) rename {android/android_api/base => java}/jni/JniOnPlatformInfoListener.cpp (100%) rename {android/android_api/base => java}/jni/JniOnPlatformInfoListener.h (100%) rename {android/android_api/base => java}/jni/JniOnPostListener.cpp (100%) rename {android/android_api/base => java}/jni/JniOnPostListener.h (100%) rename {android/android_api/base => java}/jni/JniOnPresenceListener.cpp (100%) rename {android/android_api/base => java}/jni/JniOnPresenceListener.h (100%) rename {android/android_api/base => java}/jni/JniOnPutListener.cpp (100%) rename {android/android_api/base => java}/jni/JniOnPutListener.h (100%) rename {android/android_api/base => java}/jni/JniOnResourceFoundListener.cpp (100%) rename {android/android_api/base => java}/jni/JniOnResourceFoundListener.h (100%) rename {android/android_api/base => java}/jni/JniPinCheckListener.cpp (100%) rename {android/android_api/base => java}/jni/JniPinCheckListener.h (100%) rename {android/android_api/base => java}/jni/JniProvisionResultListner.cpp (100%) rename {android/android_api/base => java}/jni/JniProvisionResultListner.h (100%) rename {android/android_api/base => java}/jni/JniSecureUtils.cpp (100%) rename {android/android_api/base => java}/jni/JniSecureUtils.h (100%) rename {android/android_api/base => java}/jni/JniUtils.cpp (100%) rename {android/android_api/base => java}/jni/JniUtils.h (100%) create mode 100644 java/jni/SConscript rename {android/android_api => java}/settings.gradle (95%) diff --git a/SConstruct b/SConstruct index 1e8ebfb..c1c8ce7 100644 --- a/SConstruct +++ b/SConstruct @@ -39,9 +39,6 @@ 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//// # @@ -68,6 +65,10 @@ SConscript(build_dir + 'plugins/SConscript') # Build "cloud" sub-project SConscript(build_dir + 'cloud/SConscript') +if env.get('BUILD_JAVA') == 'ON' or target_os == 'android': + if env.get('JAVA_HOME') != None: + SConscript(build_dir + 'java/SConscript') + # Append targets information to the help information, to see help info, execute command line: # $ scon [options] -h env.PrintTargets() diff --git a/android/android_api/.gitignore b/android/android_api/.gitignore deleted file mode 100644 index e86e67c..0000000 --- a/android/android_api/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -.gradle -/local.properties -/.idea/workspace.xml -/.idea/libraries -.DS_Store -/build/* -/base/build/* -/base/obj/* -/base/libs/* -/sample/* diff --git a/android/android_api/android_api.iml b/android/android_api/android_api.iml deleted file mode 100644 index 108b2a4..0000000 --- a/android/android_api/android_api.iml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/android/android_api/base/.gitignore b/android/android_api/base/.gitignore deleted file mode 100644 index 6e8872c..0000000 --- a/android/android_api/base/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -.gradle/ -.idea/ -sample/ -base/build/ -base/obj/ diff --git a/android/android_api/base/base.iml b/android/android_api/base/base.iml deleted file mode 100755 index 49b2159..0000000 --- a/android/android_api/base/base.iml +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/android/android_api/base/jni/Android.mk b/android/android_api/base/jni/Android.mk deleted file mode 100644 index 0bc2d5e..0000000 --- a/android/android_api/base/jni/Android.mk +++ /dev/null @@ -1,114 +0,0 @@ -LOCAL_PATH := $(call my-dir) -TARGET_ARCH_ABI := $(APP_ABI) -SECURED := $(SECURE) - -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) - -ifeq ($(SECURED), 1) -include $(CLEAR_VARS) -OIC_LIB_PATH := ../../../../out/android/$(APP_ABI)/$(APP_OPTIM) -LOCAL_MODULE := libandroid-ocprovision -LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libocprovision.so -include $(PREBUILT_SHARED_LIBRARY) - -include $(CLEAR_VARS) -OIC_LIB_PATH := ../../../../out/android/$(APP_ABI)/$(APP_OPTIM) -LOCAL_MODULE := libandroid-ocpmapi -LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libocpmapi.so -include $(PREBUILT_SHARED_LIBRARY) -endif - -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 \ - JniOnPlatformInfoListener.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 \ - JniOcSecurity.cpp -ifeq ($(SECURED), 1) -LOCAL_SRC_FILES += JniOcSecureResource.cpp \ - JniOcProvisioning.cpp \ - JniSecureUtils.cpp \ - JniProvisionResultListner.cpp \ - JniPinCheckListener.cpp \ - JniDisplayPinListener.cpp -endif - -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 -ifeq ($(SECURED), 1) -LOCAL_STATIC_LIBRARIES += android-ocprovision -LOCAL_STATIC_LIBRARIES += android-ocpmapi -endif - -LOCAL_CPPFLAGS += -std=c++0x -LOCAL_CPP_FEATURES := rtti exceptions -LOCAL_C_INCLUDES := $(OIC_SRC_PATH)/include -LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/c_common -LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/c_common/oic_string/include -LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/c_common/oic_malloc/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 -LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/security/provisioning/include -LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/security/provisioning/include/oxm/ -LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/security/provisioning/include/internal -LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/security/include -include $(BUILD_SHARED_LIBRARY) diff --git a/android/android_api/base/jni/Application.mk b/android/android_api/base/jni/Application.mk deleted file mode 100644 index 089c9b3..0000000 --- a/android/android_api/base/jni/Application.mk +++ /dev/null @@ -1,2 +0,0 @@ -NDK_TOOLCHAIN_VERSION := 4.9 -APP_STL := gnustl_shared \ No newline at end of file diff --git a/auto_build.sh b/auto_build.sh index aa2dcd4..ab79ffa 100755 --- a/auto_build.sh +++ b/auto_build.sh @@ -15,6 +15,8 @@ function build_all() build_linux_unsecured_with_rm $1 $2 build_linux_unsecured_with_rd $1 $2 build_linux_secured_with_rd $1 $2 + build_linux_unsecured_with_java $1 $2 + build_linux_secured_with_java $1 $2 build_simulator $1 $2 fi @@ -80,6 +82,18 @@ function build_linux_secured_with_rd() scons RELEASE=$1 WITH_RD=1 SECURED=1 $2 } +function build_linux_unsecured_with_java() +{ + echo "*********** Build for linux With Resource Directory & Security ************" + scons RELEASE=$1 BUILD_JAVA=ON TARGET_TRANSPORT=IP $2 +} + +function build_linux_secured_with_java() +{ + echo "*********** Build for linux With Resource Directory & Security ************" + scons RELEASE=$1 SECURED=1 BUILD_JAVA=ON TARGET_TRANSPORT=IP $2 +} + function build_android() { # Note: for android, as oic-resource uses C++11 feature stoi and to_string, @@ -247,6 +261,14 @@ then then build_linux_secured_with_rd true build_linux_secured_with_rd false + elif [ $1 = 'linux_unsecured_with_java' ] + then + build_linux_unsecured_with_java true + build_linux_unsecured_with_java false + elif [ $1 = 'linux_secured_with_java' ] + then + build_linux_secured_with_java true + build_linux_secured_with_java false elif [ $1 = 'android' ] then build_android true diff --git a/build_common/SConscript b/build_common/SConscript index 2be70ce..82f28bf 100644 --- a/build_common/SConscript +++ b/build_common/SConscript @@ -112,6 +112,9 @@ help_vars.Add(EnumVariable('ES_ROLE', 'Target build mode', 'mediator', allowed_v #ES_SOFT_MODE is for specifying MODE (Mode 1 : Enrollee with Soft AP or Mode 2 : Mediator with Soft AP) help_vars.Add(EnumVariable('ES_SOFTAP_MODE', 'Target build mode', 'ENROLLEE_SOFTAP', allowed_values=('ENROLLEE_SOFTAP', 'MEDIATOR_SOFTAP'))) +help_vars.Add(EnumVariable('BUILD_JAVA', 'Build Java bindings', 'OFF', allowed_values=('ON', 'OFF'))) +help_vars.Add(PathVariable('JAVA_HOME', 'JDK directory', os.environ.get('JAVA_HOME'), PathVariable.PathAccept)) + AddOption('--prefix', dest='prefix', type='string', diff --git a/build_common/external_libs.scons b/build_common/external_libs.scons index 2e28220..fe1d1f1 100644 --- a/build_common/external_libs.scons +++ b/build_common/external_libs.scons @@ -2,7 +2,7 @@ # This script manages external libraries # # Some methods are added to manage external packages: -# 'PrepareLib': Checks the existence of an external library, if it +# 'PrepareLib': Checks the existence of an external library, if it # doesn't exist, calls the script user provided to download(if required) # and build the source code of the external library or notify user to # install the library. @@ -13,7 +13,7 @@ # 'InstallLib': Install library binaries(.so, .a etc) # # By default, assume the script for an exteranl library is: -# /extlibs//SConscript +# /extlibs//SConscript # # Note: After the external library is built: # Head files should be installed to /deps//include @@ -33,11 +33,23 @@ target_arch = env.get('TARGET_ARCH') if target_os == 'android': if target_arch == 'armeabi-v7a-hard': target_arch = 'armeabi-v7a' + env.AppendUnique(CCFLAGS = ['-D__JAVA__']) if target_os == 'darwin': env.AppendUnique(CPPPATH = ['/usr/local/include']) env.AppendUnique(LIBPATH = ['/usr/local/lib']) +if env.get('BUILD_JAVA') == 'ON' and target_os != 'android': + if env.get('JAVA_HOME') != None: + env.AppendUnique(CCFLAGS = ['-D__JAVA__']) + env.AppendUnique(CPPPATH = [ + env.get('JAVA_HOME') + '/include', + env.get('JAVA_HOME') + '/include/' + target_os + ]) + else: + raise SCons.Errors.StopError( 'BUILD_JAVA is ON, but JAVA_HOME is not set.') + + # External library include files are in /deps//include # the library binaries are in /deps//lib/ env.AppendUnique(CPPPATH = [os.path.join(env.get('SRC_DIR'), 'deps', target_os, 'include')]) @@ -47,7 +59,7 @@ env.AppendUnique(LIBPATH = [os.path.join(env.get('SRC_DIR'), 'deps', target_os, # download the source code and build it # @param libname - the name of the library try to prepare # @param lib - the lib(.so, .a etc) to check (a library may include more then -# one lib, e.g. boost, includes boost_thread, boost_system ... +# one lib, e.g. boost, includes boost_thread, boost_system ... # @param path - the directory of the library building script, if it's not set, # by default, it's /extlibs// # @param script - the building script, by default, it's 'SConscript' diff --git a/build_common/linux/SConscript b/build_common/linux/SConscript index 6a9393b..29ba56a 100644 --- a/build_common/linux/SConscript +++ b/build_common/linux/SConscript @@ -2,10 +2,34 @@ # This script set linux specific flags (GNU GCC) # ## +import os Import('env') print "Reading linux configuration script" +SConscript('../external_libs.scons') +help_vars = Variables() +if env.get('BUILD_JAVA') == 'ON': + if not env.get('ANDROID_GRADLE'): + SConscript('../../extlibs/android/gradle/SConscript') + 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'))) + + 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)) + + # Set release/debug flags if env.get('RELEASE'): env.AppendUnique(CCFLAGS = ['-Os']) diff --git a/android/android_api/SConscript b/java/SConscript similarity index 58% rename from android/android_api/SConscript rename to java/SConscript index 38fd526..395fca5 100644 --- a/android/android_api/SConscript +++ b/java/SConscript @@ -2,20 +2,22 @@ import os import platform Import('env') -android_home = env.get('ANDROID_HOME') - -ANDROID_TARGET_ARCH = env.get('TARGET_ARCH') +TARGET_ARCH = env.get('TARGET_ARCH') if env.get('RELEASE'): - ANDROID_RELEASE="release" + RELEASE="release" else: - ANDROID_RELEASE="debug" -ANDROID_SECURED = env.get('SECURED') + RELEASE="debug" +SECURED = env.get('SECURED') + +target_os = env.get('TARGET_OS') -os.environ['ANDROID_HOME'] = env.get('ANDROID_HOME') -os.environ['ANDROID_NDK_HOME'] = env.get('ANDROID_NDK') +if target_os == "android": + android_home = env.get('ANDROID_HOME') + 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 ''' + 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 * @@ -41,20 +43,23 @@ if not os.path.exists(android_home + '/platforms/android-21') or not os.path.exi ...Opening Android SDK Manager now. Once you are finished, the build will continue. ''' - os.system(android_home + '/tools/android') + os.system(android_home + '/tools/android') def ensure_libs(target, source, env): - return target, [source, env.get('BUILD_DIR') + 'liboc.so', env.get('BUILD_DIR') + 'liboc_logger.so'] + return target, [source, env.get('BUILD_DIR') + 'liboc.so', env.get('BUILD_DIR') + 'liboc_logger.so', env.get('BUILD_DIR') + 'libocstack-jni.so'] + +SConscript('jni/SConscript') -# build android_api 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 -PSECURED=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE, ANDROID_SECURED), emitter = ensure_libs) +jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b' + env.get('SRC_DIR') + '/java/iotivity-%s/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s -PBUILD_DIR=%s -PSRC_DIR=%s --stacktrace' %(target_os, TARGET_ARCH, RELEASE, SECURED, env.get('BUILD_DIR'), env.get('SRC_DIR')), emitter = ensure_libs) jdk_env['BUILD_DIR'] = env.get('BUILD_DIR') -cmdBuildApi=jdk_env.Gradle(target="base/objs", source="base/src/main/java/org/iotivity/base/OcResource.java") +cmdBuildApi=jdk_env.Gradle(target="base/objs", source="common/src/main/java/org/iotivity/base/OcResource.java") -jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b' + 'android/examples/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE, ANDROID_SECURED)) -cmdBuildExamples=jdk_env.Gradle(target="../examples/devicediscoveryclient/apk", source="../examples/devicediscoveryclient/src/main/java/org/iotivity/base/examples/DeviceDiscoveryClient.java") +examples_target = "java" +if target_os == 'android': + examples_target = "android" -# android examples require android api to be built before being invoked -Depends(cmdBuildExamples, cmdBuildApi) +jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b' + 'java/examples-%s/build.gradle -PTARGET_OS=%s -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s --stacktrace' % (examples_target, target_os, TARGET_ARCH, RELEASE, SECURED)) +cmdBuildExamples=jdk_env.Gradle(target="examples-%s/simpleclient/jar" % (examples_target, ), source="examples-%s/simpleclient/src/main/java/org/iotivity/base/examples/SimpleClient.java" % (examples_target, )) +Depends(cmdBuildExamples, cmdBuildApi) diff --git a/android/android_api/build.gradle b/java/build.gradle similarity index 80% rename from android/android_api/build.gradle rename to java/build.gradle index cfcb3a2..c97209e 100755 --- a/android/android_api/build.gradle +++ b/java/build.gradle @@ -26,12 +26,6 @@ buildscript { repositories { jcenter() } - dependencies { - classpath 'com.android.tools.build:gradle:1.3.0' - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } } allprojects { diff --git a/android/android_api/base/src/main/java/org/iotivity/base/CredType.java b/java/common/src/main/java/org/iotivity/base/CredType.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/CredType.java rename to java/common/src/main/java/org/iotivity/base/CredType.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/DeviceStatus.java b/java/common/src/main/java/org/iotivity/base/DeviceStatus.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/DeviceStatus.java rename to java/common/src/main/java/org/iotivity/base/DeviceStatus.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/EntityHandlerResult.java b/java/common/src/main/java/org/iotivity/base/EntityHandlerResult.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/EntityHandlerResult.java rename to java/common/src/main/java/org/iotivity/base/EntityHandlerResult.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/ErrorCode.java b/java/common/src/main/java/org/iotivity/base/ErrorCode.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/ErrorCode.java rename to java/common/src/main/java/org/iotivity/base/ErrorCode.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/KeySize.java b/java/common/src/main/java/org/iotivity/base/KeySize.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/KeySize.java rename to java/common/src/main/java/org/iotivity/base/KeySize.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/ModeType.java b/java/common/src/main/java/org/iotivity/base/ModeType.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/ModeType.java rename to java/common/src/main/java/org/iotivity/base/ModeType.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/ObservationInfo.java b/java/common/src/main/java/org/iotivity/base/ObservationInfo.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/ObservationInfo.java rename to java/common/src/main/java/org/iotivity/base/ObservationInfo.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/ObserveAction.java b/java/common/src/main/java/org/iotivity/base/ObserveAction.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/ObserveAction.java rename to java/common/src/main/java/org/iotivity/base/ObserveAction.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/ObserveType.java b/java/common/src/main/java/org/iotivity/base/ObserveType.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/ObserveType.java rename to java/common/src/main/java/org/iotivity/base/ObserveType.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcConnectivityType.java b/java/common/src/main/java/org/iotivity/base/OcConnectivityType.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/OcConnectivityType.java rename to java/common/src/main/java/org/iotivity/base/OcConnectivityType.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcDeviceInfo.java b/java/common/src/main/java/org/iotivity/base/OcDeviceInfo.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/OcDeviceInfo.java rename to java/common/src/main/java/org/iotivity/base/OcDeviceInfo.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcException.java b/java/common/src/main/java/org/iotivity/base/OcException.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/OcException.java rename to java/common/src/main/java/org/iotivity/base/OcException.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcHeaderOption.java b/java/common/src/main/java/org/iotivity/base/OcHeaderOption.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/OcHeaderOption.java rename to java/common/src/main/java/org/iotivity/base/OcHeaderOption.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcPlatformInfo.java b/java/common/src/main/java/org/iotivity/base/OcPlatformInfo.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/OcPlatformInfo.java rename to java/common/src/main/java/org/iotivity/base/OcPlatformInfo.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcPlatformStatus.java b/java/common/src/main/java/org/iotivity/base/OcPlatformStatus.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/OcPlatformStatus.java rename to java/common/src/main/java/org/iotivity/base/OcPlatformStatus.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcPresenceHandle.java b/java/common/src/main/java/org/iotivity/base/OcPresenceHandle.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/OcPresenceHandle.java rename to java/common/src/main/java/org/iotivity/base/OcPresenceHandle.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcPresenceStatus.java b/java/common/src/main/java/org/iotivity/base/OcPresenceStatus.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/OcPresenceStatus.java rename to java/common/src/main/java/org/iotivity/base/OcPresenceStatus.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcProvisioning.java b/java/common/src/main/java/org/iotivity/base/OcProvisioning.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/OcProvisioning.java rename to java/common/src/main/java/org/iotivity/base/OcProvisioning.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcRepresentation.java b/java/common/src/main/java/org/iotivity/base/OcRepresentation.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/OcRepresentation.java rename to java/common/src/main/java/org/iotivity/base/OcRepresentation.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcRequestHandle.java b/java/common/src/main/java/org/iotivity/base/OcRequestHandle.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/OcRequestHandle.java rename to java/common/src/main/java/org/iotivity/base/OcRequestHandle.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcResource.java b/java/common/src/main/java/org/iotivity/base/OcResource.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/OcResource.java rename to java/common/src/main/java/org/iotivity/base/OcResource.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcResourceHandle.java b/java/common/src/main/java/org/iotivity/base/OcResourceHandle.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/OcResourceHandle.java rename to java/common/src/main/java/org/iotivity/base/OcResourceHandle.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcResourceIdentifier.java b/java/common/src/main/java/org/iotivity/base/OcResourceIdentifier.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/OcResourceIdentifier.java rename to java/common/src/main/java/org/iotivity/base/OcResourceIdentifier.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcResourceRequest.java b/java/common/src/main/java/org/iotivity/base/OcResourceRequest.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/OcResourceRequest.java rename to java/common/src/main/java/org/iotivity/base/OcResourceRequest.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcResourceResponse.java b/java/common/src/main/java/org/iotivity/base/OcResourceResponse.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/OcResourceResponse.java rename to java/common/src/main/java/org/iotivity/base/OcResourceResponse.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcSecureResource.java b/java/common/src/main/java/org/iotivity/base/OcSecureResource.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/OcSecureResource.java rename to java/common/src/main/java/org/iotivity/base/OcSecureResource.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OicSecAcl.java b/java/common/src/main/java/org/iotivity/base/OicSecAcl.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/OicSecAcl.java rename to java/common/src/main/java/org/iotivity/base/OicSecAcl.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OwnedStatus.java b/java/common/src/main/java/org/iotivity/base/OwnedStatus.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/OwnedStatus.java rename to java/common/src/main/java/org/iotivity/base/OwnedStatus.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OxmType.java b/java/common/src/main/java/org/iotivity/base/OxmType.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/OxmType.java rename to java/common/src/main/java/org/iotivity/base/OxmType.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/ProvisionResult.java b/java/common/src/main/java/org/iotivity/base/ProvisionResult.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/ProvisionResult.java rename to java/common/src/main/java/org/iotivity/base/ProvisionResult.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/QualityOfService.java b/java/common/src/main/java/org/iotivity/base/QualityOfService.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/QualityOfService.java rename to java/common/src/main/java/org/iotivity/base/QualityOfService.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/RequestHandlerFlag.java b/java/common/src/main/java/org/iotivity/base/RequestHandlerFlag.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/RequestHandlerFlag.java rename to java/common/src/main/java/org/iotivity/base/RequestHandlerFlag.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/RequestType.java b/java/common/src/main/java/org/iotivity/base/RequestType.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/RequestType.java rename to java/common/src/main/java/org/iotivity/base/RequestType.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/ResourceProperty.java b/java/common/src/main/java/org/iotivity/base/ResourceProperty.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/ResourceProperty.java rename to java/common/src/main/java/org/iotivity/base/ResourceProperty.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/ServiceType.java b/java/common/src/main/java/org/iotivity/base/ServiceType.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/ServiceType.java rename to java/common/src/main/java/org/iotivity/base/ServiceType.java diff --git a/android/examples/build.gradle b/java/examples-android/build.gradle similarity index 100% rename from android/examples/build.gradle rename to java/examples-android/build.gradle diff --git a/android/examples/presenceserver/.gitignore b/java/examples-android/devicediscoveryclient/.gitignore similarity index 100% rename from android/examples/presenceserver/.gitignore rename to java/examples-android/devicediscoveryclient/.gitignore diff --git a/java/examples-android/devicediscoveryclient/build.gradle b/java/examples-android/devicediscoveryclient/build.gradle new file mode 100644 index 0000000..cc18c5b --- /dev/null +++ b/java/examples-android/devicediscoveryclient/build.gradle @@ -0,0 +1,37 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 21 + buildToolsVersion "20.0.0" + + defaultConfig { + applicationId "org.iotivity.base.examples.devicediscoveryclient" + minSdkVersion 21 + targetSdkVersion 21 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + lintOptions { + abortOnError false + } +} +repositories { + flatDir { + dirs "../../iotivity-android/build/outputs/aar/" + } +} + +try { + dependencies { + compile ":iotivity-base-${TARGET_ARCH}-${RELEASE}@aar" + } +} catch (all) { + print "${ERROR_MSG}" + assert all +} diff --git a/android/examples/devicediscoveryclient/devicediscoveryclient.iml b/java/examples-android/devicediscoveryclient/devicediscoveryclient.iml similarity index 100% rename from android/examples/devicediscoveryclient/devicediscoveryclient.iml rename to java/examples-android/devicediscoveryclient/devicediscoveryclient.iml diff --git a/android/examples/simpleserver/proguard-rules.pro b/java/examples-android/devicediscoveryclient/proguard-rules.pro similarity index 100% rename from android/examples/simpleserver/proguard-rules.pro rename to java/examples-android/devicediscoveryclient/proguard-rules.pro diff --git a/android/examples/devicediscoveryclient/src/main/AndroidManifest.xml b/java/examples-android/devicediscoveryclient/src/main/AndroidManifest.xml similarity index 100% rename from android/examples/devicediscoveryclient/src/main/AndroidManifest.xml rename to java/examples-android/devicediscoveryclient/src/main/AndroidManifest.xml diff --git a/android/examples/devicediscoveryclient/src/main/java/org/iotivity/base/examples/DeviceDiscoveryClient.java b/java/examples-android/devicediscoveryclient/src/main/java/org/iotivity/base/examples/DeviceDiscoveryClient.java similarity index 100% rename from android/examples/devicediscoveryclient/src/main/java/org/iotivity/base/examples/DeviceDiscoveryClient.java rename to java/examples-android/devicediscoveryclient/src/main/java/org/iotivity/base/examples/DeviceDiscoveryClient.java diff --git a/android/examples/simpleserver/src/main/res/mipmap-hdpi/iotivityicon.png b/java/examples-android/devicediscoveryclient/src/main/res/drawable/iotivityicon.png similarity index 100% rename from android/examples/simpleserver/src/main/res/mipmap-hdpi/iotivityicon.png rename to java/examples-android/devicediscoveryclient/src/main/res/drawable/iotivityicon.png diff --git a/android/examples/simpleserver/src/main/res/drawable/iotivitylogo.png b/java/examples-android/devicediscoveryclient/src/main/res/drawable/iotivitylogo.png similarity index 100% rename from android/examples/simpleserver/src/main/res/drawable/iotivitylogo.png rename to java/examples-android/devicediscoveryclient/src/main/res/drawable/iotivitylogo.png diff --git a/android/examples/devicediscoveryclient/src/main/res/layout/activity_device_discovery_client.xml b/java/examples-android/devicediscoveryclient/src/main/res/layout/activity_device_discovery_client.xml similarity index 100% rename from android/examples/devicediscoveryclient/src/main/res/layout/activity_device_discovery_client.xml rename to java/examples-android/devicediscoveryclient/src/main/res/layout/activity_device_discovery_client.xml diff --git a/android/examples/simpleserver/src/main/res/drawable/iotivityicon.png b/java/examples-android/devicediscoveryclient/src/main/res/mipmap-hdpi/iotivityicon.png similarity index 100% rename from android/examples/simpleserver/src/main/res/drawable/iotivityicon.png rename to java/examples-android/devicediscoveryclient/src/main/res/mipmap-hdpi/iotivityicon.png diff --git a/android/examples/simpleserver/src/main/res/mipmap-mdpi/iotivityicon.png b/java/examples-android/devicediscoveryclient/src/main/res/mipmap-mdpi/iotivityicon.png similarity index 100% rename from android/examples/simpleserver/src/main/res/mipmap-mdpi/iotivityicon.png rename to java/examples-android/devicediscoveryclient/src/main/res/mipmap-mdpi/iotivityicon.png diff --git a/android/examples/simpleserver/src/main/res/mipmap-xhdpi/iotivityicon.png b/java/examples-android/devicediscoveryclient/src/main/res/mipmap-xhdpi/iotivityicon.png similarity index 100% rename from android/examples/simpleserver/src/main/res/mipmap-xhdpi/iotivityicon.png rename to java/examples-android/devicediscoveryclient/src/main/res/mipmap-xhdpi/iotivityicon.png diff --git a/android/examples/simpleserver/src/main/res/mipmap-xxhdpi/iotivityicon.png b/java/examples-android/devicediscoveryclient/src/main/res/mipmap-xxhdpi/iotivityicon.png similarity index 100% rename from android/examples/simpleserver/src/main/res/mipmap-xxhdpi/iotivityicon.png rename to java/examples-android/devicediscoveryclient/src/main/res/mipmap-xxhdpi/iotivityicon.png diff --git a/android/examples/simpleserver/src/main/res/values-v21/styles.xml b/java/examples-android/devicediscoveryclient/src/main/res/values-v21/styles.xml similarity index 100% rename from android/examples/simpleserver/src/main/res/values-v21/styles.xml rename to java/examples-android/devicediscoveryclient/src/main/res/values-v21/styles.xml diff --git a/android/examples/simpleserver/src/main/res/values-w820dp/dimens.xml b/java/examples-android/devicediscoveryclient/src/main/res/values-w820dp/dimens.xml similarity index 100% rename from android/examples/simpleserver/src/main/res/values-w820dp/dimens.xml rename to java/examples-android/devicediscoveryclient/src/main/res/values-w820dp/dimens.xml diff --git a/android/examples/simpleserver/src/main/res/values/dimens.xml b/java/examples-android/devicediscoveryclient/src/main/res/values/dimens.xml similarity index 100% rename from android/examples/simpleserver/src/main/res/values/dimens.xml rename to java/examples-android/devicediscoveryclient/src/main/res/values/dimens.xml diff --git a/android/examples/devicediscoveryclient/src/main/res/values/strings.xml b/java/examples-android/devicediscoveryclient/src/main/res/values/strings.xml similarity index 100% rename from android/examples/devicediscoveryclient/src/main/res/values/strings.xml rename to java/examples-android/devicediscoveryclient/src/main/res/values/strings.xml diff --git a/android/examples/simpleserver/src/main/res/values/styles.xml b/java/examples-android/devicediscoveryclient/src/main/res/values/styles.xml similarity index 100% rename from android/examples/simpleserver/src/main/res/values/styles.xml rename to java/examples-android/devicediscoveryclient/src/main/res/values/styles.xml diff --git a/android/examples/presenceclient/.gitignore b/java/examples-android/devicediscoveryserver/.gitignore similarity index 100% rename from android/examples/presenceclient/.gitignore rename to java/examples-android/devicediscoveryserver/.gitignore diff --git a/java/examples-android/devicediscoveryserver/build.gradle b/java/examples-android/devicediscoveryserver/build.gradle new file mode 100644 index 0000000..dc14408 --- /dev/null +++ b/java/examples-android/devicediscoveryserver/build.gradle @@ -0,0 +1,37 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 21 + buildToolsVersion "20.0.0" + + defaultConfig { + applicationId "org.iotivity.base.examples.devicediscoveryserver" + minSdkVersion 21 + targetSdkVersion 21 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + lintOptions { + abortOnError false + } +} +repositories { + flatDir { + dirs "../../iotivity-android/build/outputs/aar/" + } +} + +try { + dependencies { + compile ":iotivity-base-${TARGET_ARCH}-${RELEASE}@aar" + } +} catch (all) { + print "${ERROR_MSG}" + assert all +} diff --git a/android/examples/devicediscoveryserver/devicediscoveryserver.iml b/java/examples-android/devicediscoveryserver/devicediscoveryserver.iml similarity index 100% rename from android/examples/devicediscoveryserver/devicediscoveryserver.iml rename to java/examples-android/devicediscoveryserver/devicediscoveryserver.iml diff --git a/android/examples/simpleclient/proguard-rules.pro b/java/examples-android/devicediscoveryserver/proguard-rules.pro similarity index 100% rename from android/examples/simpleclient/proguard-rules.pro rename to java/examples-android/devicediscoveryserver/proguard-rules.pro diff --git a/android/examples/devicediscoveryserver/src/main/AndroidManifest.xml b/java/examples-android/devicediscoveryserver/src/main/AndroidManifest.xml similarity index 100% rename from android/examples/devicediscoveryserver/src/main/AndroidManifest.xml rename to java/examples-android/devicediscoveryserver/src/main/AndroidManifest.xml diff --git a/android/examples/devicediscoveryserver/src/main/java/org/iotivity/base/examples/DeviceDiscoveryServer.java b/java/examples-android/devicediscoveryserver/src/main/java/org/iotivity/base/examples/DeviceDiscoveryServer.java similarity index 100% rename from android/examples/devicediscoveryserver/src/main/java/org/iotivity/base/examples/DeviceDiscoveryServer.java rename to java/examples-android/devicediscoveryserver/src/main/java/org/iotivity/base/examples/DeviceDiscoveryServer.java diff --git a/android/examples/simpleclient/src/main/res/mipmap-hdpi/iotivityicon.png b/java/examples-android/devicediscoveryserver/src/main/res/drawable/iotivityicon.png similarity index 100% rename from android/examples/simpleclient/src/main/res/mipmap-hdpi/iotivityicon.png rename to java/examples-android/devicediscoveryserver/src/main/res/drawable/iotivityicon.png diff --git a/android/examples/simpleclient/src/main/res/drawable/iotivitylogo.png b/java/examples-android/devicediscoveryserver/src/main/res/drawable/iotivitylogo.png similarity index 100% rename from android/examples/simpleclient/src/main/res/drawable/iotivitylogo.png rename to java/examples-android/devicediscoveryserver/src/main/res/drawable/iotivitylogo.png diff --git a/android/examples/devicediscoveryserver/src/main/res/layout/activity_device_discovery_server.xml b/java/examples-android/devicediscoveryserver/src/main/res/layout/activity_device_discovery_server.xml similarity index 100% rename from android/examples/devicediscoveryserver/src/main/res/layout/activity_device_discovery_server.xml rename to java/examples-android/devicediscoveryserver/src/main/res/layout/activity_device_discovery_server.xml diff --git a/android/examples/simpleclient/src/main/res/drawable/iotivityicon.png b/java/examples-android/devicediscoveryserver/src/main/res/mipmap-hdpi/iotivityicon.png similarity index 100% rename from android/examples/simpleclient/src/main/res/drawable/iotivityicon.png rename to java/examples-android/devicediscoveryserver/src/main/res/mipmap-hdpi/iotivityicon.png diff --git a/android/examples/simpleclient/src/main/res/mipmap-mdpi/iotivityicon.png b/java/examples-android/devicediscoveryserver/src/main/res/mipmap-mdpi/iotivityicon.png similarity index 100% rename from android/examples/simpleclient/src/main/res/mipmap-mdpi/iotivityicon.png rename to java/examples-android/devicediscoveryserver/src/main/res/mipmap-mdpi/iotivityicon.png diff --git a/android/examples/simpleclient/src/main/res/mipmap-xhdpi/iotivityicon.png b/java/examples-android/devicediscoveryserver/src/main/res/mipmap-xhdpi/iotivityicon.png similarity index 100% rename from android/examples/simpleclient/src/main/res/mipmap-xhdpi/iotivityicon.png rename to java/examples-android/devicediscoveryserver/src/main/res/mipmap-xhdpi/iotivityicon.png diff --git a/android/examples/simpleclient/src/main/res/mipmap-xxhdpi/iotivityicon.png b/java/examples-android/devicediscoveryserver/src/main/res/mipmap-xxhdpi/iotivityicon.png similarity index 100% rename from android/examples/simpleclient/src/main/res/mipmap-xxhdpi/iotivityicon.png rename to java/examples-android/devicediscoveryserver/src/main/res/mipmap-xxhdpi/iotivityicon.png diff --git a/android/examples/simpleclient/src/main/res/values-v21/styles.xml b/java/examples-android/devicediscoveryserver/src/main/res/values-v21/styles.xml similarity index 100% rename from android/examples/simpleclient/src/main/res/values-v21/styles.xml rename to java/examples-android/devicediscoveryserver/src/main/res/values-v21/styles.xml diff --git a/android/examples/simpleclient/src/main/res/values-w820dp/dimens.xml b/java/examples-android/devicediscoveryserver/src/main/res/values-w820dp/dimens.xml similarity index 100% rename from android/examples/simpleclient/src/main/res/values-w820dp/dimens.xml rename to java/examples-android/devicediscoveryserver/src/main/res/values-w820dp/dimens.xml diff --git a/android/examples/simpleclient/src/main/res/values/dimens.xml b/java/examples-android/devicediscoveryserver/src/main/res/values/dimens.xml similarity index 100% rename from android/examples/simpleclient/src/main/res/values/dimens.xml rename to java/examples-android/devicediscoveryserver/src/main/res/values/dimens.xml diff --git a/android/examples/devicediscoveryserver/src/main/res/values/strings.xml b/java/examples-android/devicediscoveryserver/src/main/res/values/strings.xml similarity index 100% rename from android/examples/devicediscoveryserver/src/main/res/values/strings.xml rename to java/examples-android/devicediscoveryserver/src/main/res/values/strings.xml diff --git a/android/examples/simpleclient/src/main/res/values/styles.xml b/java/examples-android/devicediscoveryserver/src/main/res/values/styles.xml similarity index 100% rename from android/examples/simpleclient/src/main/res/values/styles.xml rename to java/examples-android/devicediscoveryserver/src/main/res/values/styles.xml diff --git a/android/examples/examples.iml b/java/examples-android/examples.iml similarity index 100% rename from android/examples/examples.iml rename to java/examples-android/examples.iml diff --git a/android/examples/simpleserver/.gitignore b/java/examples-android/fridgeclient/.gitignore old mode 100644 new mode 100755 similarity index 100% rename from android/examples/simpleserver/.gitignore rename to java/examples-android/fridgeclient/.gitignore diff --git a/java/examples-android/fridgeclient/build.gradle b/java/examples-android/fridgeclient/build.gradle new file mode 100755 index 0000000..1966fa1 --- /dev/null +++ b/java/examples-android/fridgeclient/build.gradle @@ -0,0 +1,35 @@ +apply plugin: 'com.android.application' +android { + compileSdkVersion 21 + buildToolsVersion "20.0.0" + + defaultConfig { + applicationId "org.iotivity.base.examples.fridgeclient" + minSdkVersion 21 + targetSdkVersion 21 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + lintOptions { + abortOnError false + } +} +repositories { + flatDir { + dirs "../../iotivity-android/build/outputs/aar/" + } +} +try { + dependencies { + compile ":iotivity-base-${TARGET_ARCH}-${RELEASE}@aar" + } +} catch (all) { + print "${ERROR_MSG}" + assert all +} diff --git a/android/examples/fridgeclient/fridgeclient.iml b/java/examples-android/fridgeclient/fridgeclient.iml similarity index 100% rename from android/examples/fridgeclient/fridgeclient.iml rename to java/examples-android/fridgeclient/fridgeclient.iml diff --git a/android/examples/fridgeclient/src/main/AndroidManifest.xml b/java/examples-android/fridgeclient/src/main/AndroidManifest.xml similarity index 100% rename from android/examples/fridgeclient/src/main/AndroidManifest.xml rename to java/examples-android/fridgeclient/src/main/AndroidManifest.xml diff --git a/android/examples/fridgeclient/src/main/java/org/iotivity/base/examples/FridgeClient.java b/java/examples-android/fridgeclient/src/main/java/org/iotivity/base/examples/FridgeClient.java similarity index 100% rename from android/examples/fridgeclient/src/main/java/org/iotivity/base/examples/FridgeClient.java rename to java/examples-android/fridgeclient/src/main/java/org/iotivity/base/examples/FridgeClient.java diff --git a/android/examples/simplebase/src/main/res/mipmap-hdpi/iotivityicon.png b/java/examples-android/fridgeclient/src/main/res/drawable-hdpi/iotivityicon.png old mode 100644 new mode 100755 similarity index 100% rename from android/examples/simplebase/src/main/res/mipmap-hdpi/iotivityicon.png rename to java/examples-android/fridgeclient/src/main/res/drawable-hdpi/iotivityicon.png diff --git a/android/examples/simplebase/src/main/res/drawable/iotivitylogo.png b/java/examples-android/fridgeclient/src/main/res/drawable-hdpi/iotivitylogo.png old mode 100644 new mode 100755 similarity index 100% rename from android/examples/simplebase/src/main/res/drawable/iotivitylogo.png rename to java/examples-android/fridgeclient/src/main/res/drawable-hdpi/iotivitylogo.png diff --git a/android/examples/simplebase/src/main/res/drawable/iotivityicon.png b/java/examples-android/fridgeclient/src/main/res/drawable-mdpi/iotivityicon.png old mode 100644 new mode 100755 similarity index 100% rename from android/examples/simplebase/src/main/res/drawable/iotivityicon.png rename to java/examples-android/fridgeclient/src/main/res/drawable-mdpi/iotivityicon.png diff --git a/android/examples/presenceserver/src/main/res/drawable/iotivitylogo.png b/java/examples-android/fridgeclient/src/main/res/drawable-mdpi/iotivitylogo.png old mode 100644 new mode 100755 similarity index 100% rename from android/examples/presenceserver/src/main/res/drawable/iotivitylogo.png rename to java/examples-android/fridgeclient/src/main/res/drawable-mdpi/iotivitylogo.png diff --git a/android/examples/presenceserver/src/main/res/mipmap-hdpi/iotivityicon.png b/java/examples-android/fridgeclient/src/main/res/drawable-xhdpi/iotivityicon.png old mode 100644 new mode 100755 similarity index 100% rename from android/examples/presenceserver/src/main/res/mipmap-hdpi/iotivityicon.png rename to java/examples-android/fridgeclient/src/main/res/drawable-xhdpi/iotivityicon.png diff --git a/android/examples/presenceclient/src/main/res/drawable/iotivitylogo.png b/java/examples-android/fridgeclient/src/main/res/drawable-xhdpi/iotivitylogo.png old mode 100644 new mode 100755 similarity index 100% rename from android/examples/presenceclient/src/main/res/drawable/iotivitylogo.png rename to java/examples-android/fridgeclient/src/main/res/drawable-xhdpi/iotivitylogo.png diff --git a/android/examples/presenceserver/src/main/res/drawable/iotivityicon.png b/java/examples-android/fridgeclient/src/main/res/drawable-xxhdpi/iotivityicon.png old mode 100644 new mode 100755 similarity index 100% rename from android/examples/presenceserver/src/main/res/drawable/iotivityicon.png rename to java/examples-android/fridgeclient/src/main/res/drawable-xxhdpi/iotivityicon.png diff --git a/android/examples/groupserver/src/main/res/drawable/iotivitylogo.png b/java/examples-android/fridgeclient/src/main/res/drawable-xxhdpi/iotivitylogo.png old mode 100644 new mode 100755 similarity index 100% rename from android/examples/groupserver/src/main/res/drawable/iotivitylogo.png rename to java/examples-android/fridgeclient/src/main/res/drawable-xxhdpi/iotivitylogo.png diff --git a/android/examples/fridgeclient/src/main/res/layout/activity_fridge_client.xml b/java/examples-android/fridgeclient/src/main/res/layout/activity_fridge_client.xml similarity index 100% rename from android/examples/fridgeclient/src/main/res/layout/activity_fridge_client.xml rename to java/examples-android/fridgeclient/src/main/res/layout/activity_fridge_client.xml diff --git a/android/examples/fridgeclient/src/main/res/menu/menu_fridge_client.xml b/java/examples-android/fridgeclient/src/main/res/menu/menu_fridge_client.xml similarity index 100% rename from android/examples/fridgeclient/src/main/res/menu/menu_fridge_client.xml rename to java/examples-android/fridgeclient/src/main/res/menu/menu_fridge_client.xml diff --git a/android/examples/simplebase/src/main/res/values-w820dp/dimens.xml b/java/examples-android/fridgeclient/src/main/res/values-w820dp/dimens.xml old mode 100644 new mode 100755 similarity index 100% rename from android/examples/simplebase/src/main/res/values-w820dp/dimens.xml rename to java/examples-android/fridgeclient/src/main/res/values-w820dp/dimens.xml diff --git a/android/examples/provisioningclient/src/main/res/values/dimens.xml b/java/examples-android/fridgeclient/src/main/res/values/dimens.xml old mode 100644 new mode 100755 similarity index 100% rename from android/examples/provisioningclient/src/main/res/values/dimens.xml rename to java/examples-android/fridgeclient/src/main/res/values/dimens.xml diff --git a/android/examples/fridgeclient/src/main/res/values/strings.xml b/java/examples-android/fridgeclient/src/main/res/values/strings.xml similarity index 100% rename from android/examples/fridgeclient/src/main/res/values/strings.xml rename to java/examples-android/fridgeclient/src/main/res/values/strings.xml diff --git a/android/examples/simplebase/src/main/res/values/styles.xml b/java/examples-android/fridgeclient/src/main/res/values/styles.xml old mode 100644 new mode 100755 similarity index 100% rename from android/examples/simplebase/src/main/res/values/styles.xml rename to java/examples-android/fridgeclient/src/main/res/values/styles.xml diff --git a/android/examples/simpleclient/.gitignore b/java/examples-android/fridgegroupclient/.gitignore old mode 100644 new mode 100755 similarity index 100% rename from android/examples/simpleclient/.gitignore rename to java/examples-android/fridgegroupclient/.gitignore diff --git a/java/examples-android/fridgegroupclient/build.gradle b/java/examples-android/fridgegroupclient/build.gradle new file mode 100755 index 0000000..608f5e7 --- /dev/null +++ b/java/examples-android/fridgegroupclient/build.gradle @@ -0,0 +1,35 @@ +apply plugin: 'com.android.application' +android { + compileSdkVersion 21 + buildToolsVersion "20.0.0" + + defaultConfig { + applicationId "org.iotivity.base.examples.fridgegroupclient" + minSdkVersion 21 + targetSdkVersion 21 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + lintOptions { + abortOnError false + } +} +repositories { + flatDir { + dirs "../../iotivity-android/build/outputs/aar/" + } +} +try { + dependencies { + compile ":iotivity-base-${TARGET_ARCH}-${RELEASE}@aar" + } +} catch (all) { + print "${ERROR_MSG}" + assert all +} diff --git a/android/examples/fridgegroupclient/src/main/AndroidManifest.xml b/java/examples-android/fridgegroupclient/src/main/AndroidManifest.xml similarity index 100% rename from android/examples/fridgegroupclient/src/main/AndroidManifest.xml rename to java/examples-android/fridgegroupclient/src/main/AndroidManifest.xml diff --git a/android/examples/fridgegroupclient/src/main/java/org/iotivity/base/examples/FridgeGroupClient.java b/java/examples-android/fridgegroupclient/src/main/java/org/iotivity/base/examples/FridgeGroupClient.java similarity index 100% rename from android/examples/fridgegroupclient/src/main/java/org/iotivity/base/examples/FridgeGroupClient.java rename to java/examples-android/fridgegroupclient/src/main/java/org/iotivity/base/examples/FridgeGroupClient.java diff --git a/android/examples/presenceclient/src/main/res/mipmap-hdpi/iotivityicon.png b/java/examples-android/fridgegroupclient/src/main/res/drawable-hdpi/iotivityicon.png old mode 100644 new mode 100755 similarity index 100% rename from android/examples/presenceclient/src/main/res/mipmap-hdpi/iotivityicon.png rename to java/examples-android/fridgegroupclient/src/main/res/drawable-hdpi/iotivityicon.png diff --git a/android/examples/groupclient/src/main/res/drawable/iotivitylogo.png b/java/examples-android/fridgegroupclient/src/main/res/drawable-hdpi/iotivitylogo.png old mode 100644 new mode 100755 similarity index 100% rename from android/examples/groupclient/src/main/res/drawable/iotivitylogo.png rename to java/examples-android/fridgegroupclient/src/main/res/drawable-hdpi/iotivitylogo.png diff --git a/android/examples/presenceclient/src/main/res/drawable/iotivityicon.png b/java/examples-android/fridgegroupclient/src/main/res/drawable-mdpi/iotivityicon.png old mode 100644 new mode 100755 similarity index 100% rename from android/examples/presenceclient/src/main/res/drawable/iotivityicon.png rename to java/examples-android/fridgegroupclient/src/main/res/drawable-mdpi/iotivityicon.png diff --git a/android/examples/fridgeserver/src/main/res/drawable-xxhdpi/iotivitylogo.png b/java/examples-android/fridgegroupclient/src/main/res/drawable-mdpi/iotivitylogo.png similarity index 100% rename from android/examples/fridgeserver/src/main/res/drawable-xxhdpi/iotivitylogo.png rename to java/examples-android/fridgegroupclient/src/main/res/drawable-mdpi/iotivitylogo.png diff --git a/android/examples/groupserver/src/main/res/mipmap-hdpi/iotivityicon.png b/java/examples-android/fridgegroupclient/src/main/res/drawable-xhdpi/iotivityicon.png old mode 100644 new mode 100755 similarity index 100% rename from android/examples/groupserver/src/main/res/mipmap-hdpi/iotivityicon.png rename to java/examples-android/fridgegroupclient/src/main/res/drawable-xhdpi/iotivityicon.png diff --git a/android/examples/fridgeserver/src/main/res/drawable-xhdpi/iotivitylogo.png b/java/examples-android/fridgegroupclient/src/main/res/drawable-xhdpi/iotivitylogo.png similarity index 100% rename from android/examples/fridgeserver/src/main/res/drawable-xhdpi/iotivitylogo.png rename to java/examples-android/fridgegroupclient/src/main/res/drawable-xhdpi/iotivitylogo.png diff --git a/android/examples/groupserver/src/main/res/drawable/iotivityicon.png b/java/examples-android/fridgegroupclient/src/main/res/drawable-xxhdpi/iotivityicon.png old mode 100644 new mode 100755 similarity index 100% rename from android/examples/groupserver/src/main/res/drawable/iotivityicon.png rename to java/examples-android/fridgegroupclient/src/main/res/drawable-xxhdpi/iotivityicon.png diff --git a/android/examples/fridgeserver/src/main/res/drawable-mdpi/iotivitylogo.png b/java/examples-android/fridgegroupclient/src/main/res/drawable-xxhdpi/iotivitylogo.png similarity index 100% rename from android/examples/fridgeserver/src/main/res/drawable-mdpi/iotivitylogo.png rename to java/examples-android/fridgegroupclient/src/main/res/drawable-xxhdpi/iotivitylogo.png diff --git a/android/examples/fridgegroupclient/src/main/res/layout/activity_fridge_client.xml b/java/examples-android/fridgegroupclient/src/main/res/layout/activity_fridge_client.xml similarity index 100% rename from android/examples/fridgegroupclient/src/main/res/layout/activity_fridge_client.xml rename to java/examples-android/fridgegroupclient/src/main/res/layout/activity_fridge_client.xml diff --git a/android/examples/provisioningclient/src/main/res/values-w820dp/dimens.xml b/java/examples-android/fridgegroupclient/src/main/res/values-w820dp/dimens.xml old mode 100644 new mode 100755 similarity index 100% rename from android/examples/provisioningclient/src/main/res/values-w820dp/dimens.xml rename to java/examples-android/fridgegroupclient/src/main/res/values-w820dp/dimens.xml diff --git a/android/examples/fridgegroupclient/src/main/res/values/assets.xml b/java/examples-android/fridgegroupclient/src/main/res/values/assets.xml similarity index 100% rename from android/examples/fridgegroupclient/src/main/res/values/assets.xml rename to java/examples-android/fridgegroupclient/src/main/res/values/assets.xml diff --git a/android/examples/presenceserver/src/main/res/values/dimens.xml b/java/examples-android/fridgegroupclient/src/main/res/values/dimens.xml old mode 100644 new mode 100755 similarity index 100% rename from android/examples/presenceserver/src/main/res/values/dimens.xml rename to java/examples-android/fridgegroupclient/src/main/res/values/dimens.xml diff --git a/android/examples/fridgegroupclient/src/main/res/values/strings.xml b/java/examples-android/fridgegroupclient/src/main/res/values/strings.xml similarity index 100% rename from android/examples/fridgegroupclient/src/main/res/values/strings.xml rename to java/examples-android/fridgegroupclient/src/main/res/values/strings.xml diff --git a/android/examples/provisioningclient/src/main/res/values/styles.xml b/java/examples-android/fridgegroupclient/src/main/res/values/styles.xml old mode 100644 new mode 100755 similarity index 100% rename from android/examples/provisioningclient/src/main/res/values/styles.xml rename to java/examples-android/fridgegroupclient/src/main/res/values/styles.xml diff --git a/android/examples/simplebase/.gitignore b/java/examples-android/fridgegroupserver/.gitignore old mode 100644 new mode 100755 similarity index 100% rename from android/examples/simplebase/.gitignore rename to java/examples-android/fridgegroupserver/.gitignore diff --git a/java/examples-android/fridgegroupserver/build.gradle b/java/examples-android/fridgegroupserver/build.gradle new file mode 100755 index 0000000..a7d1da6 --- /dev/null +++ b/java/examples-android/fridgegroupserver/build.gradle @@ -0,0 +1,35 @@ +apply plugin: 'com.android.application' +android { + compileSdkVersion 21 + buildToolsVersion "20.0.0" + + defaultConfig { + applicationId "org.iotivity.base.examples.fridgegroupserver" + minSdkVersion 21 + targetSdkVersion 21 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + lintOptions { + abortOnError false + } +} +repositories { + flatDir { + dirs "../../iotivity-android/build/outputs/aar/" + } +} +try { + dependencies { + compile ":iotivity-base-${TARGET_ARCH}-${RELEASE}@aar" + } +} catch (all) { + print "${ERROR_MSG}" + assert all +} diff --git a/android/examples/fridgegroupserver/src/main/AndroidManifest.xml b/java/examples-android/fridgegroupserver/src/main/AndroidManifest.xml similarity index 100% rename from android/examples/fridgegroupserver/src/main/AndroidManifest.xml rename to java/examples-android/fridgegroupserver/src/main/AndroidManifest.xml diff --git a/android/examples/fridgegroupserver/src/main/java/org/iotivity/base/examples/DoorResource.java b/java/examples-android/fridgegroupserver/src/main/java/org/iotivity/base/examples/DoorResource.java similarity index 100% rename from android/examples/fridgegroupserver/src/main/java/org/iotivity/base/examples/DoorResource.java rename to java/examples-android/fridgegroupserver/src/main/java/org/iotivity/base/examples/DoorResource.java diff --git a/android/examples/fridgegroupserver/src/main/java/org/iotivity/base/examples/FridgeGroupServer.java b/java/examples-android/fridgegroupserver/src/main/java/org/iotivity/base/examples/FridgeGroupServer.java similarity index 100% rename from android/examples/fridgegroupserver/src/main/java/org/iotivity/base/examples/FridgeGroupServer.java rename to java/examples-android/fridgegroupserver/src/main/java/org/iotivity/base/examples/FridgeGroupServer.java diff --git a/android/examples/fridgegroupserver/src/main/java/org/iotivity/base/examples/FridgeResource.java b/java/examples-android/fridgegroupserver/src/main/java/org/iotivity/base/examples/FridgeResource.java similarity index 100% rename from android/examples/fridgegroupserver/src/main/java/org/iotivity/base/examples/FridgeResource.java rename to java/examples-android/fridgegroupserver/src/main/java/org/iotivity/base/examples/FridgeResource.java diff --git a/android/examples/fridgegroupserver/src/main/java/org/iotivity/base/examples/LightResource.java b/java/examples-android/fridgegroupserver/src/main/java/org/iotivity/base/examples/LightResource.java similarity index 100% rename from android/examples/fridgegroupserver/src/main/java/org/iotivity/base/examples/LightResource.java rename to java/examples-android/fridgegroupserver/src/main/java/org/iotivity/base/examples/LightResource.java diff --git a/android/examples/fridgegroupserver/src/main/java/org/iotivity/base/examples/Refrigerator.java b/java/examples-android/fridgegroupserver/src/main/java/org/iotivity/base/examples/Refrigerator.java similarity index 100% rename from android/examples/fridgegroupserver/src/main/java/org/iotivity/base/examples/Refrigerator.java rename to java/examples-android/fridgegroupserver/src/main/java/org/iotivity/base/examples/Refrigerator.java diff --git a/android/examples/fridgegroupserver/src/main/java/org/iotivity/base/examples/Resource.java b/java/examples-android/fridgegroupserver/src/main/java/org/iotivity/base/examples/Resource.java similarity index 100% rename from android/examples/fridgegroupserver/src/main/java/org/iotivity/base/examples/Resource.java rename to java/examples-android/fridgegroupserver/src/main/java/org/iotivity/base/examples/Resource.java diff --git a/android/examples/guiclient/src/main/res/drawable-hdpi/ic_launcher.png b/java/examples-android/fridgegroupserver/src/main/res/drawable-hdpi/ic_launcher.png old mode 100644 new mode 100755 similarity index 100% rename from android/examples/guiclient/src/main/res/drawable-hdpi/ic_launcher.png rename to java/examples-android/fridgegroupserver/src/main/res/drawable-hdpi/ic_launcher.png diff --git a/android/examples/groupclient/src/main/res/mipmap-hdpi/iotivityicon.png b/java/examples-android/fridgegroupserver/src/main/res/drawable-hdpi/iotivityicon.png old mode 100644 new mode 100755 similarity index 100% rename from android/examples/groupclient/src/main/res/mipmap-hdpi/iotivityicon.png rename to java/examples-android/fridgegroupserver/src/main/res/drawable-hdpi/iotivityicon.png diff --git a/android/examples/fridgeserver/src/main/res/drawable-hdpi/iotivitylogo.png b/java/examples-android/fridgegroupserver/src/main/res/drawable-hdpi/iotivitylogo.png similarity index 100% rename from android/examples/fridgeserver/src/main/res/drawable-hdpi/iotivitylogo.png rename to java/examples-android/fridgegroupserver/src/main/res/drawable-hdpi/iotivitylogo.png diff --git a/android/examples/guiclient/src/main/res/drawable-mdpi/ic_launcher.png b/java/examples-android/fridgegroupserver/src/main/res/drawable-mdpi/ic_launcher.png old mode 100644 new mode 100755 similarity index 100% rename from android/examples/guiclient/src/main/res/drawable-mdpi/ic_launcher.png rename to java/examples-android/fridgegroupserver/src/main/res/drawable-mdpi/ic_launcher.png diff --git a/android/examples/groupclient/src/main/res/drawable/iotivityicon.png b/java/examples-android/fridgegroupserver/src/main/res/drawable-mdpi/iotivityicon.png old mode 100644 new mode 100755 similarity index 100% rename from android/examples/groupclient/src/main/res/drawable/iotivityicon.png rename to java/examples-android/fridgegroupserver/src/main/res/drawable-mdpi/iotivityicon.png diff --git a/android/examples/fridgegroupserver/src/main/res/drawable-xxhdpi/iotivitylogo.png b/java/examples-android/fridgegroupserver/src/main/res/drawable-mdpi/iotivitylogo.png similarity index 100% rename from android/examples/fridgegroupserver/src/main/res/drawable-xxhdpi/iotivitylogo.png rename to java/examples-android/fridgegroupserver/src/main/res/drawable-mdpi/iotivitylogo.png diff --git a/android/examples/guiclient/src/main/res/drawable-xhdpi/ic_launcher.png b/java/examples-android/fridgegroupserver/src/main/res/drawable-xhdpi/ic_launcher.png old mode 100644 new mode 100755 similarity index 100% rename from android/examples/guiclient/src/main/res/drawable-xhdpi/ic_launcher.png rename to java/examples-android/fridgegroupserver/src/main/res/drawable-xhdpi/ic_launcher.png diff --git a/android/examples/fridgeserver/src/main/res/drawable-xxhdpi/iotivityicon.png b/java/examples-android/fridgegroupserver/src/main/res/drawable-xhdpi/iotivityicon.png similarity index 100% rename from android/examples/fridgeserver/src/main/res/drawable-xxhdpi/iotivityicon.png rename to java/examples-android/fridgegroupserver/src/main/res/drawable-xhdpi/iotivityicon.png diff --git a/android/examples/fridgegroupserver/src/main/res/drawable-xhdpi/iotivitylogo.png b/java/examples-android/fridgegroupserver/src/main/res/drawable-xhdpi/iotivitylogo.png similarity index 100% rename from android/examples/fridgegroupserver/src/main/res/drawable-xhdpi/iotivitylogo.png rename to java/examples-android/fridgegroupserver/src/main/res/drawable-xhdpi/iotivitylogo.png diff --git a/android/examples/guiclient/src/main/res/drawable-xxhdpi/ic_launcher.png b/java/examples-android/fridgegroupserver/src/main/res/drawable-xxhdpi/ic_launcher.png old mode 100644 new mode 100755 similarity index 100% rename from android/examples/guiclient/src/main/res/drawable-xxhdpi/ic_launcher.png rename to java/examples-android/fridgegroupserver/src/main/res/drawable-xxhdpi/ic_launcher.png diff --git a/android/examples/fridgeserver/src/main/res/drawable-xhdpi/iotivityicon.png b/java/examples-android/fridgegroupserver/src/main/res/drawable-xxhdpi/iotivityicon.png similarity index 100% rename from android/examples/fridgeserver/src/main/res/drawable-xhdpi/iotivityicon.png rename to java/examples-android/fridgegroupserver/src/main/res/drawable-xxhdpi/iotivityicon.png diff --git a/android/examples/fridgegroupserver/src/main/res/drawable-mdpi/iotivitylogo.png b/java/examples-android/fridgegroupserver/src/main/res/drawable-xxhdpi/iotivitylogo.png similarity index 100% rename from android/examples/fridgegroupserver/src/main/res/drawable-mdpi/iotivitylogo.png rename to java/examples-android/fridgegroupserver/src/main/res/drawable-xxhdpi/iotivitylogo.png diff --git a/android/examples/fridgegroupserver/src/main/res/layout/activity_fridge_server.xml b/java/examples-android/fridgegroupserver/src/main/res/layout/activity_fridge_server.xml similarity index 100% rename from android/examples/fridgegroupserver/src/main/res/layout/activity_fridge_server.xml rename to java/examples-android/fridgegroupserver/src/main/res/layout/activity_fridge_server.xml diff --git a/android/examples/presenceserver/src/main/res/values-w820dp/dimens.xml b/java/examples-android/fridgegroupserver/src/main/res/values-w820dp/dimens.xml old mode 100644 new mode 100755 similarity index 100% rename from android/examples/presenceserver/src/main/res/values-w820dp/dimens.xml rename to java/examples-android/fridgegroupserver/src/main/res/values-w820dp/dimens.xml diff --git a/android/examples/presenceclient/src/main/res/values/dimens.xml b/java/examples-android/fridgegroupserver/src/main/res/values/dimens.xml old mode 100644 new mode 100755 similarity index 100% rename from android/examples/presenceclient/src/main/res/values/dimens.xml rename to java/examples-android/fridgegroupserver/src/main/res/values/dimens.xml diff --git a/android/examples/fridgegroupserver/src/main/res/values/strings.xml b/java/examples-android/fridgegroupserver/src/main/res/values/strings.xml similarity index 100% rename from android/examples/fridgegroupserver/src/main/res/values/strings.xml rename to java/examples-android/fridgegroupserver/src/main/res/values/strings.xml diff --git a/android/examples/presenceserver/src/main/res/values/styles.xml b/java/examples-android/fridgegroupserver/src/main/res/values/styles.xml old mode 100644 new mode 100755 similarity index 100% rename from android/examples/presenceserver/src/main/res/values/styles.xml rename to java/examples-android/fridgegroupserver/src/main/res/values/styles.xml diff --git a/android/examples/fridgeserver/.gitignore b/java/examples-android/fridgeserver/.gitignore similarity index 100% rename from android/examples/fridgeserver/.gitignore rename to java/examples-android/fridgeserver/.gitignore diff --git a/java/examples-android/fridgeserver/build.gradle b/java/examples-android/fridgeserver/build.gradle new file mode 100755 index 0000000..db51c26 --- /dev/null +++ b/java/examples-android/fridgeserver/build.gradle @@ -0,0 +1,35 @@ +apply plugin: 'com.android.application' +android { + compileSdkVersion 21 + buildToolsVersion "20.0.0" + + defaultConfig { + applicationId "org.iotivity.base.examples.fridgeserver" + minSdkVersion 21 + targetSdkVersion 21 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + lintOptions { + abortOnError false + } +} +repositories { + flatDir { + dirs "../../iotivity-android/build/outputs/aar/" + } +} +try { + dependencies { + compile ":iotivity-base-${TARGET_ARCH}-${RELEASE}@aar" + } +} catch (all) { + print "${ERROR_MSG}" + assert all +} diff --git a/android/examples/fridgeserver/fridgeserver.iml b/java/examples-android/fridgeserver/fridgeserver.iml similarity index 100% rename from android/examples/fridgeserver/fridgeserver.iml rename to java/examples-android/fridgeserver/fridgeserver.iml diff --git a/android/examples/fridgeserver/src/main/AndroidManifest.xml b/java/examples-android/fridgeserver/src/main/AndroidManifest.xml similarity index 100% rename from android/examples/fridgeserver/src/main/AndroidManifest.xml rename to java/examples-android/fridgeserver/src/main/AndroidManifest.xml diff --git a/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DeviceResource.java b/java/examples-android/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DeviceResource.java similarity index 100% rename from android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DeviceResource.java rename to java/examples-android/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DeviceResource.java diff --git a/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DoorResource.java b/java/examples-android/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DoorResource.java similarity index 100% rename from android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DoorResource.java rename to java/examples-android/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DoorResource.java diff --git a/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/FridgeServer.java b/java/examples-android/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/FridgeServer.java similarity index 100% rename from android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/FridgeServer.java rename to java/examples-android/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/FridgeServer.java diff --git a/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/LightResource.java b/java/examples-android/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/LightResource.java similarity index 100% rename from android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/LightResource.java rename to java/examples-android/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/LightResource.java diff --git a/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Refrigerator.java b/java/examples-android/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Refrigerator.java similarity index 100% rename from android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Refrigerator.java rename to java/examples-android/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Refrigerator.java diff --git a/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Resource.java b/java/examples-android/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Resource.java similarity index 100% rename from android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Resource.java rename to java/examples-android/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Resource.java diff --git a/android/examples/fridgeserver/src/main/res/drawable-mdpi/iotivityicon.png b/java/examples-android/fridgeserver/src/main/res/drawable-hdpi/iotivityicon.png similarity index 100% rename from android/examples/fridgeserver/src/main/res/drawable-mdpi/iotivityicon.png rename to java/examples-android/fridgeserver/src/main/res/drawable-hdpi/iotivityicon.png diff --git a/android/examples/fridgegroupserver/src/main/res/drawable-hdpi/iotivitylogo.png b/java/examples-android/fridgeserver/src/main/res/drawable-hdpi/iotivitylogo.png similarity index 100% rename from android/examples/fridgegroupserver/src/main/res/drawable-hdpi/iotivitylogo.png rename to java/examples-android/fridgeserver/src/main/res/drawable-hdpi/iotivitylogo.png diff --git a/android/examples/fridgeserver/src/main/res/drawable-hdpi/iotivityicon.png b/java/examples-android/fridgeserver/src/main/res/drawable-mdpi/iotivityicon.png similarity index 100% rename from android/examples/fridgeserver/src/main/res/drawable-hdpi/iotivityicon.png rename to java/examples-android/fridgeserver/src/main/res/drawable-mdpi/iotivityicon.png diff --git a/android/examples/fridgegroupclient/src/main/res/drawable-xxhdpi/iotivitylogo.png b/java/examples-android/fridgeserver/src/main/res/drawable-mdpi/iotivitylogo.png similarity index 100% rename from android/examples/fridgegroupclient/src/main/res/drawable-xxhdpi/iotivitylogo.png rename to java/examples-android/fridgeserver/src/main/res/drawable-mdpi/iotivitylogo.png diff --git a/android/examples/fridgegroupserver/src/main/res/drawable-xxhdpi/iotivityicon.png b/java/examples-android/fridgeserver/src/main/res/drawable-xhdpi/iotivityicon.png similarity index 100% rename from android/examples/fridgegroupserver/src/main/res/drawable-xxhdpi/iotivityicon.png rename to java/examples-android/fridgeserver/src/main/res/drawable-xhdpi/iotivityicon.png diff --git a/android/examples/fridgegroupclient/src/main/res/drawable-xhdpi/iotivitylogo.png b/java/examples-android/fridgeserver/src/main/res/drawable-xhdpi/iotivitylogo.png similarity index 100% rename from android/examples/fridgegroupclient/src/main/res/drawable-xhdpi/iotivitylogo.png rename to java/examples-android/fridgeserver/src/main/res/drawable-xhdpi/iotivitylogo.png diff --git a/android/examples/fridgegroupserver/src/main/res/drawable-xhdpi/iotivityicon.png b/java/examples-android/fridgeserver/src/main/res/drawable-xxhdpi/iotivityicon.png similarity index 100% rename from android/examples/fridgegroupserver/src/main/res/drawable-xhdpi/iotivityicon.png rename to java/examples-android/fridgeserver/src/main/res/drawable-xxhdpi/iotivityicon.png diff --git a/android/examples/fridgegroupclient/src/main/res/drawable-mdpi/iotivitylogo.png b/java/examples-android/fridgeserver/src/main/res/drawable-xxhdpi/iotivitylogo.png similarity index 100% rename from android/examples/fridgegroupclient/src/main/res/drawable-mdpi/iotivitylogo.png rename to java/examples-android/fridgeserver/src/main/res/drawable-xxhdpi/iotivitylogo.png diff --git a/android/examples/fridgeserver/src/main/res/layout/activity_fridge_server.xml b/java/examples-android/fridgeserver/src/main/res/layout/activity_fridge_server.xml similarity index 100% rename from android/examples/fridgeserver/src/main/res/layout/activity_fridge_server.xml rename to java/examples-android/fridgeserver/src/main/res/layout/activity_fridge_server.xml diff --git a/android/examples/presenceclient/src/main/res/values-w820dp/dimens.xml b/java/examples-android/fridgeserver/src/main/res/values-w820dp/dimens.xml old mode 100644 new mode 100755 similarity index 100% rename from android/examples/presenceclient/src/main/res/values-w820dp/dimens.xml rename to java/examples-android/fridgeserver/src/main/res/values-w820dp/dimens.xml diff --git a/android/examples/groupserver/src/main/res/values/dimens.xml b/java/examples-android/fridgeserver/src/main/res/values/dimens.xml old mode 100644 new mode 100755 similarity index 100% rename from android/examples/groupserver/src/main/res/values/dimens.xml rename to java/examples-android/fridgeserver/src/main/res/values/dimens.xml diff --git a/android/examples/fridgeserver/src/main/res/values/strings.xml b/java/examples-android/fridgeserver/src/main/res/values/strings.xml similarity index 100% rename from android/examples/fridgeserver/src/main/res/values/strings.xml rename to java/examples-android/fridgeserver/src/main/res/values/strings.xml diff --git a/android/examples/presenceclient/src/main/res/values/styles.xml b/java/examples-android/fridgeserver/src/main/res/values/styles.xml old mode 100644 new mode 100755 similarity index 100% rename from android/examples/presenceclient/src/main/res/values/styles.xml rename to java/examples-android/fridgeserver/src/main/res/values/styles.xml diff --git a/android/examples/gradle.properties b/java/examples-android/gradle.properties similarity index 100% rename from android/examples/gradle.properties rename to java/examples-android/gradle.properties diff --git a/android/examples/gradle/wrapper/gradle-wrapper.jar b/java/examples-android/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from android/examples/gradle/wrapper/gradle-wrapper.jar rename to java/examples-android/gradle/wrapper/gradle-wrapper.jar diff --git a/android/examples/gradle/wrapper/gradle-wrapper.properties b/java/examples-android/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from android/examples/gradle/wrapper/gradle-wrapper.properties rename to java/examples-android/gradle/wrapper/gradle-wrapper.properties diff --git a/android/examples/gradlew b/java/examples-android/gradlew similarity index 100% rename from android/examples/gradlew rename to java/examples-android/gradlew diff --git a/android/examples/gradlew.bat b/java/examples-android/gradlew.bat similarity index 100% rename from android/examples/gradlew.bat rename to java/examples-android/gradlew.bat diff --git a/android/examples/groupserver/.gitignore b/java/examples-android/groupclient/.gitignore similarity index 100% rename from android/examples/groupserver/.gitignore rename to java/examples-android/groupclient/.gitignore diff --git a/java/examples-android/groupclient/build.gradle b/java/examples-android/groupclient/build.gradle new file mode 100644 index 0000000..ac9d344 --- /dev/null +++ b/java/examples-android/groupclient/build.gradle @@ -0,0 +1,37 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 21 + buildToolsVersion "20.0.0" + + defaultConfig { + applicationId "org.iotivity.base.examples.groupclient" + minSdkVersion 21 + targetSdkVersion 21 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + lintOptions { + abortOnError false + } +} +repositories { + flatDir { + dirs "../../iotivity-android/build/outputs/aar/" + } +} + +try { + dependencies { + compile ":iotivity-base-${TARGET_ARCH}-${RELEASE}@aar" + } +} catch (all) { + print "${ERROR_MSG}" + assert all +} diff --git a/android/examples/groupclient/groupclient.iml b/java/examples-android/groupclient/groupclient.iml similarity index 100% rename from android/examples/groupclient/groupclient.iml rename to java/examples-android/groupclient/groupclient.iml diff --git a/android/examples/groupserver/proguard-rules.pro b/java/examples-android/groupclient/proguard-rules.pro similarity index 100% rename from android/examples/groupserver/proguard-rules.pro rename to java/examples-android/groupclient/proguard-rules.pro diff --git a/android/examples/groupclient/src/main/AndroidManifest.xml b/java/examples-android/groupclient/src/main/AndroidManifest.xml similarity index 100% rename from android/examples/groupclient/src/main/AndroidManifest.xml rename to java/examples-android/groupclient/src/main/AndroidManifest.xml diff --git a/android/examples/groupclient/src/main/java/org/iotivity/base/examples/GroupClient.java b/java/examples-android/groupclient/src/main/java/org/iotivity/base/examples/GroupClient.java similarity index 100% rename from android/examples/groupclient/src/main/java/org/iotivity/base/examples/GroupClient.java rename to java/examples-android/groupclient/src/main/java/org/iotivity/base/examples/GroupClient.java diff --git a/android/examples/fridgegroupserver/src/main/res/drawable-mdpi/iotivityicon.png b/java/examples-android/groupclient/src/main/res/drawable/iotivityicon.png old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgegroupserver/src/main/res/drawable-mdpi/iotivityicon.png rename to java/examples-android/groupclient/src/main/res/drawable/iotivityicon.png diff --git a/android/examples/fridgegroupclient/src/main/res/drawable-hdpi/iotivitylogo.png b/java/examples-android/groupclient/src/main/res/drawable/iotivitylogo.png old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgegroupclient/src/main/res/drawable-hdpi/iotivitylogo.png rename to java/examples-android/groupclient/src/main/res/drawable/iotivitylogo.png diff --git a/android/examples/groupclient/src/main/res/layout/activity_group_client.xml b/java/examples-android/groupclient/src/main/res/layout/activity_group_client.xml similarity index 100% rename from android/examples/groupclient/src/main/res/layout/activity_group_client.xml rename to java/examples-android/groupclient/src/main/res/layout/activity_group_client.xml diff --git a/android/examples/fridgegroupserver/src/main/res/drawable-hdpi/iotivityicon.png b/java/examples-android/groupclient/src/main/res/mipmap-hdpi/iotivityicon.png old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgegroupserver/src/main/res/drawable-hdpi/iotivityicon.png rename to java/examples-android/groupclient/src/main/res/mipmap-hdpi/iotivityicon.png diff --git a/android/examples/simplebase/src/main/res/mipmap-mdpi/iotivityicon.png b/java/examples-android/groupclient/src/main/res/mipmap-mdpi/iotivityicon.png similarity index 100% rename from android/examples/simplebase/src/main/res/mipmap-mdpi/iotivityicon.png rename to java/examples-android/groupclient/src/main/res/mipmap-mdpi/iotivityicon.png diff --git a/android/examples/simplebase/src/main/res/mipmap-xhdpi/iotivityicon.png b/java/examples-android/groupclient/src/main/res/mipmap-xhdpi/iotivityicon.png similarity index 100% rename from android/examples/simplebase/src/main/res/mipmap-xhdpi/iotivityicon.png rename to java/examples-android/groupclient/src/main/res/mipmap-xhdpi/iotivityicon.png diff --git a/android/examples/simplebase/src/main/res/mipmap-xxhdpi/iotivityicon.png b/java/examples-android/groupclient/src/main/res/mipmap-xxhdpi/iotivityicon.png similarity index 100% rename from android/examples/simplebase/src/main/res/mipmap-xxhdpi/iotivityicon.png rename to java/examples-android/groupclient/src/main/res/mipmap-xxhdpi/iotivityicon.png diff --git a/android/examples/simplebase/src/main/res/values-v21/styles.xml b/java/examples-android/groupclient/src/main/res/values-v21/styles.xml similarity index 100% rename from android/examples/simplebase/src/main/res/values-v21/styles.xml rename to java/examples-android/groupclient/src/main/res/values-v21/styles.xml diff --git a/android/examples/guiclient/src/main/res/values-w820dp/dimens.xml b/java/examples-android/groupclient/src/main/res/values-w820dp/dimens.xml similarity index 100% rename from android/examples/guiclient/src/main/res/values-w820dp/dimens.xml rename to java/examples-android/groupclient/src/main/res/values-w820dp/dimens.xml diff --git a/android/examples/groupclient/src/main/res/values/dimens.xml b/java/examples-android/groupclient/src/main/res/values/dimens.xml similarity index 100% rename from android/examples/groupclient/src/main/res/values/dimens.xml rename to java/examples-android/groupclient/src/main/res/values/dimens.xml diff --git a/android/examples/groupclient/src/main/res/values/strings.xml b/java/examples-android/groupclient/src/main/res/values/strings.xml similarity index 100% rename from android/examples/groupclient/src/main/res/values/strings.xml rename to java/examples-android/groupclient/src/main/res/values/strings.xml diff --git a/android/examples/groupserver/src/main/res/values/styles.xml b/java/examples-android/groupclient/src/main/res/values/styles.xml similarity index 100% rename from android/examples/groupserver/src/main/res/values/styles.xml rename to java/examples-android/groupclient/src/main/res/values/styles.xml diff --git a/android/examples/groupclient/.gitignore b/java/examples-android/groupserver/.gitignore similarity index 100% rename from android/examples/groupclient/.gitignore rename to java/examples-android/groupserver/.gitignore diff --git a/java/examples-android/groupserver/build.gradle b/java/examples-android/groupserver/build.gradle new file mode 100644 index 0000000..d21c713 --- /dev/null +++ b/java/examples-android/groupserver/build.gradle @@ -0,0 +1,37 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 21 + buildToolsVersion "20.0.0" + + defaultConfig { + applicationId "org.iotivity.base.examples.groupserver" + minSdkVersion 21 + targetSdkVersion 21 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + lintOptions { + abortOnError false + } +} +repositories { + flatDir { + dirs "../../iotivity-android/build/outputs/aar/" + } +} + +try { + dependencies { + compile ":iotivity-base-${TARGET_ARCH}-${RELEASE}@aar" + } +} catch (all) { + print "${ERROR_MSG}" + assert all +} diff --git a/android/examples/groupserver/groupserver.iml b/java/examples-android/groupserver/groupserver.iml similarity index 100% rename from android/examples/groupserver/groupserver.iml rename to java/examples-android/groupserver/groupserver.iml diff --git a/android/examples/groupclient/proguard-rules.pro b/java/examples-android/groupserver/proguard-rules.pro similarity index 100% rename from android/examples/groupclient/proguard-rules.pro rename to java/examples-android/groupserver/proguard-rules.pro diff --git a/android/examples/groupserver/src/main/AndroidManifest.xml b/java/examples-android/groupserver/src/main/AndroidManifest.xml similarity index 100% rename from android/examples/groupserver/src/main/AndroidManifest.xml rename to java/examples-android/groupserver/src/main/AndroidManifest.xml diff --git a/android/examples/groupserver/src/main/java/org/iotivity/base/examples/GroupServer.java b/java/examples-android/groupserver/src/main/java/org/iotivity/base/examples/GroupServer.java similarity index 100% rename from android/examples/groupserver/src/main/java/org/iotivity/base/examples/GroupServer.java rename to java/examples-android/groupserver/src/main/java/org/iotivity/base/examples/GroupServer.java diff --git a/android/examples/fridgegroupclient/src/main/res/drawable-xxhdpi/iotivityicon.png b/java/examples-android/groupserver/src/main/res/drawable/iotivityicon.png old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgegroupclient/src/main/res/drawable-xxhdpi/iotivityicon.png rename to java/examples-android/groupserver/src/main/res/drawable/iotivityicon.png diff --git a/android/examples/fridgeclient/src/main/res/drawable-xxhdpi/iotivitylogo.png b/java/examples-android/groupserver/src/main/res/drawable/iotivitylogo.png old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgeclient/src/main/res/drawable-xxhdpi/iotivitylogo.png rename to java/examples-android/groupserver/src/main/res/drawable/iotivitylogo.png diff --git a/android/examples/groupserver/src/main/res/layout/activity_group_server.xml b/java/examples-android/groupserver/src/main/res/layout/activity_group_server.xml similarity index 100% rename from android/examples/groupserver/src/main/res/layout/activity_group_server.xml rename to java/examples-android/groupserver/src/main/res/layout/activity_group_server.xml diff --git a/android/examples/fridgegroupclient/src/main/res/drawable-xhdpi/iotivityicon.png b/java/examples-android/groupserver/src/main/res/mipmap-hdpi/iotivityicon.png old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgegroupclient/src/main/res/drawable-xhdpi/iotivityicon.png rename to java/examples-android/groupserver/src/main/res/mipmap-hdpi/iotivityicon.png diff --git a/android/examples/presenceserver/src/main/res/mipmap-mdpi/iotivityicon.png b/java/examples-android/groupserver/src/main/res/mipmap-mdpi/iotivityicon.png similarity index 100% rename from android/examples/presenceserver/src/main/res/mipmap-mdpi/iotivityicon.png rename to java/examples-android/groupserver/src/main/res/mipmap-mdpi/iotivityicon.png diff --git a/android/examples/presenceserver/src/main/res/mipmap-xhdpi/iotivityicon.png b/java/examples-android/groupserver/src/main/res/mipmap-xhdpi/iotivityicon.png similarity index 100% rename from android/examples/presenceserver/src/main/res/mipmap-xhdpi/iotivityicon.png rename to java/examples-android/groupserver/src/main/res/mipmap-xhdpi/iotivityicon.png diff --git a/android/examples/presenceserver/src/main/res/mipmap-xxhdpi/iotivityicon.png b/java/examples-android/groupserver/src/main/res/mipmap-xxhdpi/iotivityicon.png similarity index 100% rename from android/examples/presenceserver/src/main/res/mipmap-xxhdpi/iotivityicon.png rename to java/examples-android/groupserver/src/main/res/mipmap-xxhdpi/iotivityicon.png diff --git a/android/examples/provisioningclient/src/main/res/values-v21/styles.xml b/java/examples-android/groupserver/src/main/res/values-v21/styles.xml similarity index 100% rename from android/examples/provisioningclient/src/main/res/values-v21/styles.xml rename to java/examples-android/groupserver/src/main/res/values-v21/styles.xml diff --git a/android/examples/groupserver/src/main/res/values-w820dp/dimens.xml b/java/examples-android/groupserver/src/main/res/values-w820dp/dimens.xml similarity index 100% rename from android/examples/groupserver/src/main/res/values-w820dp/dimens.xml rename to java/examples-android/groupserver/src/main/res/values-w820dp/dimens.xml diff --git a/android/examples/fridgeserver/src/main/res/values/dimens.xml b/java/examples-android/groupserver/src/main/res/values/dimens.xml old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgeserver/src/main/res/values/dimens.xml rename to java/examples-android/groupserver/src/main/res/values/dimens.xml diff --git a/android/examples/groupserver/src/main/res/values/strings.xml b/java/examples-android/groupserver/src/main/res/values/strings.xml similarity index 100% rename from android/examples/groupserver/src/main/res/values/strings.xml rename to java/examples-android/groupserver/src/main/res/values/strings.xml diff --git a/android/examples/groupclient/src/main/res/values/styles.xml b/java/examples-android/groupserver/src/main/res/values/styles.xml similarity index 100% rename from android/examples/groupclient/src/main/res/values/styles.xml rename to java/examples-android/groupserver/src/main/res/values/styles.xml diff --git a/android/examples/guiclient/.gitignore b/java/examples-android/guiclient/.gitignore similarity index 100% rename from android/examples/guiclient/.gitignore rename to java/examples-android/guiclient/.gitignore diff --git a/android/examples/guiclient/build.gradle b/java/examples-android/guiclient/build.gradle similarity index 100% rename from android/examples/guiclient/build.gradle rename to java/examples-android/guiclient/build.gradle diff --git a/android/examples/guiclient/guiclient.iml b/java/examples-android/guiclient/guiclient.iml similarity index 100% rename from android/examples/guiclient/guiclient.iml rename to java/examples-android/guiclient/guiclient.iml diff --git a/android/examples/guiclient/proguard-rules.pro b/java/examples-android/guiclient/proguard-rules.pro similarity index 100% rename from android/examples/guiclient/proguard-rules.pro rename to java/examples-android/guiclient/proguard-rules.pro diff --git a/android/examples/guiclient/src/main/AndroidManifest.xml b/java/examples-android/guiclient/src/main/AndroidManifest.xml similarity index 100% rename from android/examples/guiclient/src/main/AndroidManifest.xml rename to java/examples-android/guiclient/src/main/AndroidManifest.xml diff --git a/android/examples/guiclient/src/main/java/org/iotivity/guiclient/ExpandableResourceListAdapter.java b/java/examples-android/guiclient/src/main/java/org/iotivity/guiclient/ExpandableResourceListAdapter.java similarity index 100% rename from android/examples/guiclient/src/main/java/org/iotivity/guiclient/ExpandableResourceListAdapter.java rename to java/examples-android/guiclient/src/main/java/org/iotivity/guiclient/ExpandableResourceListAdapter.java diff --git a/android/examples/guiclient/src/main/java/org/iotivity/guiclient/MainActivity.java b/java/examples-android/guiclient/src/main/java/org/iotivity/guiclient/MainActivity.java similarity index 100% rename from android/examples/guiclient/src/main/java/org/iotivity/guiclient/MainActivity.java rename to java/examples-android/guiclient/src/main/java/org/iotivity/guiclient/MainActivity.java diff --git a/android/examples/guiclient/src/main/java/org/iotivity/guiclient/OcAttributeInfo.java b/java/examples-android/guiclient/src/main/java/org/iotivity/guiclient/OcAttributeInfo.java similarity index 100% rename from android/examples/guiclient/src/main/java/org/iotivity/guiclient/OcAttributeInfo.java rename to java/examples-android/guiclient/src/main/java/org/iotivity/guiclient/OcAttributeInfo.java diff --git a/android/examples/guiclient/src/main/java/org/iotivity/guiclient/OcProtocolStrings.java b/java/examples-android/guiclient/src/main/java/org/iotivity/guiclient/OcProtocolStrings.java similarity index 100% rename from android/examples/guiclient/src/main/java/org/iotivity/guiclient/OcProtocolStrings.java rename to java/examples-android/guiclient/src/main/java/org/iotivity/guiclient/OcProtocolStrings.java diff --git a/android/examples/guiclient/src/main/java/org/iotivity/guiclient/OcResourceInfo.java b/java/examples-android/guiclient/src/main/java/org/iotivity/guiclient/OcResourceInfo.java similarity index 100% rename from android/examples/guiclient/src/main/java/org/iotivity/guiclient/OcResourceInfo.java rename to java/examples-android/guiclient/src/main/java/org/iotivity/guiclient/OcResourceInfo.java diff --git a/android/examples/guiclient/src/main/java/org/iotivity/guiclient/OcWorker.java b/java/examples-android/guiclient/src/main/java/org/iotivity/guiclient/OcWorker.java similarity index 100% rename from android/examples/guiclient/src/main/java/org/iotivity/guiclient/OcWorker.java rename to java/examples-android/guiclient/src/main/java/org/iotivity/guiclient/OcWorker.java diff --git a/android/examples/guiclient/src/main/java/org/iotivity/guiclient/OcWorkerListener.java b/java/examples-android/guiclient/src/main/java/org/iotivity/guiclient/OcWorkerListener.java similarity index 100% rename from android/examples/guiclient/src/main/java/org/iotivity/guiclient/OcWorkerListener.java rename to java/examples-android/guiclient/src/main/java/org/iotivity/guiclient/OcWorkerListener.java diff --git a/android/examples/fridgegroupserver/src/main/res/drawable-hdpi/ic_launcher.png b/java/examples-android/guiclient/src/main/res/drawable-hdpi/ic_launcher.png old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgegroupserver/src/main/res/drawable-hdpi/ic_launcher.png rename to java/examples-android/guiclient/src/main/res/drawable-hdpi/ic_launcher.png diff --git a/android/examples/fridgegroupserver/src/main/res/drawable-mdpi/ic_launcher.png b/java/examples-android/guiclient/src/main/res/drawable-mdpi/ic_launcher.png old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgegroupserver/src/main/res/drawable-mdpi/ic_launcher.png rename to java/examples-android/guiclient/src/main/res/drawable-mdpi/ic_launcher.png diff --git a/android/examples/fridgegroupserver/src/main/res/drawable-xhdpi/ic_launcher.png b/java/examples-android/guiclient/src/main/res/drawable-xhdpi/ic_launcher.png old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgegroupserver/src/main/res/drawable-xhdpi/ic_launcher.png rename to java/examples-android/guiclient/src/main/res/drawable-xhdpi/ic_launcher.png diff --git a/android/examples/fridgegroupserver/src/main/res/drawable-xxhdpi/ic_launcher.png b/java/examples-android/guiclient/src/main/res/drawable-xxhdpi/ic_launcher.png old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgegroupserver/src/main/res/drawable-xxhdpi/ic_launcher.png rename to java/examples-android/guiclient/src/main/res/drawable-xxhdpi/ic_launcher.png diff --git a/android/examples/guiclient/src/main/res/drawable/android_resource_icon.png b/java/examples-android/guiclient/src/main/res/drawable/android_resource_icon.png similarity index 100% rename from android/examples/guiclient/src/main/res/drawable/android_resource_icon.png rename to java/examples-android/guiclient/src/main/res/drawable/android_resource_icon.png diff --git a/android/examples/guiclient/src/main/res/drawable/attribute_icon.png b/java/examples-android/guiclient/src/main/res/drawable/attribute_icon.png similarity index 100% rename from android/examples/guiclient/src/main/res/drawable/attribute_icon.png rename to java/examples-android/guiclient/src/main/res/drawable/attribute_icon.png diff --git a/android/examples/guiclient/src/main/res/drawable/ic_action_discard.png b/java/examples-android/guiclient/src/main/res/drawable/ic_action_discard.png similarity index 100% rename from android/examples/guiclient/src/main/res/drawable/ic_action_discard.png rename to java/examples-android/guiclient/src/main/res/drawable/ic_action_discard.png diff --git a/android/examples/guiclient/src/main/res/drawable/ic_action_discard_dark.png b/java/examples-android/guiclient/src/main/res/drawable/ic_action_discard_dark.png similarity index 100% rename from android/examples/guiclient/src/main/res/drawable/ic_action_discard_dark.png rename to java/examples-android/guiclient/src/main/res/drawable/ic_action_discard_dark.png diff --git a/android/examples/guiclient/src/main/res/drawable/ic_action_refresh.png b/java/examples-android/guiclient/src/main/res/drawable/ic_action_refresh.png similarity index 100% rename from android/examples/guiclient/src/main/res/drawable/ic_action_refresh.png rename to java/examples-android/guiclient/src/main/res/drawable/ic_action_refresh.png diff --git a/android/examples/guiclient/src/main/res/drawable/iotivity_hex_icon.png b/java/examples-android/guiclient/src/main/res/drawable/iotivity_hex_icon.png similarity index 100% rename from android/examples/guiclient/src/main/res/drawable/iotivity_hex_icon.png rename to java/examples-android/guiclient/src/main/res/drawable/iotivity_hex_icon.png diff --git a/android/examples/guiclient/src/main/res/drawable/led_icon.png b/java/examples-android/guiclient/src/main/res/drawable/led_icon.png similarity index 100% rename from android/examples/guiclient/src/main/res/drawable/led_icon.png rename to java/examples-android/guiclient/src/main/res/drawable/led_icon.png diff --git a/android/examples/guiclient/src/main/res/drawable/light_icon.png b/java/examples-android/guiclient/src/main/res/drawable/light_icon.png similarity index 100% rename from android/examples/guiclient/src/main/res/drawable/light_icon.png rename to java/examples-android/guiclient/src/main/res/drawable/light_icon.png diff --git a/android/examples/guiclient/src/main/res/drawable/thermometer_icon.png b/java/examples-android/guiclient/src/main/res/drawable/thermometer_icon.png similarity index 100% rename from android/examples/guiclient/src/main/res/drawable/thermometer_icon.png rename to java/examples-android/guiclient/src/main/res/drawable/thermometer_icon.png diff --git a/android/examples/guiclient/src/main/res/layout/actionbar_indeterminate_progress.xml b/java/examples-android/guiclient/src/main/res/layout/actionbar_indeterminate_progress.xml similarity index 100% rename from android/examples/guiclient/src/main/res/layout/actionbar_indeterminate_progress.xml rename to java/examples-android/guiclient/src/main/res/layout/actionbar_indeterminate_progress.xml diff --git a/android/examples/guiclient/src/main/res/layout/activity_main.xml b/java/examples-android/guiclient/src/main/res/layout/activity_main.xml similarity index 100% rename from android/examples/guiclient/src/main/res/layout/activity_main.xml rename to java/examples-android/guiclient/src/main/res/layout/activity_main.xml diff --git a/android/examples/guiclient/src/main/res/layout/attribute_layout_on_off_switch.xml b/java/examples-android/guiclient/src/main/res/layout/attribute_layout_on_off_switch.xml similarity index 100% rename from android/examples/guiclient/src/main/res/layout/attribute_layout_on_off_switch.xml rename to java/examples-android/guiclient/src/main/res/layout/attribute_layout_on_off_switch.xml diff --git a/android/examples/guiclient/src/main/res/layout/attribute_layout_progress_bar.xml b/java/examples-android/guiclient/src/main/res/layout/attribute_layout_progress_bar.xml similarity index 100% rename from android/examples/guiclient/src/main/res/layout/attribute_layout_progress_bar.xml rename to java/examples-android/guiclient/src/main/res/layout/attribute_layout_progress_bar.xml diff --git a/android/examples/guiclient/src/main/res/layout/attribute_layout_slider.xml b/java/examples-android/guiclient/src/main/res/layout/attribute_layout_slider.xml similarity index 100% rename from android/examples/guiclient/src/main/res/layout/attribute_layout_slider.xml rename to java/examples-android/guiclient/src/main/res/layout/attribute_layout_slider.xml diff --git a/android/examples/guiclient/src/main/res/layout/resource_list_item_layout.xml b/java/examples-android/guiclient/src/main/res/layout/resource_list_item_layout.xml similarity index 100% rename from android/examples/guiclient/src/main/res/layout/resource_list_item_layout.xml rename to java/examples-android/guiclient/src/main/res/layout/resource_list_item_layout.xml diff --git a/android/examples/guiclient/src/main/res/menu/menu_main.xml b/java/examples-android/guiclient/src/main/res/menu/menu_main.xml similarity index 100% rename from android/examples/guiclient/src/main/res/menu/menu_main.xml rename to java/examples-android/guiclient/src/main/res/menu/menu_main.xml diff --git a/android/examples/guiclient/src/main/res/values/refs.xml b/java/examples-android/guiclient/src/main/res/values-large/refs.xml similarity index 100% rename from android/examples/guiclient/src/main/res/values/refs.xml rename to java/examples-android/guiclient/src/main/res/values-large/refs.xml diff --git a/android/examples/guiclient/src/main/res/values-sw600dp/refs.xml b/java/examples-android/guiclient/src/main/res/values-sw600dp/refs.xml similarity index 100% rename from android/examples/guiclient/src/main/res/values-sw600dp/refs.xml rename to java/examples-android/guiclient/src/main/res/values-sw600dp/refs.xml diff --git a/android/examples/groupclient/src/main/res/values-w820dp/dimens.xml b/java/examples-android/guiclient/src/main/res/values-w820dp/dimens.xml similarity index 100% rename from android/examples/groupclient/src/main/res/values-w820dp/dimens.xml rename to java/examples-android/guiclient/src/main/res/values-w820dp/dimens.xml diff --git a/android/examples/guiclient/src/main/res/values/dimens.xml b/java/examples-android/guiclient/src/main/res/values/dimens.xml similarity index 100% rename from android/examples/guiclient/src/main/res/values/dimens.xml rename to java/examples-android/guiclient/src/main/res/values/dimens.xml diff --git a/android/examples/guiclient/src/main/res/values-large/refs.xml b/java/examples-android/guiclient/src/main/res/values/refs.xml similarity index 100% rename from android/examples/guiclient/src/main/res/values-large/refs.xml rename to java/examples-android/guiclient/src/main/res/values/refs.xml diff --git a/android/examples/guiclient/src/main/res/values/strings.xml b/java/examples-android/guiclient/src/main/res/values/strings.xml similarity index 100% rename from android/examples/guiclient/src/main/res/values/strings.xml rename to java/examples-android/guiclient/src/main/res/values/strings.xml diff --git a/android/examples/guiclient/src/main/res/values/styles.xml b/java/examples-android/guiclient/src/main/res/values/styles.xml similarity index 100% rename from android/examples/guiclient/src/main/res/values/styles.xml rename to java/examples-android/guiclient/src/main/res/values/styles.xml diff --git a/android/examples/devicediscoveryserver/.gitignore b/java/examples-android/presenceclient/.gitignore similarity index 100% rename from android/examples/devicediscoveryserver/.gitignore rename to java/examples-android/presenceclient/.gitignore diff --git a/java/examples-android/presenceclient/build.gradle b/java/examples-android/presenceclient/build.gradle new file mode 100644 index 0000000..7169b9b --- /dev/null +++ b/java/examples-android/presenceclient/build.gradle @@ -0,0 +1,37 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 21 + buildToolsVersion "20.0.0" + + defaultConfig { + applicationId "org.iotivity.base.examples.presenceclient" + minSdkVersion 21 + targetSdkVersion 21 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + lintOptions { + abortOnError false + } +} +repositories { + flatDir { + dirs "../../iotivity-android/build/outputs/aar/" + } +} + +try { + dependencies { + compile ":iotivity-base-${TARGET_ARCH}-${RELEASE}@aar" + } +} catch (all) { + print "${ERROR_MSG}" + assert all +} diff --git a/android/examples/presenceclient/presenceclient.iml b/java/examples-android/presenceclient/presenceclient.iml similarity index 100% rename from android/examples/presenceclient/presenceclient.iml rename to java/examples-android/presenceclient/presenceclient.iml diff --git a/android/examples/presenceclient/src/main/AndroidManifest.xml b/java/examples-android/presenceclient/src/main/AndroidManifest.xml similarity index 100% rename from android/examples/presenceclient/src/main/AndroidManifest.xml rename to java/examples-android/presenceclient/src/main/AndroidManifest.xml diff --git a/android/examples/presenceclient/src/main/java/org/iotivity/base/examples/PresenceClient.java b/java/examples-android/presenceclient/src/main/java/org/iotivity/base/examples/PresenceClient.java similarity index 100% rename from android/examples/presenceclient/src/main/java/org/iotivity/base/examples/PresenceClient.java rename to java/examples-android/presenceclient/src/main/java/org/iotivity/base/examples/PresenceClient.java diff --git a/android/examples/fridgegroupclient/src/main/res/drawable-mdpi/iotivityicon.png b/java/examples-android/presenceclient/src/main/res/drawable/iotivityicon.png old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgegroupclient/src/main/res/drawable-mdpi/iotivityicon.png rename to java/examples-android/presenceclient/src/main/res/drawable/iotivityicon.png diff --git a/android/examples/fridgeclient/src/main/res/drawable-xhdpi/iotivitylogo.png b/java/examples-android/presenceclient/src/main/res/drawable/iotivitylogo.png old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgeclient/src/main/res/drawable-xhdpi/iotivitylogo.png rename to java/examples-android/presenceclient/src/main/res/drawable/iotivitylogo.png diff --git a/android/examples/presenceclient/src/main/res/layout/activity_presence_client.xml b/java/examples-android/presenceclient/src/main/res/layout/activity_presence_client.xml similarity index 100% rename from android/examples/presenceclient/src/main/res/layout/activity_presence_client.xml rename to java/examples-android/presenceclient/src/main/res/layout/activity_presence_client.xml diff --git a/android/examples/fridgegroupclient/src/main/res/drawable-hdpi/iotivityicon.png b/java/examples-android/presenceclient/src/main/res/mipmap-hdpi/iotivityicon.png old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgegroupclient/src/main/res/drawable-hdpi/iotivityicon.png rename to java/examples-android/presenceclient/src/main/res/mipmap-hdpi/iotivityicon.png diff --git a/android/examples/presenceclient/src/main/res/mipmap-mdpi/iotivityicon.png b/java/examples-android/presenceclient/src/main/res/mipmap-mdpi/iotivityicon.png similarity index 100% rename from android/examples/presenceclient/src/main/res/mipmap-mdpi/iotivityicon.png rename to java/examples-android/presenceclient/src/main/res/mipmap-mdpi/iotivityicon.png diff --git a/android/examples/presenceclient/src/main/res/mipmap-xhdpi/iotivityicon.png b/java/examples-android/presenceclient/src/main/res/mipmap-xhdpi/iotivityicon.png similarity index 100% rename from android/examples/presenceclient/src/main/res/mipmap-xhdpi/iotivityicon.png rename to java/examples-android/presenceclient/src/main/res/mipmap-xhdpi/iotivityicon.png diff --git a/android/examples/presenceclient/src/main/res/mipmap-xxhdpi/iotivityicon.png b/java/examples-android/presenceclient/src/main/res/mipmap-xxhdpi/iotivityicon.png similarity index 100% rename from android/examples/presenceclient/src/main/res/mipmap-xxhdpi/iotivityicon.png rename to java/examples-android/presenceclient/src/main/res/mipmap-xxhdpi/iotivityicon.png diff --git a/android/examples/presenceclient/src/main/res/values-v21/styles.xml b/java/examples-android/presenceclient/src/main/res/values-v21/styles.xml similarity index 100% rename from android/examples/presenceclient/src/main/res/values-v21/styles.xml rename to java/examples-android/presenceclient/src/main/res/values-v21/styles.xml diff --git a/android/examples/fridgeserver/src/main/res/values-w820dp/dimens.xml b/java/examples-android/presenceclient/src/main/res/values-w820dp/dimens.xml old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgeserver/src/main/res/values-w820dp/dimens.xml rename to java/examples-android/presenceclient/src/main/res/values-w820dp/dimens.xml diff --git a/android/examples/fridgegroupserver/src/main/res/values/dimens.xml b/java/examples-android/presenceclient/src/main/res/values/dimens.xml old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgegroupserver/src/main/res/values/dimens.xml rename to java/examples-android/presenceclient/src/main/res/values/dimens.xml diff --git a/android/examples/presenceclient/src/main/res/values/strings.xml b/java/examples-android/presenceclient/src/main/res/values/strings.xml similarity index 100% rename from android/examples/presenceclient/src/main/res/values/strings.xml rename to java/examples-android/presenceclient/src/main/res/values/strings.xml diff --git a/android/examples/fridgeserver/src/main/res/values/styles.xml b/java/examples-android/presenceclient/src/main/res/values/styles.xml old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgeserver/src/main/res/values/styles.xml rename to java/examples-android/presenceclient/src/main/res/values/styles.xml diff --git a/android/examples/devicediscoveryclient/.gitignore b/java/examples-android/presenceserver/.gitignore similarity index 100% rename from android/examples/devicediscoveryclient/.gitignore rename to java/examples-android/presenceserver/.gitignore diff --git a/java/examples-android/presenceserver/build.gradle b/java/examples-android/presenceserver/build.gradle new file mode 100644 index 0000000..18e8668 --- /dev/null +++ b/java/examples-android/presenceserver/build.gradle @@ -0,0 +1,37 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 21 + buildToolsVersion "20.0.0" + + defaultConfig { + applicationId "org.iotivity.base.examples.presenceserver" + minSdkVersion 21 + targetSdkVersion 21 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + lintOptions { + abortOnError false + } +} +repositories { + flatDir { + dirs "../../iotivity-android/build/outputs/aar/" + } +} + +try { + dependencies { + compile ":iotivity-base-${TARGET_ARCH}-${RELEASE}@aar" + } +} catch (all) { + print "${ERROR_MSG}" + assert all +} diff --git a/android/examples/presenceserver/presenceserver.iml b/java/examples-android/presenceserver/presenceserver.iml similarity index 100% rename from android/examples/presenceserver/presenceserver.iml rename to java/examples-android/presenceserver/presenceserver.iml diff --git a/android/examples/presenceserver/src/main/AndroidManifest.xml b/java/examples-android/presenceserver/src/main/AndroidManifest.xml similarity index 100% rename from android/examples/presenceserver/src/main/AndroidManifest.xml rename to java/examples-android/presenceserver/src/main/AndroidManifest.xml diff --git a/android/examples/presenceserver/src/main/java/org/iotivity/base/examples/PresenceServer.java b/java/examples-android/presenceserver/src/main/java/org/iotivity/base/examples/PresenceServer.java similarity index 100% rename from android/examples/presenceserver/src/main/java/org/iotivity/base/examples/PresenceServer.java rename to java/examples-android/presenceserver/src/main/java/org/iotivity/base/examples/PresenceServer.java diff --git a/android/examples/fridgeclient/src/main/res/drawable-xxhdpi/iotivityicon.png b/java/examples-android/presenceserver/src/main/res/drawable/iotivityicon.png old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgeclient/src/main/res/drawable-xxhdpi/iotivityicon.png rename to java/examples-android/presenceserver/src/main/res/drawable/iotivityicon.png diff --git a/android/examples/fridgeclient/src/main/res/drawable-mdpi/iotivitylogo.png b/java/examples-android/presenceserver/src/main/res/drawable/iotivitylogo.png old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgeclient/src/main/res/drawable-mdpi/iotivitylogo.png rename to java/examples-android/presenceserver/src/main/res/drawable/iotivitylogo.png diff --git a/android/examples/presenceserver/src/main/res/layout/activity_presence_server.xml b/java/examples-android/presenceserver/src/main/res/layout/activity_presence_server.xml similarity index 100% rename from android/examples/presenceserver/src/main/res/layout/activity_presence_server.xml rename to java/examples-android/presenceserver/src/main/res/layout/activity_presence_server.xml diff --git a/android/examples/fridgeclient/src/main/res/drawable-xhdpi/iotivityicon.png b/java/examples-android/presenceserver/src/main/res/mipmap-hdpi/iotivityicon.png old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgeclient/src/main/res/drawable-xhdpi/iotivityicon.png rename to java/examples-android/presenceserver/src/main/res/mipmap-hdpi/iotivityicon.png diff --git a/android/examples/groupserver/src/main/res/mipmap-mdpi/iotivityicon.png b/java/examples-android/presenceserver/src/main/res/mipmap-mdpi/iotivityicon.png similarity index 100% rename from android/examples/groupserver/src/main/res/mipmap-mdpi/iotivityicon.png rename to java/examples-android/presenceserver/src/main/res/mipmap-mdpi/iotivityicon.png diff --git a/android/examples/groupserver/src/main/res/mipmap-xhdpi/iotivityicon.png b/java/examples-android/presenceserver/src/main/res/mipmap-xhdpi/iotivityicon.png similarity index 100% rename from android/examples/groupserver/src/main/res/mipmap-xhdpi/iotivityicon.png rename to java/examples-android/presenceserver/src/main/res/mipmap-xhdpi/iotivityicon.png diff --git a/android/examples/groupserver/src/main/res/mipmap-xxhdpi/iotivityicon.png b/java/examples-android/presenceserver/src/main/res/mipmap-xxhdpi/iotivityicon.png similarity index 100% rename from android/examples/groupserver/src/main/res/mipmap-xxhdpi/iotivityicon.png rename to java/examples-android/presenceserver/src/main/res/mipmap-xxhdpi/iotivityicon.png diff --git a/android/examples/presenceserver/src/main/res/values-v21/styles.xml b/java/examples-android/presenceserver/src/main/res/values-v21/styles.xml similarity index 100% rename from android/examples/presenceserver/src/main/res/values-v21/styles.xml rename to java/examples-android/presenceserver/src/main/res/values-v21/styles.xml diff --git a/android/examples/fridgegroupserver/src/main/res/values-w820dp/dimens.xml b/java/examples-android/presenceserver/src/main/res/values-w820dp/dimens.xml old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgegroupserver/src/main/res/values-w820dp/dimens.xml rename to java/examples-android/presenceserver/src/main/res/values-w820dp/dimens.xml diff --git a/android/examples/fridgegroupclient/src/main/res/values/dimens.xml b/java/examples-android/presenceserver/src/main/res/values/dimens.xml old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgegroupclient/src/main/res/values/dimens.xml rename to java/examples-android/presenceserver/src/main/res/values/dimens.xml diff --git a/android/examples/presenceserver/src/main/res/values/strings.xml b/java/examples-android/presenceserver/src/main/res/values/strings.xml similarity index 100% rename from android/examples/presenceserver/src/main/res/values/strings.xml rename to java/examples-android/presenceserver/src/main/res/values/strings.xml diff --git a/android/examples/fridgegroupserver/src/main/res/values/styles.xml b/java/examples-android/presenceserver/src/main/res/values/styles.xml old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgegroupserver/src/main/res/values/styles.xml rename to java/examples-android/presenceserver/src/main/res/values/styles.xml diff --git a/java/examples-android/provisioningclient/build.gradle b/java/examples-android/provisioningclient/build.gradle new file mode 100644 index 0000000..ca87673 --- /dev/null +++ b/java/examples-android/provisioningclient/build.gradle @@ -0,0 +1,38 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 21 + buildToolsVersion "20.0.0" + + defaultConfig { + applicationId "org.iotivity.base.examples.provisioningclient" + minSdkVersion 21 + targetSdkVersion 21 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + lintOptions { + abortOnError false + } +} +repositories { + flatDir { + dirs "../../iotivity-android/build/outputs/aar/" + } +} + +try { + dependencies { + compile ":iotivity-base-${TARGET_ARCH}-${RELEASE}@aar" + } +} catch (all) { + print "${ERROR_MSG}" + assert all +} + diff --git a/android/examples/provisioningclient/proguard-rules.pro b/java/examples-android/provisioningclient/proguard-rules.pro similarity index 100% rename from android/examples/provisioningclient/proguard-rules.pro rename to java/examples-android/provisioningclient/proguard-rules.pro diff --git a/android/examples/provisioningclient/provisioningclient.iml b/java/examples-android/provisioningclient/provisioningclient.iml similarity index 100% rename from android/examples/provisioningclient/provisioningclient.iml rename to java/examples-android/provisioningclient/provisioningclient.iml diff --git a/android/examples/provisioningclient/src/main/AndroidManifest.xml b/java/examples-android/provisioningclient/src/main/AndroidManifest.xml similarity index 100% rename from android/examples/provisioningclient/src/main/AndroidManifest.xml rename to java/examples-android/provisioningclient/src/main/AndroidManifest.xml diff --git a/android/examples/provisioningclient/src/main/assets/oic_svr_db_client.json b/java/examples-android/provisioningclient/src/main/assets/oic_svr_db_client.json similarity index 100% rename from android/examples/provisioningclient/src/main/assets/oic_svr_db_client.json rename to java/examples-android/provisioningclient/src/main/assets/oic_svr_db_client.json diff --git a/android/examples/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/ProvisioningClient.java b/java/examples-android/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/ProvisioningClient.java similarity index 100% rename from android/examples/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/ProvisioningClient.java rename to java/examples-android/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/ProvisioningClient.java diff --git a/android/examples/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/StringConstants.java b/java/examples-android/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/StringConstants.java similarity index 100% rename from android/examples/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/StringConstants.java rename to java/examples-android/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/StringConstants.java diff --git a/android/examples/provisioningclient/src/main/res/layout/activity_secure_provision_client.xml b/java/examples-android/provisioningclient/src/main/res/layout/activity_secure_provision_client.xml similarity index 100% rename from android/examples/provisioningclient/src/main/res/layout/activity_secure_provision_client.xml rename to java/examples-android/provisioningclient/src/main/res/layout/activity_secure_provision_client.xml diff --git a/android/examples/provisioningclient/src/main/res/menu/menu_secure_provision_client.xml b/java/examples-android/provisioningclient/src/main/res/menu/menu_secure_provision_client.xml similarity index 100% rename from android/examples/provisioningclient/src/main/res/menu/menu_secure_provision_client.xml rename to java/examples-android/provisioningclient/src/main/res/menu/menu_secure_provision_client.xml diff --git a/android/examples/provisioningclient/src/main/res/mipmap-hdpi/ic_launcher.png b/java/examples-android/provisioningclient/src/main/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from android/examples/provisioningclient/src/main/res/mipmap-hdpi/ic_launcher.png rename to java/examples-android/provisioningclient/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/android/examples/provisioningclient/src/main/res/mipmap-mdpi/ic_launcher.png b/java/examples-android/provisioningclient/src/main/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from android/examples/provisioningclient/src/main/res/mipmap-mdpi/ic_launcher.png rename to java/examples-android/provisioningclient/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/android/examples/provisioningclient/src/main/res/mipmap-xhdpi/ic_launcher.png b/java/examples-android/provisioningclient/src/main/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from android/examples/provisioningclient/src/main/res/mipmap-xhdpi/ic_launcher.png rename to java/examples-android/provisioningclient/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/android/examples/provisioningclient/src/main/res/mipmap-xxhdpi/ic_launcher.png b/java/examples-android/provisioningclient/src/main/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from android/examples/provisioningclient/src/main/res/mipmap-xxhdpi/ic_launcher.png rename to java/examples-android/provisioningclient/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/android/examples/groupserver/src/main/res/values-v21/styles.xml b/java/examples-android/provisioningclient/src/main/res/values-v21/styles.xml similarity index 100% rename from android/examples/groupserver/src/main/res/values-v21/styles.xml rename to java/examples-android/provisioningclient/src/main/res/values-v21/styles.xml diff --git a/android/examples/fridgegroupclient/src/main/res/values-w820dp/dimens.xml b/java/examples-android/provisioningclient/src/main/res/values-w820dp/dimens.xml old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgegroupclient/src/main/res/values-w820dp/dimens.xml rename to java/examples-android/provisioningclient/src/main/res/values-w820dp/dimens.xml diff --git a/android/examples/fridgeclient/src/main/res/values/dimens.xml b/java/examples-android/provisioningclient/src/main/res/values/dimens.xml old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgeclient/src/main/res/values/dimens.xml rename to java/examples-android/provisioningclient/src/main/res/values/dimens.xml diff --git a/android/examples/provisioningclient/src/main/res/values/strings.xml b/java/examples-android/provisioningclient/src/main/res/values/strings.xml similarity index 100% rename from android/examples/provisioningclient/src/main/res/values/strings.xml rename to java/examples-android/provisioningclient/src/main/res/values/strings.xml diff --git a/android/examples/fridgegroupclient/src/main/res/values/styles.xml b/java/examples-android/provisioningclient/src/main/res/values/styles.xml old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgegroupclient/src/main/res/values/styles.xml rename to java/examples-android/provisioningclient/src/main/res/values/styles.xml diff --git a/android/examples/settings.gradle b/java/examples-android/settings.gradle similarity index 100% rename from android/examples/settings.gradle rename to java/examples-android/settings.gradle diff --git a/android/examples/fridgegroupserver/.gitignore b/java/examples-android/simplebase/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgegroupserver/.gitignore rename to java/examples-android/simplebase/.gitignore diff --git a/android/examples/simplebase/build.gradle b/java/examples-android/simplebase/build.gradle similarity index 93% rename from android/examples/simplebase/build.gradle rename to java/examples-android/simplebase/build.gradle index d84d82c..a7d3b2d 100644 --- a/android/examples/simplebase/build.gradle +++ b/java/examples-android/simplebase/build.gradle @@ -23,7 +23,7 @@ android { } repositories { flatDir { - dirs "../../android_api/base/build/outputs/aar/" + dirs "../../iotivity-android/build/outputs/aar/" } } diff --git a/android/examples/simplebase/libs/android-support-v4.jar b/java/examples-android/simplebase/libs/android-support-v4.jar similarity index 100% rename from android/examples/simplebase/libs/android-support-v4.jar rename to java/examples-android/simplebase/libs/android-support-v4.jar diff --git a/android/examples/simplebase/proguard-rules.pro b/java/examples-android/simplebase/proguard-rules.pro similarity index 100% rename from android/examples/simplebase/proguard-rules.pro rename to java/examples-android/simplebase/proguard-rules.pro diff --git a/android/examples/simplebase/simplebase.iml b/java/examples-android/simplebase/simplebase.iml similarity index 100% rename from android/examples/simplebase/simplebase.iml rename to java/examples-android/simplebase/simplebase.iml diff --git a/android/examples/simplebase/src/main/AndroidManifest.xml b/java/examples-android/simplebase/src/main/AndroidManifest.xml similarity index 100% rename from android/examples/simplebase/src/main/AndroidManifest.xml rename to java/examples-android/simplebase/src/main/AndroidManifest.xml diff --git a/android/examples/simplebase/src/main/java/org/iotivity/base/examples/BluetoothFragment.java b/java/examples-android/simplebase/src/main/java/org/iotivity/base/examples/BluetoothFragment.java similarity index 100% rename from android/examples/simplebase/src/main/java/org/iotivity/base/examples/BluetoothFragment.java rename to java/examples-android/simplebase/src/main/java/org/iotivity/base/examples/BluetoothFragment.java diff --git a/android/examples/simplebase/src/main/java/org/iotivity/base/examples/Common.java b/java/examples-android/simplebase/src/main/java/org/iotivity/base/examples/Common.java similarity index 100% rename from android/examples/simplebase/src/main/java/org/iotivity/base/examples/Common.java rename to java/examples-android/simplebase/src/main/java/org/iotivity/base/examples/Common.java diff --git a/android/examples/simplebase/src/main/java/org/iotivity/base/examples/DrawerFragment.java b/java/examples-android/simplebase/src/main/java/org/iotivity/base/examples/DrawerFragment.java similarity index 100% rename from android/examples/simplebase/src/main/java/org/iotivity/base/examples/DrawerFragment.java rename to java/examples-android/simplebase/src/main/java/org/iotivity/base/examples/DrawerFragment.java diff --git a/android/examples/simplebase/src/main/java/org/iotivity/base/examples/MessageFragment.java b/java/examples-android/simplebase/src/main/java/org/iotivity/base/examples/MessageFragment.java similarity index 100% rename from android/examples/simplebase/src/main/java/org/iotivity/base/examples/MessageFragment.java rename to java/examples-android/simplebase/src/main/java/org/iotivity/base/examples/MessageFragment.java diff --git a/android/examples/simplebase/src/main/java/org/iotivity/base/examples/SimpleBase.java b/java/examples-android/simplebase/src/main/java/org/iotivity/base/examples/SimpleBase.java similarity index 100% rename from android/examples/simplebase/src/main/java/org/iotivity/base/examples/SimpleBase.java rename to java/examples-android/simplebase/src/main/java/org/iotivity/base/examples/SimpleBase.java diff --git a/android/examples/simplebase/src/main/java/org/iotivity/base/examples/TemplateFragment.java b/java/examples-android/simplebase/src/main/java/org/iotivity/base/examples/TemplateFragment.java similarity index 100% rename from android/examples/simplebase/src/main/java/org/iotivity/base/examples/TemplateFragment.java rename to java/examples-android/simplebase/src/main/java/org/iotivity/base/examples/TemplateFragment.java diff --git a/android/examples/simplebase/src/main/res/drawable-hdpi/drawer_shadow.9.png b/java/examples-android/simplebase/src/main/res/drawable-hdpi/drawer_shadow.9.png similarity index 100% rename from android/examples/simplebase/src/main/res/drawable-hdpi/drawer_shadow.9.png rename to java/examples-android/simplebase/src/main/res/drawable-hdpi/drawer_shadow.9.png diff --git a/android/examples/simplebase/src/main/res/drawable-hdpi/ic_drawer.png b/java/examples-android/simplebase/src/main/res/drawable-hdpi/ic_drawer.png similarity index 100% rename from android/examples/simplebase/src/main/res/drawable-hdpi/ic_drawer.png rename to java/examples-android/simplebase/src/main/res/drawable-hdpi/ic_drawer.png diff --git a/android/examples/simplebase/src/main/res/drawable-mdpi/drawer_shadow.9.png b/java/examples-android/simplebase/src/main/res/drawable-mdpi/drawer_shadow.9.png similarity index 100% rename from android/examples/simplebase/src/main/res/drawable-mdpi/drawer_shadow.9.png rename to java/examples-android/simplebase/src/main/res/drawable-mdpi/drawer_shadow.9.png diff --git a/android/examples/simplebase/src/main/res/drawable-mdpi/ic_drawer.png b/java/examples-android/simplebase/src/main/res/drawable-mdpi/ic_drawer.png similarity index 100% rename from android/examples/simplebase/src/main/res/drawable-mdpi/ic_drawer.png rename to java/examples-android/simplebase/src/main/res/drawable-mdpi/ic_drawer.png diff --git a/android/examples/simplebase/src/main/res/drawable-xhdpi/drawer_shadow.9.png b/java/examples-android/simplebase/src/main/res/drawable-xhdpi/drawer_shadow.9.png similarity index 100% rename from android/examples/simplebase/src/main/res/drawable-xhdpi/drawer_shadow.9.png rename to java/examples-android/simplebase/src/main/res/drawable-xhdpi/drawer_shadow.9.png diff --git a/android/examples/simplebase/src/main/res/drawable-xhdpi/ic_drawer.png b/java/examples-android/simplebase/src/main/res/drawable-xhdpi/ic_drawer.png similarity index 100% rename from android/examples/simplebase/src/main/res/drawable-xhdpi/ic_drawer.png rename to java/examples-android/simplebase/src/main/res/drawable-xhdpi/ic_drawer.png diff --git a/android/examples/simplebase/src/main/res/drawable-xxhdpi/drawer_shadow.9.png b/java/examples-android/simplebase/src/main/res/drawable-xxhdpi/drawer_shadow.9.png similarity index 100% rename from android/examples/simplebase/src/main/res/drawable-xxhdpi/drawer_shadow.9.png rename to java/examples-android/simplebase/src/main/res/drawable-xxhdpi/drawer_shadow.9.png diff --git a/android/examples/simplebase/src/main/res/drawable-xxhdpi/ic_drawer.png b/java/examples-android/simplebase/src/main/res/drawable-xxhdpi/ic_drawer.png similarity index 100% rename from android/examples/simplebase/src/main/res/drawable-xxhdpi/ic_drawer.png rename to java/examples-android/simplebase/src/main/res/drawable-xxhdpi/ic_drawer.png diff --git a/android/examples/fridgeclient/src/main/res/drawable-mdpi/iotivityicon.png b/java/examples-android/simplebase/src/main/res/drawable/iotivityicon.png old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgeclient/src/main/res/drawable-mdpi/iotivityicon.png rename to java/examples-android/simplebase/src/main/res/drawable/iotivityicon.png diff --git a/android/examples/fridgeclient/src/main/res/drawable-hdpi/iotivitylogo.png b/java/examples-android/simplebase/src/main/res/drawable/iotivitylogo.png old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgeclient/src/main/res/drawable-hdpi/iotivitylogo.png rename to java/examples-android/simplebase/src/main/res/drawable/iotivitylogo.png diff --git a/android/examples/simplebase/src/main/res/layout/activity_simplebase.xml b/java/examples-android/simplebase/src/main/res/layout/activity_simplebase.xml similarity index 100% rename from android/examples/simplebase/src/main/res/layout/activity_simplebase.xml rename to java/examples-android/simplebase/src/main/res/layout/activity_simplebase.xml diff --git a/android/examples/simplebase/src/main/res/layout/fragment_bluetooth.xml b/java/examples-android/simplebase/src/main/res/layout/fragment_bluetooth.xml similarity index 100% rename from android/examples/simplebase/src/main/res/layout/fragment_bluetooth.xml rename to java/examples-android/simplebase/src/main/res/layout/fragment_bluetooth.xml diff --git a/android/examples/simplebase/src/main/res/layout/fragment_drawer.xml b/java/examples-android/simplebase/src/main/res/layout/fragment_drawer.xml similarity index 100% rename from android/examples/simplebase/src/main/res/layout/fragment_drawer.xml rename to java/examples-android/simplebase/src/main/res/layout/fragment_drawer.xml diff --git a/android/examples/simplebase/src/main/res/layout/fragment_message.xml b/java/examples-android/simplebase/src/main/res/layout/fragment_message.xml similarity index 100% rename from android/examples/simplebase/src/main/res/layout/fragment_message.xml rename to java/examples-android/simplebase/src/main/res/layout/fragment_message.xml diff --git a/android/examples/simplebase/src/main/res/layout/fragment_template.xml b/java/examples-android/simplebase/src/main/res/layout/fragment_template.xml similarity index 100% rename from android/examples/simplebase/src/main/res/layout/fragment_template.xml rename to java/examples-android/simplebase/src/main/res/layout/fragment_template.xml diff --git a/android/examples/simplebase/src/main/res/layout/tcp_input.xml b/java/examples-android/simplebase/src/main/res/layout/tcp_input.xml similarity index 100% rename from android/examples/simplebase/src/main/res/layout/tcp_input.xml rename to java/examples-android/simplebase/src/main/res/layout/tcp_input.xml diff --git a/android/examples/fridgeclient/src/main/res/drawable-hdpi/iotivityicon.png b/java/examples-android/simplebase/src/main/res/mipmap-hdpi/iotivityicon.png old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgeclient/src/main/res/drawable-hdpi/iotivityicon.png rename to java/examples-android/simplebase/src/main/res/mipmap-hdpi/iotivityicon.png diff --git a/android/examples/groupclient/src/main/res/mipmap-mdpi/iotivityicon.png b/java/examples-android/simplebase/src/main/res/mipmap-mdpi/iotivityicon.png similarity index 100% rename from android/examples/groupclient/src/main/res/mipmap-mdpi/iotivityicon.png rename to java/examples-android/simplebase/src/main/res/mipmap-mdpi/iotivityicon.png diff --git a/android/examples/groupclient/src/main/res/mipmap-xhdpi/iotivityicon.png b/java/examples-android/simplebase/src/main/res/mipmap-xhdpi/iotivityicon.png similarity index 100% rename from android/examples/groupclient/src/main/res/mipmap-xhdpi/iotivityicon.png rename to java/examples-android/simplebase/src/main/res/mipmap-xhdpi/iotivityicon.png diff --git a/android/examples/groupclient/src/main/res/mipmap-xxhdpi/iotivityicon.png b/java/examples-android/simplebase/src/main/res/mipmap-xxhdpi/iotivityicon.png similarity index 100% rename from android/examples/groupclient/src/main/res/mipmap-xxhdpi/iotivityicon.png rename to java/examples-android/simplebase/src/main/res/mipmap-xxhdpi/iotivityicon.png diff --git a/android/examples/groupclient/src/main/res/values-v21/styles.xml b/java/examples-android/simplebase/src/main/res/values-v21/styles.xml similarity index 100% rename from android/examples/groupclient/src/main/res/values-v21/styles.xml rename to java/examples-android/simplebase/src/main/res/values-v21/styles.xml diff --git a/android/examples/fridgeclient/src/main/res/values-w820dp/dimens.xml b/java/examples-android/simplebase/src/main/res/values-w820dp/dimens.xml old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgeclient/src/main/res/values-w820dp/dimens.xml rename to java/examples-android/simplebase/src/main/res/values-w820dp/dimens.xml diff --git a/android/examples/simplebase/src/main/res/values/dimens.xml b/java/examples-android/simplebase/src/main/res/values/dimens.xml similarity index 100% rename from android/examples/simplebase/src/main/res/values/dimens.xml rename to java/examples-android/simplebase/src/main/res/values/dimens.xml diff --git a/android/examples/simplebase/src/main/res/values/strings.xml b/java/examples-android/simplebase/src/main/res/values/strings.xml similarity index 100% rename from android/examples/simplebase/src/main/res/values/strings.xml rename to java/examples-android/simplebase/src/main/res/values/strings.xml diff --git a/android/examples/fridgeclient/src/main/res/values/styles.xml b/java/examples-android/simplebase/src/main/res/values/styles.xml old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgeclient/src/main/res/values/styles.xml rename to java/examples-android/simplebase/src/main/res/values/styles.xml diff --git a/android/examples/fridgegroupclient/.gitignore b/java/examples-android/simpleclient/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgegroupclient/.gitignore rename to java/examples-android/simpleclient/.gitignore diff --git a/android/examples/simpleclient/build.gradle b/java/examples-android/simpleclient/build.gradle similarity index 92% rename from android/examples/simpleclient/build.gradle rename to java/examples-android/simpleclient/build.gradle index f105e1a..ea6d5be 100644 --- a/android/examples/simpleclient/build.gradle +++ b/java/examples-android/simpleclient/build.gradle @@ -23,7 +23,7 @@ android { } repositories { flatDir { - dirs "../../android_api/base/build/outputs/aar/" + dirs "../../iotivity-android/build/outputs/aar/" } } diff --git a/android/examples/devicediscoveryserver/proguard-rules.pro b/java/examples-android/simpleclient/proguard-rules.pro similarity index 100% rename from android/examples/devicediscoveryserver/proguard-rules.pro rename to java/examples-android/simpleclient/proguard-rules.pro diff --git a/android/examples/simpleclient/simpleclient.iml b/java/examples-android/simpleclient/simpleclient.iml similarity index 100% rename from android/examples/simpleclient/simpleclient.iml rename to java/examples-android/simpleclient/simpleclient.iml diff --git a/android/examples/simpleclient/src/main/AndroidManifest.xml b/java/examples-android/simpleclient/src/main/AndroidManifest.xml similarity index 100% rename from android/examples/simpleclient/src/main/AndroidManifest.xml rename to java/examples-android/simpleclient/src/main/AndroidManifest.xml diff --git a/android/examples/simpleclient/src/main/assets/oic_svr_db_client.json b/java/examples-android/simpleclient/src/main/assets/oic_svr_db_client.json similarity index 100% rename from android/examples/simpleclient/src/main/assets/oic_svr_db_client.json rename to java/examples-android/simpleclient/src/main/assets/oic_svr_db_client.json diff --git a/android/examples/simpleclient/src/main/java/org/iotivity/base/examples/Light.java b/java/examples-android/simpleclient/src/main/java/org/iotivity/base/examples/Light.java similarity index 100% rename from android/examples/simpleclient/src/main/java/org/iotivity/base/examples/Light.java rename to java/examples-android/simpleclient/src/main/java/org/iotivity/base/examples/Light.java diff --git a/android/examples/simpleclient/src/main/java/org/iotivity/base/examples/SimpleClient.java b/java/examples-android/simpleclient/src/main/java/org/iotivity/base/examples/SimpleClient.java similarity index 100% rename from android/examples/simpleclient/src/main/java/org/iotivity/base/examples/SimpleClient.java rename to java/examples-android/simpleclient/src/main/java/org/iotivity/base/examples/SimpleClient.java diff --git a/android/examples/devicediscoveryserver/src/main/res/mipmap-hdpi/iotivityicon.png b/java/examples-android/simpleclient/src/main/res/drawable/iotivityicon.png similarity index 100% rename from android/examples/devicediscoveryserver/src/main/res/mipmap-hdpi/iotivityicon.png rename to java/examples-android/simpleclient/src/main/res/drawable/iotivityicon.png diff --git a/android/examples/devicediscoveryserver/src/main/res/drawable/iotivitylogo.png b/java/examples-android/simpleclient/src/main/res/drawable/iotivitylogo.png similarity index 100% rename from android/examples/devicediscoveryserver/src/main/res/drawable/iotivitylogo.png rename to java/examples-android/simpleclient/src/main/res/drawable/iotivitylogo.png diff --git a/android/examples/simpleclient/src/main/res/layout/activity_simple_client.xml b/java/examples-android/simpleclient/src/main/res/layout/activity_simple_client.xml similarity index 100% rename from android/examples/simpleclient/src/main/res/layout/activity_simple_client.xml rename to java/examples-android/simpleclient/src/main/res/layout/activity_simple_client.xml diff --git a/android/examples/devicediscoveryserver/src/main/res/drawable/iotivityicon.png b/java/examples-android/simpleclient/src/main/res/mipmap-hdpi/iotivityicon.png similarity index 100% rename from android/examples/devicediscoveryserver/src/main/res/drawable/iotivityicon.png rename to java/examples-android/simpleclient/src/main/res/mipmap-hdpi/iotivityicon.png diff --git a/android/examples/devicediscoveryserver/src/main/res/mipmap-mdpi/iotivityicon.png b/java/examples-android/simpleclient/src/main/res/mipmap-mdpi/iotivityicon.png similarity index 100% rename from android/examples/devicediscoveryserver/src/main/res/mipmap-mdpi/iotivityicon.png rename to java/examples-android/simpleclient/src/main/res/mipmap-mdpi/iotivityicon.png diff --git a/android/examples/devicediscoveryserver/src/main/res/mipmap-xhdpi/iotivityicon.png b/java/examples-android/simpleclient/src/main/res/mipmap-xhdpi/iotivityicon.png similarity index 100% rename from android/examples/devicediscoveryserver/src/main/res/mipmap-xhdpi/iotivityicon.png rename to java/examples-android/simpleclient/src/main/res/mipmap-xhdpi/iotivityicon.png diff --git a/android/examples/devicediscoveryserver/src/main/res/mipmap-xxhdpi/iotivityicon.png b/java/examples-android/simpleclient/src/main/res/mipmap-xxhdpi/iotivityicon.png similarity index 100% rename from android/examples/devicediscoveryserver/src/main/res/mipmap-xxhdpi/iotivityicon.png rename to java/examples-android/simpleclient/src/main/res/mipmap-xxhdpi/iotivityicon.png diff --git a/android/examples/devicediscoveryserver/src/main/res/values-v21/styles.xml b/java/examples-android/simpleclient/src/main/res/values-v21/styles.xml similarity index 100% rename from android/examples/devicediscoveryserver/src/main/res/values-v21/styles.xml rename to java/examples-android/simpleclient/src/main/res/values-v21/styles.xml diff --git a/android/examples/devicediscoveryserver/src/main/res/values-w820dp/dimens.xml b/java/examples-android/simpleclient/src/main/res/values-w820dp/dimens.xml similarity index 100% rename from android/examples/devicediscoveryserver/src/main/res/values-w820dp/dimens.xml rename to java/examples-android/simpleclient/src/main/res/values-w820dp/dimens.xml diff --git a/android/examples/devicediscoveryserver/src/main/res/values/dimens.xml b/java/examples-android/simpleclient/src/main/res/values/dimens.xml similarity index 100% rename from android/examples/devicediscoveryserver/src/main/res/values/dimens.xml rename to java/examples-android/simpleclient/src/main/res/values/dimens.xml diff --git a/android/examples/simpleclient/src/main/res/values/strings.xml b/java/examples-android/simpleclient/src/main/res/values/strings.xml similarity index 100% rename from android/examples/simpleclient/src/main/res/values/strings.xml rename to java/examples-android/simpleclient/src/main/res/values/strings.xml diff --git a/android/examples/devicediscoveryserver/src/main/res/values/styles.xml b/java/examples-android/simpleclient/src/main/res/values/styles.xml similarity index 100% rename from android/examples/devicediscoveryserver/src/main/res/values/styles.xml rename to java/examples-android/simpleclient/src/main/res/values/styles.xml diff --git a/android/examples/fridgeclient/.gitignore b/java/examples-android/simpleserver/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from android/examples/fridgeclient/.gitignore rename to java/examples-android/simpleserver/.gitignore diff --git a/android/examples/simpleserver/build.gradle b/java/examples-android/simpleserver/build.gradle similarity index 92% rename from android/examples/simpleserver/build.gradle rename to java/examples-android/simpleserver/build.gradle index 81bdc88..fec6de8 100644 --- a/android/examples/simpleserver/build.gradle +++ b/java/examples-android/simpleserver/build.gradle @@ -23,7 +23,7 @@ android { } repositories { flatDir { - dirs "../../android_api/base/build/outputs/aar/" + dirs "../../iotivity-android/build/outputs/aar/" } } diff --git a/android/examples/devicediscoveryclient/proguard-rules.pro b/java/examples-android/simpleserver/proguard-rules.pro similarity index 100% rename from android/examples/devicediscoveryclient/proguard-rules.pro rename to java/examples-android/simpleserver/proguard-rules.pro diff --git a/android/examples/simpleserver/simpleserver.iml b/java/examples-android/simpleserver/simpleserver.iml similarity index 100% rename from android/examples/simpleserver/simpleserver.iml rename to java/examples-android/simpleserver/simpleserver.iml diff --git a/android/examples/simpleserver/src/main/AndroidManifest.xml b/java/examples-android/simpleserver/src/main/AndroidManifest.xml similarity index 100% rename from android/examples/simpleserver/src/main/AndroidManifest.xml rename to java/examples-android/simpleserver/src/main/AndroidManifest.xml diff --git a/android/examples/simpleserver/src/main/assets/oic_svr_db_server.json b/java/examples-android/simpleserver/src/main/assets/oic_svr_db_server.json similarity index 100% rename from android/examples/simpleserver/src/main/assets/oic_svr_db_server.json rename to java/examples-android/simpleserver/src/main/assets/oic_svr_db_server.json diff --git a/android/examples/simpleserver/src/main/java/org/iotivity/base/examples/Light.java b/java/examples-android/simpleserver/src/main/java/org/iotivity/base/examples/Light.java similarity index 100% rename from android/examples/simpleserver/src/main/java/org/iotivity/base/examples/Light.java rename to java/examples-android/simpleserver/src/main/java/org/iotivity/base/examples/Light.java diff --git a/android/examples/simpleserver/src/main/java/org/iotivity/base/examples/SimpleServer.java b/java/examples-android/simpleserver/src/main/java/org/iotivity/base/examples/SimpleServer.java similarity index 100% rename from android/examples/simpleserver/src/main/java/org/iotivity/base/examples/SimpleServer.java rename to java/examples-android/simpleserver/src/main/java/org/iotivity/base/examples/SimpleServer.java diff --git a/android/examples/devicediscoveryclient/src/main/res/mipmap-hdpi/iotivityicon.png b/java/examples-android/simpleserver/src/main/res/drawable/iotivityicon.png similarity index 100% rename from android/examples/devicediscoveryclient/src/main/res/mipmap-hdpi/iotivityicon.png rename to java/examples-android/simpleserver/src/main/res/drawable/iotivityicon.png diff --git a/android/examples/devicediscoveryclient/src/main/res/drawable/iotivitylogo.png b/java/examples-android/simpleserver/src/main/res/drawable/iotivitylogo.png similarity index 100% rename from android/examples/devicediscoveryclient/src/main/res/drawable/iotivitylogo.png rename to java/examples-android/simpleserver/src/main/res/drawable/iotivitylogo.png diff --git a/android/examples/simpleserver/src/main/res/layout/activity_simple_server.xml b/java/examples-android/simpleserver/src/main/res/layout/activity_simple_server.xml similarity index 100% rename from android/examples/simpleserver/src/main/res/layout/activity_simple_server.xml rename to java/examples-android/simpleserver/src/main/res/layout/activity_simple_server.xml diff --git a/android/examples/devicediscoveryclient/src/main/res/drawable/iotivityicon.png b/java/examples-android/simpleserver/src/main/res/mipmap-hdpi/iotivityicon.png similarity index 100% rename from android/examples/devicediscoveryclient/src/main/res/drawable/iotivityicon.png rename to java/examples-android/simpleserver/src/main/res/mipmap-hdpi/iotivityicon.png diff --git a/android/examples/devicediscoveryclient/src/main/res/mipmap-mdpi/iotivityicon.png b/java/examples-android/simpleserver/src/main/res/mipmap-mdpi/iotivityicon.png similarity index 100% rename from android/examples/devicediscoveryclient/src/main/res/mipmap-mdpi/iotivityicon.png rename to java/examples-android/simpleserver/src/main/res/mipmap-mdpi/iotivityicon.png diff --git a/android/examples/devicediscoveryclient/src/main/res/mipmap-xhdpi/iotivityicon.png b/java/examples-android/simpleserver/src/main/res/mipmap-xhdpi/iotivityicon.png similarity index 100% rename from android/examples/devicediscoveryclient/src/main/res/mipmap-xhdpi/iotivityicon.png rename to java/examples-android/simpleserver/src/main/res/mipmap-xhdpi/iotivityicon.png diff --git a/android/examples/devicediscoveryclient/src/main/res/mipmap-xxhdpi/iotivityicon.png b/java/examples-android/simpleserver/src/main/res/mipmap-xxhdpi/iotivityicon.png similarity index 100% rename from android/examples/devicediscoveryclient/src/main/res/mipmap-xxhdpi/iotivityicon.png rename to java/examples-android/simpleserver/src/main/res/mipmap-xxhdpi/iotivityicon.png diff --git a/android/examples/devicediscoveryclient/src/main/res/values-v21/styles.xml b/java/examples-android/simpleserver/src/main/res/values-v21/styles.xml similarity index 100% rename from android/examples/devicediscoveryclient/src/main/res/values-v21/styles.xml rename to java/examples-android/simpleserver/src/main/res/values-v21/styles.xml diff --git a/android/examples/devicediscoveryclient/src/main/res/values-w820dp/dimens.xml b/java/examples-android/simpleserver/src/main/res/values-w820dp/dimens.xml similarity index 100% rename from android/examples/devicediscoveryclient/src/main/res/values-w820dp/dimens.xml rename to java/examples-android/simpleserver/src/main/res/values-w820dp/dimens.xml diff --git a/android/examples/devicediscoveryclient/src/main/res/values/dimens.xml b/java/examples-android/simpleserver/src/main/res/values/dimens.xml similarity index 100% rename from android/examples/devicediscoveryclient/src/main/res/values/dimens.xml rename to java/examples-android/simpleserver/src/main/res/values/dimens.xml diff --git a/android/examples/simpleserver/src/main/res/values/strings.xml b/java/examples-android/simpleserver/src/main/res/values/strings.xml similarity index 100% rename from android/examples/simpleserver/src/main/res/values/strings.xml rename to java/examples-android/simpleserver/src/main/res/values/strings.xml diff --git a/android/examples/devicediscoveryclient/src/main/res/values/styles.xml b/java/examples-android/simpleserver/src/main/res/values/styles.xml similarity index 100% rename from android/examples/devicediscoveryclient/src/main/res/values/styles.xml rename to java/examples-android/simpleserver/src/main/res/values/styles.xml diff --git a/java/examples-java/build.gradle b/java/examples-java/build.gradle new file mode 100755 index 0000000..8b82b2b --- /dev/null +++ b/java/examples-java/build.gradle @@ -0,0 +1,22 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + repositories { + jcenter() + } + dependencies { + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + apply plugin: 'java' + repositories { + jcenter() + } + dependencies { + compile fileTree(dir: "../../iotivity-$TARGET_OS/build/libs/", include: '*.jar') + } +} diff --git a/java/examples-java/devicediscoveryclient/.gitignore b/java/examples-java/devicediscoveryclient/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/java/examples-java/devicediscoveryclient/.gitignore @@ -0,0 +1 @@ +/build diff --git a/android/examples/devicediscoveryclient/build.gradle b/java/examples-java/devicediscoveryclient/build.gradle similarity index 100% rename from android/examples/devicediscoveryclient/build.gradle rename to java/examples-java/devicediscoveryclient/build.gradle diff --git a/java/examples-java/devicediscoveryclient/src/main/java/org/iotivity/base/examples/DeviceDiscoveryClient.java b/java/examples-java/devicediscoveryclient/src/main/java/org/iotivity/base/examples/DeviceDiscoveryClient.java new file mode 100644 index 0000000..6c2d317 --- /dev/null +++ b/java/examples-java/devicediscoveryclient/src/main/java/org/iotivity/base/examples/DeviceDiscoveryClient.java @@ -0,0 +1,233 @@ +/* + ******************************************************************* + * + * 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; + +import android.app.Activity; +import android.content.Context; +import android.os.Bundle; +import android.text.method.ScrollingMovementMethod; +import android.util.Log; +import android.view.View; +import android.widget.Button; +import android.widget.ScrollView; +import android.widget.TextView; + +import org.iotivity.base.ModeType; +import org.iotivity.base.OcConnectivityType; +import org.iotivity.base.OcException; +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 java.util.EnumSet; +import java.util.HashMap; +import java.util.Map; + +/** + * This sample demonstrates the device discovery feature. + * The client queries for the device related information stored by the server. + */ +public class DeviceDiscoveryClient extends Activity implements + OcPlatform.OnDeviceFoundListener, + OcPlatform.OnPlatformFoundListener { + private void startDeviceDiscoveryClient() { + Context context = this; + + PlatformConfig platformConfig = new PlatformConfig( + context, + ServiceType.IN_PROC, + ModeType.CLIENT, + "0.0.0.0", // By setting to "0.0.0.0", it binds to all available interfaces + 0, // Uses randomly available port + QualityOfService.LOW + ); + + msg("Configuring platform."); + OcPlatform.Configure(platformConfig); + sleep(1); + + try { + msg("Querying for platform information..."); + OcPlatform.getPlatformInfo("", + OcPlatform.WELL_KNOWN_PLATFORM_QUERY, + EnumSet.of(OcConnectivityType.CT_DEFAULT), + this); + } catch (OcException e) { + Log.e(TAG, e.toString()); + msg("Failed to query for platform information"); + } + sleep(2); + + try { + msg("Querying for device information..."); + OcPlatform.getDeviceInfo("", + OcPlatform.WELL_KNOWN_DEVICE_QUERY, + EnumSet.of(OcConnectivityType.CT_DEFAULT), + this); + } catch (OcException e) { + Log.e(TAG, e.toString()); + msg("Failed to query for device information"); + } + sleep(2); + + enableStartButton(); + printLine(); + } + + private final static Map PLATFORM_INFO_KEYS = new HashMap() {{ + put("pi", "Platform ID: "); + put("mnmn", "Manufacturer name: "); + put("mnml", "Manufacturer url: "); + put("mnmo", "Manufacturer Model No: "); + put("mndt", "Manufactured Date: "); + put("mnpv", "Manufacturer Platform Version: "); + put("mnos", "Manufacturer OS version: "); + put("mnhw", "Manufacturer hardware version: "); + put("mnfv", "Manufacturer firmware version: "); + put("mnsl", "Manufacturer support url: "); + put("st", "Manufacturer system time: "); + }}; + + @Override + public synchronized void onPlatformFound(OcRepresentation ocRepresentation) { + msg("Platform Information received:"); + try { + for (String key : PLATFORM_INFO_KEYS.keySet()) { + msg("\t" + PLATFORM_INFO_KEYS.get(key) + ocRepresentation.getValue(key)); + } + } catch (OcException e) { + Log.e(TAG, e.toString()); + msg("Failed to read platform info values."); + } + + printLine(); + } + + private final static Map DEVICE_INFO_KEYS = new HashMap() {{ + put("di", "Device ID: "); + put("n", "Device name: "); + put("lcv", "Spec version url: "); + put("dmv", "Data Model: "); + }}; + + @Override + public synchronized void onDeviceFound(OcRepresentation ocRepresentation) { + msg("Device Information received:"); + try { + for (String key : DEVICE_INFO_KEYS.keySet()) { + msg("\t" + DEVICE_INFO_KEYS.get(key) + ocRepresentation.getValue(key)); + } + } catch (OcException e) { + Log.e(TAG, e.toString()); + msg("Failed to read device info values."); + } + + printLine(); + } + + //****************************************************************************** + // End of the OIC specific code + //****************************************************************************** + + private final static String TAG = DeviceDiscoveryClient.class.getSimpleName(); + private TextView mConsoleTextView; + private ScrollView mScrollView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_device_discovery_client); + + mConsoleTextView = (TextView) findViewById(R.id.consoleTextView); + mConsoleTextView.setMovementMethod(new ScrollingMovementMethod()); + mScrollView = (ScrollView) findViewById(R.id.scrollView); + mScrollView.fullScroll(View.FOCUS_DOWN); + final Button button = (Button) findViewById(R.id.button); + + if (null == savedInstanceState) { + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + button.setText("Re-start"); + button.setEnabled(false); + new Thread(new Runnable() { + public void run() { + startDeviceDiscoveryClient(); + } + }).start(); + } + }); + } else { + String consoleOutput = savedInstanceState.getString("consoleOutputString"); + mConsoleTextView.setText(consoleOutput); + } + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + outState.putString("consoleOutputString", mConsoleTextView.getText().toString()); + } + + @Override + protected void onRestoreInstanceState(Bundle savedInstanceState) { + super.onRestoreInstanceState(savedInstanceState); + + String consoleOutput = savedInstanceState.getString("consoleOutputString"); + mConsoleTextView.setText(consoleOutput); + } + + private void enableStartButton() { + runOnUiThread(new Runnable() { + public void run() { + Button button = (Button) findViewById(R.id.button); + button.setEnabled(true); + } + }); + } + + private void sleep(int seconds) { + try { + Thread.sleep(seconds * 1000); + } catch (InterruptedException e) { + e.printStackTrace(); + Log.e(TAG, e.toString()); + } + } + + private void msg(final String text) { + runOnUiThread(new Runnable() { + public void run() { + mConsoleTextView.append("\n"); + mConsoleTextView.append(text); + mScrollView.fullScroll(View.FOCUS_DOWN); + } + }); + Log.i(TAG, text); + } + + private void printLine() { + msg("------------------------------------------------------------------------"); + } +} diff --git a/java/examples-java/devicediscoveryserver/.gitignore b/java/examples-java/devicediscoveryserver/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/java/examples-java/devicediscoveryserver/.gitignore @@ -0,0 +1 @@ +/build diff --git a/android/examples/devicediscoveryserver/build.gradle b/java/examples-java/devicediscoveryserver/build.gradle similarity index 100% rename from android/examples/devicediscoveryserver/build.gradle rename to java/examples-java/devicediscoveryserver/build.gradle diff --git a/java/examples-java/devicediscoveryserver/src/main/java/org/iotivity/base/examples/DeviceDiscoveryServer.java b/java/examples-java/devicediscoveryserver/src/main/java/org/iotivity/base/examples/DeviceDiscoveryServer.java new file mode 100644 index 0000000..a2920f4 --- /dev/null +++ b/java/examples-java/devicediscoveryserver/src/main/java/org/iotivity/base/examples/DeviceDiscoveryServer.java @@ -0,0 +1,163 @@ +/* + ******************************************************************* + * + * 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; + +import android.app.Activity; +import android.content.Context; +import android.os.Bundle; +import android.text.method.ScrollingMovementMethod; +import android.util.Log; +import android.view.View; +import android.widget.Button; +import android.widget.ScrollView; +import android.widget.TextView; + +import org.iotivity.base.ModeType; +import org.iotivity.base.OcDeviceInfo; +import org.iotivity.base.OcException; +import org.iotivity.base.OcPlatform; +import org.iotivity.base.OcPlatformInfo; +import org.iotivity.base.PlatformConfig; +import org.iotivity.base.QualityOfService; +import org.iotivity.base.ServiceType; + +/** + * This sample demonstrates platform and device discovery feature. + * The server sets the platform and device related info. which can be later retrieved by a client. + */ +public class DeviceDiscoveryServer extends Activity { + + private void startDeviceDiscoveryServer() { + Context context = this; + + PlatformConfig platformConfig = new PlatformConfig( + context, + ServiceType.IN_PROC, + ModeType.SERVER, + "0.0.0.0", // By setting to "0.0.0.0", it binds to all available interfaces + 0, // Uses randomly available port + QualityOfService.LOW + ); + + msg("Configuring platform."); + OcPlatform.Configure(platformConfig); + + OcDeviceInfo deviceInfo = new OcDeviceInfo("myDeviceName"); + try { + msg("Registering device info"); + OcPlatform.registerDeviceInfo(deviceInfo); + } catch (OcException e) { + Log.e(TAG, e.toString()); + msg("Failed to register device info."); + } + + OcPlatformInfo platformInfo = new OcPlatformInfo( + "myPlatformId", //Platform ID + "myManufactName", //Manufacturer Name + "www.myurl.com", //Manufacturer URL + "myModelNumber", //Model Number + "myDateOfManufacture", //Date of Manufacture + "myPlatformVersion", //Platform Version + "Manufacturer OS version", //Operating System Version + "myHardwareVersion", //Hardware Version + "myFirmwareVersion", //Firmware Version + "www.mysupporturl.com", //Support URL + String.valueOf(System.currentTimeMillis()) // System Time + ); + try { + msg("Registering platform info"); + OcPlatform.registerPlatformInfo(platformInfo); + } catch (OcException e) { + Log.e(TAG, e.toString()); + msg("Failed to register platform info."); + } + + msg("Waiting for the requests..."); + printLine(); + } + + //****************************************************************************** + // End of the OIC specific code + //****************************************************************************** + + private final static String TAG = DeviceDiscoveryServer.class.getSimpleName(); + private TextView mConsoleTextView; + private ScrollView mScrollView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_device_discovery_server); + + mConsoleTextView = (TextView) findViewById(R.id.consoleTextView); + mConsoleTextView.setMovementMethod(new ScrollingMovementMethod()); + mScrollView = (ScrollView) findViewById(R.id.scrollView); + mScrollView.fullScroll(View.FOCUS_DOWN); + final Button button = (Button) findViewById(R.id.button); + + if (null == savedInstanceState) { + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + button.setEnabled(false); + new Thread(new Runnable() { + public void run() { + startDeviceDiscoveryServer(); + } + }).start(); + } + }); + } else { + String consoleOutput = savedInstanceState.getString("consoleOutputString"); + mConsoleTextView.setText(consoleOutput); + } + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + outState.putString("consoleOutputString", mConsoleTextView.getText().toString()); + } + + @Override + protected void onRestoreInstanceState(Bundle savedInstanceState) { + super.onRestoreInstanceState(savedInstanceState); + + String consoleOutput = savedInstanceState.getString("consoleOutputString"); + mConsoleTextView.setText(consoleOutput); + } + + private void msg(final String text) { + runOnUiThread(new Runnable() { + public void run() { + mConsoleTextView.append("\n"); + mConsoleTextView.append(text); + mScrollView.fullScroll(View.FOCUS_DOWN); + } + }); + Log.i(TAG, text); + } + + private void printLine() { + msg("------------------------------------------------------------------------"); + } +} diff --git a/java/examples-java/fridgeclient/.gitignore b/java/examples-java/fridgeclient/.gitignore new file mode 100755 index 0000000..3543521 --- /dev/null +++ b/java/examples-java/fridgeclient/.gitignore @@ -0,0 +1 @@ +/build diff --git a/android/examples/fridgeclient/build.gradle b/java/examples-java/fridgeclient/build.gradle similarity index 100% rename from android/examples/fridgeclient/build.gradle rename to java/examples-java/fridgeclient/build.gradle diff --git a/java/examples-java/fridgeclient/src/main/java/org/iotivity/base/examples/FridgeClient.java b/java/examples-java/fridgeclient/src/main/java/org/iotivity/base/examples/FridgeClient.java new file mode 100755 index 0000000..20d692c --- /dev/null +++ b/java/examples-java/fridgeclient/src/main/java/org/iotivity/base/examples/FridgeClient.java @@ -0,0 +1,248 @@ +/* + ******************************************************************* + * + * 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; + +import android.app.Activity; +import android.os.Bundle; +import android.os.Message; +import android.text.method.ScrollingMovementMethod; +import android.util.Log; +import android.view.View; +import android.widget.Button; +import android.widget.TextView; + +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.EnumSet; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; + +/** + * FridgeClient + *

+ * FridgeClient is a sample client app which should be started after the fridgeServer is started. + * It creates DeviceResource, DoorResources, LightResource and performs a GET operation on them. + */ +public class FridgeClient extends Activity implements + OcPlatform.OnResourceFoundListener, + OcResource.OnGetListener { + public static final String DEVICE_URI = "/device"; + 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 API_VERSION = "v.1.0"; + public static final String CLIENT_TOKEN = "21ae43gf"; + public static final int API_VERSION_KEY = 2048; + public static final int CLIENT_TOKEN_KEY = 3000; + + private final List mResourceList = new LinkedList(); + private OcResource mFridgeResource; + + /** + * configure OIC platform and call findResource + */ + private void startFridgeClient() { + PlatformConfig cfg = new PlatformConfig( + this, // context + ServiceType.IN_PROC, + ModeType.CLIENT, + "0.0.0.0", // bind to all available interfaces + 0, + QualityOfService.LOW); + + logMessage("Configuring platform"); + OcPlatform.Configure(cfg); + logMessage("Initiating fridge discovery"); + try { + OcPlatform.findResource("", + OcPlatform.WELL_KNOWN_QUERY + "?rt=" + "intel.fridge", + EnumSet.of(OcConnectivityType.CT_DEFAULT), + this); + } catch (OcException e) { + logMessage(" Failed to discover resource"); + Log.e(TAG, e.getMessage()); + } + logMessage("-----------------------------------------------------"); + } + + /** + * An event handler to be executed whenever a "findResource" request completes successfully + * + * @param ocResource found resource + */ + @Override + public synchronized void onResourceFound(OcResource ocResource) { + if (null != mFridgeResource || !ocResource.getUri().equals(DEVICE_URI)) { + logMessage("Didn't find the correct fridge resource. Exiting"); + return; + } + mFridgeResource = ocResource; + logMessage("Discovered a fridge with \nHost: " + mFridgeResource.getHost()); + + List lightTypes = new LinkedList<>(); + lightTypes.add("intel.fridge.light"); + List doorTypes = new LinkedList<>(); + doorTypes.add("intel.fridge.door"); + List resourceInterfaces = new LinkedList<>(); + resourceInterfaces.add(OcPlatform.DEFAULT_INTERFACE); + logMessage("Creating child resource proxies for the previously known fridge components"); + OcResource light = null; + OcResource leftDoor = null; + OcResource rightDoor = null; + OcResource randomDoor = null; + try { + light = OcPlatform.constructResourceObject(mFridgeResource.getHost(), + LIGHT, + mFridgeResource.getConnectivityTypeSet(), + false, //isObservable + lightTypes, + resourceInterfaces); + mResourceList.add(light); + + leftDoor = OcPlatform.constructResourceObject(mFridgeResource.getHost(), + LEFT_DOOR, + mFridgeResource.getConnectivityTypeSet(), + false, //isObservable + doorTypes, + resourceInterfaces); + mResourceList.add(leftDoor); + + rightDoor = OcPlatform.constructResourceObject(mFridgeResource.getHost(), + RIGHT_DOOR, + mFridgeResource.getConnectivityTypeSet(), + false, //isObservable + doorTypes, + resourceInterfaces); + mResourceList.add(rightDoor); + + randomDoor = OcPlatform.constructResourceObject(mFridgeResource.getHost(), + RANDOM_DOOR, + mFridgeResource.getConnectivityTypeSet(), + false, //isObservable + doorTypes, + resourceInterfaces); + mResourceList.add(randomDoor); + } catch (OcException e) { + logMessage("Error in constructResourceObject"); + Log.e(TAG, e.getMessage()); + } + + List headerOptions = new LinkedList<>(); + OcHeaderOption apiVersion = new OcHeaderOption(API_VERSION_KEY, API_VERSION); + OcHeaderOption clientToken = new OcHeaderOption(CLIENT_TOKEN_KEY, CLIENT_TOKEN); + headerOptions.add(apiVersion); + headerOptions.add(clientToken); + mFridgeResource.setHeaderOptions(headerOptions); + + logMessage("Calling GET api on mFridgeResource and other component resources"); + try { + mFridgeResource.get(new HashMap(), this); + if (null != light) light.get(new HashMap(), this); + if (null != leftDoor) leftDoor.get(new HashMap(), this); + if (null != rightDoor) rightDoor.get(new HashMap(), this); + if (null != randomDoor) randomDoor.get(new HashMap(), this); + } catch (OcException e) { + logMessage("Error in GET calls"); + Log.e(TAG, e.getMessage()); + } + } + + /** + * An event handler to be executed whenever a "get" request completes successfully + * + * @param headerOptionList list of the header options + * @param ocRepresentation representation of a resource + */ + @Override + public synchronized void onGetCompleted(List headerOptionList, + OcRepresentation ocRepresentation) { + logMessage("Got a response from " + ocRepresentation.getUri()); + } + + /** + * An event handler to be executed whenever a "get" request fails + * + * @param throwable exception + */ + @Override + public synchronized void onGetFailed(Throwable throwable) { + logMessage("GET request has failed"); + Log.e(TAG, throwable.toString()); + } + + //****************************************************************************** + // End of the OIC specific code + //****************************************************************************** + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_fridge_client); + + mConsoleTextView = (TextView) findViewById(R.id.consoleTextView); + mConsoleTextView.setMovementMethod(new ScrollingMovementMethod()); + final Button button = (Button) findViewById(R.id.button); + + if (null == savedInstanceState) { + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + button.setEnabled(false); + new Thread(new Runnable() { + public void run() { + startFridgeClient(); + } + }).start(); + } + }); + } else { + String consoleOutput = savedInstanceState.getString("consoleOutputString"); + mConsoleTextView.setText(consoleOutput); + } + } + + private void logMessage(final String text) { + runOnUiThread(new Runnable() { + public void run() { + final Message msg = new Message(); + msg.obj = text; + mConsoleTextView.append("\n"); + mConsoleTextView.append(text); + } + }); + Log.i(TAG, text); + } + + private static String TAG = "FridgeClient: "; + private TextView mConsoleTextView; +} \ No newline at end of file diff --git a/java/examples-java/fridgegroupclient/.gitignore b/java/examples-java/fridgegroupclient/.gitignore new file mode 100755 index 0000000..3543521 --- /dev/null +++ b/java/examples-java/fridgegroupclient/.gitignore @@ -0,0 +1 @@ +/build diff --git a/android/examples/fridgegroupclient/build.gradle b/java/examples-java/fridgegroupclient/build.gradle similarity index 100% rename from android/examples/fridgegroupclient/build.gradle rename to java/examples-java/fridgegroupclient/build.gradle diff --git a/java/examples-java/fridgegroupclient/src/main/java/org/iotivity/base/examples/FridgeGroupClient.java b/java/examples-java/fridgegroupclient/src/main/java/org/iotivity/base/examples/FridgeGroupClient.java new file mode 100755 index 0000000..26b07dd --- /dev/null +++ b/java/examples-java/fridgegroupclient/src/main/java/org/iotivity/base/examples/FridgeGroupClient.java @@ -0,0 +1,258 @@ +/* + ******************************************************************* + * + * 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; + +import android.app.Activity; +import android.os.Bundle; +import android.os.Message; +import android.text.method.ScrollingMovementMethod; +import android.util.Log; +import android.view.View; +import android.widget.Button; +import android.widget.TextView; + +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.EnumSet; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; + +/** + * FridgeGroupClient + *

+ * FridgeGroupClient is a sample client app which should be started after the fridgeGroupServer is + * started. It discovers a fridge resource and then creates the proxy resources for each one of its + * children (light and door) and performs a GET on them. + */ +public class FridgeGroupClient extends Activity implements + OcPlatform.OnResourceFoundListener, + OcResource.OnGetListener { + private static String TAG = "FridgeGroupClient: "; + + private final List childResourceList = new LinkedList<>(); + private OcResource fridgeResource; + + private void startFridgeClient() { + PlatformConfig cfg = new PlatformConfig( + this, // context + ServiceType.IN_PROC, + ModeType.CLIENT, + "0.0.0.0", // bind to all available interfaces + 0, + QualityOfService.LOW); + + logMessage("Configuring platform"); + OcPlatform.Configure(cfg); + String requestUri = OcPlatform.WELL_KNOWN_QUERY + "?rt=intel.fridge.group"; + logMessage("Initiating fridge discovery"); + try { + OcPlatform.findResource("", + requestUri, + EnumSet.of(OcConnectivityType.CT_DEFAULT), + this); + } catch (OcException e) { + logMessage("Failed to discover resource"); + Log.e(TAG, e.getMessage()); + } + logMessage("-----------------------------------------------------"); + } + + /** + * callback when a fridge resource is found. + */ + @Override + public synchronized void onResourceFound(OcResource ocResource) { + if ((null != fridgeResource) && !fridgeResource.getUri().equals("/fridge/group")) { + logMessage("Didn't find the correct fridge resource. Exiting"); + return; + } + fridgeResource = ocResource; + logMessage("Discovered a fridge with \nHost: " + fridgeResource.getHost()); + logMessage("Trying to call GET api on fridgeResource"); + try { + fridgeResource.get(new HashMap(), this); + } catch (OcException e) { + logMessage("Failed to call GET api"); + Log.e(TAG, e.getMessage()); + } + logMessage("-----------------------------------------------------"); + } + + /** + * once the fridge resource is discovered, create proxy child resources of the fridge + * and call GET on each of the child resource proxies. + * + * @param list + * @param ocRepresentation parent resource + */ + @Override + public synchronized void onGetCompleted(List list, + OcRepresentation ocRepresentation) { + logMessage("Got a response from " + ocRepresentation.getUri()); + for (OcRepresentation child : ocRepresentation.getChildren()) { + try { + logMessage("Creating child resource proxy from fridgeResource with uri " + + child.getUri()); + OcResource childResource = OcPlatform.constructResourceObject( + fridgeResource.getHost(), + child.getUri(), + fridgeResource.getConnectivityTypeSet(), + false, // isObservable set to false + child.getResourceTypes(), + child.getResourceInterfaces()); + childResourceList.add(childResource); + } catch (OcException e) { + logMessage("Error in creating child resource proxy"); + Log.e(TAG, e.getMessage()); + } + logMessage("-----------------------------------------------------"); + } + + OcResource.OnGetListener childOnGetListener = new OcResource.OnGetListener() { + public static final String DOOR_STATE_KEY = "state"; + public static final String DOOR_SIDE_KEY = "side"; + public static final String LIGHT_STATUS_KEY = "light"; + + @Override + public synchronized void onGetCompleted(List list, + OcRepresentation ocRepresentation) { + logMessage("Received a response from a child of the fridge with uri: " + + ocRepresentation.getUri()); + for (String resType : ocRepresentation.getResourceTypes()) { + if (resType.equals("intel.fridge.door")) { + try { + logMessage(ocRepresentation.getValue(DOOR_SIDE_KEY) + + " door is " + ((ocRepresentation.getValue(DOOR_STATE_KEY) + ) ? "open" : "close")); + } catch (OcException e) { + logMessage("Failed to get the door resource representation"); + Log.e(TAG, e.getMessage()); + } + } else if (resType.equals("intel.fridge.light")) { + try { + logMessage("Fridge light is " + + ((ocRepresentation.getValue(LIGHT_STATUS_KEY)) ? + "on" : "off")); + } catch (OcException e) { + logMessage("Failed to get the light resource representation"); + Log.e(TAG, e.getMessage()); + } + } + } + logMessage("-----------------------------------------------------"); + } + + @Override + public synchronized void onGetFailed(Throwable throwable) { + logMessage("OnGet failed for child of fridge"); + Log.e(TAG, throwable.getMessage()); + } + }; + + for (OcResource child : childResourceList) { + try { + logMessage("Trying to get a representation of " + child.getUri() + + " resource from server"); + child.get(new HashMap(), childOnGetListener); + } catch (OcException e) { + logMessage(e.getMessage()); + Log.e(TAG, e.getMessage()); + } + } + + } + + @Override + public synchronized void onGetFailed(Throwable throwable) { + logMessage("Failed to get representation of the fridge"); + Log.e(TAG, throwable.toString()); + } + + //****************************************************************************** + // End of the OIC specific code + //****************************************************************************** + private TextView mConsoleTextView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_fridge_client); + + mConsoleTextView = (TextView) findViewById(R.id.consoleTextView); + mConsoleTextView.setMovementMethod(new ScrollingMovementMethod()); + final Button button = (Button) findViewById(R.id.button); + + if (null == savedInstanceState) { + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + button.setEnabled(false); + new Thread(new Runnable() { + public void run() { + startFridgeClient(); + } + }).start(); + } + }); + } else { + String consoleOutput = savedInstanceState.getString("consoleOutputString"); + mConsoleTextView.setText(consoleOutput); + } + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + outState.putString("consoleOutputString", mConsoleTextView.getText().toString()); + } + + @Override + protected void onRestoreInstanceState(Bundle savedInstanceState) { + super.onRestoreInstanceState(savedInstanceState); + + String consoleOutput = savedInstanceState.getString("consoleOutputString"); + mConsoleTextView.setText(consoleOutput); + } + + private void logMessage(final String text) { + runOnUiThread(new Runnable() { + public void run() { + final Message msg = new Message(); + msg.obj = text; + mConsoleTextView.append("\n"); + mConsoleTextView.append(text); + } + }); + Log.i(TAG, text); + } +} \ No newline at end of file diff --git a/java/examples-java/fridgegroupserver/.gitignore b/java/examples-java/fridgegroupserver/.gitignore new file mode 100755 index 0000000..3543521 --- /dev/null +++ b/java/examples-java/fridgegroupserver/.gitignore @@ -0,0 +1 @@ +/build diff --git a/android/examples/fridgegroupserver/build.gradle b/java/examples-java/fridgegroupserver/build.gradle similarity index 100% rename from android/examples/fridgegroupserver/build.gradle rename to java/examples-java/fridgegroupserver/build.gradle diff --git a/java/examples-java/fridgegroupserver/src/main/java/org/iotivity/base/examples/DoorResource.java b/java/examples-java/fridgegroupserver/src/main/java/org/iotivity/base/examples/DoorResource.java new file mode 100755 index 0000000..63d02ae --- /dev/null +++ b/java/examples-java/fridgegroupserver/src/main/java/org/iotivity/base/examples/DoorResource.java @@ -0,0 +1,172 @@ +/* + ******************************************************************* + * + * 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; + +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.OcResourceHandle; +import org.iotivity.base.OcResourceRequest; +import org.iotivity.base.OcResourceResponse; +import org.iotivity.base.RequestHandlerFlag; +import org.iotivity.base.ResourceProperty; + +import java.util.EnumSet; + +/** + * DoorResource + *

+ * DoorResource is a sample OIC server resource created by the refrigerator. + */ +public class DoorResource extends Resource implements OcPlatform.EntityHandler { + DoorResource(String side, Context context) { + mContext = context; + mSide = side; + + registerDoorResource(); + } + + private void registerDoorResource() { + String resourceURI = DOOR_URI + mSide; + logMessage(TAG + "RegisterDoorResource " + resourceURI + " : " + RESOURCE_TYPEDOOR); + try { + mResourceHandle = OcPlatform.registerResource( + resourceURI, + RESOURCE_TYPEDOOR, + OcPlatform.DEFAULT_INTERFACE, + this, + EnumSet.of(ResourceProperty.DISCOVERABLE)); + } catch (OcException e) { + logMessage(TAG + "Failed to register DoorResource"); + Log.e(TAG, e.getMessage()); + } + logMessage("-----------------------------------------------------"); + } + + /** + * sample implementation of eventHandler for doorResource - this can be implemented in many + * different ways + * + * @param ocResourceRequest OcResourceRequest from the client + * @return EntityHandlerResult indicates whether the request was handled successfully or not + */ + @Override + public synchronized EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) { + EntityHandlerResult result = EntityHandlerResult.ERROR; + if (null != ocResourceRequest) { + try { + if (ocResourceRequest.getRequestHandlerFlagSet().contains( + RequestHandlerFlag.REQUEST)) { + OcResourceResponse response = new OcResourceResponse(); + response.setRequestHandle(ocResourceRequest.getRequestHandle()); + response.setResourceHandle(ocResourceRequest.getResourceHandle()); + + switch (ocResourceRequest.getRequestType()) { + case GET: + response.setErrorCode(Resource.SUCCESS); + updateRepresentationValues(); + response.setResourceRepresentation(mRepresentation); + response.setResponseResult(EntityHandlerResult.OK); + OcPlatform.sendResponse(response); + break; + case PUT: + response.setErrorCode(Resource.SUCCESS); + put(ocResourceRequest.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("Error in handleEntity of DoorResource"); + Log.e(TAG, e.getMessage()); + return EntityHandlerResult.ERROR; + } + } + logMessage("-----------------------------------------------------"); + return result; + } + + public OcResourceHandle getHandle() { + return mResourceHandle; + } + + /** + * helper function to update the current value of the door resource + */ + private void updateRepresentationValues() { + try { + mRepresentation.setValue(DOOR_STATE_KEY, mDoorState); + mRepresentation.setValue(DOOR_SIDE_KEY, mSide); + logMessage(TAG + "door state is " + ((mDoorState == true) ? "open" : "close") + + " and door side is " + mSide); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + } + + /** + * update the value of doorResource, depending on if door is open/ closed + * + * @param representation new state of a door + */ + private void put(OcRepresentation representation) { + try { + mDoorState = representation.getValue(DOOR_STATE_KEY); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + // Note, we won't let the user change the door side! + } + + //****************************************************************************** + // End of the OIC specific code + //****************************************************************************** + private Context mContext; + private String mSide; + private boolean mDoorState; + public static final String DOOR_URI = "/door/"; + public static final String RESOURCE_TYPEDOOR = "intel.fridge.door"; + private static String TAG = "DoorResource: "; + public static final String DOOR_STATE_KEY = "state"; + public static final String DOOR_SIDE_KEY = "side"; + + private void logMessage(String msg) { + Intent intent = new Intent(Resource.INTENT); + intent.putExtra(Resource.MESSAGE, msg); + mContext.sendBroadcast(intent); + } +} \ No newline at end of file diff --git a/java/examples-java/fridgegroupserver/src/main/java/org/iotivity/base/examples/FridgeGroupServer.java b/java/examples-java/fridgegroupserver/src/main/java/org/iotivity/base/examples/FridgeGroupServer.java new file mode 100755 index 0000000..4ee0aca --- /dev/null +++ b/java/examples-java/fridgegroupserver/src/main/java/org/iotivity/base/examples/FridgeGroupServer.java @@ -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. + * + *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base.examples; + +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.text.method.ScrollingMovementMethod; +import android.util.Log; +import android.view.View; +import android.widget.Button; +import android.widget.ScrollView; +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; + +/** + * FridgeGroupServer + *

+ * This is the main fridgeGroupServer class. This instantiates Refrigerator object + * which has different resources such as LightResource, DoorResource, etc. + */ +public class FridgeGroupServer extends Activity { + private Refrigerator refrigerator; + + /** + * configure OIC platform and call findResource + */ + private void startFridgeServer() { + logMessage("Configuring platform config"); + PlatformConfig cfg = new PlatformConfig( + this, // context + ServiceType.IN_PROC, + ModeType.SERVER, + "0.0.0.0", // bind to all available interfaces + 0, + QualityOfService.LOW); + OcPlatform.Configure(cfg); + + logMessage("Creating refrigerator resources"); + refrigerator = new Refrigerator(this); + logMessage("-----------------------------------------------------"); + } + + //****************************************************************************** + // End of the OIC specific code + //****************************************************************************** + private static String TAG = "FridgeServer: "; + private TextView mConsoleTextView; + private ScrollView mScrollView; + private BroadcastReceiver mMessageReceiver = new MessageReceiver(); + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_fridge_server); + registerReceiver(mMessageReceiver, new IntentFilter(Resource.INTENT)); + + mConsoleTextView = (TextView) findViewById(R.id.consoleTextView); + mConsoleTextView.setMovementMethod(new ScrollingMovementMethod()); + mScrollView = (ScrollView) findViewById(R.id.scrollView); + mScrollView.fullScroll(View.FOCUS_DOWN); + final Button button = (Button) findViewById(R.id.button); + + if (null == savedInstanceState) { + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + button.setEnabled(false); + new Thread(new Runnable() { + public void run() { + startFridgeServer(); + } + }).start(); + } + }); + } else { + String consoleOutput = savedInstanceState.getString("consoleOutputString"); + mConsoleTextView.setText(consoleOutput); + } + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + outState.putString("consoleOutputString", mConsoleTextView.getText().toString()); + } + + @Override + protected void onRestoreInstanceState(Bundle savedInstanceState) { + super.onRestoreInstanceState(savedInstanceState); + String consoleOutput = savedInstanceState.getString("consoleOutputString"); + mConsoleTextView.setText(consoleOutput); + } + + public class MessageReceiver extends BroadcastReceiver { + @Override + public void onReceive(Context context, Intent intent) { + final String message = intent.getStringExtra(Resource.MESSAGE); + logMessage(message); + } + } + + private void logMessage(final String text) { + runOnUiThread(new Runnable() { + public void run() { + final Message msg = new Message(); + msg.obj = text; + mConsoleTextView.append("\n"); + mConsoleTextView.append(text); + } + }); + Log.i(TAG, text); + } +} diff --git a/java/examples-java/fridgegroupserver/src/main/java/org/iotivity/base/examples/FridgeResource.java b/java/examples-java/fridgegroupserver/src/main/java/org/iotivity/base/examples/FridgeResource.java new file mode 100755 index 0000000..dc10327 --- /dev/null +++ b/java/examples-java/fridgegroupserver/src/main/java/org/iotivity/base/examples/FridgeResource.java @@ -0,0 +1,82 @@ +/* + ******************************************************************* + * + * 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; + +import android.content.Context; +import android.content.Intent; +import android.util.Log; + +import org.iotivity.base.OcException; +import org.iotivity.base.OcPlatform; +import org.iotivity.base.OcResourceHandle; +import org.iotivity.base.ResourceProperty; + +import java.util.EnumSet; + + +/** + * FridgeResource + *

+ * FridgeResource is a sample OIC server resource created by the refrigerator. + */ +public class FridgeResource extends Resource { + FridgeResource(Context context) { + mContext = context; + registerFridgeResource(); + } + + private void registerFridgeResource() { + try { + logMessage(TAG + "RegisterFridgeResource " + FRIDGE_URI + + " : " + FRIDGE_TYPENAME); + mResourceHandle = OcPlatform.registerResource( + FRIDGE_URI, + FRIDGE_TYPENAME, + OcPlatform.GROUP_INTERFACE, + null, + EnumSet.of(ResourceProperty.DISCOVERABLE)); + } catch (OcException e) { + logMessage(TAG + "FridgeResource register error: " + e.getMessage()); + Log.e(TAG, e.getMessage()); + } + logMessage("-----------------------------------------------------"); + } + + public OcResourceHandle getHandle() { + return mResourceHandle; + } + + //****************************************************************************** + // End of the OIC specific code + //****************************************************************************** + private Context mContext; + public static final String FRIDGE_URI = "/fridge/group"; + public static final String FRIDGE_TYPENAME = "intel.fridge.group"; + private static String TAG = "FridgeResource: "; + + private void logMessage(String msg) { + Intent intent = new Intent(Resource.INTENT); + intent.putExtra("message", msg); + mContext.sendBroadcast(intent); + } +} diff --git a/java/examples-java/fridgegroupserver/src/main/java/org/iotivity/base/examples/LightResource.java b/java/examples-java/fridgegroupserver/src/main/java/org/iotivity/base/examples/LightResource.java new file mode 100755 index 0000000..79f8347 --- /dev/null +++ b/java/examples-java/fridgegroupserver/src/main/java/org/iotivity/base/examples/LightResource.java @@ -0,0 +1,161 @@ +/* + ******************************************************************* + * + * 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; + +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.OcResourceHandle; +import org.iotivity.base.OcResourceRequest; +import org.iotivity.base.OcResourceResponse; +import org.iotivity.base.RequestHandlerFlag; +import org.iotivity.base.ResourceProperty; + +import java.util.EnumSet; + + +/** + * LightResource + *

+ * LightResource is a sample OIC server resource created by the refrigerator. + */ +public class LightResource extends Resource implements OcPlatform.EntityHandler { + LightResource(Context context) { + mContext = context; + + registerLightResource(); + } + + private void registerLightResource() { + try { + logMessage(TAG + "RegisterLightResource " + LIGHT_URI + " : " + RESOURCE_TYPELIGHT); + mResourceHandle = OcPlatform.registerResource( + LIGHT_URI, + RESOURCE_TYPELIGHT, + OcPlatform.DEFAULT_INTERFACE, + this, + EnumSet.of(ResourceProperty.DISCOVERABLE)); + } catch (OcException e) { + logMessage(TAG + "Failed to register LightResource"); + Log.e(TAG, e.getMessage()); + } + logMessage("-----------------------------------------------------"); + } + + /** + * sample implementation of eventHandler for lightResource - this can be implemented in many + * different ways + * + * @param ocResourceRequest OcResourceRequest from the client + * @return EntityHandlerResult indicates whether the request was handled successfully or not + */ + @Override + public synchronized EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) { + EntityHandlerResult result = EntityHandlerResult.ERROR; + if (null != ocResourceRequest) { + try { + if (ocResourceRequest.getRequestHandlerFlagSet().contains( + RequestHandlerFlag.REQUEST)) { + OcResourceResponse response = new OcResourceResponse(); + response.setRequestHandle(ocResourceRequest.getRequestHandle()); + response.setResourceHandle(ocResourceRequest.getResourceHandle()); + switch (ocResourceRequest.getRequestType()) { + case GET: + response.setErrorCode(Resource.SUCCESS); + updateRepresentationValues(); + response.setResourceRepresentation(mRepresentation); + response.setResponseResult(EntityHandlerResult.OK); + OcPlatform.sendResponse(response); + result = EntityHandlerResult.OK; + break; + case PUT: + response.setErrorCode(Resource.SUCCESS); + put(ocResourceRequest.getResourceRepresentation()); + updateRepresentationValues(); + response.setResourceRepresentation(mRepresentation); + response.setResponseResult(EntityHandlerResult.OK); + OcPlatform.sendResponse(response); + result = EntityHandlerResult.OK; + break; + } + } + } catch (OcException e) { + logMessage("Error in handleEntity"); + Log.e(TAG, e.getMessage()); + return EntityHandlerResult.ERROR; + } + } + logMessage("-----------------------------------------------------"); + return result; + } + + public OcResourceHandle getHandle() { + return mResourceHandle; + } + + /** + * update the value of light (ON/ OFF) from the representation + * + * @param representation new state of light + */ + private void put(OcRepresentation representation) { + try { + mIsLightOn = representation.getValue(LIGHT_STATUS_KEY); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + } + + /** + * helper function to update the current state of the light + */ + private void updateRepresentationValues() { + try { + mRepresentation.setValue(LIGHT_STATUS_KEY, mIsLightOn); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + } + + //****************************************************************************** + // End of the OIC specific code + //****************************************************************************** + private Context mContext; + private boolean mIsLightOn = false; + + private static String TAG = "LightResource: "; + public static final String LIGHT_URI = "/light"; + public static final String RESOURCE_TYPELIGHT = "intel.fridge.light"; + public static final String LIGHT_STATUS_KEY = "light"; + + private void logMessage(String msg) { + Intent intent = new Intent(Resource.INTENT); + intent.putExtra(Resource.MESSAGE, msg); + mContext.sendBroadcast(intent); + } +} diff --git a/java/examples-java/fridgegroupserver/src/main/java/org/iotivity/base/examples/Refrigerator.java b/java/examples-java/fridgegroupserver/src/main/java/org/iotivity/base/examples/Refrigerator.java new file mode 100755 index 0000000..3a48b36 --- /dev/null +++ b/java/examples-java/fridgegroupserver/src/main/java/org/iotivity/base/examples/Refrigerator.java @@ -0,0 +1,62 @@ +/* + ******************************************************************* + * + * 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; + +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 { + public static final String LEFT_SIDE = "left"; + public static final String RIGHT_SIDE = "right"; + public static final String RANDOM_SIDE = "random"; + + private FridgeResource mFridge; + private LightResource mLight; + private DoorResource mLeftDoor; + private DoorResource mRightDoor; + private DoorResource mRandomDoor; + + /** + * constructor - creates resources of light and doors + * + * @param context needed by individual resources to be able to send broadcast + * messages to be displayed on the user screen + */ + Refrigerator(Context context) { + mFridge = new FridgeResource(context); + mLight = new LightResource(context); + mLeftDoor = new DoorResource(LEFT_SIDE, context); + mRightDoor = new DoorResource(RIGHT_SIDE, context); + mRandomDoor = new DoorResource(RANDOM_SIDE, context); + + mLight.bindTo(mFridge.getHandle()); + mLeftDoor.bindTo(mFridge.getHandle()); + mRightDoor.bindTo(mFridge.getHandle()); + mRandomDoor.bindTo(mFridge.getHandle()); + } +} \ No newline at end of file diff --git a/java/examples-java/fridgegroupserver/src/main/java/org/iotivity/base/examples/Resource.java b/java/examples-java/fridgegroupserver/src/main/java/org/iotivity/base/examples/Resource.java new file mode 100755 index 0000000..6934546 --- /dev/null +++ b/java/examples-java/fridgegroupserver/src/main/java/org/iotivity/base/examples/Resource.java @@ -0,0 +1,59 @@ +/* + ******************************************************************* + * + * 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; + +import android.util.Log; + +import org.iotivity.base.OcException; +import org.iotivity.base.OcPlatform; +import org.iotivity.base.OcRepresentation; +import org.iotivity.base.OcResourceHandle; + +/** + * Resource + *

+ * Each of the other resource classes (DeviceResource, DoorResource and LightResource extend Resource + */ +public abstract class Resource { + protected OcResourceHandle mResourceHandle; + protected OcRepresentation mRepresentation; + + Resource() { + mResourceHandle = null; + mRepresentation = new OcRepresentation(); + } + + public void bindTo(OcResourceHandle collectionResourceHandle) { + try { + if (null != mResourceHandle && null != collectionResourceHandle) { + OcPlatform.bindResource(collectionResourceHandle, mResourceHandle); + } + } catch (OcException e) { + Log.e("Resource", e.getMessage()); + } + } + + public static final int SUCCESS = 200; + public static final String INTENT = "org.iotivity.base.examples.fridgegroupserver"; + public static final String MESSAGE = "message"; +} \ No newline at end of file diff --git a/java/examples-java/fridgeserver/.gitignore b/java/examples-java/fridgeserver/.gitignore new file mode 100755 index 0000000..3543521 --- /dev/null +++ b/java/examples-java/fridgeserver/.gitignore @@ -0,0 +1 @@ +/build diff --git a/android/examples/fridgeserver/build.gradle b/java/examples-java/fridgeserver/build.gradle similarity index 100% rename from android/examples/fridgeserver/build.gradle rename to java/examples-java/fridgeserver/build.gradle diff --git a/java/examples-java/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DeviceResource.java b/java/examples-java/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DeviceResource.java new file mode 100755 index 0000000..b4338fa --- /dev/null +++ b/java/examples-java/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DeviceResource.java @@ -0,0 +1,165 @@ +/* + ******************************************************************* + * + * 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; + +/** + * DeviceResource + *

+ * Creates a device resource and performs action based on client requests + */ +public class DeviceResource extends Resource implements OcPlatform.EntityHandler { + public static final String DEVICE_URI = "/device"; + public static final String RESOURCE_TYPENAME = "intel.fridge"; + public static final String API_VERSION = "v.1.0"; + public static final String CLIENT_TOKEN = "21ae43gf"; + public static final String DEVICE_NAME = "device_name"; + private static String TAG = "DeviceResource: "; + public static final int SUCCESS = 200; + public static final int API_VERSION_KEY = 2048; + public static final int CLIENT_VERSION_KEY = 3000; + + private Context mContext; + + /** + * constructor + * + * @param context to enable sending of broadcast messages to be displayed on the user screen + */ + DeviceResource(Context context) { + mContext = context; + registerDeviceResource(); + } + + private void registerDeviceResource() { + try { + logMessage("RegisterDeviceResource " + DEVICE_URI + " : " + RESOURCE_TYPENAME); + mResourceHandle = OcPlatform.registerResource( + DEVICE_URI, + RESOURCE_TYPENAME, + OcPlatform.DEFAULT_INTERFACE, + this, + EnumSet.of(ResourceProperty.DISCOVERABLE)); + } catch (OcException e) { + logMessage(TAG + "Failed to register DeviceResource"); + Log.e(TAG, e.getMessage()); + } + } + + /** + * this is the main method which handles different incoming requests appropriately. + * + * @param ocResourceRequest OcResourceRequest from the client + * @return EntityHandlerResult indicates whether the request was handled successfully or not + */ + @Override + public synchronized EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) { + EntityHandlerResult result = EntityHandlerResult.ERROR; + if (null != ocResourceRequest) { + List headerOptions = ocResourceRequest.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 (API_VERSION_KEY == optionId) { + clientAPIVersion = headerOption.getOptionData(); + logMessage(TAG + " Client API Version: " + clientAPIVersion); + } else if (CLIENT_VERSION_KEY == optionId) { + clientToken = headerOption.getOptionData(); + logMessage(TAG + " Client Token: " + clientToken); + } + } + if (clientAPIVersion.equals(API_VERSION) && + clientToken.equals(CLIENT_TOKEN)) { + List serverHeaderOptions = new LinkedList<>(); + OcHeaderOption apiVersion = new OcHeaderOption(API_VERSION_KEY, + API_VERSION); + serverHeaderOptions.add(apiVersion); + try { + if (ocResourceRequest.getRequestHandlerFlagSet().contains(RequestHandlerFlag.REQUEST)) { + OcResourceResponse response = new OcResourceResponse(); + response.setRequestHandle(ocResourceRequest.getRequestHandle()); + response.setResourceHandle(ocResourceRequest.getResourceHandle()); + response.setHeaderOptions(serverHeaderOptions); + + switch (ocResourceRequest.getRequestType()) { + case GET: + response.setErrorCode(SUCCESS); + response.setResponseResult(EntityHandlerResult.OK); + updateRepresentationValues(); + response.setResourceRepresentation(mRepresentation); + OcPlatform.sendResponse(response); + break; + } + result = EntityHandlerResult.OK; + } + } catch (OcException e) { + logMessage("Error in handleEntity of DeviceResource"); + Log.e(TAG, e.getMessage()); + } + } + } + logMessage("-----------------------------------------------------"); + return result; + } + + /** + * update state of device + * + * @return device representation + */ + private void updateRepresentationValues() { + try { + mRepresentation.setValue(DEVICE_NAME, + "Intel Powered 3 door, 1 light refrigerator"); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + } + + //****************************************************************************** + // End of the OIC specific code + //****************************************************************************** + public void logMessage(String msg) { + Intent intent = new Intent(FridgeServer.INTENT); + intent.putExtra("message", msg); + mContext.sendBroadcast(intent); + } +} diff --git a/java/examples-java/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DoorResource.java b/java/examples-java/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DoorResource.java new file mode 100755 index 0000000..8302468 --- /dev/null +++ b/java/examples-java/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DoorResource.java @@ -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. + * + *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +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; + +/** + * DoorResource + *

+ * Creates a door resource and performs actions based on the client requests + */ +public class DoorResource extends Resource implements OcPlatform.EntityHandler { + public static final String DOOR_URI = "/door/"; + public static final String RESOURCE_TYPEDOOR = "intel.fridge.door"; + public static final String DOOR_STATE_KEY = "state"; + public static final String DOOR_SIDE_KEY = "side"; + private boolean mDoorState; + private String mSide; + + /** + * Constructor + * + * @param side 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; + registerDoorResource(); + } + + private void registerDoorResource() { + String resourceURI = DOOR_URI + mSide; + logMessage(TAG + "RegisterDoorResource " + resourceURI + " : " + RESOURCE_TYPEDOOR); + try { + mResourceHandle = OcPlatform.registerResource(resourceURI, + RESOURCE_TYPEDOOR, + OcPlatform.DEFAULT_INTERFACE, + this, + EnumSet.of(ResourceProperty.DISCOVERABLE)); + } catch (OcException e) { + logMessage(TAG + "Failed to register DoorResource"); + Log.e(TAG, e.getMessage()); + } + } + + /** + * this is the main method which handles different incoming requests appropriately. + * + * @param ocResourceRequest OcResourceRequest from the client + * @return EntityHandlerResult indicates whether the request was handled successfully or not + */ + @Override + public synchronized EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) { + EntityHandlerResult result = EntityHandlerResult.ERROR; + if (null != ocResourceRequest) { + try { + if (ocResourceRequest.getRequestHandlerFlagSet().contains(RequestHandlerFlag.REQUEST)) { + OcResourceResponse response = new OcResourceResponse(); + response.setRequestHandle(ocResourceRequest.getRequestHandle()); + response.setResourceHandle(ocResourceRequest.getResourceHandle()); + + switch (ocResourceRequest.getRequestType()) { + case GET: + response.setErrorCode(SUCCESS); + updateRepresentationValues(); + response.setResourceRepresentation(mRepresentation); + response.setResponseResult(EntityHandlerResult.OK); + OcPlatform.sendResponse(response); + break; + case PUT: + response.setErrorCode(SUCCESS); + put(ocResourceRequest.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("Error in handleEntity of DoorResource"); + Log.e(TAG, e.getMessage()); + return EntityHandlerResult.ERROR; + } + } + logMessage("-----------------------------------------------------"); + return result; + } + + /** + * helper function to update the current value of the door resource + */ + private void updateRepresentationValues() { + try { + mRepresentation.setValue(DOOR_STATE_KEY, mDoorState); + mRepresentation.setValue(DOOR_SIDE_KEY, mSide); + logMessage(TAG + "door state is " + ((mDoorState == true) ? "open" : "close") + + " and door side is " + mSide); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + } + + /** + * update the value of doorResource, depending on if door is open/ closed + * + * @param representation new state of a door + */ + private void put(OcRepresentation representation) { + try { + mDoorState = representation.getValue(DOOR_STATE_KEY); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + // Note, we won't let the user change the door side! + } + + //****************************************************************************** + // End of the OIC specific code + //****************************************************************************** + private Context mContext; + private static String TAG = "DoorResource: "; + + public void logMessage(String msg) { + Intent intent = new Intent(FridgeServer.INTENT); + intent.putExtra(FridgeServer.MESSAGE, msg); + mContext.sendBroadcast(intent); + } +} \ No newline at end of file diff --git a/java/examples-java/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/FridgeServer.java b/java/examples-java/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/FridgeServer.java new file mode 100755 index 0000000..5f0c962 --- /dev/null +++ b/java/examples-java/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/FridgeServer.java @@ -0,0 +1,132 @@ +/* + ******************************************************************* + * + * 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.text.method.ScrollingMovementMethod; +import android.util.Log; +import android.view.View; +import android.widget.Button; +import android.widget.ScrollView; +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; + +/** + * FridgeServer + *

+ * This is the main fridgeServer class. This instantiates Refrigerator object + * which has different resources (DeviceResource, LightResource, DoorResources). + */ +public class FridgeServer extends Activity { + private Refrigerator refrigerator; + + /** + * configure OIC platform and call findResource + */ + private void startFridgeServer() { + //create platform config + PlatformConfig cfg = new PlatformConfig( + this, //context + ServiceType.IN_PROC, + ModeType.SERVER, + "0.0.0.0", // bind to all available interfaces + 0, + QualityOfService.LOW); + logMessage("Configuring platform"); + OcPlatform.Configure(cfg); + logMessage("Creating refrigerator resources"); + refrigerator = new Refrigerator(this); + logMessage("-----------------------------------------------------"); + } + + //****************************************************************************** + // End of the OIC specific code + //****************************************************************************** + private static String TAG = "FridgeServer: "; + public static final String MESSAGE = "message"; + public static final String INTENT = "org.iotivity.base.examples.fridgeserver"; + private TextView mConsoleTextView; + private ScrollView mScrollView; + private MessageReceiver mMessageReceiver = new MessageReceiver(); + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_fridge_server); + registerReceiver(mMessageReceiver, new IntentFilter(INTENT)); + + mConsoleTextView = (TextView) findViewById(R.id.consoleTextView); + mConsoleTextView.setMovementMethod(new ScrollingMovementMethod()); + mScrollView = (ScrollView) findViewById(R.id.scrollView); + mScrollView.fullScroll(View.FOCUS_DOWN); + final Button button = (Button) findViewById(R.id.button); + + if (null == savedInstanceState) { + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + button.setEnabled(false); + new Thread(new Runnable() { + public void run() { + startFridgeServer(); + } + }).start(); + } + }); + } else { + String consoleOutput = savedInstanceState.getString("consoleOutputString"); + mConsoleTextView.setText(consoleOutput); + } + } + + public class MessageReceiver extends BroadcastReceiver { + @Override + public void onReceive(Context context, Intent intent) { + final String message = intent.getStringExtra(MESSAGE); + logMessage(message); + } + } + + public void logMessage(final String text) { + runOnUiThread(new Runnable() { + public void run() { + final Message msg = new Message(); + msg.obj = text; + mConsoleTextView.append("\n"); + mConsoleTextView.append(text); + } + }); + Log.i(TAG, text); + } +} diff --git a/java/examples-java/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/LightResource.java b/java/examples-java/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/LightResource.java new file mode 100755 index 0000000..cf3d549 --- /dev/null +++ b/java/examples-java/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/LightResource.java @@ -0,0 +1,159 @@ +/* + ******************************************************************* + * + * 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; + +/** + * LightResource + *

+ * Creates a light resource and performs actions based on the client requests + */ +public class LightResource extends Resource implements OcPlatform.EntityHandler { + public static final String LIGHT_STATUS_KEY = "light"; + public static final String LIGHT_URI = "/light"; + public static final String RESOURCE_TYPELIGHT = "intel.fridge.light"; + private boolean mIsLightOn = false; + + /** + * constructor + * + * @param context to enable sending of broadcast messages to be displayed on the user screen + */ + LightResource(Context context) { + mContext = context; + registerLightResource(); + } + + private void registerLightResource() { + try { + logMessage(TAG + "RegisterLightResource " + LIGHT_URI + " : " + RESOURCE_TYPELIGHT); + mResourceHandle = OcPlatform.registerResource(LIGHT_URI, + RESOURCE_TYPELIGHT, + OcPlatform.DEFAULT_INTERFACE, + this, + EnumSet.of(ResourceProperty.DISCOVERABLE)); + } catch (OcException e) { + logMessage(TAG + "Failed to register LightResource"); + Log.e(TAG, e.getMessage()); + } + logMessage("-----------------------------------------------------"); + } + + /** + * this is the main method which handles different incoming requests appropriately. + * + * @param ocResourceRequest OcResourceRequest from the client + * @return EntityHandlerResult indicates whether the request was handled successfully or not + */ + @Override + public synchronized EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) { + EntityHandlerResult result = EntityHandlerResult.ERROR; + if (null != ocResourceRequest) { + try { + if (ocResourceRequest.getRequestHandlerFlagSet().contains(RequestHandlerFlag.REQUEST)) { + OcResourceResponse response = new OcResourceResponse(); + response.setRequestHandle(ocResourceRequest.getRequestHandle()); + response.setResourceHandle(ocResourceRequest.getResourceHandle()); + + switch (ocResourceRequest.getRequestType()) { + case GET: + response.setErrorCode(SUCCESS); + updateRepresentationValues(); + response.setResourceRepresentation(mRepresentation); + response.setResponseResult(EntityHandlerResult.OK); + OcPlatform.sendResponse(response); + result = EntityHandlerResult.OK; + break; + case PUT: + response.setErrorCode(SUCCESS); + put(ocResourceRequest.getResourceRepresentation()); + updateRepresentationValues(); + response.setResourceRepresentation(mRepresentation); + response.setResponseResult(EntityHandlerResult.OK); + OcPlatform.sendResponse(response); + result = EntityHandlerResult.OK; + break; + } + } + } catch (OcException e) { + logMessage("Error in handleEntity of LightResource"); + Log.e(TAG, e.getMessage()); + return EntityHandlerResult.ERROR; + } + } + logMessage("-----------------------------------------------------"); + return result; + } + + /** + * updates the current state of the light (on/ off) + * + * @return light is on or off + */ + private void updateRepresentationValues() { + try { + mRepresentation.setValue(LIGHT_STATUS_KEY, mIsLightOn); + } 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 { + mIsLightOn = representation.getValue(LIGHT_STATUS_KEY); + } catch (OcException e) { + Log.e(TAG, e.getMessage()); + } + } + + //****************************************************************************** + // End of the OIC specific code + //****************************************************************************** + private Context mContext; + private static String TAG = "LightResource: "; + + public void logMessage(String msg) { + Intent intent = new Intent(FridgeServer.INTENT); + intent.putExtra(FridgeServer.MESSAGE, msg); + mContext.sendBroadcast(intent); + } +} diff --git a/java/examples-java/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Refrigerator.java b/java/examples-java/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Refrigerator.java new file mode 100755 index 0000000..6717650 --- /dev/null +++ b/java/examples-java/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Refrigerator.java @@ -0,0 +1,62 @@ +/* + ******************************************************************* + * + * 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. + */ +public class Refrigerator { + public static final String LEFT_SIDE = "left"; + public static final String RIGHT_SIDE = "right"; + public static final String RANDOM_SIDE = "random"; + + 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) { + mLight = new LightResource(context); + mDevice = new DeviceResource(context); + mLeftDoor = new DoorResource(LEFT_SIDE, context); + mRightDoor = new DoorResource(RIGHT_SIDE, context); + mRandomDoor = new DoorResource(RANDOM_SIDE, context); + + mLight.bindTo(mDevice.getHandle()); + mLeftDoor.bindTo(mDevice.getHandle()); + mRightDoor.bindTo(mDevice.getHandle()); + mRandomDoor.bindTo(mDevice.getHandle()); + } +} diff --git a/java/examples-java/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Resource.java b/java/examples-java/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Resource.java new file mode 100755 index 0000000..987c414 --- /dev/null +++ b/java/examples-java/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Resource.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.examples.fridgeserver; + +import android.util.Log; + +import org.iotivity.base.OcException; +import org.iotivity.base.OcPlatform; +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(); + } + + public void bindTo(OcResourceHandle collectionResourceHandle) { + try { + if (null != mResourceHandle && null != collectionResourceHandle) { + OcPlatform.bindResource(collectionResourceHandle, mResourceHandle); + } + } catch (OcException e) { + Log.e("Resource", e.getMessage()); + } + } + + public OcResourceHandle getHandle() { + return mResourceHandle; + } + + public static final int SUCCESS = 200; +} \ No newline at end of file diff --git a/java/examples-java/gradle.properties b/java/examples-java/gradle.properties new file mode 100644 index 0000000..9046951 --- /dev/null +++ b/java/examples-java/gradle.properties @@ -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. +# // +# //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +# + +# 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 +TARGET_ARCH=armeabi +RELEASE=release +SECURED=1 +ERROR_MSG="if building examples from android-studio, you might need to modify the default TARGET_ARCH\ + and RELEASE in /android/examples/gradle.properties,\ + if your aar file has different values for TARGET_ARCH and RELEASE" + diff --git a/android/android_api/gradle/wrapper/gradle-wrapper.jar b/java/examples-java/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from android/android_api/gradle/wrapper/gradle-wrapper.jar rename to java/examples-java/gradle/wrapper/gradle-wrapper.jar diff --git a/java/examples-java/gradle/wrapper/gradle-wrapper.properties b/java/examples-java/gradle/wrapper/gradle-wrapper.properties new file mode 100755 index 0000000..cdc433f --- /dev/null +++ b/java/examples-java/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Wed Apr 10 15:27:10 PDT 2013 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip diff --git a/android/android_api/gradlew b/java/examples-java/gradlew similarity index 100% rename from android/android_api/gradlew rename to java/examples-java/gradlew diff --git a/android/android_api/gradlew.bat b/java/examples-java/gradlew.bat similarity index 100% rename from android/android_api/gradlew.bat rename to java/examples-java/gradlew.bat diff --git a/java/examples-java/groupclient/.gitignore b/java/examples-java/groupclient/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/java/examples-java/groupclient/.gitignore @@ -0,0 +1 @@ +/build diff --git a/android/examples/groupclient/build.gradle b/java/examples-java/groupclient/build.gradle similarity index 100% rename from android/examples/groupclient/build.gradle rename to java/examples-java/groupclient/build.gradle diff --git a/java/examples-java/groupclient/src/main/java/org/iotivity/base/examples/GroupClient.java b/java/examples-java/groupclient/src/main/java/org/iotivity/base/examples/GroupClient.java new file mode 100644 index 0000000..1cabcf9 --- /dev/null +++ b/java/examples-java/groupclient/src/main/java/org/iotivity/base/examples/GroupClient.java @@ -0,0 +1,295 @@ +/* + ******************************************************************* + * + * 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; + +import android.app.Activity; +import android.content.Context; +import android.os.Bundle; +import android.text.method.ScrollingMovementMethod; +import android.util.Log; +import android.view.View; +import android.widget.CompoundButton; +import android.widget.ScrollView; +import android.widget.TextView; +import android.widget.ToggleButton; + +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.EnumSet; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * GroupClient + */ +public class GroupClient extends Activity implements + OcPlatform.OnResourceFoundListener, + OcResource.OnGetListener { + + private OcResource mFoundCollectionResource; + + /** + * A local method to configure and initialize platform and then search for the collection + * resources + */ + private synchronized void startGroupClient() { + Context context = this; + + PlatformConfig platformConfig = new PlatformConfig( + context, + ServiceType.IN_PROC, + ModeType.CLIENT, + "0.0.0.0", 0, + QualityOfService.LOW + ); + + msg("Configuring platform."); + OcPlatform.Configure(platformConfig); + + msg("Find all resources of type \"a.collection\"."); + try { + OcPlatform.findResource( + "", + OcPlatform.WELL_KNOWN_QUERY + "?rt=a.collection", + EnumSet.of(OcConnectivityType.CT_DEFAULT), + this + ); + } catch (OcException e) { + Log.e(TAG, e.toString()); + msg("Failed to invoke find resource API"); + } + + printLine(); + } + + /** + * An event handler to be executed whenever a "findResource" request completes successfully + * + * @param foundResource found resource + */ + @Override + public synchronized void onResourceFound(OcResource foundResource) { + if (null == foundResource) { + msg("Found resource is invalid"); + return; + } + if (null != mFoundCollectionResource) { + msg("Found another resource, ignoring"); + return; + } + + // Get the resource URI + String resourceUri = foundResource.getUri(); + // Get the resource host address + String hostAddress = foundResource.getHost(); + msg("\tURI of the resource: " + resourceUri); + msg("\tHost address of the resource: " + hostAddress); + // Get the resource types + msg("\tList of resource types: "); + for (String resourceType : foundResource.getResourceTypes()) { + msg("\t\t" + resourceType); + } + msg("\tList of resource interfaces:"); + for (String resourceInterface : foundResource.getResourceInterfaces()) { + msg("\t\t" + resourceInterface); + } + msg("\tList of resource connectivity types:"); + for (OcConnectivityType connectivityType : foundResource.getConnectivityTypeSet()) { + msg("\t\t" + connectivityType); + } + + if (resourceUri.equals("/core/a/collection")) { + mFoundCollectionResource = foundResource; + + msg("Getting representation of a collection resource..."); + + Map queryParams = new HashMap<>(); + try { + mFoundCollectionResource.get( + "", + OcPlatform.DEFAULT_INTERFACE, + queryParams, + this + ); + } catch (OcException e) { + Log.e(TAG, e.toString()); + msg("Error occurred while invoking \"get\" API"); + } + } + + printLine(); + enableStartStopButton(); + } + + /** + * An event handler to be executed whenever a "get" request completes successfully + * + * @param list list of the header options + * @param representation representation of a resource + */ + @Override + public void onGetCompleted(List list, OcRepresentation representation) { + msg("Representation of a light collection resource:"); + for (OcRepresentation childRepresentation : representation.getChildren()) { + msg("\t\tURI: " + childRepresentation.getUri()); + } + } + + /** + * An event handler to be executed whenever a "get" request fails + * + * @param throwable exception + */ + @Override + public synchronized void onGetFailed(Throwable throwable) { + if (throwable instanceof OcException) { + OcException ocEx = (OcException) throwable; + Log.e(TAG, ocEx.toString()); + ErrorCode errCode = ocEx.getErrorCode(); + //do something based on errorCode + msg("Error code: " + errCode); + } + msg("Failed to get representation of a found collection resource"); + } + + /** + * A local method to reset group client + */ + private synchronized void stopGroupClient() { + mFoundCollectionResource = null; + + msg("Group Client is reset."); + printLine(); + + enableStartStopButton(); + } + + //****************************************************************************** + // End of the OIC specific code + //****************************************************************************** + + private final static String TAG = GroupClient.class.getSimpleName(); + private TextView mConsoleTextView; + private ScrollView mScrollView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_group_client); + + mConsoleTextView = (TextView) findViewById(R.id.consoleTextView); + mConsoleTextView.setMovementMethod(new ScrollingMovementMethod()); + mScrollView = (ScrollView) findViewById(R.id.scrollView); + mScrollView.fullScroll(View.FOCUS_DOWN); + final ToggleButton toggleButton = (ToggleButton) findViewById(R.id.toggleButton); + + if (null == savedInstanceState) { + toggleButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + toggleButton.setEnabled(false); + if (isChecked) { + new Thread(new Runnable() { + public void run() { + startGroupClient(); + } + }).start(); + } else { + new Thread(new Runnable() { + public void run() { + stopGroupClient(); + } + }).start(); + } + } + }); + } else { + String consoleOutput = savedInstanceState.getString("consoleOutputString"); + mConsoleTextView.setText(consoleOutput); + boolean buttonCheked = savedInstanceState.getBoolean("toggleButtonChecked"); + toggleButton.setChecked(buttonCheked); + } + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + outState.putString("consoleOutputString", mConsoleTextView.getText().toString()); + ToggleButton toggleButton = (ToggleButton) findViewById(R.id.toggleButton); + outState.putBoolean("toggleButtonChecked", toggleButton.isChecked()); + } + + @Override + protected void onRestoreInstanceState(Bundle savedInstanceState) { + super.onRestoreInstanceState(savedInstanceState); + + String consoleOutput = savedInstanceState.getString("consoleOutputString"); + mConsoleTextView.setText(consoleOutput); + + final ToggleButton toggleButton = (ToggleButton) findViewById(R.id.toggleButton); + boolean buttonCheked = savedInstanceState.getBoolean("toggleButtonChecked"); + toggleButton.setChecked(buttonCheked); + } + + private void msg(final String text) { + runOnUiThread(new Runnable() { + public void run() { + mConsoleTextView.append("\n"); + mConsoleTextView.append(text); + mScrollView.fullScroll(View.FOCUS_DOWN); + } + }); + Log.i(TAG, text); + } + + private void printLine() { + msg("------------------------------------------------------------------------"); + } + + private void sleep(int seconds) { + try { + Thread.sleep(seconds * 1000); + } catch (InterruptedException e) { + e.printStackTrace(); + Log.e(TAG, e.toString()); + } + } + + private void enableStartStopButton() { + runOnUiThread(new Runnable() { + public void run() { + ToggleButton toggleButton = (ToggleButton) findViewById(R.id.toggleButton); + toggleButton.setEnabled(true); + } + }); + } +} diff --git a/java/examples-java/groupserver/.gitignore b/java/examples-java/groupserver/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/java/examples-java/groupserver/.gitignore @@ -0,0 +1 @@ +/build diff --git a/android/examples/groupserver/build.gradle b/java/examples-java/groupserver/build.gradle similarity index 100% rename from android/examples/groupserver/build.gradle rename to java/examples-java/groupserver/build.gradle diff --git a/java/examples-java/groupserver/src/main/java/org/iotivity/base/examples/GroupServer.java b/java/examples-java/groupserver/src/main/java/org/iotivity/base/examples/GroupServer.java new file mode 100644 index 0000000..3aab27a --- /dev/null +++ b/java/examples-java/groupserver/src/main/java/org/iotivity/base/examples/GroupServer.java @@ -0,0 +1,333 @@ +/* + ******************************************************************* + * + * 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; + +import android.app.Activity; +import android.content.Context; +import android.os.Bundle; +import android.text.method.ScrollingMovementMethod; +import android.util.Log; +import android.view.View; +import android.widget.CompoundButton; +import android.widget.ScrollView; +import android.widget.TextView; +import android.widget.ToggleButton; + +import org.iotivity.base.ModeType; +import org.iotivity.base.OcConnectivityType; +import org.iotivity.base.OcException; +import org.iotivity.base.OcPlatform; +import org.iotivity.base.OcResource; +import org.iotivity.base.OcResourceHandle; +import org.iotivity.base.PlatformConfig; +import org.iotivity.base.QualityOfService; +import org.iotivity.base.ResourceProperty; +import org.iotivity.base.ServiceType; + +import java.util.EnumSet; +import java.util.LinkedList; +import java.util.List; + +/** + * GroupServer + */ +public class GroupServer extends Activity implements OcPlatform.OnResourceFoundListener { + + private OcResourceHandle mCollectionResourceHandle; + private List mProxyResourceHandleList = new LinkedList<>(); + + /** + * A local method to configure and initialize platform, register a collection resource + * and then search for the light resources.In addition it creates a local light resource and + * adds it to the collection. + */ + private synchronized void startGroupServer() { + Context context = this; + + PlatformConfig platformConfig = new PlatformConfig( + context, + ServiceType.IN_PROC, + ModeType.CLIENT_SERVER, + "0.0.0.0", 0, + QualityOfService.LOW + ); + + msg("Configuring platform."); + OcPlatform.Configure(platformConfig); + + String resourceUri = "/core/a/collection"; + String resourceTypeName = "a.collection"; + msg("Registering a collection resource."); + try { + mCollectionResourceHandle = OcPlatform.registerResource( + resourceUri, //resource URI + resourceTypeName, //resource type name + OcPlatform.BATCH_INTERFACE, //using batch interface + null, //use default entity handler + EnumSet.of(ResourceProperty.DISCOVERABLE) + ); + } catch (OcException e) { + Log.e(TAG, e.toString()); + msg("Failed to register a collection resource"); + } + + if (null != mCollectionResourceHandle) { + try { + OcPlatform.bindInterfaceToResource( + mCollectionResourceHandle, + OcPlatform.GROUP_INTERFACE); + + OcPlatform.bindInterfaceToResource( + mCollectionResourceHandle, + OcPlatform.DEFAULT_INTERFACE); + } catch (OcException e) { + e.printStackTrace(); + } + + } + + msg("Sending request to find all resources with \"core.light\" type name"); + try { + OcPlatform.findResource( + "", + OcPlatform.WELL_KNOWN_QUERY + "?rt=core.light", + EnumSet.of(OcConnectivityType.CT_DEFAULT), + this); + + } catch (OcException e) { + Log.e(TAG, e.toString()); + msg("Failed to invoke find resource API"); + } + + OcResourceHandle localLightResourceHandle = null; + msg("Registering a local light resource"); + try { + localLightResourceHandle = OcPlatform.registerResource( + "/a/light/local", //resource URI + "core.light", //resource type name + OcPlatform.DEFAULT_INTERFACE, //using default interface + null, //use default entity handler + EnumSet.of(ResourceProperty.DISCOVERABLE) + ); + } catch (OcException e) { + Log.e(TAG, e.toString()); + msg("Failed to register a local ligh resource"); + } + + if (null != localLightResourceHandle) { + msg("Binding a found resource proxy handle to the collection resource"); + try { + OcPlatform.bindResource(mCollectionResourceHandle, localLightResourceHandle); + } catch (OcException e) { + Log.e(TAG, e.toString()); + msg("Failed to bind found resource proxy handle to the collection resource"); + } + mProxyResourceHandleList.add(localLightResourceHandle); + } + + printLine(); + } + + /** + * An event handler to be executed whenever a "findResource" request completes successfully + * + * @param foundResource found resource + */ + @Override + public synchronized void onResourceFound(OcResource foundResource) { + if (null == foundResource) { + msg("Found resource is invalid"); + return; + } + msg("Found resource with \"core.light\" type name\"."); + // Get the resource host address + String hostAddress = foundResource.getHost(); + // Get the resource URI + String resourceUri = foundResource.getUri(); + msg("\tHost address of the resource: " + hostAddress); + msg("\tURI of the resource: " + resourceUri); + // Get the resource types + msg("\tList of resource types: "); + for (String resourceType : foundResource.getResourceTypes()) { + msg("\t\t" + resourceType); + } + msg("\tList of resource interfaces:"); + for (String resourceInterface : foundResource.getResourceInterfaces()) { + msg("\t\t" + resourceInterface); + } + msg("\tList of resource connectivity types:"); + for (OcConnectivityType connectivityType : foundResource.getConnectivityTypeSet()) { + msg("\t\t" + connectivityType); + } + + //In this example we are only interested in the light resources + if (resourceUri.equals("/a/light")) { + msg("Registering a found resource as a local proxy resource"); + OcResourceHandle proxyResourceHandle = null; + try { + proxyResourceHandle = OcPlatform.registerResource(foundResource); + } catch (OcException e) { + Log.e(TAG, e.toString()); + msg("Failed to register a found resource as a local proxy resource"); + } + + if (null != proxyResourceHandle) { + msg("Binding a found resource proxy handle to the collection resource"); + try { + OcPlatform.bindResource(mCollectionResourceHandle, proxyResourceHandle); + } catch (OcException e) { + Log.e(TAG, e.toString()); + msg("Failed to bind found resource proxy handle to the collection resource"); + } + mProxyResourceHandleList.add(proxyResourceHandle); + } + } + + printLine(); + enableStartStopButton(); + } + + /** + * A local method to reset group server + */ + private synchronized void stopGroupServer() { + msg("Unregistering resources"); + for (OcResourceHandle proxyResourceHandle : mProxyResourceHandleList) { + try { + OcPlatform.unbindResource(mCollectionResourceHandle, proxyResourceHandle); + } catch (OcException e) { + Log.e(TAG, e.toString()); + msg("Failed to unbind a proxy resource"); + } + try { + OcPlatform.unregisterResource(proxyResourceHandle); + } catch (OcException e) { + Log.e(TAG, e.toString()); + msg("Failed to unregister a proxy resource"); + } + } + mProxyResourceHandleList.clear(); + + if (null != mCollectionResourceHandle) { + try { + OcPlatform.unregisterResource(mCollectionResourceHandle); + } catch (OcException e) { + Log.e(TAG, e.toString()); + msg("Failed to unregister a collection resource"); + } + } + msg("Group Server is reset."); + + printLine(); + enableStartStopButton(); + } + + //****************************************************************************** + // End of the OIC specific code + //****************************************************************************** + + private final static String TAG = GroupServer.class.getSimpleName(); + private TextView mConsoleTextView; + private ScrollView mScrollView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_group_server); + + mConsoleTextView = (TextView) findViewById(R.id.consoleTextView); + mConsoleTextView.setMovementMethod(new ScrollingMovementMethod()); + mScrollView = (ScrollView) findViewById(R.id.scrollView); + mScrollView.fullScroll(View.FOCUS_DOWN); + final ToggleButton toggleButton = (ToggleButton) findViewById(R.id.toggleButton); + + if (null == savedInstanceState) { + toggleButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + toggleButton.setEnabled(false); + if (isChecked) { + new Thread(new Runnable() { + public void run() { + startGroupServer(); + } + }).start(); + } else { + new Thread(new Runnable() { + public void run() { + stopGroupServer(); + } + }).start(); + } + } + }); + } else { + String consoleOutput = savedInstanceState.getString("consoleOutputString"); + mConsoleTextView.setText(consoleOutput); + boolean buttonCheked = savedInstanceState.getBoolean("toggleButtonChecked"); + toggleButton.setChecked(buttonCheked); + } + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + outState.putString("consoleOutputString", mConsoleTextView.getText().toString()); + ToggleButton toggleButton = (ToggleButton) findViewById(R.id.toggleButton); + outState.putBoolean("toggleButtonChecked", toggleButton.isChecked()); + } + + @Override + protected void onRestoreInstanceState(Bundle savedInstanceState) { + super.onRestoreInstanceState(savedInstanceState); + + String consoleOutput = savedInstanceState.getString("consoleOutputString"); + mConsoleTextView.setText(consoleOutput); + + final ToggleButton toggleButton = (ToggleButton) findViewById(R.id.toggleButton); + boolean buttonCheked = savedInstanceState.getBoolean("toggleButtonChecked"); + toggleButton.setChecked(buttonCheked); + } + + private void msg(final String text) { + runOnUiThread(new Runnable() { + public void run() { + mConsoleTextView.append("\n"); + mConsoleTextView.append(text); + mScrollView.fullScroll(View.FOCUS_DOWN); + } + }); + Log.i(TAG, text); + } + + private void printLine() { + msg("------------------------------------------------------------------------"); + } + + private void enableStartStopButton() { + runOnUiThread(new Runnable() { + public void run() { + ToggleButton toggleButton = (ToggleButton) findViewById(R.id.toggleButton); + toggleButton.setEnabled(true); + } + }); + } +} \ No newline at end of file diff --git a/java/examples-java/guiclient/.gitignore b/java/examples-java/guiclient/.gitignore new file mode 100644 index 0000000..c795b05 --- /dev/null +++ b/java/examples-java/guiclient/.gitignore @@ -0,0 +1 @@ +build \ No newline at end of file diff --git a/java/examples-java/guiclient/build.gradle b/java/examples-java/guiclient/build.gradle new file mode 100644 index 0000000..9aec23e --- /dev/null +++ b/java/examples-java/guiclient/build.gradle @@ -0,0 +1,25 @@ +//apply plugin: 'com.android.application' +// +//android { +// compileSdkVersion 21 +// buildToolsVersion "21.1.1" +// +// defaultConfig { +// applicationId "org.iotivity.guiclient" +// 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.2' +//} diff --git a/java/examples-java/guiclient/src/main/java/org/iotivity/guiclient/ExpandableResourceListAdapter.java b/java/examples-java/guiclient/src/main/java/org/iotivity/guiclient/ExpandableResourceListAdapter.java new file mode 100644 index 0000000..000913d --- /dev/null +++ b/java/examples-java/guiclient/src/main/java/org/iotivity/guiclient/ExpandableResourceListAdapter.java @@ -0,0 +1,382 @@ +//****************************************************************** +// +// 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. +// +//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +package org.iotivity.guiclient; + +import android.content.Context; +import android.media.Image; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseExpandableListAdapter; +import android.widget.CompoundButton; +import android.widget.ImageView; +import android.widget.ProgressBar; +import android.widget.SeekBar; +import android.widget.Switch; +import android.widget.TextView; + +import java.util.List; + +import static org.iotivity.guiclient.OcAttributeInfo.OC_ATTRIBUTE_TYPE; +import static org.iotivity.guiclient.OcProtocolStrings.AMBIENT_LIGHT_RESOURCE_URI; +import static org.iotivity.guiclient.OcProtocolStrings.LIGHT_RESOURCE_URI; +import static org.iotivity.guiclient.OcProtocolStrings.PLATFORM_LED_RESOURCE_URI; +import static org.iotivity.guiclient.OcProtocolStrings.ROOM_TEMPERATURE_RESOURCE_URI; + +/** + * ExpandableResourceListAdapter knows how to render an ExpandableListView, using a + * List of OcResourceInfo objects as the parents of the ExpandableListView, + * and OcAttributeInfo objects as the children. + * + * @see org.iotivity.guiclient.OcAttributeInfo + */ +public class ExpandableResourceListAdapter extends BaseExpandableListAdapter { + /** + * Hardcoded TAG... if project never uses proguard then + * MyOcClient.class.getName() is the better way. + */ + private static final String TAG = "ExpandableResourceListAdapter"; + + private static final boolean LOCAL_LOGV = true; // set to false to compile out verbose logging + + private List resourceList; + private Context ctx; + + public ExpandableResourceListAdapter(List resourceList, Context ctx) { + this.resourceList = resourceList; + this.ctx = ctx; + } + + @Override + public Object getChild(int groupPosition, int childPosition) { + return resourceList.get(groupPosition).getAttributes().get(childPosition); + } + + @Override + public int getChildrenCount(int groupPosition) { + return resourceList.get(groupPosition).getAttributes().size(); + } + + @Override + public long getChildId(int groupPosition, int childPosition) { + return resourceList.get(groupPosition).getAttributes().get(childPosition).hashCode(); + } + + @Override + public int getChildType(int groupPosition, int childPosition) { + return this.resourceList.get(groupPosition).getAttributes().get(childPosition) + .getType().ordinal(); + } + + @Override + public int getChildTypeCount() { + return OC_ATTRIBUTE_TYPE.values().length; + } + + @Override + public View getChildView(final int groupPosition, int childPosition, + boolean isLastChild, View convertView, ViewGroup parent) { + View v = convertView; + if (v == null) { + LayoutInflater inflater = (LayoutInflater)ctx.getSystemService + (Context.LAYOUT_INFLATER_SERVICE); + switch(OC_ATTRIBUTE_TYPE.fromInt(getChildType(groupPosition, childPosition))) { + case AMBIENT_LIGHT_SENSOR_READING: + case ROOM_TEMPERATURE_SENSOR_READING: + v = inflater.inflate(R.layout.attribute_layout_progress_bar, parent, false); + break; + case LIGHT_DIMMER: + v = inflater.inflate(R.layout.attribute_layout_slider, parent, false); + break; + case LIGHT_SWITCH: + case PLATFORM_LED_SWITCH: + v = inflater.inflate(R.layout.attribute_layout_on_off_switch, parent, false); + break; + } + } + + OcAttributeInfo attribute = + resourceList.get(groupPosition).getAttributes().get(childPosition); + + // All attribute icons and names are currently treated the same so we handle them outside + // the type-specific inflater functions + ImageView attributeIcon = (ImageView) v.findViewById(R.id.attribute_icon_id); + attributeIcon.setVisibility(View.VISIBLE); + TextView attributeName = (TextView) v.findViewById(R.id.attribute_name_id); + attributeName.setText(getAttributeLabelFromType(attribute.getType())); + attributeName.setVisibility(View.VISIBLE); + + // Now inflate the rest of the layout in a type-specific way + switch(attribute.getType()){ + case AMBIENT_LIGHT_SENSOR_READING: + this.renderAmbientLightSensorReading(v, groupPosition, attribute); + break; + case LIGHT_DIMMER: + this.renderLightDimmer(v, groupPosition, attribute); + break; + case LIGHT_SWITCH: + this.renderLightSwitch(v, groupPosition, attribute); + break; + case PLATFORM_LED_SWITCH: + this.renderPlatformLedSwitch(v, groupPosition, attribute); + break; + case ROOM_TEMPERATURE_SENSOR_READING: + this.renderRoomTemperatureSensorReading(v, groupPosition, attribute); + break; + } + + return v; + } + + @Override + public Object getGroup(int groupPosition) { + return resourceList.get(groupPosition); + } + + @Override + public int getGroupCount() { + return resourceList.size(); + } + + @Override + public long getGroupId(int groupPosition) { + return resourceList.get(groupPosition).hashCode(); + } + + @Override + public View getGroupView(int groupPosition, boolean isExpanded, + View convertView, ViewGroup parent) { + + View v = convertView; + + if (v == null) { + LayoutInflater inflater = (LayoutInflater)ctx.getSystemService + (Context.LAYOUT_INFLATER_SERVICE); + v = inflater.inflate(R.layout.resource_list_item_layout, parent, false); + } + + TextView resourceName = (TextView) v.findViewById(R.id.resource_name_id); + TextView resourceDescription = (TextView) v.findViewById(R.id.resource_description_id); + ImageView resourceIcon = (ImageView) v.findViewById(R.id.resource_icon_id); + + OcResourceInfo resource = resourceList.get(groupPosition); + + resourceName.setText(this.getResourceLabelFromType(resource.getType())); + resourceDescription.setText(resource.getHost()+resource.getUri()); + switch (resource.getType()) { + case AMBIENT_LIGHT_SENSOR: + resourceIcon.setImageResource(R.drawable.iotivity_hex_icon); + break; + case LIGHT: + resourceIcon.setImageResource(R.drawable.light_icon); + break; + case PLATFORM_LED: + resourceIcon.setImageResource(R.drawable.led_icon); + break; + case ROOM_TEMPERATURE_SENSOR: + resourceIcon.setImageResource(R.drawable.thermometer_icon); + break; + default: + resourceIcon.setImageResource(R.drawable.iotivity_hex_icon); + break; + } + + return v; + } + + @Override + public boolean hasStableIds() { + return true; + } + + @Override + public boolean isChildSelectable(int groupPosition, int childPosition) { + return true; + } + + /** + * Type-specific layout render for Ambient Light Sensor reading attribute. + */ + private void renderAmbientLightSensorReading(final View view, + final int groupPosition, + final OcAttributeInfo attribute) { + // Render attributeValue + TextView attributeValue = (TextView) view.findViewById(R.id.attribute_value_id); + attributeValue.setText(String.valueOf(attribute.getValueInt())); + attributeValue.setVisibility(View.VISIBLE); + + // Render progressBar + ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.attribute_progress_bar); + progressBar.setMax(100); // display as percent from 0-100 + progressBar.setProgress(attribute.getValueAsPercentOfMax()); + progressBar.setVisibility(View.VISIBLE); + } + + /** + * Type-specific layout render for Light Dimmer attribute. + */ + private void renderLightDimmer(final View view, + final int groupPosition, + final OcAttributeInfo attribute) { + // Render attributeValue + TextView attributeValue = (TextView) view.findViewById(R.id.attribute_value_id); + attributeValue.setText(String.valueOf(attribute.getValueInt())); + attributeValue.setVisibility(View.VISIBLE); + + // Render SeekBar + SeekBar slider = (SeekBar) view.findViewById(R.id.attribute_slider); + slider.setMax(attribute.getValueMax()); + slider.setProgress(attribute.getValueInt()); + slider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { + private int mSliderVal; + @Override + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + if (LOCAL_LOGV) Log.v(TAG, String.format("onProgressChanged(%s)", progress)); + this.mSliderVal = progress; + } + @Override + public void onStartTrackingTouch(SeekBar seekBar) {} + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + if (LOCAL_LOGV) Log.v(TAG, "onStopTrackingTouch()"); + if(ctx instanceof MainActivity) { + // call MainActivity + ((MainActivity) ctx).setLightDimmerLevel(resourceList.get(groupPosition), + this.mSliderVal); + } + } + }); + slider.setVisibility(View.VISIBLE); + } + + /** + * Type-specific layout render for Light Switch attribute. + */ + private void renderLightSwitch(final View view, + final int groupPosition, + final OcAttributeInfo attribute) { + // Render attributeValue + TextView attributeValue = (TextView) view.findViewById(R.id.attribute_value_id); + if(false == attribute.getValueBool()) { + attributeValue.setText("off"); + } else { + attributeValue.setText("on"); + } + attributeValue.setVisibility(View.VISIBLE); + + // Render Switch + Switch toggleSwitch = (Switch) view.findViewById(R.id.attribute_switch); + toggleSwitch.setText(this.ctx.getString(R.string.oc_light_switch_toggle_text)); + toggleSwitch.setChecked(attribute.getValueBool()); + toggleSwitch.setOnCheckedChangeListener(new Switch.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + if (LOCAL_LOGV) Log.v(TAG, String.format("onCheckedChanged(%s)", isChecked)); + if(ctx instanceof MainActivity) { + // call MainActivity + ((MainActivity) ctx).toggleLightSwitch(resourceList.get(groupPosition), + isChecked); + } + } + }); + toggleSwitch.setVisibility(View.VISIBLE); + } + + /** + * Type-specific layout render for LED Switch attribute. + */ + private void renderPlatformLedSwitch(final View view, + final int groupPosition, + final OcAttributeInfo attribute) { + // Render attributeValue + TextView attributeValue = (TextView) view.findViewById(R.id.attribute_value_id); + if(1 == attribute.getValueInt()) { + attributeValue.setText("on"); + } else { + attributeValue.setText("off"); + } + attributeValue.setVisibility(View.VISIBLE); + + // Render Switch + Switch toggleSwitch = (Switch) view.findViewById(R.id.attribute_switch); + toggleSwitch.setText(this.ctx.getString(R.string.oc_led_switch_toggle_text)); + toggleSwitch.setChecked(1 == attribute.getValueInt()); + toggleSwitch.setOnCheckedChangeListener( new Switch.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + if (LOCAL_LOGV) Log.v(TAG, String.format("onCheckedChanged(%s)", isChecked)); + if(ctx instanceof MainActivity) { + // call MainActivity + ((MainActivity) ctx).toggleLedSwitch(resourceList.get(groupPosition), + isChecked); + } + } + }); + toggleSwitch.setVisibility(View.VISIBLE); + } + + /** + * Type-specific layout render for Room Temperature Sensor Reading attribute. + */ + private void renderRoomTemperatureSensorReading(final View view, + final int groupPosition, + final OcAttributeInfo attribute) { + // this happens to have the same behavior as ambient light sensor, so just re-use + this.renderAmbientLightSensorReading(view, groupPosition, attribute); + } + + private String getAttributeLabelFromType(OC_ATTRIBUTE_TYPE type) { + switch (type) { + case AMBIENT_LIGHT_SENSOR_READING: + return ctx.getString(R.string.ui_attribute_label_ambient_light_sensor_reading); + case LIGHT_DIMMER: + return ctx.getString(R.string.ui_attribute_label_light_dimmer); + case LIGHT_SWITCH: + return ctx.getString(R.string.ui_attribute_label_light_switch); + case PLATFORM_LED_SWITCH: + return ctx.getString(R.string.ui_attribute_label_led_switch); + case ROOM_TEMPERATURE_SENSOR_READING: + return ctx.getString(R.string.ui_attribute_label_room_temperature_sensor_reading); + default: + Log.w(TAG, "getAttributeLabelFromType(): unrecognized attribute type."); + return "Attribute:"; + } + } + + private String getResourceLabelFromType(OcResourceInfo.OC_RESOURCE_TYPE type) { + if (LOCAL_LOGV) Log.v(TAG, "getResourceLabelFromType()"); + + switch(type) { + case AMBIENT_LIGHT_SENSOR: + return ctx.getString(R.string.ui_resource_label_ambient_light_sensor); + case LIGHT: + return ctx.getString(R.string.ui_resource_label_light); + case PLATFORM_LED: + return ctx.getString(R.string.ui_resource_label_platform_led); + case ROOM_TEMPERATURE_SENSOR: + return ctx.getString(R.string.ui_resource_label_room_temperature_sensor); + default: + Log.w(TAG, "getResourceLabelFromType(): unrecognized resource type."); + return "Resource:"; + } + } +} diff --git a/java/examples-java/guiclient/src/main/java/org/iotivity/guiclient/MainActivity.java b/java/examples-java/guiclient/src/main/java/org/iotivity/guiclient/MainActivity.java new file mode 100644 index 0000000..375b158 --- /dev/null +++ b/java/examples-java/guiclient/src/main/java/org/iotivity/guiclient/MainActivity.java @@ -0,0 +1,336 @@ +//****************************************************************** +// +// 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. +// +//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +package org.iotivity.guiclient; + +import android.app.AlertDialog; +import android.content.DialogInterface; +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.util.Log; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.ExpandableListView; +import android.widget.ProgressBar; + +import java.util.ArrayList; +import java.util.List; + +import static org.iotivity.guiclient.OcAttributeInfo.OC_ATTRIBUTE_TYPE.LIGHT_DIMMER; +import static org.iotivity.guiclient.OcAttributeInfo.OC_ATTRIBUTE_TYPE.LIGHT_SWITCH; +import static org.iotivity.guiclient.OcAttributeInfo.OC_ATTRIBUTE_TYPE.PLATFORM_LED_SWITCH; +import static org.iotivity.guiclient.R.id.expandableResourceListView; + +/** + * MainActivity instantiates a ExpandableListView of type ExpandableResourceListView, and + * also creates and starts a OcWorker object to handle the IoTivity specific work. + * + * @see org.iotivity.guiclient.OcWorker + * @see org.iotivity.guiclient.OcWorkerListener + * @see org.iotivity.guiclient.ExpandableResourceListAdapter + */ +public class MainActivity + extends ActionBarActivity + implements OcWorkerListener, View.OnClickListener, ExpandableListView.OnChildClickListener { + /** + * Hardcoded TAG... if project never uses proguard then + * MyOcClient.class.getName() is the better way. + */ + private static final String TAG = "MainActivity"; + + private static final boolean LOCAL_LOGV = true; // set to false to compile out verbose logging + + /** + * The data structure behind the displayed List of resources and attributes. + */ + private List mResourceList; + + /** + * The custom adapter for displaying the ResourceListItem List + */ + private ExpandableResourceListAdapter mResourceListAdapter; + + /** + * The OIC-aware worker class which does all the OIC API interaction + * and handles the results, notifying MainActivity whenever an event + * requires a UI update. + */ + private OcWorker mOcWorker; + + /** + * Preserve a ref to Action Bar Menu for changing progress icon + */ + private Menu optionsMenu; + + @Override + protected void onCreate(Bundle savedInstanceState) { + if (LOCAL_LOGV) Log.v(TAG, "onCreate()"); + + super.onCreate(savedInstanceState); + + setContentView(R.layout.activity_main); + + // start the OcWorker thread and register as a listener + if(null == this.mOcWorker) { + this.mOcWorker = new OcWorker(this); + this.mOcWorker.start(); // configures the OIC platform and wait for further calls + this.mOcWorker.registerListener(this); + } + + // init the Resource display list + if(null == this.mResourceList) { + this.mResourceList = new ArrayList<>(); + } + + // init the ListView Adapter + if(null == this.mResourceListAdapter) { + this.mResourceListAdapter = new ExpandableResourceListAdapter(this.mResourceList, + this); + } + + // init the Expandable List View + ExpandableListView exListView = + (ExpandableListView) findViewById(expandableResourceListView); + exListView.setIndicatorBounds(5, 5); + exListView.setIndicatorBounds(0, 20); + exListView.setAdapter(this.mResourceListAdapter); + exListView.setOnChildClickListener(this); + } + + @Override + public void onRestoreInstanceState(Bundle savedInstanceState) { + if (LOCAL_LOGV) Log.v(TAG, "onRestoreInstanceState()"); + } + + @Override + public void onSaveInstanceState(Bundle outState) { + if (LOCAL_LOGV) Log.v(TAG, "onSaveInstanceState()"); + } + + @Override + public void onClick(View v) { + if (LOCAL_LOGV) Log.v(TAG, "onClick()"); + + this.setRefreshActionButtonState(false); + } + + @Override + public boolean onChildClick(ExpandableListView parent, + View v, + int groupPosition, + int childPosition, + long id) { + if (LOCAL_LOGV) Log.v(TAG, "onChildClick()"); + + this.mOcWorker.doGetResource(mResourceList.get(groupPosition)); + + return false; + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + if (LOCAL_LOGV) Log.v(TAG, "onCreateOptionsMenu()"); + + // save a reference for use in controlling refresh icon later + this.optionsMenu = menu; + + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_main, menu); + + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + if (LOCAL_LOGV) Log.v(TAG, String.format("onOptionsItemSelected(%s)", item.toString())); + // 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(); + + // Handle the "settings" icon/text click + if (id == R.id.action_settings) { + return true; + } + + // Handle the "developer test" icon/text click + if (id == R.id.action_test) { + return true; + } + + // Handle the trash can "discard" icon click + if (id == R.id.action_discard) { + AlertDialog diaBox = confirmDiscard(); + diaBox.show(); + } + + // Handle the refresh/progress icon click + if (id == R.id.action_refresh) { + // show the indeterminate progress bar + this.setRefreshActionButtonState(true); + // use OcWorker to discover resources + this.mOcWorker.doDiscoverResources(); + } + + return super.onOptionsItemSelected(item); + } + + /** + * Handle a resource changed callback from OcWorker by posting a runnable to our + * own UI-safe looper/handler + */ + @Override + public void onResourceChanged(final OcResourceInfo resourceInfo) { + if (LOCAL_LOGV) Log.v(TAG, "onResourceChanged()"); + + runOnUiThread(new Runnable() { + @Override + public void run() { + // in case we were waiting for a refresh, hide the indeterminate progress bar + setRefreshActionButtonState(false); + + mResourceListAdapter.notifyDataSetChanged(); + } + }); + } + + /** + * Handle a new resource found callback from OcWorker by posting a runnable to our + * own UI-safe looper/handler + */ + @Override + public void onResourceFound(final OcResourceInfo resourceInfo) { + if (LOCAL_LOGV) Log.v(TAG, "onResourceFound()"); + + runOnUiThread(new Runnable() { + @Override + public void run() { + // in case we were waiting for a refresh, hide the indeterminate progress bar + setRefreshActionButtonState(false); + + // if resource not already in list, add it + if(!mResourceList.contains(resourceInfo)) { + mResourceList.add(resourceInfo); + } + + mResourceListAdapter.notifyDataSetChanged(); + } + }); + } + + public void toggleLedSwitch(OcResourceInfo resourceInfo, boolean onOff) { + if (LOCAL_LOGV) Log.d(TAG, String.format("toggleLedSwitch(%s, %s)", + resourceInfo.getHost() + resourceInfo.getUri(), String.valueOf(onOff))); + + // send a msg to OcWorker to put the switch value + for(OcAttributeInfo ai : resourceInfo.getAttributes()) { + if(ai.getType() == PLATFORM_LED_SWITCH) { + if(onOff) { + ai.setValueInt(1); + } else { + ai.setValueInt(0); + } + } + } + this.mOcWorker.doPutResource(resourceInfo); + } + + public void toggleLightSwitch(OcResourceInfo resourceInfo, boolean onOff) { + if (LOCAL_LOGV) Log.d(TAG, String.format("toggleLightSwitch(%s, %s)", + resourceInfo.getHost() + resourceInfo.getUri(), String.valueOf(onOff))); + + // send a msg to OcWorker to put the switch value + for(OcAttributeInfo ai : resourceInfo.getAttributes()) { + if(ai.getType() == LIGHT_SWITCH) { + ai.setValueBool(onOff); + } + } + this.mOcWorker.doPutResource(resourceInfo); + } + + public void setLightDimmerLevel(OcResourceInfo resourceInfo, int value) { + if (LOCAL_LOGV) Log.d(TAG, String.format("setLightDimmerLevel(%s, %s)", + resourceInfo.getHost() + resourceInfo.getUri(), String.valueOf(value))); + + // send a msg to OcWorker to put the switch value + for(OcAttributeInfo ai : resourceInfo.getAttributes()) { + if(ai.getType() == LIGHT_DIMMER) { + ai.setValueInt(value); + } + } + this.mOcWorker.doPutResource(resourceInfo); + } + + /** + * Sets the Action Bar icon to "progress" (spinning circle), or returns it to refresh icon + * + * @param refreshing true sets icon to animated "progress" spinner; false to static + * refresh icon + */ + private void setRefreshActionButtonState(final boolean refreshing) { + if (this.optionsMenu != null) { + final MenuItem refreshItem + = this.optionsMenu + .findItem(R.id.action_refresh); + if (refreshItem != null) { + if (refreshing) { + refreshItem.setActionView(R.layout.actionbar_indeterminate_progress); + ProgressBar progressBar = + (ProgressBar) findViewById(R.id.find_resource_progress_bar); + progressBar.setOnClickListener(this); + + } else { + refreshItem.setActionView(null); + } + } + } + } + + private AlertDialog confirmDiscard() + { + if (LOCAL_LOGV) Log.v(TAG, "confirmDiscard()"); + + return new AlertDialog.Builder(this) + .setTitle("Clear Resource List?") + .setIcon(R.drawable.ic_action_discard_dark) + .setPositiveButton("Yes", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int whichButton) { + // clear OcWorker's list + mOcWorker.doClearResources(); + // in case its running, hide the indeterminate progress bar + setRefreshActionButtonState(false); + // clear our local data model list + mResourceList.clear(); + mResourceListAdapter.notifyDataSetChanged(); + dialog.dismiss(); + } + }) + + .setNegativeButton("No", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + } + }) + + .create(); + } + +} diff --git a/java/examples-java/guiclient/src/main/java/org/iotivity/guiclient/OcAttributeInfo.java b/java/examples-java/guiclient/src/main/java/org/iotivity/guiclient/OcAttributeInfo.java new file mode 100644 index 0000000..d3ad18e --- /dev/null +++ b/java/examples-java/guiclient/src/main/java/org/iotivity/guiclient/OcAttributeInfo.java @@ -0,0 +1,176 @@ +//****************************************************************** +// +// 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. +// +//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +package org.iotivity.guiclient; + +import android.util.Log; + +import java.io.Serializable; + +/** + * Created by nathanhs on 12/28/15. + */ +public class OcAttributeInfo implements Serializable { + /** + * Hardcoded TAG... if project never uses proguard then + * MyOcClient.class.getName() is the better way. + */ + private static final String TAG = "OcAttributeInfo"; + + private static final boolean LOCAL_LOGV = true; // set to false to compile out verbose logging + + private static final int AMBIENT_LIGHT_SENSOR_READING_MAX = 4096; + private static final int LIGHT_DIMMER_MAX = 100; + private static final int LIGHT_SWITCH_MAX = 1; + private static final int PLATFORM_LED_SWITCH_MAX = 1; + // TODO: once the temp getValueInt works, figure out how to scale this properly + private static final int ROOM_TEMPERATURE_SENSOR_READING_MAX = 4096; + + /** + * These are the resource types supported by OcResourceInfo. + */ + public enum OC_ATTRIBUTE_TYPE { + AMBIENT_LIGHT_SENSOR_READING, + LIGHT_DIMMER, + LIGHT_SWITCH, + PLATFORM_LED_SWITCH, + ROOM_TEMPERATURE_SENSOR_READING; + + private static final OC_ATTRIBUTE_TYPE[] values = OC_ATTRIBUTE_TYPE.values(); + + public static OC_ATTRIBUTE_TYPE fromInt(int i) { + return values[i]; + } + } + + private boolean mCurrentlyObserved; + private final int mId; + private static int mIdInitializer = 0; + private final boolean mObservable = true; //TODO BROKEN fix when implementing observe + private final OcResourceInfo mParentResource; + private final boolean mReadOnly; + private final OC_ATTRIBUTE_TYPE mType; + private boolean mValueBool; // used if attribute has a boolean value + private int mValueInt; // used if attribute has an int value + private String mValueString; // used if attribute has a String value + private final int mValueMax; + + public OcAttributeInfo(OC_ATTRIBUTE_TYPE type, OcResourceInfo parent) { + if (LOCAL_LOGV) Log.v(TAG, "OcAttributeInfo() constructor"); + + this.mId = OcAttributeInfo.mIdInitializer++; // give a unique Id from other OcResourceInfos + this.mParentResource = parent; + this.mReadOnly = this.getReadOnlyBasedOnType(type); + this.mType = type; + this.mValueBool = false; + this.mValueInt = 0; + this.mValueString = "error"; + this.mValueMax = this.getMaxAttributeValueBasedOnType(type); + } + + public int getId() { + return mId; + } + + public OC_ATTRIBUTE_TYPE getType() { + return mType; + } + + public boolean getValueBool() { + return this.mValueBool; + } + + public int getValueInt() { + return this.mValueInt; + } + + public int getValueMax() { + return mValueMax; + } + + public String getValueString() { + return this.mValueString; + } + + public int getValueAsPercentOfMax() { + return (this.mValueInt*100)/this.mValueMax; + } + + public boolean isCurrentlyObserved() { + return this.mCurrentlyObserved; + } + + public boolean isObservable() { + return this.mObservable; + } + + public boolean isReadOnly() { + return mReadOnly; + } + + public void setCurrentlyObserved(boolean currentlyObserved) { + this.mCurrentlyObserved = currentlyObserved; + } + + public void setValueBool(boolean value) { + this.mValueBool = value; + } + + public void setValueInt(int value) { + this.mValueInt = value; + } + + public void setValueString(String value) { + this.mValueString = value; + } + + private int getMaxAttributeValueBasedOnType(OC_ATTRIBUTE_TYPE type) { + switch(type) { + case AMBIENT_LIGHT_SENSOR_READING: + return AMBIENT_LIGHT_SENSOR_READING_MAX; + case LIGHT_DIMMER: + return LIGHT_DIMMER_MAX; + case LIGHT_SWITCH: + return LIGHT_SWITCH_MAX; + case PLATFORM_LED_SWITCH: + return PLATFORM_LED_SWITCH_MAX; + case ROOM_TEMPERATURE_SENSOR_READING: + return ROOM_TEMPERATURE_SENSOR_READING_MAX; + default: + Log.w(TAG, "getMaxAttributeValueBasedOnType(): unrecognized attribute type."); + return 0; + } + } + + private boolean getReadOnlyBasedOnType(OC_ATTRIBUTE_TYPE type) { + switch(type) { + case AMBIENT_LIGHT_SENSOR_READING: + case ROOM_TEMPERATURE_SENSOR_READING: + return true; + case LIGHT_DIMMER: + case LIGHT_SWITCH: + case PLATFORM_LED_SWITCH: + return false; + default: + Log.w(TAG, "getReadOnlyBasedOnType(): unrecognized attribute type."); + return false; + } + } +} diff --git a/java/examples-java/guiclient/src/main/java/org/iotivity/guiclient/OcProtocolStrings.java b/java/examples-java/guiclient/src/main/java/org/iotivity/guiclient/OcProtocolStrings.java new file mode 100644 index 0000000..5afc2f7 --- /dev/null +++ b/java/examples-java/guiclient/src/main/java/org/iotivity/guiclient/OcProtocolStrings.java @@ -0,0 +1,50 @@ +//****************************************************************** +// +// 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. +// +//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +package org.iotivity.guiclient; + +/** + * OcProtocolStrings contains the IoTivity-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 OcProtocolStrings { + // OIC core protocol strings + public static final String COAP_CORE = "coap://224.0.1.187/oic/res"; + public static final String RESOURCE_TYPE_QUERY = "?rt="; + public static final String INTERFACE_QUERY = "?if="; + // find resource queries + public static final String CORE_LIGHT = "core.light"; + public static final String CORE_EDISON_RESOURCES = "core.edison.resources"; + // resource URIs + public static final String LIGHT_RESOURCE_URI = "/a/light"; + public static final String LIGHT_RESOURCE_URI2 = "/light0"; + public static final String LIGHT_RESOURCE_URI3 = "/a/light1"; + public static final String ROOM_TEMPERATURE_RESOURCE_URI = "/temperature"; + public static final String AMBIENT_LIGHT_RESOURCE_URI = "/ambientlight"; + public static final String PLATFORM_LED_RESOURCE_URI = "/led"; + // attribute keys for set() calls + public static final String LIGHT_SWITCH_RESOURCE_KEY = "state"; + public static final String LIGHT_DIMMER_RESOURCE_KEY = "power"; + public static final String ROOM_TEMPERATURE_RESOURCE_KEY = "temperature"; + public static final String AMBIENT_LIGHT_RESOURCE_KEY = "ambientlight"; + public static final String PLATFORM_LED_RESOURCE_KEY = "switch"; +} diff --git a/java/examples-java/guiclient/src/main/java/org/iotivity/guiclient/OcResourceInfo.java b/java/examples-java/guiclient/src/main/java/org/iotivity/guiclient/OcResourceInfo.java new file mode 100644 index 0000000..c603e2f --- /dev/null +++ b/java/examples-java/guiclient/src/main/java/org/iotivity/guiclient/OcResourceInfo.java @@ -0,0 +1,375 @@ +//****************************************************************** +// +// 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. +// +//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +package org.iotivity.guiclient; + +import android.util.Log; + +import org.iotivity.base.ErrorCode; +import org.iotivity.base.OcException; +import org.iotivity.base.OcHeaderOption; +import org.iotivity.base.OcRepresentation; +import org.iotivity.base.OcResource; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import static org.iotivity.guiclient.OcAttributeInfo.OC_ATTRIBUTE_TYPE.AMBIENT_LIGHT_SENSOR_READING; +import static org.iotivity.guiclient.OcAttributeInfo.OC_ATTRIBUTE_TYPE.LIGHT_DIMMER; +import static org.iotivity.guiclient.OcAttributeInfo.OC_ATTRIBUTE_TYPE.LIGHT_SWITCH; +import static org.iotivity.guiclient.OcProtocolStrings.AMBIENT_LIGHT_RESOURCE_KEY; +import static org.iotivity.guiclient.OcProtocolStrings.AMBIENT_LIGHT_RESOURCE_URI; +import static org.iotivity.guiclient.OcProtocolStrings.LIGHT_DIMMER_RESOURCE_KEY; +import static org.iotivity.guiclient.OcProtocolStrings.LIGHT_RESOURCE_URI; +import static org.iotivity.guiclient.OcProtocolStrings.LIGHT_RESOURCE_URI2; +import static org.iotivity.guiclient.OcProtocolStrings.LIGHT_RESOURCE_URI3; +import static org.iotivity.guiclient.OcProtocolStrings.LIGHT_SWITCH_RESOURCE_KEY; +import static org.iotivity.guiclient.OcProtocolStrings.PLATFORM_LED_RESOURCE_KEY; +import static org.iotivity.guiclient.OcProtocolStrings.PLATFORM_LED_RESOURCE_URI; +import static org.iotivity.guiclient.OcProtocolStrings.ROOM_TEMPERATURE_RESOURCE_URI; + +/** + * OcResourceInfo is a wrapper object for the OcResource object. It implements the Resource- + * specific callbacks, and abstracts the IoTivity implementation details from the application. + * + * In order to use OcResourceInfo, an application should implement the OcResourceInfoListener + * interface, which is called when the OcResourceInfo changes in any meaningful way. + */ +public class OcResourceInfo + implements OcResource.OnGetListener, OcResource.OnPutListener, Serializable { + /** + * Hardcoded TAG... if project never uses proguard then + * MyOcClient.class.getName() is the better way. + */ + private static final String TAG = "OcResourceInfo"; + + private static final boolean LOCAL_LOGV = true; // set to false to compile out verbose logging + + /** + * These are the resource types supported by OcResourceInfo. They should have corresponding + * URI strings in the OcProtocolStrings interface. + */ + public enum OC_RESOURCE_TYPE { + AMBIENT_LIGHT_SENSOR, + LIGHT, + PLATFORM_LED, + ROOM_TEMPERATURE_SENSOR; + + private static final OC_RESOURCE_TYPE[] values = OC_RESOURCE_TYPE.values(); + + public static OC_RESOURCE_TYPE fromInt(int i) { + return values[i]; + } + } + + private List mAttributes; + private final String mHost; + private final int mId; + private static int mIdInitializer = 0; + private List mListeners; + private final OcResource mResource; + private final OC_RESOURCE_TYPE mType; + private final String mUri; + + public interface OcResourceInfoListener { + public void onResourceInfoChanged(OcResourceInfo resourceInfo); + } + + + public OcResourceInfo(OcResource resource, OcResourceInfoListener changeListener) { + if (LOCAL_LOGV) Log.v(TAG, "OcResourceInfo() constructor"); + + this.mAttributes = new ArrayList<>(); + this.mHost = resource.getHost(); + this.mId = OcResourceInfo.mIdInitializer++; // give a unique Id from other OcResourceInfos + this.mListeners = new ArrayList<>(); + this.mListeners.add(changeListener); + this.mResource = resource; + this.mType = this.getResourceTypeFromUri(resource.getUri()); + this.mUri = resource.getUri(); + + } + + public void registerListener(OcResourceInfoListener changeListener) { + if(null == this.mListeners) { + Log.e(TAG, "registerListener(): null mListeners List"); + } else { + boolean alreadyRegistered = false; + for(OcResourceInfoListener rl : this.mListeners) { + if(changeListener == rl) { + alreadyRegistered = true; + } + } + if(!alreadyRegistered) { + this.mListeners.add(changeListener); + } + } + } + + public OC_RESOURCE_TYPE getType() { + return this.mType; + } + + public String getHost() { + return this.mHost; + } + + public String getUri() { + return this.mUri; + } + + @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()); + } + + @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()); + } + + public List getAttributes() { + return this.mAttributes; + } + + public void doOcGet() { + if(null != this.mResource) { + try { + this.mResource.get(new HashMap(), this); + } catch (OcException e) { + e.printStackTrace(); + Log.e(TAG, e.getMessage()); + } + } else { + Log.e(TAG, "doOcGet(): null mResource"); + } + } + + public void doOcPut(OcAttributeInfo attribute) { + if (LOCAL_LOGV) Log.v(TAG, "doOcPut()"); + + if(attribute.isReadOnly()) { + Log.w(TAG, String.format("doOcPut(): %s attribute is read only; skipping put!", + attribute.getType())); + } else { + if (null != this.mResource) { + try { + OcRepresentation representation = new OcRepresentation(); + switch (attribute.getType()) { + case AMBIENT_LIGHT_SENSOR_READING: + break; + case LIGHT_DIMMER: + representation.setValueInt(LIGHT_DIMMER_RESOURCE_KEY, + attribute.getValueInt()); + // This 'sw' logic is here because the current IoTivity Light forces + // the switch to "false" if the switch val is not specified. + boolean sw = true; + for(OcAttributeInfo ai : this.mAttributes) { + if(ai.getType() == LIGHT_SWITCH) { + sw = ai.getValueBool(); + } + } + representation.setValueBool(LIGHT_SWITCH_RESOURCE_KEY, sw); + break; + case LIGHT_SWITCH: + representation.setValueBool(LIGHT_SWITCH_RESOURCE_KEY, + attribute.getValueBool()); + break; + case PLATFORM_LED_SWITCH: + representation.setValueInt(PLATFORM_LED_RESOURCE_KEY, + attribute.getValueInt()); + break; + case ROOM_TEMPERATURE_SENSOR_READING: + break; + default: + break; + } + this.mResource.put(representation, new HashMap(), this); + } catch (OcException e) { + e.printStackTrace(); + Log.e(TAG, e.getMessage()); + } + } else { + Log.e(TAG, "doOcGet(): null mResource"); + } + } + } + + private static Object onGetCompletedLock = new Object(); + @Override +// public void onGetCompleted(HeaderOptions headerOptions, OcRepresentation ocRepresentation) { + public void onGetCompleted(List headerOptionList, + OcRepresentation ocRepresentation) { + synchronized (onGetCompletedLock) { + if (LOCAL_LOGV) Log.v(TAG, "enter -> onGetCompleted()"); + if (LOCAL_LOGV) Log.v(TAG, String.format("\tthis = %s", this.toString())); + if (LOCAL_LOGV) Log.v(TAG, String.format("\tthis.mType = %s", this.mType)); + + this.mAttributes.clear(); + switch(this.mType) { + case AMBIENT_LIGHT_SENSOR: + int ambientLightVal = ocRepresentation.getValueInt(AMBIENT_LIGHT_RESOURCE_KEY); + if (LOCAL_LOGV) Log.v(TAG, + String.format("%s int value of %s attribute = %d", + mType, AMBIENT_LIGHT_RESOURCE_KEY, ambientLightVal)); + OcAttributeInfo ambientAttribute = new OcAttributeInfo( + AMBIENT_LIGHT_SENSOR_READING, this); + ambientAttribute.setValueInt(ambientLightVal); + this.mAttributes.add(ambientAttribute); + break; + case LIGHT: + // do switch first + boolean lightSwitchVal = ocRepresentation.getValueBool(LIGHT_SWITCH_RESOURCE_KEY); + OcAttributeInfo lightSwitchAttribute = new OcAttributeInfo( + LIGHT_SWITCH, this); + lightSwitchAttribute.setValueBool(lightSwitchVal); + this.mAttributes.add(lightSwitchAttribute); + // then dimmer + int dimmerVal = ocRepresentation.getValueInt(LIGHT_DIMMER_RESOURCE_KEY); + OcAttributeInfo dimmerAttribute = new OcAttributeInfo( + LIGHT_DIMMER, this); + dimmerAttribute.setValueInt(dimmerVal); + this.mAttributes.add(dimmerAttribute); + break; + case PLATFORM_LED: + int ledVal = ocRepresentation.getValueInt(PLATFORM_LED_RESOURCE_KEY); + if (LOCAL_LOGV) Log.v(TAG, + String.format("%s int value of %s attribute = %d", + mType, PLATFORM_LED_RESOURCE_KEY, ledVal)); + OcAttributeInfo ledAttribute = new OcAttributeInfo( + OcAttributeInfo.OC_ATTRIBUTE_TYPE.PLATFORM_LED_SWITCH, this); + ledAttribute.setValueInt(ledVal); + this.mAttributes.add(ledAttribute); + break; + case ROOM_TEMPERATURE_SENSOR: + int temperatureVal = 98; + Log.w(TAG, "getting 'temperature' value is causing crash;" + + " skipping and using 98."); + // TODO This call crashes in the native JNI code. The example .cpp + // app receives a double for the Room Temp key, but the Java API + // doesn't support getValueDouble yet. + // Debug crash when API fixed? +// temperatureVal = ocRepresentation.getValueInt(ROOM_TEMPERATURE_RESOURCE_KEY); + if (LOCAL_LOGV) Log.v(TAG, + String.format("%s int value of 'temperature' attribute = %d", + mType, temperatureVal)); + OcAttributeInfo temperatureAttribute = new OcAttributeInfo( + OcAttributeInfo.OC_ATTRIBUTE_TYPE.ROOM_TEMPERATURE_SENSOR_READING, + this); + temperatureAttribute.setValueInt(temperatureVal); + this.mAttributes.add(temperatureAttribute); + break; + } + this.notifyListeners(); + if (LOCAL_LOGV) Log.v(TAG, "exit <- onGetCompleted()"); + } + } + + /** + * Should be called whenever any Resource or Attribute values change on this object. + */ + private void notifyListeners() { + if (LOCAL_LOGV) Log.v(TAG, "notifyListeners()"); + + for(OcResourceInfoListener l : this.mListeners) { + l.onResourceInfoChanged(this); + } + } + + private Object onPutCompletedLock = new Object(); + @Override + public void onPutCompleted(List headerOptionList, + OcRepresentation ocRepresentation) { + synchronized (onPutCompletedLock) { + if (LOCAL_LOGV) Log.v(TAG, "enter -> onPutCompleted()"); + if (LOCAL_LOGV) Log.v(TAG, String.format("\tthis = %s", this.toString())); + if (LOCAL_LOGV) Log.v(TAG, String.format("\tthis.mType = %s", this.mType)); + + switch(this.mType) { + case AMBIENT_LIGHT_SENSOR: + Log.w(TAG, String.format("onPutCompleted(): %s is a readonly attribute type.", + this.mType)); + break; + case LIGHT: + // do switch first + boolean lightSwitchVal = ocRepresentation.getValueBool(LIGHT_SWITCH_RESOURCE_KEY); + for(OcAttributeInfo ai : this.mAttributes) { + if (ai.getType() == OcAttributeInfo.OC_ATTRIBUTE_TYPE.LIGHT_SWITCH) { + ai.setValueBool(lightSwitchVal); + } + } + // then dimmer + int dimmerVal = ocRepresentation.getValueInt(LIGHT_DIMMER_RESOURCE_KEY); + for(OcAttributeInfo ai : this.mAttributes) { + if (ai.getType() == OcAttributeInfo.OC_ATTRIBUTE_TYPE.LIGHT_DIMMER) { + ai.setValueInt(dimmerVal); + } + } + break; + case PLATFORM_LED: + int value = ocRepresentation.getValueInt(PLATFORM_LED_RESOURCE_KEY); + for(OcAttributeInfo ai : this.mAttributes) { + if (ai.getType() == OcAttributeInfo.OC_ATTRIBUTE_TYPE.PLATFORM_LED_SWITCH) { + ai.setValueInt(value); + } + } + break; + case ROOM_TEMPERATURE_SENSOR: + Log.w(TAG, String.format("onPutCompleted(): %s is a readonly attribute type.", + this.mType)); + break; + } + this.notifyListeners(); + if (LOCAL_LOGV) Log.v(TAG, "exit <- onPutCompleted()"); + } + } + + private OC_RESOURCE_TYPE getResourceTypeFromUri(String uri) { + if (LOCAL_LOGV) Log.v(TAG, "getResourceTypeFromUri()"); + + switch(uri) { + case LIGHT_RESOURCE_URI: + case LIGHT_RESOURCE_URI2: + case LIGHT_RESOURCE_URI3: + return OC_RESOURCE_TYPE.LIGHT; + case AMBIENT_LIGHT_RESOURCE_URI: + return OC_RESOURCE_TYPE.AMBIENT_LIGHT_SENSOR; + case PLATFORM_LED_RESOURCE_URI: + return OC_RESOURCE_TYPE.PLATFORM_LED; + case ROOM_TEMPERATURE_RESOURCE_URI: + return OC_RESOURCE_TYPE.ROOM_TEMPERATURE_SENSOR; + default: + Log.w(TAG, "getResourceTypeFromUri(): unsupported resource '" + uri + "'" ); + } + return null; + } +} diff --git a/java/examples-java/guiclient/src/main/java/org/iotivity/guiclient/OcWorker.java b/java/examples-java/guiclient/src/main/java/org/iotivity/guiclient/OcWorker.java new file mode 100644 index 0000000..cb049a6 --- /dev/null +++ b/java/examples-java/guiclient/src/main/java/org/iotivity/guiclient/OcWorker.java @@ -0,0 +1,524 @@ +// +// 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. +// +//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +package org.iotivity.guiclient; + +import android.content.Context; +import android.os.Handler; +import android.os.Looper; +import android.os.Message; +import android.util.Log; + +import org.iotivity.base.ModeType; +import org.iotivity.base.OcConnectivityType; +import org.iotivity.base.OcException; +import org.iotivity.base.OcPlatform; +import org.iotivity.base.OcResource; +import org.iotivity.base.PlatformConfig; +import org.iotivity.base.QualityOfService; +import org.iotivity.base.ServiceType; + +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.List; + +import static org.iotivity.guiclient.OcProtocolStrings.COAP_CORE; +import static org.iotivity.guiclient.OcProtocolStrings.CORE_EDISON_RESOURCES; +import static org.iotivity.guiclient.OcProtocolStrings.CORE_LIGHT; +import static org.iotivity.guiclient.OcProtocolStrings.INTERFACE_QUERY; +import static org.iotivity.guiclient.OcProtocolStrings.RESOURCE_TYPE_QUERY; +import static org.iotivity.guiclient.OcWorker.OCW_IN_MSG.DO_CLEAR_RESOURCES; +import static org.iotivity.guiclient.OcWorker.OCW_IN_MSG.DO_DISCOVER_RESOURCES; +import static org.iotivity.guiclient.OcWorker.OCW_IN_MSG.DO_GET_RESOURCE; +import static org.iotivity.guiclient.OcWorker.OCW_IN_MSG.DO_PUT_RESOURCE; +import static org.iotivity.guiclient.OcWorker.OCW_IN_MSG.fromInt; + +/** + * OcWorker + * + * A class designed to encapsulate the OIC API functionality. OcWorker has its own + * thread which is used to call all OIC APIs. To get results back from OcWorker, + * implement the interface OcWorkerListener, and call registerListener(). + * + * @see org.iotivity.guiclient.OcWorkerListener + * + * Created by nathanhs on 12/22/15. + */ +public class OcWorker extends Thread + implements OcPlatform.OnResourceFoundListener, OcResourceInfo.OcResourceInfoListener { + /** + * Hardcoded TAG... if project never uses proguard then + * MyOcClient.class.getName() is the better way. + */ + private static final String TAG = "OcWorker"; + private Context mContext; + + private static final boolean LOCAL_LOGV = true; // set to false to compile out verbose logging + + /** + * NOTE: DO NOT assign non-default values to these enums! + * The correctness of "fromInt()" depends on the enum values not being + * overridden. For example DO_TEST = 100, RESULT_TEST = 101.. would BREAK the + * fromInt() function. There are designs which can account for arbitrary enum + * values, but they are less desirable for other reasons and since we do not + * need to use any specific value, this design is the best for this case. + */ + + /** + * These "IN" message types are for posting API-generated request actions + * to our OcWorker queue. + */ + public enum OCW_IN_MSG { + DO_TEST, // developer testing only + DO_DISCOVER_RESOURCES, + DO_CLEAR_RESOURCES, + DO_GET_RESOURCE, + DO_PUT_RESOURCE, + DO_OBSERVE_RESOURCE, + DO_STOP_OBSERVING_RESOURCE; + + private static final OCW_IN_MSG[] values = values(); + + public static OCW_IN_MSG fromInt(int i) { + return values[i]; + } + } + + /** + * These events are for internally putting work on our thread's looper + * queue, usually in a callback where we don't want to do work on the + * callback thread. + */ + private enum OC_EVENT { + OIC_RESOURCE_FOUND, + OIC_RESOURCE_CHANGED; + + private static final OC_EVENT[] values = OC_EVENT.values(); + + public static OC_EVENT fromInt(int i) { + return values[i]; + } + } + + private Handler mDoMsgHandler; + + private Handler mOcEventHandler; + + /** + * The OcResourceInfo List + */ + private ArrayList mOcResourceInfoList; + + /** + * The types of OIC Resources included in "FindResource" calls by this object. + */ + private final String[] mOcFindQueries = { + COAP_CORE + RESOURCE_TYPE_QUERY + CORE_LIGHT, + COAP_CORE + INTERFACE_QUERY + CORE_EDISON_RESOURCES + }; + + private List mListeners; + + public OcWorker(Context context) { + if (LOCAL_LOGV) Log.v(TAG, "OcWorker() constructor"); + + mContext = context; + this.mListeners = new ArrayList<>(); + } + + /** + * Set up our Handler and Looper, then initialize the OIC platform and + * start processing messages as they arrive. + */ + public void run() { + if (LOCAL_LOGV) Log.v(TAG, "run()"); + + Looper.prepare(); + this.initHandlers(); // set up our message handler + this.ocInit(); // init the OIC layer including calling ConfigurePlatform + Looper.loop(); + } + + /** + * Registers a listener for OcWorker events. + * + * @see org.iotivity.guiclient.OcWorkerListener + */ + public void registerListener(OcWorkerListener listener) { + if (LOCAL_LOGV) Log.v(TAG, "registerListener()"); + + if(null != this.mListeners) { + this.mListeners.add(listener); + } else { + Log.e(TAG, "registerListener(): null mListeners list; not adding listener!"); + Log.e(TAG, "OcWorker.run() must be called before using public methods."); + } + } + + /** + * The Resource discovery external API + */ + public void doDiscoverResources() { + if (LOCAL_LOGV) Log.v(TAG, "doDiscoverResources()"); + + if(null != this.mDoMsgHandler) { + this.mDoMsgHandler.obtainMessage( + DO_DISCOVER_RESOURCES.ordinal()).sendToTarget(); + } else { + Log.e(TAG, "doDiscoverResources(): null mDoMsgHandler; not discovering resources!"); + Log.e(TAG, "OcWorker.run() must be called before using public methods."); + } + } + + /** + * The GetResource external API + */ + public void doGetResource(OcResourceInfo resourceInfo) { + if (LOCAL_LOGV) Log.v(TAG, "doGetResource()"); + + if(null != this.mDoMsgHandler) { + this.mDoMsgHandler.obtainMessage( + DO_GET_RESOURCE.ordinal(), resourceInfo).sendToTarget(); + } else { + Log.e(TAG, "doPutResource(): null mDoMsgHandler; not putting resource!"); + Log.e(TAG, "OcWorker.run() must be called before using public methods."); + } + } + + /** + * The PutResource external API + */ + public void doPutResource(OcResourceInfo resourceInfo) { + if (LOCAL_LOGV) Log.v(TAG, "doPutResource()"); + + if(null != this.mDoMsgHandler) { + this.mDoMsgHandler.obtainMessage( + DO_PUT_RESOURCE.ordinal(), resourceInfo).sendToTarget(); + } else { + Log.e(TAG, "doPutResource(): null mDoMsgHandler; not putting resource!"); + Log.e(TAG, "OcWorker.run() must be called before using public methods."); + } + } + + /** + * The Clear Resources external API + */ + public void doClearResources() { + if (LOCAL_LOGV) Log.v(TAG, "doClearResources()"); + + if(null != this.mDoMsgHandler) { + this.mDoMsgHandler.obtainMessage( + DO_CLEAR_RESOURCES.ordinal()).sendToTarget(); + } else { + Log.e(TAG, "doClearResources(): null mDoMsgHandler; not clearing resources!"); + Log.e(TAG, "OcWorker.run() must be called before using public methods."); + } + } + + /** + * Set up handlers + */ + private void initHandlers() { + if (LOCAL_LOGV) Log.v(TAG, "initHandler()"); + + this.mDoMsgHandler = new Handler() { + public void handleMessage(Message msg) { + Log.d(TAG, String.format("mDoMsgHandler.handleMessage(%s)", msg.toString())); + // process incoming messages here + OCW_IN_MSG type = fromInt(msg.what); + switch(type) { + case DO_TEST: + break; + case DO_DISCOVER_RESOURCES: + discoverResources(); + break; + case DO_CLEAR_RESOURCES: + clearResourceInfoList(); + break; + case DO_GET_RESOURCE: + getResourceAttributes((OcResourceInfo)msg.obj); + break; + case DO_PUT_RESOURCE: + putResourceAttributes((OcResourceInfo)msg.obj); + break; + case DO_OBSERVE_RESOURCE: + break; + case DO_STOP_OBSERVING_RESOURCE: + break; + default: + Log.e(TAG, "unknown msg.what in handler"); + break; + } + } + }; + + this.mOcEventHandler = new Handler() { + public void handleMessage(Message msg) { + Log.d(TAG, String.format("mOcEventHandler.handleMessage(%s)", msg.toString())); + // process incoming messages here + OC_EVENT type = OC_EVENT.fromInt(msg.what); + switch(type) { + case OIC_RESOURCE_FOUND: + handleNewResourceFound((OcResource)msg.obj); + break; + case OIC_RESOURCE_CHANGED: + handleResourceInfoChange((OcResourceInfo)msg.obj); + break; + } + } + }; + } + + /** + * Get the attributes on resourceInfo. + * + * @param resourceInfo + */ + private void getResourceAttributes(OcResourceInfo resourceInfo) { + if (LOCAL_LOGV) Log.v(TAG, "getResourceAttributes()"); + + // find the matching resource in our resourceList + OcResourceInfo existingResource = this.selectResourceInfoByHostAndUri( + resourceInfo.getHost() + resourceInfo.getUri()); + if(null != existingResource) { + existingResource.doOcGet(); + } else { + Log.e(TAG, "getResourceAttributes(): could not find target resource."); + } + // Done. Later, the onGet listener in the OcResourceInfo object will notify us of a change + // via our onResourceChanged() method + } + + /** + * For each attribute in the resourceInfo.mAttributes, put the attribute value to the + * Resource. + * + * @param resourceInfo + */ + private void putResourceAttributes(OcResourceInfo resourceInfo) { + if (LOCAL_LOGV) Log.v(TAG, "putResourceAttributes()"); + + // find the matching resource in our resourceList + OcResourceInfo existingResource = this.selectResourceInfoByHostAndUri( + resourceInfo.getHost() + resourceInfo.getUri()); + if(null != existingResource) { + // for each attribute in resourceInfo, put that attribute to the resource + for(OcAttributeInfo attribute : resourceInfo.getAttributes()) { + if(false == attribute.isReadOnly()) { + existingResource.doOcPut(attribute); + } + } + } else { + Log.e(TAG, "putResourceAttributes(): could not find target resource."); + } + // Done. later, the onPut listener in the OcResourceInfo object will notify us of a change + // via our onResourceChanged() method + } + + /** + * Because this callback is called on a JNI layer thread, don't do work here. + * Instead, create a "found resource" message and send to OcWorker's message queue, + * Our looper/handler then calls handleNewResource on our own worker thread. + * + * Also note that this method must be thread safe because it can be called by + * multiple concurrent native threads. + * + * @param resource + */ + private Object onResourceFoundLock = new Object(); // not strictly necessary with this impl., + // but clears up Log message readability. + @Override + public void onResourceFound(OcResource resource) { + synchronized (onResourceFoundLock) { + if (LOCAL_LOGV) Log.v(TAG, "onResourceFound()"); + if (LOCAL_LOGV) Log.v(TAG, "host: " + resource.getHost()); + if (LOCAL_LOGV) Log.v(TAG, "uri: " + resource.getUri()); + if (LOCAL_LOGV) Log.v(TAG, "is observable: " + resource.isObservable()); + + this.mOcEventHandler.obtainMessage(OC_EVENT.OIC_RESOURCE_FOUND.ordinal(), + resource).sendToTarget(); + } + } + + /** + * Handles the internal NEW_RESOURCE_FOUND event, typically engueued on "onResourceFound". + * Creates a new OcResourceInfo object to wrap the new OcResource and store other info. + * + * @param resource the OcResource object + */ + private void handleNewResourceFound(OcResource resource) { + if (LOCAL_LOGV) Log.v(TAG, String.format("handleNewResourceFound(%s)", + resource.toString())); + + OcResourceInfo ri = + this.selectResourceInfoByHostAndUri(resource.getHost() + resource.getUri()); + + // before notifying listeners, update our own internal OcResourceInfo list + if(null != mOcResourceInfoList) { + // check for pre-existing duplicate before adding + if(null == ri) { + if (LOCAL_LOGV) Log.v(TAG, "handleNewResourceFound(): ri is new; adding."); + // if not found, create new info object + ri = new OcResourceInfo(resource, this); + // register as a listener to the newly created OcResourceInfo + ri.registerListener(this); + // kick off a get to fill in attributes + ri.doOcGet(); + // add the info object to our list + mOcResourceInfoList.add(ri); + } + } + // notify listeners + for(OcWorkerListener l : this.mListeners) { + l.onResourceFound(ri); + } + } + + /** + * The "listener" callback from the OcResourceInfo class. + * Called by the OcResourceInfo object using the native callback thread. + * We use this callback to post an event to our queue so that the work + * is serialized with other incoming events, and executed on our worker thread. + * + * Also note that this method must be thread safe because it could be called by + * one of many OcResourceInfo objects on separate native threads. + * + * @param resourceInfo + */ + private Object onResourceInfoChangedLock = new Object(); + @Override + public void onResourceInfoChanged(OcResourceInfo resourceInfo) { + + synchronized (onResourceInfoChangedLock) { + if (LOCAL_LOGV) Log.v(TAG, String.format("resourceInfoChanged(%s)", + resourceInfo.toString())); + + // this is a result of a callback (i.e. onGetCompleted, onPut, onObserve) + // so we post a message to our queue to transfer the work to our own thread + this.mOcEventHandler.obtainMessage(OC_EVENT.OIC_RESOURCE_CHANGED.ordinal(), + resourceInfo).sendToTarget(); + } + } + + /** + * Handle our internal event that is enqueued when a resource is found. + * + * @param resourceInfo + */ + private void handleResourceInfoChange(OcResourceInfo resourceInfo) { + if (LOCAL_LOGV) Log.v(TAG, "handleResourceInfoChange()"); + + // notify listeners + for(OcWorkerListener l : this.mListeners) { + l.onResourceChanged(resourceInfo); + } + } + + /** + * Complete OIC-related initialization, including configuring the platform + */ + private void ocInit() { + if (LOCAL_LOGV) Log.v(TAG, "ocInit()"); + + // OIC initialization + mOcResourceInfoList = new ArrayList<>(); + + this.configurePlatform(); + } + + /** + * Configures the OIC platform. + */ + private void configurePlatform() { + if (LOCAL_LOGV) Log.v(TAG, "configurePlatform()"); + + PlatformConfig cfg = new PlatformConfig( + mContext, + ServiceType.IN_PROC, + ModeType.CLIENT_SERVER, + "0.0.0.0", // bind to all available interfaces + 0, + QualityOfService.LOW); + + Log.d(TAG, "configurePlatform(): calling OcPlatform.Configure()"); + OcPlatform.Configure(cfg); + } + + /** + * Search mOcResourceInfo list for a resource whose Host and Uri concatenated + * matches the param passed, and return it. + * + * @param resourceHostAndUri + * @return OcResourceInfo with Host and Uri matching resourceHostAndUri, or null if + * no such OcResourceInfo exists in mOcResourceInfoList + */ + private OcResourceInfo selectResourceInfoByHostAndUri(String resourceHostAndUri) { + if (LOCAL_LOGV) Log.v(TAG, "selectResourceByHostAndUri()"); + + boolean found = false; + OcResourceInfo retVal = null; + + for(OcResourceInfo ri : mOcResourceInfoList) { + if(!found) { + String s = ri.getHost() + ri.getUri(); + if (resourceHostAndUri.equalsIgnoreCase(s)) { + retVal = ri; + found = true; + } + } + } + if(!found) { + Log.v(TAG, "selectResourceByHostAndUri(): no resource found matching HostAndUri " + + resourceHostAndUri); + } + + return retVal; + } + + /** + * Finds OIC Resources matching known patterns. + * + * @see org.iotivity.guiclient.OcProtocolStrings + */ + private void discoverResources() { + if (LOCAL_LOGV) Log.v(TAG, "discoverResources()"); + + try { + for (String s : mOcFindQueries) { + Log.d(TAG, String.format("discoverResources(): Calling OcPlatform.findResource(%s)", s)); + OcPlatform.findResource("", + OcPlatform.WELL_KNOWN_QUERY + "?rt=" + s, + EnumSet.of(OcConnectivityType.CT_DEFAULT), + this); + } + } catch (OcException e) { + e.printStackTrace(); + Log.e(TAG, e.getMessage()); + } + } + + /** + * Clear the ResourceInfoList + */ + private void clearResourceInfoList() { + if (LOCAL_LOGV) Log.v(TAG, "clearResourceInfoList()"); + + this.mOcResourceInfoList.clear(); + } +} diff --git a/java/examples-java/guiclient/src/main/java/org/iotivity/guiclient/OcWorkerListener.java b/java/examples-java/guiclient/src/main/java/org/iotivity/guiclient/OcWorkerListener.java new file mode 100644 index 0000000..d78949b --- /dev/null +++ b/java/examples-java/guiclient/src/main/java/org/iotivity/guiclient/OcWorkerListener.java @@ -0,0 +1,56 @@ +//****************************************************************** +// +// 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. +// +//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +package org.iotivity.guiclient; + +import android.os.Handler; + +import java.util.List; + +/** + * Applications wishing to use the OcWorker object must implement this interface to + * receive notification of OcWorker's ResourceFound and ResourceChanged events. + * + * @see org.iotivity.guiclient.OcWorker + */ +public interface OcWorkerListener { + + /** + * Called whenever a new Resource is discovered. + * + * Note that the calling thread for this callback is not a UI thread. OcWorkerListeners + * with UI functionality should post a message to their own UI thread, or similar action. + * + * @param resourceInfo + */ + public void onResourceFound(final OcResourceInfo resourceInfo); + + /** + * Called whenever a previously-discovered Resource changes, e.g. as a result of Put, + * or Observe callbacks. + * + * Note that the calling thread for this callback is not a UI thread. OcWorkerListeners + * with UI functionality should post a message to their own UI thread, or similar action. + * + * @param resourceInfo + */ + public void onResourceChanged(final OcResourceInfo resourceInfo); + +} diff --git a/java/examples-java/presenceclient/.gitignore b/java/examples-java/presenceclient/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/java/examples-java/presenceclient/.gitignore @@ -0,0 +1 @@ +/build diff --git a/android/examples/presenceclient/build.gradle b/java/examples-java/presenceclient/build.gradle similarity index 100% rename from android/examples/presenceclient/build.gradle rename to java/examples-java/presenceclient/build.gradle diff --git a/java/examples-java/presenceclient/src/main/java/org/iotivity/base/examples/PresenceClient.java b/java/examples-java/presenceclient/src/main/java/org/iotivity/base/examples/PresenceClient.java new file mode 100644 index 0000000..dae5a2b --- /dev/null +++ b/java/examples-java/presenceclient/src/main/java/org/iotivity/base/examples/PresenceClient.java @@ -0,0 +1,240 @@ +/* + ******************************************************************* + * + * 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; + +import android.app.Activity; +import android.content.Context; +import android.os.Bundle; +import android.text.method.ScrollingMovementMethod; +import android.util.Log; +import android.view.View; +import android.widget.CompoundButton; +import android.widget.ScrollView; +import android.widget.TextView; +import android.widget.ToggleButton; + +import org.iotivity.base.ModeType; +import org.iotivity.base.OcConnectivityType; +import org.iotivity.base.OcException; +import org.iotivity.base.OcPlatform; +import org.iotivity.base.OcPresenceHandle; +import org.iotivity.base.OcPresenceStatus; +import org.iotivity.base.OcResource; +import org.iotivity.base.PlatformConfig; +import org.iotivity.base.QualityOfService; +import org.iotivity.base.ServiceType; + +import java.util.EnumSet; + +/** + * A client example for presence notification + */ +public class PresenceClient extends Activity implements + OcPlatform.OnResourceFoundListener, + OcPlatform.OnPresenceListener { + private final static String TAG = PresenceClient.class.getSimpleName(); + private OcResource mResource; + private OcPresenceHandle mPresenceHandle; + private TextView mConsoleTextView; + private ScrollView mScrollView; + + private void startPresenceClient() { + Context context = this; + + PlatformConfig platformConfig = new PlatformConfig( + context, + ServiceType.IN_PROC, + ModeType.CLIENT, + "0.0.0.0", // By setting to "0.0.0.0", it binds to all available interfaces + 0, // Uses randomly available port + QualityOfService.LOW + ); + + msg("Configuring platform."); + OcPlatform.Configure(platformConfig); + + try { + msg("Finding Resource..."); + OcPlatform.findResource("", OcPlatform.WELL_KNOWN_QUERY, + EnumSet.of(OcConnectivityType.CT_DEFAULT), this); + } catch (OcException e) { + Log.e(TAG, e.toString()); + msg("Failed to find resource(s). "); + } + printLine(); + enableStartStopButton(); + } + + //****************************************************************************** + // End of the OIC specific code + //****************************************************************************** + + @Override + public synchronized void onResourceFound(OcResource foundResource) { + String resourceUri = foundResource.getUri(); + if (null != mResource || !resourceUri.equals("/a/light")) { + msg("Found resource, ignoring"); + return; + } + + msg("Found Resource"); + String hostAddress = foundResource.getHost(); + msg("\tResource URI : " + resourceUri); + msg("\tResource Host : " + hostAddress); + msg("\tResource Interfaces : "); + for (String resInterface : foundResource.getResourceInterfaces()) { + msg("\t\t" + resInterface); + } + msg("\tResource Type : "); + for (String resTypes : foundResource.getResourceTypes()) { + msg("\t\t" + resTypes); + } + + try { + msg("Subscribing to unicast address:" + hostAddress); + OcPlatform.subscribePresence(hostAddress, + EnumSet.of(OcConnectivityType.CT_DEFAULT), this); + } catch (OcException e) { + Log.e(TAG, e.toString()); + msg("Failed to subscribe to unicast address:" + hostAddress); + } + mResource = foundResource; + printLine(); + } + + @Override + public void onPresence(OcPresenceStatus ocPresenceStatus, int nonce, String hostAddress) { + msg("Received presence notification from : " + hostAddress); + switch (ocPresenceStatus) { + case OK: + msg("Nonce# " + nonce); + break; + case STOPPED: + msg("Presence Stopped"); + break; + case TIMEOUT: + msg("Presence Timeout"); + break; + case DO_NOT_HANDLE: + msg("Presence Do Not Handle"); + break; + } + } + + private void stopPresenceClient() { + if (null != mPresenceHandle) { + try { + msg("Unsubscribing from the presence notifications."); + OcPlatform.unsubscribePresence(mPresenceHandle); + mPresenceHandle = null; + } catch (OcException e) { + Log.e(TAG, e.toString()); + msg("Failed to unsubscribe from the presence notifications" + e.toString()); + } + } + mResource = null; + printLine(); + enableStartStopButton(); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_presence_client); + + mConsoleTextView = (TextView) findViewById(R.id.consoleTextView); + mConsoleTextView.setMovementMethod(new ScrollingMovementMethod()); + mScrollView = (ScrollView) findViewById(R.id.scrollView); + mScrollView.fullScroll(View.FOCUS_DOWN); + final ToggleButton toggleButton = (ToggleButton) findViewById(R.id.toggleButton); + + if (null == savedInstanceState) { + toggleButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + toggleButton.setEnabled(false); + if (isChecked) { + new Thread(new Runnable() { + public void run() { + startPresenceClient(); + } + }).start(); + } else { + new Thread(new Runnable() { + public void run() { + stopPresenceClient(); + } + }).start(); + } + } + }); + } else { + String consoleOutput = savedInstanceState.getString("consoleOutputString"); + mConsoleTextView.setText(consoleOutput); + boolean buttonCheked = savedInstanceState.getBoolean("toggleButtonChecked"); + toggleButton.setChecked(buttonCheked); + } + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + outState.putString("consoleOutputString", mConsoleTextView.getText().toString()); + ToggleButton toggleButton = (ToggleButton) findViewById(R.id.toggleButton); + outState.putBoolean("toggleButtonChecked", toggleButton.isChecked()); + } + + @Override + protected void onRestoreInstanceState(Bundle savedInstanceState) { + super.onRestoreInstanceState(savedInstanceState); + + String consoleOutput = savedInstanceState.getString("consoleOutputString"); + mConsoleTextView.setText(consoleOutput); + + final ToggleButton toggleButton = (ToggleButton) findViewById(R.id.toggleButton); + boolean buttonCheked = savedInstanceState.getBoolean("toggleButtonChecked"); + toggleButton.setChecked(buttonCheked); + } + + private void msg(final String text) { + runOnUiThread(new Runnable() { + public void run() { + mConsoleTextView.append("\n"); + mConsoleTextView.append(text); + mScrollView.fullScroll(View.FOCUS_DOWN); + } + }); + Log.i(TAG, text); + } + + private void printLine() { + msg("------------------------------------------------------------------------"); + } + + private void enableStartStopButton() { + runOnUiThread(new Runnable() { + public void run() { + ToggleButton toggleButton = (ToggleButton) findViewById(R.id.toggleButton); + toggleButton.setEnabled(true); + } + }); + } +} \ No newline at end of file diff --git a/java/examples-java/presenceserver/.gitignore b/java/examples-java/presenceserver/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/java/examples-java/presenceserver/.gitignore @@ -0,0 +1 @@ +/build diff --git a/android/examples/presenceserver/build.gradle b/java/examples-java/presenceserver/build.gradle similarity index 100% rename from android/examples/presenceserver/build.gradle rename to java/examples-java/presenceserver/build.gradle diff --git a/java/examples-java/presenceserver/src/main/java/org/iotivity/base/examples/PresenceServer.java b/java/examples-java/presenceserver/src/main/java/org/iotivity/base/examples/PresenceServer.java new file mode 100644 index 0000000..fcd612b --- /dev/null +++ b/java/examples-java/presenceserver/src/main/java/org/iotivity/base/examples/PresenceServer.java @@ -0,0 +1,219 @@ +/* + ******************************************************************* + * + * 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; + +import android.app.Activity; +import android.content.Context; +import android.os.Bundle; +import android.text.method.ScrollingMovementMethod; +import android.util.Log; +import android.view.View; +import android.widget.CompoundButton; +import android.widget.ScrollView; +import android.widget.TextView; +import android.widget.ToggleButton; + +import org.iotivity.base.ModeType; +import org.iotivity.base.OcException; +import org.iotivity.base.OcPlatform; +import org.iotivity.base.OcResourceHandle; +import org.iotivity.base.PlatformConfig; +import org.iotivity.base.QualityOfService; +import org.iotivity.base.ResourceProperty; +import org.iotivity.base.ServiceType; + +import java.util.EnumSet; + +/** + * A server example for presence notification + */ +public class PresenceServer extends Activity { + private OcResourceHandle mResourceHandle; + + private void startPresenceServer() { + Context context = this; + + PlatformConfig platformConfig = new PlatformConfig( + context, + ServiceType.IN_PROC, + ModeType.SERVER, + "0.0.0.0", // By setting to "0.0.0.0", it binds to all available interfaces + 0, // Uses randomly available port + QualityOfService.LOW + ); + + msg("Configuring platform."); + OcPlatform.Configure(platformConfig); + + try { + msg("Creating resource of type \"core.light\"."); + createResource(); + sleep(1); + + msg("Starting presence notifications."); + OcPlatform.startPresence(OcPlatform.DEFAULT_PRESENCE_TTL); + sleep(1); + } catch (OcException e) { + Log.e(TAG, e.toString()); + msg("Error: " + e.toString()); + } + printLine(); + enableStartStopButton(); + } + + /** + * This function internally calls registerResource API. + */ + private void createResource() { + String resourceUri = "/a/light"; // URI of the resource + String resourceTypeName = "core.light"; // resource type name. + String resourceInterface = OcPlatform.DEFAULT_INTERFACE; // resource interface. + + try { + // This will internally create and register the resource. + mResourceHandle = OcPlatform.registerResource( + resourceUri, + resourceTypeName, + resourceInterface, + null, //Use default entity handler + EnumSet.of(ResourceProperty.DISCOVERABLE)); + } catch (OcException e) { + msg("Resource creation was unsuccessful."); + Log.e(TAG, e.toString()); + } + } + + private void stopPresenceServer() { + try { + msg("Stopping presence notifications."); + OcPlatform.stopPresence(); + + msg("Unregister resource."); + if (null != mResourceHandle) OcPlatform.unregisterResource(mResourceHandle); + } catch (OcException e) { + Log.e(TAG, e.toString()); + msg("Error: " + e.toString()); + } + + printLine(); + enableStartStopButton(); + } + + //****************************************************************************** + // End of the OIC specific code + //****************************************************************************** + + private final static String TAG = PresenceServer.class.getSimpleName(); + private TextView mConsoleTextView; + private ScrollView mScrollView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_presence_server); + + mConsoleTextView = (TextView) findViewById(R.id.consoleTextView); + mConsoleTextView.setMovementMethod(new ScrollingMovementMethod()); + mScrollView = (ScrollView) findViewById(R.id.scrollView); + mScrollView.fullScroll(View.FOCUS_DOWN); + final ToggleButton toggleButton = (ToggleButton) findViewById(R.id.toggleButton); + + if (null == savedInstanceState) { + toggleButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + toggleButton.setEnabled(false); + if (isChecked) { + new Thread(new Runnable() { + public void run() { + startPresenceServer(); + } + }).start(); + } else { + new Thread(new Runnable() { + public void run() { + stopPresenceServer(); + } + }).start(); + } + } + }); + } else { + String consoleOutput = savedInstanceState.getString("consoleOutputString"); + mConsoleTextView.setText(consoleOutput); + boolean buttonCheked = savedInstanceState.getBoolean("toggleButtonChecked"); + toggleButton.setChecked(buttonCheked); + } + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + outState.putString("consoleOutputString", mConsoleTextView.getText().toString()); + ToggleButton toggleButton = (ToggleButton) findViewById(R.id.toggleButton); + outState.putBoolean("toggleButtonChecked", toggleButton.isChecked()); + } + + @Override + protected void onRestoreInstanceState(Bundle savedInstanceState) { + super.onRestoreInstanceState(savedInstanceState); + + String consoleOutput = savedInstanceState.getString("consoleOutputString"); + mConsoleTextView.setText(consoleOutput); + + final ToggleButton toggleButton = (ToggleButton) findViewById(R.id.toggleButton); + boolean buttonCheked = savedInstanceState.getBoolean("toggleButtonChecked"); + toggleButton.setChecked(buttonCheked); + } + + private void msg(final String text) { + runOnUiThread(new Runnable() { + public void run() { + mConsoleTextView.append("\n"); + mConsoleTextView.append(text); + mScrollView.fullScroll(View.FOCUS_DOWN); + } + }); + Log.i(TAG, text); + } + + private void printLine() { + msg("------------------------------------------------------------------------"); + } + + private void sleep(int seconds) { + try { + Thread.sleep(seconds * 1000); + } catch (InterruptedException e) { + e.printStackTrace(); + Log.e(TAG, e.toString()); + } + } + + private void enableStartStopButton() { + runOnUiThread(new Runnable() { + public void run() { + ToggleButton toggleButton = (ToggleButton) findViewById(R.id.toggleButton); + toggleButton.setEnabled(true); + } + }); + } +} \ No newline at end of file diff --git a/android/examples/provisioningclient/build.gradle b/java/examples-java/provisioningclient/build.gradle similarity index 100% rename from android/examples/provisioningclient/build.gradle rename to java/examples-java/provisioningclient/build.gradle diff --git a/java/examples-java/provisioningclient/src/main/assets/oic_svr_db_client.json b/java/examples-java/provisioningclient/src/main/assets/oic_svr_db_client.json new file mode 100644 index 0000000..1219d6a --- /dev/null +++ b/java/examples-java/provisioningclient/src/main/assets/oic_svr_db_client.json @@ -0,0 +1,43 @@ +{ + "acl": [ + { + "sub": "Kg==", + "rsrc": [ + "/oic/res", + "/oic/d", + "/oic/p", + "/oic/res/types/d", + "/oic/ad", + "/oic/sec/amacl" + ], + "perms": 2, + "ownrs" : ["YWRtaW5EZXZpY2VVVUlEMA=="] + }, + { + "sub": "Kg==", + "rsrc": [ + "/oic/sec/doxm", + "/oic/sec/pstat" + ], + "perms": 2, + "ownrs" : ["YWRtaW5EZXZpY2VVVUlEMA=="] + } + ], + "pstat": { + "isop": true, + "deviceid": "YWRtaW5EZXZpY2VVVUlEMA==", + "ch": 0, + "cm": 0, + "tm": 0, + "om": 3, + "sm": [3] + }, + "doxm": { + "oxm": [0], + "oxmsel": 0, + "sct": 1, + "owned": true, + "deviceid": "YWRtaW5EZXZpY2VVVUlEMA==", + "ownr": "YWRtaW5EZXZpY2VVVUlEMA==" + } +} diff --git a/java/examples-java/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/ProvisioningClient.java b/java/examples-java/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/ProvisioningClient.java new file mode 100644 index 0000000..df92e2f --- /dev/null +++ b/java/examples-java/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/ProvisioningClient.java @@ -0,0 +1,593 @@ +package org.iotivity.base.examples.provisioningclient; + +import android.app.Activity; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.AsyncTask; +import android.os.Bundle; +import android.os.Message; +import android.preference.PreferenceManager; +import android.text.method.ScrollingMovementMethod; +import android.util.Log; +import android.view.Gravity; +import android.widget.LinearLayout; +import android.widget.TextView; +import org.iotivity.base.ModeType; +import org.iotivity.base.OcException; +import org.iotivity.base.OcPlatform; +import org.iotivity.base.PlatformConfig; +import org.iotivity.base.QualityOfService; +import org.iotivity.base.ServiceType; +import org.iotivity.base.OcProvisioning; +import org.iotivity.base.OcSecureResource; +import org.iotivity.base.ProvisionResult; +import org.iotivity.base.OxmType; +import org.iotivity.base.OicSecAcl; +import org.iotivity.base.CredType; +import org.iotivity.base.KeySize; +import org.iotivity.base.DeviceStatus; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.List; + +public class ProvisioningClient extends Activity implements + OcSecureResource.DoOwnershipTransferListener,OcSecureResource.ProvisionPairwiseDevicesListener { + + private static final String TAG = "Provisioning Client: "; + private static final int BUFFER_SIZE = 1024; + int unownedDevCount = StringConstants.NUMBER_ZERO; + private String filePath = ""; + private OcSecureResource newSecureResource; + private List deviceList; + private List ownedDeviceList; + private TextView mEventsTextView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_secure_provision_client); + mEventsTextView = new TextView(this); + mEventsTextView.setGravity(Gravity.BOTTOM); + mEventsTextView.setMovementMethod(new ScrollingMovementMethod()); + LinearLayout layout = (LinearLayout) findViewById(R.id.linearLayout); + layout.addView(mEventsTextView, new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f) + ); + filePath = getFilesDir().getPath() + "/"; // data/data//files/ + //copy json when application runs first time + SharedPreferences wmbPreference = PreferenceManager.getDefaultSharedPreferences(this); + boolean isFirstRun = wmbPreference.getBoolean("FIRSTRUN", true); + if (isFirstRun) { + copyJsonFromAsset(); + SharedPreferences.Editor editor = wmbPreference.edit(); + editor.putBoolean("FIRSTRUN", false); + editor.commit(); + } + initOICStack(); + } + + OcProvisioning.PinCallbackListener pinCallbackListener = + new OcProvisioning.PinCallbackListener() { + @Override + public String pinCallbackListener() { + Log.d(TAG, "Inside Pin Callback "); + return ""; + } + }; + + OcSecureResource.ProvisionAclListener provisionAclListener = + new OcSecureResource.ProvisionAclListener() { + @Override + public void provisionAclListener(List provisionResults, + int hasError) { + Log.d(TAG, "Inside ProvisionAclListener "); + if (hasError == StringConstants.ERROR_CODE) { + logMessage("Error: ACL Provision failed !!"); + } else { + logMessage("ACL Provision Done !!"); + new DeviceRevocationAsyncTask().execute(); + } + } + }; + + OcSecureResource.ProvisionCredentialsListener provisionCredentialsListener = + new OcSecureResource.ProvisionCredentialsListener() { + @Override + public void provisionCredentialsListener(List provisionResults, + int hasError) { + Log.d(TAG, "Inside ProvisionCredentialsListener "); + if (hasError == StringConstants.ERROR_CODE) { + logMessage("Error: Provision Credentials failed !!"); + } else { + logMessage("Provision Credentials Done !!"); + new ProvisionACLAsyncTask().execute(); + } + } + }; + + OcSecureResource.UnlinkDevicesListener unlinkDevicesListener = + new OcSecureResource.UnlinkDevicesListener() { + @Override + public void unlinkDevicesListener(List provisionResults, + int hasError) { + Log.d(TAG, "Inside unlinkDevicesListener "); + if (hasError == StringConstants.ERROR_CODE) { + logMessage("Error: UnLinking device !!"); + } else { + logMessage("Unlink Done !!"); + new ProvisionCredentialAsyncTask().execute(); + } + } + }; + + OcSecureResource.RemoveDeviceListener removeDeviceListener = + new OcSecureResource.RemoveDeviceListener() { + @Override + public void removeDeviceListener(List provisionResults, + int hasError) { + if (hasError == StringConstants.ERROR_CODE) { + logMessage("Error: Remove Fail !!"); + } else { + logMessage("Remove Device done !!"); + } + } + }; + + /** + * configure OIC platform and call findResource + */ + private void initOICStack() { + //create platform config + PlatformConfig cfg = new PlatformConfig( + this, + ServiceType.IN_PROC, + ModeType.CLIENT_SERVER, + "0.0.0.0", // bind to all available interfaces + 0, + QualityOfService.LOW, filePath + StringConstants.OIC_CLIENT_JSON_DB_FILE); + OcPlatform.Configure(cfg); + try { + /* + * Initialize DataBase + */ + String sqlDbPath = getFilesDir().getAbsolutePath().replace("files", "databases") + + File.separator; + File file = new File(sqlDbPath); + //check files directory exists + if (!(file.isDirectory())) { + file.mkdirs(); + Log.d(TAG, "Sql db directory created at " + sqlDbPath); + } + Log.d(TAG, "Sql db directory exists at " + sqlDbPath); + OcProvisioning.provisionInit(sqlDbPath + StringConstants.OIC_SQL_DB_FILE); + } catch (OcException e) { + logMessage(TAG + "provisionInit error: " + e.getMessage()); + Log.e(TAG, e.getMessage()); + } + new DiscoveryOTTransferAsyncTask().execute(); + } + + @Override + synchronized public void doOwnershipTransferListener(List ProvisionResultList, + int hasError) { + ProvisionResult pResult = ProvisionResultList.get(0); + if (hasError == StringConstants.ERROR_CODE) { + logMessage(TAG + "Ownership Transfer Failed for " + pResult.getDevId()); + } else { + logMessage(TAG + "Ownership Transfer Successful for " + + pResult.getDevId()); + unownedDevCount--; + } + if (unownedDevCount == 0) { //When done with Ownership Transfer + new OwnedDiscoveryAsyncTask().execute(); + } + } + + private void doPairwiseProvisioning() { + try { + logMessage(TAG + "Pairwise Provisioning b/w " + ownedDeviceList.get(0).getDeviceID() + + " and " + ownedDeviceList.get(1).getDeviceID()); + newSecureResource = ownedDeviceList.get(0); + OcSecureResource newSecureResource2 = ownedDeviceList.get(1); + List resources = new ArrayList(); + List owners = new ArrayList(); + List periods = new ArrayList(); + List recurrences = new ArrayList(); + recurrences.add("Daily"); + resources.add("*"); + owners.add("adminDeviceUUID0"); + periods.add("01-01-15"); + OicSecAcl acl1 = new OicSecAcl(newSecureResource.getDeviceID(), recurrences, periods, + 31, resources, owners); + OicSecAcl acl2 = new OicSecAcl(newSecureResource2.getDeviceID(), recurrences, periods, + 31, resources, owners); + newSecureResource.provisionPairwiseDevices(EnumSet.of(CredType.SYMMETRIC_PAIR_WISE_KEY), + KeySize.OWNER_PSK_LENGTH_128, acl1, newSecureResource2, acl2, this); + } catch (Exception e) { + logMessage(TAG + "Pairwise Provisioning error: " + e.getMessage()); + Log.e(TAG, e.getMessage()); + } + } + + @Override + public void provisionPairwiseDevicesListener(List ProvisionResultList, + int hasError) { + if (hasError == StringConstants.ERROR_CODE) { + logMessage(TAG + "provisionPairwiseDevices Failed"); + } else { + for (int i = 0; i < ProvisionResultList.size(); i++) { + ProvisionResult pResult = ProvisionResultList.get(i); + logMessage(TAG + "provisionPairwiseDevices Result for " + + pResult.getDevId() + "is " + pResult.getResult()); + } + new GetLinkedDevicesAsyncTask().execute(); + } + } + + /** + * Copy svr db json file from assets folder to app data files dir + */ + private void copyJsonFromAsset() { + InputStream inputStream = null; + OutputStream outputStream = null; + int length; + byte[] buffer = new byte[BUFFER_SIZE]; + try { + inputStream = getAssets().open(StringConstants.OIC_CLIENT_JSON_DB_FILE); + File file = new File(filePath); + //check files directory exists + if (!(file.exists() && file.isDirectory())) { + file.mkdirs(); + } + outputStream = new FileOutputStream(filePath + StringConstants.OIC_CLIENT_JSON_DB_FILE); + while ((length = inputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, length); + } + } catch (NullPointerException e) { + logMessage(TAG + "Null pointer exception " + e.getMessage()); + Log.e(TAG, e.getMessage()); + } catch (FileNotFoundException e) { + logMessage(TAG + "Json svr db file not found " + e.getMessage()); + Log.e(TAG, e.getMessage()); + } catch (IOException e) { + logMessage(TAG + StringConstants.OIC_CLIENT_JSON_DB_FILE + " file copy failed"); + Log.e(TAG, e.getMessage()); + } finally { + if (inputStream != null) { + try { + inputStream.close(); + } catch (IOException e) { + Log.e(TAG, e.getMessage()); + } + } + if (outputStream != null) { + try { + outputStream.close(); + } catch (IOException e) { + Log.e(TAG, e.getMessage()); + } + } + } + } + + 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(text); + mEventsTextView.append("\n\n"); + } + }); + Log.i(TAG, text); + Intent intent = new Intent(getPackageName()); + intent.putExtra(StringConstants.MESSAGE, text); + sendBroadcast(intent); + } + + private class DiscoveryOTTransferAsyncTask extends AsyncTask { + + @Override + protected void onPreExecute() { + super.onPreExecute(); + } + + @Override + protected String doInBackground(Void... params) { + try { + /** + * Discover Un-owned devices + */ + publishProgress(TAG + "Discovering Unowned Devices"); + deviceList = new ArrayList(OcProvisioning.discoverUnownedDevices + (StringConstants.DISCOVERY_TIMEOUT_10)); + if (deviceList.size() > 0) { + unownedDevCount = deviceList.size(); + for (int i = 0; i < deviceList.size(); i++) { + publishProgress(TAG + "Un-owned Discovered Device " + (i + 1) + "= " + + deviceList.get(i).getDeviceID()); + } + try { + OcProvisioning.SetownershipTransferCBdata(OxmType.OIC_JUST_WORKS, + pinCallbackListener); + for (int i = 0; i < deviceList.size(); i++) { + publishProgress(TAG + "Doing Ownership Transfer for " + + deviceList.get(i).getDeviceID()); + deviceList.get(i).doOwnershipTransfer(ProvisioningClient.this); + } + } catch (OcException e) { + publishProgress(TAG + "Ownership Transfer error: " + e.getMessage()); + return "Ownership Transfer error: " + e.getMessage(); + + } + } else { + publishProgress(TAG + "No un-owned devices present"); + new OwnedDiscoveryAsyncTask().execute(); + } + } catch (OcException e) { + publishProgress(TAG + "Un-owned discovery error: " + e.getMessage()); + return "Un-owned discovery error: " + e.getMessage(); + } + return "success"; + } + + @Override + protected void onProgressUpdate(String... values) { + logMessage(values[0]); + } + + @Override + protected void onPostExecute(String s) { + super.onPostExecute(s); + } + } + + private class ProvisionACLAsyncTask extends AsyncTask { + + @Override + protected void onPreExecute() { + super.onPreExecute(); + } + + @Override + protected Void doInBackground(Void... params) { + try { + if (ownedDeviceList.size() > 1) { + OcSecureResource ocSecureResource = ownedDeviceList.get(0); + OcSecureResource ocSecureResourceDest = ownedDeviceList.get(1); + publishProgress(TAG + "ACL Provision for " + ocSecureResource.getDeviceID()); + List resources = new ArrayList(); + List owners = new ArrayList(); + List periods = new ArrayList(); + List recurrences = new ArrayList(); + recurrences.add("Daily"); + resources.add("*"); + owners.add("adminDeviceUUID0"); + periods.add("01-01-15"); + OicSecAcl aclObject = new OicSecAcl(ocSecureResourceDest.getDeviceID(), + recurrences, periods, 31, resources, owners); + ocSecureResource.provisionACL(aclObject, provisionAclListener); + } else { + publishProgress(TAG + "No Owned devices present"); + } + } catch (Exception e) { + publishProgress(TAG + "ProvisionACL error: " + e.getMessage()); + } + return null; + } + + @Override + protected void onProgressUpdate(String... values) { + logMessage(values[0]); + } + } + + private class ProvisionCredentialAsyncTask extends AsyncTask { + + @Override + protected void onPreExecute() { + super.onPreExecute(); + } + + @Override + protected Void doInBackground(Void... params) { + try { + if (ownedDeviceList.size() > 1) { + OcSecureResource ocSecureResource = ownedDeviceList.get(0); + OcSecureResource ocSecureResourceDest = ownedDeviceList.get(1); + publishProgress(TAG + "ProvisionCredential for " + + ocSecureResource.getDeviceID() + " with " + + ocSecureResourceDest.getDeviceID()); + ocSecureResource.provisionCredentials(EnumSet.of(CredType.SYMMETRIC_PAIR_WISE_KEY), + KeySize.OWNER_PSK_LENGTH_128, + ocSecureResourceDest, provisionCredentialsListener); + } else { + publishProgress(TAG + "Cannot perform credentials between devices"); + } + } catch (Exception e) { + publishProgress(TAG + "Provision credentials error: " + e.getMessage()); + } + return null; + } + + @Override + protected void onProgressUpdate(String... values) { + logMessage(values[0]); + } + } + + private class GetLinkedDevicesAsyncTask extends AsyncTask { + + @Override + protected void onPreExecute() { + super.onPreExecute(); + } + + @Override + protected String doInBackground(Void... params) { + try { + if (ownedDeviceList.size() > 1) { + OcSecureResource ocSecureResource = ownedDeviceList.get(0); + publishProgress(TAG + "Get linked devices of " + ocSecureResource.getDeviceID()); + List linkedDevices = ocSecureResource.getLinkedDevices(); + if (linkedDevices.size() > 0) { + for (int i = 0; i < linkedDevices.size(); i++) { + publishProgress(TAG + "Linked Devices "+ + (i + 1) + "= " + linkedDevices.get(i)); + } + } else { + publishProgress(TAG + "No linked Devices found"); + } + } else { + publishProgress(TAG + "Cannot perform linked devices"); + } + } catch (Exception e) { + publishProgress(TAG + "getLinked device error: " + e.getMessage()); + return "failed"; + } + return "success"; + } + + @Override + protected void onProgressUpdate(String... values) { + logMessage(values[0]); + } + + @Override + protected void onPostExecute(String s) { + if ("success".equals(s)) { + new ProvisionUnlinkAsyncTask().execute(); + } + } + } + + private class ProvisionUnlinkAsyncTask extends AsyncTask { + + @Override + protected void onPreExecute() { + super.onPreExecute(); + } + + @Override + protected Void doInBackground(Void... params) { + try { + if (ownedDeviceList.size() > 1) { + OcSecureResource ocSecureResource = ownedDeviceList.get(0); + OcSecureResource ocSecureResourceDest = ownedDeviceList.get(1); + publishProgress(TAG + "Un linking " + ocSecureResource.getDeviceID() + + " with " + ocSecureResourceDest.getDeviceID()); + ocSecureResource.unlinkDevices(ocSecureResourceDest, unlinkDevicesListener); + } else { + publishProgress(TAG + "Cannot perform unlink devices"); + } + } catch (Exception e) { + publishProgress(TAG + "Unlink error: " + e.getMessage()); + } + return null; + } + + @Override + protected void onProgressUpdate(String... values) { + logMessage(values[0]); + } + } + + private class DeviceRevocationAsyncTask extends AsyncTask { + + @Override + protected void onPreExecute() { + super.onPreExecute(); + } + + @Override + protected Void doInBackground(Void... params) { + try { + if (ownedDeviceList.size() > 0) { + OcSecureResource ocSecureResource = ownedDeviceList.get(0); + publishProgress(TAG + "Removing " + ocSecureResource.getDeviceID()); + ocSecureResource.removeDevice(StringConstants.DISCOVERY_TIMEOUT_20, + removeDeviceListener); + } else { + publishProgress(TAG + "Cannot remove"); + } + } catch (Exception e) { + publishProgress(TAG + "Remove Device error: " + e.getMessage()); + } + return null; + } + + @Override + protected void onProgressUpdate(String... values) { + logMessage(values[0]); + } + } + + private class OwnedDiscoveryAsyncTask extends AsyncTask { + + @Override + protected void onPreExecute() { + super.onPreExecute(); + } + + @Override + protected String doInBackground(Void... params) { + try { + publishProgress(TAG + "Initiate Owned device Discovery"); + ownedDeviceList = OcProvisioning.discoverOwnedDevices + (StringConstants.DISCOVERY_TIMEOUT_10); + if (ownedDeviceList.size() > 0) { + for (int i = 0; i < ownedDeviceList.size(); i++) { + publishProgress(TAG + "Owned Discovered Device " + (i + 1) + "= " + + ownedDeviceList.get(i).getDeviceID() + + "\nIP Address= " + ownedDeviceList.get(i).getIpAddr() + + "\nOwned Status= " + ownedDeviceList.get(i).getOwnedStatus() + + "\nDevice Status= " + ((ownedDeviceList.get(i). + getDeviceStatus() == DeviceStatus.ON) ? "ON" : "OFF") + ); + } + } else { + publishProgress(TAG + "No Owned devices present"); + } + } catch (OcException e) { + publishProgress(TAG + "Owned device Discovery error: " + e.getMessage()); + return "Owned device Discovery error: " + e.getMessage(); + } + return "success"; + } + + @Override + protected void onProgressUpdate(String... values) { + logMessage(values[0]); + } + + @Override + protected void onPostExecute(String s) { + if (ownedDeviceList.size() > 1 && "success".equals(s)) { + doPairwiseProvisioning(); + } + } + } + + /** + * to display on Server Message on Client screen + */ + public class MessageReceiver extends BroadcastReceiver { + @Override + public void onReceive(Context context, Intent intent) { + final String message = intent.getStringExtra(StringConstants.MESSAGE); + logMessage(message); + } + } +} diff --git a/java/examples-java/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/StringConstants.java b/java/examples-java/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/StringConstants.java new file mode 100644 index 0000000..9c9baed --- /dev/null +++ b/java/examples-java/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/StringConstants.java @@ -0,0 +1,14 @@ +package org.iotivity.base.examples.provisioningclient; + +public interface StringConstants { + + public static final int NUMBER_ZERO = 0; + public static final int DISCOVERY_TIMEOUT_10 = 10; + public static final int DISCOVERY_TIMEOUT_20 = 20; + public static final int ERROR_CODE = 1; + public static final String OIC_CLIENT_JSON_DB_FILE = "oic_svr_db_client.json"; + public static final String MESSAGE = "message"; + public static final String OIC_SQL_DB_FILE = "Pdm.db"; + public static final int CREDENTIAL_TYPE=1; + public static final int OWNER_PSK_LENGTH_128=128/8; +} diff --git a/java/examples-java/settings.gradle b/java/examples-java/settings.gradle new file mode 100755 index 0000000..126def3 --- /dev/null +++ b/java/examples-java/settings.gradle @@ -0,0 +1 @@ +include ':simpleserver', ':simpleclient'//, ':fridgeserver', ':fridgeclient', ':guiclient', ':provisioningclient', ':presenceserver', ':presenceclient', ':devicediscoveryclient', ':devicediscoveryserver', ':groupclient', ':groupserver', ':fridgegroupclient', ':fridgegroupserver' diff --git a/java/examples-java/simpleclient/.gitignore b/java/examples-java/simpleclient/.gitignore new file mode 100644 index 0000000..3543521 --- /dev/null +++ b/java/examples-java/simpleclient/.gitignore @@ -0,0 +1 @@ +/build diff --git a/java/examples-java/simpleclient/build.gradle b/java/examples-java/simpleclient/build.gradle new file mode 100644 index 0000000..e69de29 diff --git a/java/examples-java/simpleclient/src/main/assets/oic_svr_db_client.json b/java/examples-java/simpleclient/src/main/assets/oic_svr_db_client.json new file mode 100644 index 0000000..c16acb8 --- /dev/null +++ b/java/examples-java/simpleclient/src/main/assets/oic_svr_db_client.json @@ -0,0 +1,50 @@ +{ + "acl": [ + { + "sub": "Kg==", + "rsrc": [ + "/oic/res", + "/oic/d", + "/oic/p", + "/oic/res/types/d", + "/oic/ad", + "/oic/sec/acl" + ], + "perms": 2, + "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="] + }, + { + "sub": "Kg==", + "rsrc": [ + "/oic/sec/doxm", + "/oic/sec/pstat" + ], + "perms": 2, + "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="] + } + ], + "pstat": { + "isop": true, + "deviceid": "ZGV2aWNlaWQAAAAAABhanw==", + "ch": 0, + "cm": 0, + "tm": 0, + "om": 3, + "sm": [3] + }, + "doxm": { + "oxm": [0], + "oxmsel": 0, + "sct": 1, + "owned": true, + "deviceid": "MjIyMjIyMjIyMjIyMjIyMg==", + "ownr": "MjIyMjIyMjIyMjIyMjIyMg==" + }, + "cred": [{ + "credid": 1, + "sub": "MTExMTExMTExMTExMTExMQ==", + "credtyp": 1, + "pvdata": "QUFBQUFBQUFBQUFBQUFBQQ==", + "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="] + }] +} diff --git a/java/examples-java/simpleclient/src/main/java/org/iotivity/base/examples/Light.java b/java/examples-java/simpleclient/src/main/java/org/iotivity/base/examples/Light.java new file mode 100644 index 0000000..d40c196 --- /dev/null +++ b/java/examples-java/simpleclient/src/main/java/org/iotivity/base/examples/Light.java @@ -0,0 +1,92 @@ +/* + ******************************************************************* + * + * 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; + +import org.iotivity.base.OcException; +import org.iotivity.base.OcRepresentation; + +/** + * Light + *

+ * This class is used by SimpleClient to create an object representation of a remote light resource + * and update the values depending on the server response + */ +public class Light { + public static final String NAME_KEY = "name"; + public static final String STATE_KEY = "state"; + public static final String POWER_KEY = "power"; + + private String mName; + private boolean mState; + private int mPower; + + public Light() { + mName = ""; + mState = false; + mPower = 0; + } + + public void setOcRepresentation(OcRepresentation rep) throws OcException { + mName = rep.getValue(NAME_KEY); + mState = rep.getValue(Light.STATE_KEY); + mPower = rep.getValue(Light.POWER_KEY); + } + + public OcRepresentation getOcRepresentation() throws OcException { + OcRepresentation rep = new OcRepresentation(); + rep.setValue(NAME_KEY, mName); + rep.setValue(STATE_KEY, mState); + rep.setValue(POWER_KEY, mPower); + return rep; + } + + public String getName() { + return mName; + } + + public void setName(String name) { + this.mName = mName; + } + + public boolean getState() { + return mState; + } + + public void setState(boolean state) { + this.mState = state; + } + + public int getPower() { + return mPower; + } + + public void setPower(int power) { + this.mPower = power; + } + + @Override + public String toString() { + return "\t" + NAME_KEY + ": " + mName + + "\n\t" + STATE_KEY + ": " + mState + + "\n\t" + POWER_KEY + ": " + mPower; + } +} diff --git a/java/examples-java/simpleclient/src/main/java/org/iotivity/base/examples/SimpleClient.java b/java/examples-java/simpleclient/src/main/java/org/iotivity/base/examples/SimpleClient.java new file mode 100644 index 0000000..52207d1 --- /dev/null +++ b/java/examples-java/simpleclient/src/main/java/org/iotivity/base/examples/SimpleClient.java @@ -0,0 +1,555 @@ +/* + ******************************************************************* + * + * 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; + +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.OcResourceIdentifier; +import org.iotivity.base.PlatformConfig; +import org.iotivity.base.QualityOfService; +import org.iotivity.base.ServiceType; + +import java.util.EnumSet; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 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, DELETE and OBSERVE). + */ +public class SimpleClient implements + OcPlatform.OnResourceFoundListener, + OcResource.OnGetListener, + OcResource.OnPutListener, + OcResource.OnPostListener, + OcResource.OnObserveListener { + + private Map mFoundResources = new HashMap<>(); + private OcResource mFoundLightResource = null; + //local representation of a server's light resource + private Light mLight = new Light(); + + /** + * A local method to configure and initialize platform, and then search for the light resources. + */ + private static void startSimpleClient() { + + PlatformConfig platformConfig = new PlatformConfig( + ServiceType.IN_PROC, + ModeType.CLIENT, + "0.0.0.0", // By setting to "0.0.0.0", it binds to all available interfaces + 0, // Uses randomly available port + QualityOfService.LOW + ); + msg("Configuring platform."); + OcPlatform.Configure(platformConfig); + + SimpleClient client = new SimpleClient(); + try { + msg("Finding all resources of type \"core.light\"."); + String requestUri = OcPlatform.WELL_KNOWN_QUERY + "?rt=core.light"; + OcPlatform.findResource("", + requestUri, + EnumSet.of(OcConnectivityType.CT_DEFAULT), + client + ); + sleep(1); + + /*Find resource is done twice so that we discover the original resources a second time. + These resources will have the same uniqueidentifier (yet be different objects), + so that we can verify/show the duplicate-checking code in foundResource(above); + */ + msg("Finding all resources of type \"core.light\" for the second time"); + OcPlatform.findResource("", + requestUri, + EnumSet.of(OcConnectivityType.CT_DEFAULT), + client + ); + + } catch (OcException e) { + msgError(TAG, e.toString()); + msg("Failed to invoke find resource API"); + } + + printLine(); + } + + /** + * An event handler to be executed whenever a "findResource" request completes successfully + * + * @param ocResource found resource + */ + @Override + public synchronized void onResourceFound(OcResource ocResource) { + if (null == ocResource) { + msg("Found resource is invalid"); + return; + } + + if (mFoundResources.containsKey(ocResource.getUniqueIdentifier())) { + msg("Found a previously seen resource again!"); + } else { + msg("Found resource for the first time on server with ID: " + ocResource.getServerId()); + mFoundResources.put(ocResource.getUniqueIdentifier(), ocResource); + } + + if (null != mFoundLightResource) { + msg("Found another resource, ignoring"); + return; + } + // Get the resource URI + String resourceUri = ocResource.getUri(); + // Get the resource host address + String hostAddress = ocResource.getHost(); + msg("\tURI of the resource: " + resourceUri); + msg("\tHost address of the resource: " + hostAddress); + // Get the resource types + msg("\tList of resource types: "); + for (String resourceType : ocResource.getResourceTypes()) { + msg("\t\t" + resourceType); + } + msg("\tList of resource interfaces:"); + for (String resourceInterface : ocResource.getResourceInterfaces()) { + msg("\t\t" + resourceInterface); + } + msg("\tList of resource connectivity types:"); + for (OcConnectivityType connectivityType : ocResource.getConnectivityTypeSet()) { + msg("\t\t" + connectivityType); + } + printLine(); + + //In this example we are only interested in the light resources + if (resourceUri.equals("/a/light")) { + //Assign resource reference to a global variable to keep it from being + //destroyed by the GC when it is out of scope. + mFoundLightResource = ocResource; + + // Call a local method which will internally invoke "get" API on the foundLightResource + getLightResourceRepresentation(); + } + } + + /** + * Local method to get representation of a found light resource + */ + private void getLightResourceRepresentation() { + msg("Getting Light Representation..."); + + Map queryParams = new HashMap<>(); + try { + // Invoke resource's "get" API with a OcResource.OnGetListener event + // listener implementation + sleep(1); + mFoundLightResource.get(queryParams, this); + } catch (OcException e) { + msgError(TAG, e.toString()); + msg("Error occurred while invoking \"get\" API"); + } + } + + /** + * An event handler to be executed whenever a "get" request completes successfully + * + * @param list list of the header options + * @param ocRepresentation representation of a resource + */ + @Override + public synchronized void onGetCompleted(List list, + OcRepresentation ocRepresentation) { + msg("GET request was successful"); + msg("Resource URI: " + ocRepresentation.getUri()); + + try { + //Read attribute values into local representation of a light + mLight.setOcRepresentation(ocRepresentation); + } catch (OcException e) { + msgError(TAG, e.toString()); + msg("Failed to read the attributes of a light resource"); + } + msg("Light attributes: "); + msg(mLight.toString()); + printLine(); + + //Call a local method which will internally invoke put API on the foundLightResource + putLightRepresentation(); + } + + /** + * An event handler to be executed whenever a "get" request fails + * + * @param throwable exception + */ + @Override + public synchronized void onGetFailed(Throwable throwable) { + if (throwable instanceof OcException) { + OcException ocEx = (OcException) throwable; + msgError(TAG, ocEx.toString()); + ErrorCode errCode = ocEx.getErrorCode(); + //do something based on errorCode + msg("Error code: " + errCode); + } + msg("Failed to get representation of a found light resource"); + } + + /** + * Local method to put a different state for this light resource + */ + private void putLightRepresentation() { + //set new values + mLight.setState(true); + mLight.setPower(15); + + msg("Putting light representation..."); + OcRepresentation representation = null; + try { + representation = mLight.getOcRepresentation(); + } catch (OcException e) { + msgError(TAG, e.toString()); + msg("Failed to get OcRepresentation from a light"); + } + + Map queryParams = new HashMap<>(); + + try { + sleep(1); + // Invoke resource's "put" API with a new representation, query parameters and + // OcResource.OnPutListener event listener implementation + mFoundLightResource.put(representation, queryParams, this); + } catch (OcException e) { + msgError(TAG, e.toString()); + msg("Error occurred while invoking \"put\" API"); + } + } + + /** + * An event handler to be executed whenever a "put" request completes successfully + * + * @param list list of the header options + * @param ocRepresentation representation of a resource + */ + @Override + public synchronized void onPutCompleted(List list, OcRepresentation ocRepresentation) { + msg("PUT request was successful"); + try { + mLight.setOcRepresentation(ocRepresentation); + } catch (OcException e) { + msgError(TAG, e.toString()); + msg("Failed to create Light representation"); + } + msg("Light attributes: "); + msg(mLight.toString()); + printLine(); + + //Call a local method which will internally invoke post API on the foundLightResource + postLightRepresentation(); + } + + /** + * An event handler to be executed whenever a "put" request fails + * + * @param throwable exception + */ + @Override + public synchronized void onPutFailed(Throwable throwable) { + if (throwable instanceof OcException) { + OcException ocEx = (OcException) throwable; + msgError(TAG, ocEx.toString()); + ErrorCode errCode = ocEx.getErrorCode(); + //do something based on errorCode + msg("Error code: " + errCode); + } + msg("Failed to \"put\" a new representation"); + } + + /** + * Local method to post a different state for this light resource + */ + private void postLightRepresentation() { + //set new values + mLight.setState(false); + mLight.setPower(105); + + msg("Posting light representation..."); + OcRepresentation representation = null; + try { + representation = mLight.getOcRepresentation(); + } catch (OcException e) { + msgError(TAG, e.toString()); + msg("Failed to get OcRepresentation from a light"); + } + + Map queryParams = new HashMap<>(); + try { + sleep(1); + // Invoke resource's "post" API with a new representation, query parameters and + // OcResource.OnPostListener event listener implementation + mFoundLightResource.post(representation, queryParams, this); + } catch (OcException e) { + msgError(TAG, e.toString()); + msg("Error occurred while invoking \"post\" API"); + } + } + + /** + * An event handler to be executed whenever a "post" request completes successfully + * + * @param list list of the header options + * @param ocRepresentation representation of a resource + */ + @Override + public synchronized void onPostCompleted(List list, + OcRepresentation ocRepresentation) { + msg("POST request was successful"); + try { + if (ocRepresentation.hasAttribute(OcResource.CREATED_URI_KEY)) { + msg("\tUri of the created resource: " + + ocRepresentation.getValue(OcResource.CREATED_URI_KEY)); + } else { + mLight.setOcRepresentation(ocRepresentation); + msg(mLight.toString()); + } + } catch (OcException e) { + msgError(TAG, e.toString()); + } + + //setting new values + mLight.setState(true); + mLight.setPower(55); + msg("Posting again light representation..."); + OcRepresentation representation2 = null; + try { + representation2 = mLight.getOcRepresentation(); + } catch (OcException e) { + msgError(TAG, e.toString()); + msg("Failed to get OcRepresentation from a light"); + } + + Map queryParams = new HashMap<>(); + try { + // Invoke resource's "post" API with a new representation, query parameters and + // OcResource.OnPostListener event listener implementation + mFoundLightResource.post(representation2, queryParams, onPostListener2); + } catch (OcException e) { + msgError(TAG, e.toString()); + msg("Error occurred while invoking \"post\" API"); + } + } + + /** + * An event handler to be executed whenever a "post" request fails + * + * @param throwable exception + */ + @Override + public synchronized void onPostFailed(Throwable throwable) { + if (throwable instanceof OcException) { + OcException ocEx = (OcException) throwable; + msgError(TAG, ocEx.toString()); + ErrorCode errCode = ocEx.getErrorCode(); + //do something based on errorCode + msg("Error code: " + errCode); + } + msg("Failed to \"post\" a new representation"); + } + + /** + * Declare and implement a second OcResource.OnPostListener + */ + OcResource.OnPostListener onPostListener2 = new OcResource.OnPostListener() { + /** + * An event handler to be executed whenever a "post" request completes successfully + * @param list list of the header options + * @param ocRepresentation representation of a resource + */ + @Override + public synchronized void onPostCompleted(List list, + OcRepresentation ocRepresentation) { + msg("Second POST request was successful"); + try { + if (ocRepresentation.hasAttribute(OcResource.CREATED_URI_KEY)) { + msg("\tUri of the created resource: " + + ocRepresentation.getValue(OcResource.CREATED_URI_KEY)); + } else { + mLight.setOcRepresentation(ocRepresentation); + msg(mLight.toString()); + } + } catch (OcException e) { + msgError(TAG, e.toString()); + } + + //Call a local method which will internally invoke observe API on the foundLightResource + observeFoundLightResource(); + } + + /** + * An event handler to be executed whenever a "post" request fails + * + * @param throwable exception + */ + @Override + public synchronized void onPostFailed(Throwable throwable) { + if (throwable instanceof OcException) { + OcException ocEx = (OcException) throwable; + msgError(TAG, ocEx.toString()); + ErrorCode errCode = ocEx.getErrorCode(); + //do something based on errorCode + msg("Error code: " + errCode); + } + msg("Failed to \"post\" a new representation"); + } + }; + + /** + * Local method to start observing this light resource + */ + private void observeFoundLightResource() { + try { + sleep(1); + // Invoke resource's "observe" API with a observe type, query parameters and + // OcResource.OnObserveListener event listener implementation + mFoundLightResource.observe(ObserveType.OBSERVE, new HashMap(), this); + } catch (OcException e) { + msgError(TAG, e.toString()); + msg("Error occurred while invoking \"observe\" API"); + } + } + + // holds current number of observations + private static int mObserveCount = 0; + + /** + * An event handler to be executed whenever a "post" request completes successfully + * + * @param list list of the header options + * @param ocRepresentation representation of a resource + * @param sequenceNumber sequence number + */ + @Override + public synchronized void onObserveCompleted(List list, + OcRepresentation ocRepresentation, + int sequenceNumber) { + if (OcResource.OnObserveListener.REGISTER == sequenceNumber) { + msg("Observe registration action is successful:"); + } else if (OcResource.OnObserveListener.DEREGISTER == sequenceNumber) { + msg("Observe De-registration action is successful"); + } else if (OcResource.OnObserveListener.NO_OPTION == sequenceNumber) { + msg("Observe registration or de-registration action is failed"); + } + + msg("OBSERVE Result:"); + msg("\tSequenceNumber:" + sequenceNumber); + try { + mLight.setOcRepresentation(ocRepresentation); + } catch (OcException e) { + msgError(TAG, e.toString()); + msg("Failed to get the attribute values"); + } + msg(mLight.toString()); + + if ((++mObserveCount) == 11) { + msg("Cancelling Observe..."); + try { + mFoundLightResource.cancelObserve(); + } catch (OcException e) { + msgError(TAG, e.toString()); + msg("Error occurred while invoking \"cancelObserve\" API"); + } + msg("DONE"); + + //prepare for the next restart of the SimpleClient + resetGlobals(); + } + } + + /** + * An event handler to be executed whenever a "observe" request fails + * + * @param throwable exception + */ + @Override + public synchronized void onObserveFailed(Throwable throwable) { + if (throwable instanceof OcException) { + OcException ocEx = (OcException) throwable; + msgError(TAG, ocEx.toString()); + ErrorCode errCode = ocEx.getErrorCode(); + //do something based on errorCode + msg("Error code: " + errCode); + } + msg("Observation of the found light resource has failed"); + } + + //****************************************************************************** + // End of the OIC specific code + //****************************************************************************** + + private final static String TAG = SimpleClient.class.getSimpleName(); + + public static void main(String[] args) { + startSimpleClient(); + while (true) + sleep(1); + } + + private static void sleep(int seconds) { + try { + Thread.sleep(seconds * 1000); + } catch (InterruptedException e) { + e.printStackTrace(); + msgError(TAG, e.toString()); + } + } + + private static void msg(final String text) { + System.out.println("[O]" + TAG + " | " + text); + } + + private static void msg(final String tag, final String text) { + System.out.println("[O]" + tag + " | " + text); + } + + private static void msgError(final String tag ,final String text) { + System.out.println("[E]" + tag + " | " + text); + } + + private static void printLine() { + msg("------------------------------------------------------------------------"); + } + + private synchronized void resetGlobals() { + mFoundLightResource = null; + mFoundResources.clear(); + mLight = new Light(); + mObserveCount = 0; + } + +} diff --git a/java/examples-java/simpleserver/.gitignore b/java/examples-java/simpleserver/.gitignore new file mode 100644 index 0000000..3543521 --- /dev/null +++ b/java/examples-java/simpleserver/.gitignore @@ -0,0 +1 @@ +/build diff --git a/java/examples-java/simpleserver/build.gradle b/java/examples-java/simpleserver/build.gradle new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/java/examples-java/simpleserver/build.gradle @@ -0,0 +1 @@ + diff --git a/java/examples-java/simpleserver/src/main/assets/oic_svr_db_server.json b/java/examples-java/simpleserver/src/main/assets/oic_svr_db_server.json new file mode 100755 index 0000000..729138c --- /dev/null +++ b/java/examples-java/simpleserver/src/main/assets/oic_svr_db_server.json @@ -0,0 +1,56 @@ +{ + "acl": [ + { + "sub": "Kg==", + "rsrc": [ + "/oic/res", + "/oic/d", + "/oic/p", + "/oic/res/types/d", + "/oic/ad", + "/oic/sec/acl" + ], + "perms": 2, + "ownrs" : ["MTExMTExMTExMTExMTExMQ=="] + }, + { + "sub": "Kg==", + "rsrc": [ + "/oic/sec/doxm", + "/oic/sec/pstat" + ], + "perms": 2, + "ownrs" : ["MTExMTExMTExMTExMTExMQ=="] + }, + { + "sub": "Kg==", + "rsrc": ["/light0", "/light1", "/a/light"], + "perms": 6, + "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="] + } + ], + "pstat": { + "isop": true, + "deviceid": "ZGV2aWNlaWQAAAAAABhanw==", + "ch": 0, + "cm": 0, + "tm": 0, + "om": 3, + "sm": [3] + }, + "doxm": { + "oxm": [0], + "oxmsel": 0, + "sct": 1, + "owned": true, + "deviceid": "MTExMTExMTExMTExMTExMQ==", + "ownr": "MjIyMjIyMjIyMjIyMjIyMg==" + }, + "cred": [{ + "credid": 1, + "sub": "MjIyMjIyMjIyMjIyMjIyMg==", + "credtyp": 1, + "pvdata": "QUFBQUFBQUFBQUFBQUFBQQ==", + "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="] + }] +} diff --git a/java/examples-java/simpleserver/src/main/java/org/iotivity/base/examples/Light.java b/java/examples-java/simpleserver/src/main/java/org/iotivity/base/examples/Light.java new file mode 100644 index 0000000..aacb28d --- /dev/null +++ b/java/examples-java/simpleserver/src/main/java/org/iotivity/base/examples/Light.java @@ -0,0 +1,372 @@ +/* + ******************************************************************* + * + * 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; + +import org.iotivity.base.EntityHandlerResult; +import org.iotivity.base.ErrorCode; +import org.iotivity.base.ObservationInfo; +import org.iotivity.base.OcException; +import org.iotivity.base.OcPlatform; +import org.iotivity.base.OcRepresentation; +import org.iotivity.base.OcResource; +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 java.util.Map; + +/** + * Light + *

+ * This class represents a light resource + */ +public class Light implements OcPlatform.EntityHandler { + private static final String NAME_KEY = "name"; + private static final String STATE_KEY = "state"; + private static final String POWER_KEY = "power"; + + private String mResourceUri; //resource URI + private String mResourceTypeName; //resource type name. + private String mResourceInterface; //resource interface. + private OcResourceHandle mResourceHandle; //resource handle + + private String mName; //light name + private boolean mState; //light state + private int mPower; //light power + + public Light(String resourceUri, String name, boolean state, int power) { + mResourceUri = resourceUri; + mResourceTypeName = "core.light"; + mResourceInterface = OcPlatform.DEFAULT_INTERFACE; + mResourceHandle = null; //this is set when resource is registered + + mName = name; + mState = state; + mPower = power; + } + + public synchronized void registerResource() throws OcException { + if (null == mResourceHandle) { + mResourceHandle = OcPlatform.registerResource( + mResourceUri, + mResourceTypeName, + mResourceInterface, + this, + EnumSet.of(ResourceProperty.DISCOVERABLE, ResourceProperty.OBSERVABLE) + ); + } + } + + /** + * NOTE: This is just a sample implementation of entity handler. Entity handler can be + * implemented in several ways by the manufacturer. + * + * @param request + * @return + */ + @Override + public synchronized EntityHandlerResult handleEntity(final OcResourceRequest request) { + EntityHandlerResult ehResult = EntityHandlerResult.ERROR; + if (null == request) { + msg("Server request is invalid"); + return ehResult; + } + // Get the request flags + EnumSet requestFlags = request.getRequestHandlerFlagSet(); + if (requestFlags.contains(RequestHandlerFlag.INIT)) { + msg("\t\tRequest Flag: Init"); + ehResult = EntityHandlerResult.OK; + } + if (requestFlags.contains(RequestHandlerFlag.REQUEST)) { + msg("\t\tRequest Flag: Request"); + ehResult = handleRequest(request); + } + if (requestFlags.contains(RequestHandlerFlag.OBSERVER)) { + msg("\t\tRequest Flag: Observer"); + ehResult = handleObserver(request); + } + return ehResult; + } + + private EntityHandlerResult handleRequest(OcResourceRequest request) { + EntityHandlerResult ehResult = EntityHandlerResult.ERROR; + // Check for query params (if any) + Map queries = request.getQueryParameters(); + if (!queries.isEmpty()) { + msg("Query processing is up to entityHandler"); + } else { + msg("No query parameters in this request"); + } + + for (Map.Entry entry : queries.entrySet()) { + msg("Query key: " + entry.getKey() + " value: " + entry.getValue()); + } + + //Get the request type + RequestType requestType = request.getRequestType(); + switch (requestType) { + case GET: + msg("\t\t\tRequest Type is GET"); + ehResult = handleGetRequest(request); + break; + case PUT: + msg("\t\t\tRequest Type is PUT"); + ehResult = handlePutRequest(request); + break; + case POST: + msg("\t\t\tRequest Type is POST"); + ehResult = handlePostRequest(request); + break; + case DELETE: + msg("\t\t\tRequest Type is DELETE"); + ehResult = handleDeleteRequest(); + break; + } + return ehResult; + } + + private EntityHandlerResult handleGetRequest(final OcResourceRequest request) { + EntityHandlerResult ehResult; + OcResourceResponse response = new OcResourceResponse(); + response.setRequestHandle(request.getRequestHandle()); + response.setResourceHandle(request.getResourceHandle()); + + if (mIsSlowResponse) { // Slow response case + new Thread(new Runnable() { + public void run() { + handleSlowResponse(request); + } + }).start(); + ehResult = EntityHandlerResult.SLOW; + } else { // normal response case. + response.setErrorCode(SUCCESS); + response.setResponseResult(EntityHandlerResult.OK); + response.setResourceRepresentation(getOcRepresentation()); + ehResult = sendResponse(response); + } + return ehResult; + } + + private EntityHandlerResult handlePutRequest(OcResourceRequest request) { + OcResourceResponse response = new OcResourceResponse(); + response.setRequestHandle(request.getRequestHandle()); + response.setResourceHandle(request.getResourceHandle()); + + setOcRepresentation(request.getResourceRepresentation()); + response.setResourceRepresentation(getOcRepresentation()); + response.setResponseResult(EntityHandlerResult.OK); + response.setErrorCode(SUCCESS); + return sendResponse(response); + } + + private static int sUriCounter = 1; + private EntityHandlerResult handlePostRequest(OcResourceRequest request) { + OcResourceResponse response = new OcResourceResponse(); + response.setRequestHandle(request.getRequestHandle()); + response.setResourceHandle(request.getResourceHandle()); + String newUri = "/a/light" + (++sUriCounter); + SimpleServer.createNewLightResource(newUri, "John's light " + sUriCounter); + OcRepresentation rep_post = getOcRepresentation(); + try { + rep_post.setValue(OcResource.CREATED_URI_KEY, newUri); + } catch (OcException e) { + msgError(TAG, e.toString()); + } + response.setResourceRepresentation(rep_post); + response.setErrorCode(SUCCESS); + response.setNewResourceUri(newUri); + response.setResponseResult(EntityHandlerResult.RESOURCE_CREATED); + return sendResponse(response); + } + + private EntityHandlerResult handleDeleteRequest() { + try { + this.unregisterResource(); + return EntityHandlerResult.RESOURCE_DELETED; + } catch (OcException e) { + msgError(TAG, e.toString()); + msg("Failed to unregister a light resource"); + return EntityHandlerResult.ERROR; + } + } + + private void handleSlowResponse(OcResourceRequest request) { + sleep(10); + msg("Sending slow response..."); + OcResourceResponse response = new OcResourceResponse(); + response.setRequestHandle(request.getRequestHandle()); + response.setResourceHandle(request.getResourceHandle()); + + response.setErrorCode(SUCCESS); + response.setResponseResult(EntityHandlerResult.OK); + response.setResourceRepresentation(getOcRepresentation()); + sendResponse(response); + } + + private List mObservationIds; //IDs of observes + + private EntityHandlerResult handleObserver(final OcResourceRequest request) { + ObservationInfo observationInfo = request.getObservationInfo(); + switch (observationInfo.getObserveAction()) { + case REGISTER: + if (null == mObservationIds) { + mObservationIds = new LinkedList<>(); + } + mObservationIds.add(observationInfo.getOcObservationId()); + break; + case UNREGISTER: + mObservationIds.remove((Byte)observationInfo.getOcObservationId()); + break; + } + // Observation happens on a different thread in notifyObservers method. + // If we have not created the thread already, we will create one here. + if (null == mObserverNotifier) { + mObserverNotifier = new Thread(new Runnable() { + public void run() { + notifyObservers(request); + } + }); + mObserverNotifier.start(); + } + return EntityHandlerResult.OK; + } + + private void notifyObservers(OcResourceRequest request) { + while (true) { + // increment current power value by 10 every 2 seconds + mPower += 10; + sleep(2); + + msg("Notifying observers..."); + msg(this.toString()); + try { + if (mIsListOfObservers) { + OcResourceResponse response = new OcResourceResponse(); + response.setErrorCode(SUCCESS); + response.setResourceRepresentation(getOcRepresentation()); + OcPlatform.notifyListOfObservers( + mResourceHandle, + mObservationIds, + response); + } else { + OcPlatform.notifyAllObservers(mResourceHandle); + } + } catch (OcException e) { + ErrorCode errorCode = e.getErrorCode(); + if (ErrorCode.NO_OBSERVERS == errorCode) { + msg("No more observers, stopping notifications"); + } + return; + } + } + } + + private EntityHandlerResult sendResponse(OcResourceResponse response) { + try { + OcPlatform.sendResponse(response); + return EntityHandlerResult.OK; + } catch (OcException e) { + msgError(TAG, e.toString()); + msg("Failed to send response"); + return EntityHandlerResult.ERROR; + } + } + + public synchronized void unregisterResource() throws OcException { + if (null != mResourceHandle) { + OcPlatform.unregisterResource(mResourceHandle); + } + } + + public void setOcRepresentation(OcRepresentation rep) { + try { + if (rep.hasAttribute(NAME_KEY)) mName = rep.getValue(NAME_KEY); + if (rep.hasAttribute(STATE_KEY)) mState = rep.getValue(STATE_KEY); + if (rep.hasAttribute(POWER_KEY)) mPower = rep.getValue(POWER_KEY); + } catch (OcException e) { + msgError(TAG, e.toString()); + msg("Failed to get representation values"); + } + } + + public OcRepresentation getOcRepresentation() { + OcRepresentation rep = new OcRepresentation(); + try { + rep.setValue(NAME_KEY, mName); + rep.setValue(STATE_KEY, mState); + rep.setValue(POWER_KEY, mPower); + } catch (OcException e) { + msgError(TAG, e.toString()); + msg("Failed to set representation values"); + } + return rep; + } + + //****************************************************************************** + // End of the OIC specific code + //****************************************************************************** + + public void setSlowResponse(boolean isSlowResponse) { + mIsSlowResponse = isSlowResponse; + } + + public void useListOfObservers(boolean isListOfObservers) { + mIsListOfObservers = isListOfObservers; + } + + @Override + public String toString() { + return "\t" + "URI" + ": " + mResourceUri + + "\n\t" + NAME_KEY + ": " + mName + + "\n\t" + STATE_KEY + ": " + mState + + "\n\t" + POWER_KEY + ": " + mPower; + } + + private void sleep(int seconds) { + try { + Thread.sleep(seconds * 1000); + } catch (InterruptedException e) { + e.printStackTrace(); + msgError(TAG, e.toString()); + } + } + + private void msg(String text) { + SimpleServer.msg(text); + } + + private void msgError(String tag, String text) { + SimpleServer.msgError(tag, text); + } + + private final static String TAG = Light.class.getSimpleName(); + private final static int SUCCESS = 200; + private boolean mIsSlowResponse = false; + private boolean mIsListOfObservers = false; + private Thread mObserverNotifier; +} diff --git a/java/examples-java/simpleserver/src/main/java/org/iotivity/base/examples/SimpleServer.java b/java/examples-java/simpleserver/src/main/java/org/iotivity/base/examples/SimpleServer.java new file mode 100644 index 0000000..a5c2883 --- /dev/null +++ b/java/examples-java/simpleserver/src/main/java/org/iotivity/base/examples/SimpleServer.java @@ -0,0 +1,138 @@ +/* + ******************************************************************* + * + * 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; + +import org.iotivity.base.ModeType; +import org.iotivity.base.OcException; +import org.iotivity.base.OcPlatform; +import org.iotivity.base.PlatformConfig; +import org.iotivity.base.QualityOfService; +import org.iotivity.base.ServiceType; + +import java.util.LinkedList; +import java.util.List; + +/** + * SimpleServer + *

+ * SimpleServer is a sample OIC server application. + * It creates a Light and waits for the incoming client calls to handle + * various request scenarios. + */ +public class SimpleServer { + + static List lights = new LinkedList<>(); + + /** + * A local method to configure and initialize platform, and then create a light resource. + */ + private static void startSimpleServer() { + + PlatformConfig platformConfig = new PlatformConfig( + ServiceType.IN_PROC, + ModeType.SERVER, + "0.0.0.0", // By setting to "0.0.0.0", it binds to all available interfaces + 0, // Uses randomly available port + QualityOfService.LOW + ); + + msg("Configuring platform."); + OcPlatform.Configure(platformConfig); + + createNewLightResource("/a/light", "John's light"); + + msg("Waiting for the requests..."); + printLine(); + } + + public static void createNewLightResource(String resourceUri, String resourceName){ + msg("Creating a light"); + Light light = new Light( + resourceUri, //URI + resourceName, //name + false, //state + 0 //power + ); + msg(light.toString()); + + msg("Registering light as a resource"); + try { + light.registerResource(); + } catch (OcException e) { + msgError(TAG, e.toString()); + msg("Failed to register a light resource"); + } + lights.add(light); + } + + private static void stopSimpleServer() { + for (Light light : lights) { + try { + light.unregisterResource(); + } catch (OcException e) { + msgError(TAG, e.toString()); + msg("Failed to unregister a light resource"); + } + } + lights.clear(); + + msg("All created resources have been unregistered"); + printLine(); + } + + //****************************************************************************** + // End of the OIC specific code + //****************************************************************************** + + private final static String TAG = SimpleServer.class.getSimpleName(); + + public static void main(String[] args) { + startSimpleServer(); + } + + public void sleep(int seconds) { + try { + Thread.sleep(seconds * 1000); + } catch (InterruptedException e) { + e.printStackTrace(); + msgError(TAG, e.toString()); + } + } + + public static void msg(final String text) { + System.out.println("[O]" + TAG + " | " + text); + } + + public static void msg(final String tag, final String text) { + System.out.println("[O]" + tag + " | " + text); + } + + public static void msgError(final String tag ,final String text) { + System.out.println("[E]" + tag + " | " + text); + } + + public static void printLine() { + msg("------------------------------------------------------------------------"); + } + +} diff --git a/android/android_api/gradle.properties b/java/gradle.properties similarity index 100% rename from android/android_api/gradle.properties rename to java/gradle.properties diff --git a/java/gradle/wrapper/gradle-wrapper.jar b/java/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=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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 "$@" diff --git a/java/gradlew.bat b/java/gradlew.bat new file mode 100755 index 0000000..aec9973 --- /dev/null +++ b/java/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/android/android_api/base/build.gradle b/java/iotivity-android/build.gradle similarity index 63% rename from android/android_api/base/build.gradle rename to java/iotivity-android/build.gradle index 38e174e..970d94e 100755 --- a/android/android_api/base/build.gradle +++ b/java/iotivity-android/build.gradle @@ -20,9 +20,41 @@ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */ -apply plugin: 'com.android.library' + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:1.3.0' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + jcenter() + } +} + + +apply plugin: 'com.android.library' + android { + sourceSets { + main { + java { + srcDirs 'src/main/java', '../common/src/main/java' + } + manifest.srcFile 'src/main/AndroidManifest.xml' + jniLibs.srcDir "$buildDir/native-libs" + jni.srcDirs = [] //disable automatic ndk-build call + } + } + compileSdkVersion 21 buildToolsVersion "20.0.0" archivesBaseName = "iotivity-base" @@ -53,52 +85,34 @@ android { 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') +task copyNativeLibs(type: Copy) { + String[] libraries = [ + 'libca-interface.so', + 'libconnectivity_abstraction.so', + 'libgnustl_shared.so', + 'liboc_logger.so', + 'liboc.so', + 'libocstack-jni.so', + 'liboctbstack.so' + ] + if ("$SECURED" == '1') + libraries += [ + 'libocprovision.so', + 'libocpmapi.so' + ] + from(new File("$BUILD_DIR")) { include libraries } + into new File(buildDir, "native-libs/$TARGET_ARCH") } 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", "SECURE=$SECURED" - } else { - println '##################' - println 'Skipping NDK build' - println 'Reason: ANDROID_NDK_HOME not set.' - println '##################' - } -} diff --git a/android/android_api/base/proguard-rules.pro b/java/iotivity-android/proguard-rules.pro similarity index 100% rename from android/android_api/base/proguard-rules.pro rename to java/iotivity-android/proguard-rules.pro diff --git a/android/android_api/base/src/main/AndroidManifest.xml b/java/iotivity-android/src/androidTest/AndroidManifest.xml similarity index 100% rename from android/android_api/base/src/main/AndroidManifest.xml rename to java/iotivity-android/src/androidTest/AndroidManifest.xml diff --git a/android/android_api/base/src/androidTest/java/org/iotivity/base/OcRepresentationTest.java b/java/iotivity-android/src/androidTest/java/org/iotivity/base/OcRepresentationTest.java similarity index 100% rename from android/android_api/base/src/androidTest/java/org/iotivity/base/OcRepresentationTest.java rename to java/iotivity-android/src/androidTest/java/org/iotivity/base/OcRepresentationTest.java diff --git a/android/android_api/base/src/androidTest/java/org/iotivity/base/SmokeTest.java b/java/iotivity-android/src/androidTest/java/org/iotivity/base/SmokeTest.java similarity index 100% rename from android/android_api/base/src/androidTest/java/org/iotivity/base/SmokeTest.java rename to java/iotivity-android/src/androidTest/java/org/iotivity/base/SmokeTest.java diff --git a/android/android_api/base/src/androidTest/AndroidManifest.xml b/java/iotivity-android/src/main/AndroidManifest.xml similarity index 100% rename from android/android_api/base/src/androidTest/AndroidManifest.xml rename to java/iotivity-android/src/main/AndroidManifest.xml diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcPlatform.java b/java/iotivity-android/src/main/java/org/iotivity/base/OcPlatform.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/OcPlatform.java rename to java/iotivity-android/src/main/java/org/iotivity/base/OcPlatform.java diff --git a/android/android_api/base/src/main/java/org/iotivity/base/PlatformConfig.java b/java/iotivity-android/src/main/java/org/iotivity/base/PlatformConfig.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/base/PlatformConfig.java rename to java/iotivity-android/src/main/java/org/iotivity/base/PlatformConfig.java diff --git a/android/android_api/base/src/main/java/org/iotivity/ca/CaBtPairingInterface.java b/java/iotivity-android/src/main/java/org/iotivity/ca/CaBtPairingInterface.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/ca/CaBtPairingInterface.java rename to java/iotivity-android/src/main/java/org/iotivity/ca/CaBtPairingInterface.java diff --git a/android/android_api/base/src/main/java/org/iotivity/ca/CaEdrInterface.java b/java/iotivity-android/src/main/java/org/iotivity/ca/CaEdrInterface.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/ca/CaEdrInterface.java rename to java/iotivity-android/src/main/java/org/iotivity/ca/CaEdrInterface.java diff --git a/android/android_api/base/src/main/java/org/iotivity/ca/CaInterface.java b/java/iotivity-android/src/main/java/org/iotivity/ca/CaInterface.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/ca/CaInterface.java rename to java/iotivity-android/src/main/java/org/iotivity/ca/CaInterface.java diff --git a/android/android_api/base/src/main/java/org/iotivity/ca/CaIpInterface.java b/java/iotivity-android/src/main/java/org/iotivity/ca/CaIpInterface.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/ca/CaIpInterface.java rename to java/iotivity-android/src/main/java/org/iotivity/ca/CaIpInterface.java diff --git a/android/android_api/base/src/main/java/org/iotivity/ca/CaLeClientInterface.java b/java/iotivity-android/src/main/java/org/iotivity/ca/CaLeClientInterface.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/ca/CaLeClientInterface.java rename to java/iotivity-android/src/main/java/org/iotivity/ca/CaLeClientInterface.java diff --git a/android/android_api/base/src/main/java/org/iotivity/ca/CaLeServerInterface.java b/java/iotivity-android/src/main/java/org/iotivity/ca/CaLeServerInterface.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/ca/CaLeServerInterface.java rename to java/iotivity-android/src/main/java/org/iotivity/ca/CaLeServerInterface.java diff --git a/android/android_api/base/src/main/java/org/iotivity/ca/CaNfcInterface.java b/java/iotivity-android/src/main/java/org/iotivity/ca/CaNfcInterface.java similarity index 100% rename from android/android_api/base/src/main/java/org/iotivity/ca/CaNfcInterface.java rename to java/iotivity-android/src/main/java/org/iotivity/ca/CaNfcInterface.java diff --git a/java/iotivity-linux/build.gradle b/java/iotivity-linux/build.gradle new file mode 100755 index 0000000..1d8acbb --- /dev/null +++ b/java/iotivity-linux/build.gradle @@ -0,0 +1,37 @@ +/* + * //****************************************************************** + * // + * // 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: 'java' + +sourceSets { + main { + java { + srcDirs 'src/main/java', '../common/src/main/java' + } + } +} + + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) +} diff --git a/java/iotivity-linux/src/main/java/org/iotivity/base/OcPlatform.java b/java/iotivity-linux/src/main/java/org/iotivity/base/OcPlatform.java new file mode 100644 index 0000000..9a3e010 --- /dev/null +++ b/java/iotivity-linux/src/main/java/org/iotivity/base/OcPlatform.java @@ -0,0 +1,949 @@ +/* + ******************************************************************* + * + * 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; + +/** + * This class 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 method in this class. + */ +public final class OcPlatform { + + static { + System.loadLibrary("oc_logger"); + System.loadLibrary("octbstack"); + System.loadLibrary("oc"); + System.loadLibrary("ocstack-jni"); + } + + /** + * Default interface + */ + public static final String DEFAULT_INTERFACE = "oic.if.baseline"; + + /** + * Used in discovering (GET) links to other resources of a collection + */ + public static final String LINK_INTERFACE = "oic.if.ll"; + + /** + * Used in GET, PUT, POST, DELETE methods on links to other resources of a collection + */ + public static final String BATCH_INTERFACE = "oic.if.b"; + + /** + * Used in GET, PUT, POST methods on links to other remote resources of a group + */ + public static final String GROUP_INTERFACE = "oic.mi.grp"; + + public static final String WELL_KNOWN_QUERY = "/oic/res"; + public static final String WELL_KNOWN_DEVICE_QUERY = "/oic/d"; + public static final String WELL_KNOWN_PLATFORM_QUERY = "/oic/p"; + public static final int DEFAULT_PRESENCE_TTL = 60; + public static final String PRESENCE_URI = "/oic/ad"; + + private static volatile boolean sIsPlatformInitialized = false; + private static QualityOfService sPlatformQualityOfService = QualityOfService.NA; + + 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(); + + sPlatformQualityOfService = platformConfig.getQualityOfService(); + + OcPlatform.configure( + platformConfig.getServiceType().getValue(), + platformConfig.getModeType().getValue(), + platformConfig.getIpAddress(), + platformConfig.getPort(), + platformConfig.getQualityOfService().getValue(), + platformConfig.getSvrDbPath() + ); + + sIsPlatformInitialized = true; + } + } + + private static native void configure(int serviceType, + int modeType, + String ipAddress, + int port, + int qualityOfService, + String dbPath); + + /** + * API for notifying base that resource's attributes have changed. + *

+ * Note: This API is for server side only. + *

+ * + * @param ocResourceHandle resource handle of the resource + * @throws OcException if failure + */ + 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. + *

+ * Note: This API is for server side only. + *

+ * + * @param ocResourceHandle resource handle of the resource + * @param qualityOfService the quality of communication + * @throws OcException if failure + */ + 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. + *

+ * Note: This API is for server side only. + *

+ * + * @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 if failure + */ + 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. + *

+ * Note: This API is for server side only. + *

+ * + * @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 if failure + */ + 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 is for client side only. + *

+ * + * @param host Host 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 connectivityTypeSet Set of types of connectivity. Example: IP + * @param onResourceFoundListener Handles events, success states and failure states. + * @throws OcException if failure + */ + public static void findResource( + String host, + String resourceUri, + EnumSet connectivityTypeSet, + OnResourceFoundListener onResourceFoundListener) throws OcException { + OcPlatform.initCheck(); + + int connTypeInt = 0; + + for (OcConnectivityType connType : OcConnectivityType.values()) { + if (connectivityTypeSet.contains(connType)) + connTypeInt |= connType.getValue(); + } + + OcPlatform.findResource0( + host, + resourceUri, + connTypeInt, + 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 is for 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 connectivityTypeSet Set of types of connectivity. Example: IP + * @param onResourceFoundListener Handles events, success states and failure states. + * @param qualityOfService the quality of communication + * @throws OcException if failure + */ + public static void findResource( + String host, + String resourceUri, + EnumSet connectivityTypeSet, + OnResourceFoundListener onResourceFoundListener, + QualityOfService qualityOfService) throws OcException { + OcPlatform.initCheck(); + + int connTypeInt = 0; + + for (OcConnectivityType connType : OcConnectivityType.values()) { + if (connectivityTypeSet.contains(connType)) + connTypeInt |= connType.getValue(); + } + + OcPlatform.findResource1(host, + resourceUri, + connTypeInt, + 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 connectivityTypeSet Set of types of connectivity. Example: IP + * @param onDeviceFoundListener Handles events, success states and failure states. + * @throws OcException if failure + */ + public static void getDeviceInfo( + String host, + String deviceUri, + EnumSet connectivityTypeSet, + OnDeviceFoundListener onDeviceFoundListener) throws OcException { + OcPlatform.initCheck(); + int connTypeInt = 0; + + for (OcConnectivityType connType : OcConnectivityType.values()) { + if (connectivityTypeSet.contains(connType)) + connTypeInt |= connType.getValue(); + } + OcPlatform.getDeviceInfo0( + host, + deviceUri, + connTypeInt, + 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 connectivityTypeSet Set of types of connectivity. Example: IP + * @param onDeviceFoundListener Handles events, success states and failure states. + * @param qualityOfService the quality of communication + * @throws OcException if failure + */ + public static void getDeviceInfo( + String host, + String deviceUri, + EnumSet connectivityTypeSet, + OnDeviceFoundListener onDeviceFoundListener, + QualityOfService qualityOfService) throws OcException { + OcPlatform.initCheck(); + int connTypeInt = 0; + + for (OcConnectivityType connType : OcConnectivityType.values()) { + if (connectivityTypeSet.contains(connType)) + connTypeInt |= connType.getValue(); + } + OcPlatform.getDeviceInfo1( + host, + deviceUri, + connTypeInt, + onDeviceFoundListener, + qualityOfService.getValue() + ); + } + + private static native void getDeviceInfo1( + String host, + String deviceUri, + int connectivityType, + OnDeviceFoundListener onDeviceFoundListener, + int qualityOfService) throws OcException; + + /** + * API for Platform Discovery + * + * @param host Host IP Address. If null or empty, Multicast is performed. + * @param platformUri Uri containing address to the platform + * @param connectivityTypeSet Set of types of connectivity. Example: IP + * @param onPlatformFoundListener Handles events, success states and failure states. + * @throws OcException if failure + */ + + public static void getPlatformInfo( + String host, + String platformUri, + EnumSet connectivityTypeSet, + OnPlatformFoundListener onPlatformFoundListener) throws OcException { + OcPlatform.initCheck(); + int connTypeInt = 0; + + for (OcConnectivityType connType : OcConnectivityType.values()) { + if (connectivityTypeSet.contains(connType)) + connTypeInt |= connType.getValue(); + } + OcPlatform.getPlatformInfo0( + host, + platformUri, + connTypeInt, + onPlatformFoundListener + ); + } + + private static native void getPlatformInfo0( + String host, + String platformUri, + int connectivityType, + OnPlatformFoundListener onPlatformInfoFoundListener) throws OcException; + + /** + * API for Platform Discovery + * + * @param host Host IP Address. If null or empty, Multicast is performed. + * @param platformUri Uri containing address to the platform + * @param connectivityTypeSet Set of types of connectivity. Example: IP + * @param onPlatformFoundListener Handles events, success states and failure states. + * @param qualityOfService the quality of communication + * @throws OcException if failure + */ + + public static void getPlatformInfo( + String host, + String platformUri, + EnumSet connectivityTypeSet, + OnPlatformFoundListener onPlatformFoundListener, + QualityOfService qualityOfService) throws OcException { + OcPlatform.initCheck(); + int connTypeInt = 0; + + for (OcConnectivityType connType : OcConnectivityType.values()) { + if (connectivityTypeSet.contains(connType)) + connTypeInt |= connType.getValue(); + } + OcPlatform.getPlatformInfo1( + host, + platformUri, + connTypeInt, + onPlatformFoundListener, + qualityOfService.getValue() + ); + } + + private static native void getPlatformInfo1( + String host, + String platformUri, + int connectivityType, + OnPlatformFoundListener onPlatformFoundListener, + int qualityOfService) throws OcException; + + /** + * This API registers a resource with the server + *

+ * Note: This API applies to server & client side. + *

+ * + * @param ocResource The instance of OcResource with all data filled + * @return resource handle + * @throws OcException if failure + */ + 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. + *

+ * 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 if failure + */ + 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 if failure + */ + public static void registerDeviceInfo( + OcDeviceInfo ocDeviceInfo) throws OcException { + OcPlatform.initCheck(); + OcPlatform.registerDeviceInfo0( + ocDeviceInfo.getDeviceName() + ); + } + + private static native void registerDeviceInfo0( + String deviceName + ) throws OcException; + + /** + * Register Platform Info + * + * @param ocPlatformInfo object containing all the platform specific information + * @throws OcException if failure + */ + public static void registerPlatformInfo( + OcPlatformInfo ocPlatformInfo) throws OcException { + OcPlatform.initCheck(); + OcPlatform.registerPlatformInfo0( + ocPlatformInfo.getPlatformId(), + ocPlatformInfo.getManufacturerName(), + ocPlatformInfo.getManufacturerUrl(), + ocPlatformInfo.getModelNumber(), + ocPlatformInfo.getDateOfManufacture(), + ocPlatformInfo.getPlatformVersion(), + ocPlatformInfo.getOperatingSystemVersion(), + ocPlatformInfo.getHardwareVersion(), + ocPlatformInfo.getFirmwareVersion(), + ocPlatformInfo.getSupportUrl(), + ocPlatformInfo.getSystemTime() + ); + } + + private static native void registerPlatformInfo0( + String platformId, String manufacturerName, String manufacturerUrl, + String modelNumber, String dateOfManufacture, String platformVersion, + String operatingSystemVersion, String hardwareVersion, String firmwareVersion, + String supportUrl, String systemTime + ) 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 if failure + */ + 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 if failure + */ + 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 if failure + */ + 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 if failure + */ + 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 if failure + */ + 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 if failure + */ + 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 if failure + */ + 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 if failure + */ + 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 if failure + */ + 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 connectivityTypeSet Set of types of connectivity. Example: IP + * @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 if failure + */ + public static OcPresenceHandle subscribePresence( + String host, + EnumSet connectivityTypeSet, + OnPresenceListener onPresenceListener) throws OcException { + OcPlatform.initCheck(); + int connTypeInt = 0; + + for (OcConnectivityType connType : OcConnectivityType.values()) { + if (connectivityTypeSet.contains(connType)) + connTypeInt |= connType.getValue(); + } + return OcPlatform.subscribePresence0( + host, + connTypeInt, + 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 connectivityTypeSet Set of types of connectivity. Example: IP + * @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 if failure + */ + public static OcPresenceHandle subscribePresence( + String host, + String resourceType, + EnumSet connectivityTypeSet, + OnPresenceListener onPresenceListener) throws OcException { + OcPlatform.initCheck(); + int connTypeInt = 0; + + for (OcConnectivityType connType : OcConnectivityType.values()) { + if (connectivityTypeSet.contains(connType)) + connTypeInt |= connType.getValue(); + } + return OcPlatform.subscribePresence1( + host, + resourceType, + connTypeInt, + 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 if failure + */ + 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 connectivityTypeSet Set of types of connectivity. Example: IP + * @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 if failure + */ + public static OcResource constructResourceObject( + String host, + String uri, + EnumSet connectivityTypeSet, + boolean isObservable, + List resourceTypeList, + List interfaceList) throws OcException { + OcPlatform.initCheck(); + int connTypeInt = 0; + + for (OcConnectivityType connType : OcConnectivityType.values()) { + if (connectivityTypeSet.contains(connType)) + connTypeInt |= connType.getValue(); + } + return OcPlatform.constructResourceObject0( + host, + uri, + connTypeInt, + 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 if failure + */ + 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 OnPlatformFoundListener can be registered via the OcPlatform.getPlatformInfo call. + * Event listeners are notified asynchronously + */ + public interface OnPlatformFoundListener { + public void onPlatformFound(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"); + } + } + + /** + * Gets platform quality of service + * + * @return quality of service + */ + public static QualityOfService getPlatformQualityOfService() { + OcPlatform.initCheck(); + return sPlatformQualityOfService; + } +} diff --git a/java/iotivity-linux/src/main/java/org/iotivity/base/PlatformConfig.java b/java/iotivity-linux/src/main/java/org/iotivity/base/PlatformConfig.java new file mode 100644 index 0000000..7f56d4d --- /dev/null +++ b/java/iotivity-linux/src/main/java/org/iotivity/base/PlatformConfig.java @@ -0,0 +1,108 @@ +/* + ******************************************************************* + * + * 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; + +/** + * Data structure to provide the configuration. + */ +public class PlatformConfig { + private ServiceType mServiceType; + private ModeType mModeType; + private String mIpAddress; + private int mPort; + private QualityOfService mQualityOfService; + private String mSvrDbPath; //TODO: Instead of SVRDB file, it should be Persistent Storage. + //this is only for 0.9.2 + /** + * @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 + * @param dbPath Persistant storage file for SVR Database. + */ + public PlatformConfig( + ServiceType serviceType, + ModeType modeType, + String ipAddress, + int port, + QualityOfService qualityOfService, + String dbPath) { + this.mServiceType = serviceType; + this.mModeType = modeType; + this.mIpAddress = ipAddress; + this.mPort = port; + this.mQualityOfService = qualityOfService; + this.mSvrDbPath = dbPath; + } + + /** + * @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 + */ + // Avoid breaking building java samples due to persistent storage SVR DB changes. + public PlatformConfig( + ServiceType serviceType, + ModeType modeType, + String ipAddress, + int port, + QualityOfService qualityOfService) { + this(serviceType,modeType,ipAddress,port,qualityOfService, ""); + } + + 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; + } + + public String getSvrDbPath() { + return mSvrDbPath; + } + +} diff --git a/java/iotivity-linux/src/main/java/org/iotivity/ca/CaInterface.java b/java/iotivity-linux/src/main/java/org/iotivity/ca/CaInterface.java new file mode 100644 index 0000000..c72bf64 --- /dev/null +++ b/java/iotivity-linux/src/main/java/org/iotivity/ca/CaInterface.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.ca; + +import org.iotivity.base.OcException; +import org.iotivity.base.OcConnectivityType; + +class BluetoothDevice {} + +public class CaInterface { + static { + } + private static volatile boolean isConnectionManagerInitialized = false; + private static volatile boolean isBtPairingInitialized = false; + + public static void initialize() {} + + /** + * Method start connection manager service. + * this method has to be called before other API call. + * @param context application context + * @param onConnectionManagerStateListener connection state callback listener + */ + public synchronized static void startManagerService( + OnConnectionManagerStateListener onConnectionManagerStateListener) { + if (!isConnectionManagerInitialized) { + CaInterface.caManagerInitialize(onConnectionManagerStateListener); + isConnectionManagerInitialized = true; + } + } + + /** + * Method stop connection manager service. + * this method must be called, when Application is destroied. + */ + public synchronized static void stopManagerService() { + if (isConnectionManagerInitialized) { + CaInterface.caManagerTerminate(); + isConnectionManagerInitialized = false; + } + } + + /** + * Method set device information for Auto-Connection. + * this method has to be called before FindResource is called. + * @param address LE address of scanned bluetooth device. + */ + public synchronized static void setAutoConnectionDevice(String address) + throws OcException { + CaInterface.initCheckForConnectionManager(); + CaInterface.caManagerSetAutoConnectionDeviceInfo(address); + } + + /** + * Method unset device information for Auto-Connection. + * @param address LE address of scanned bluetooth device. + */ + public synchronized static void unsetAutoConnectionDevice(String address) + throws OcException { + CaInterface.initCheckForConnectionManager(); + CaInterface.caManagerUnsetAutoConnectionDeviceInfo(address); + } + + /** + * Interface for connection manager state listener. + * Event listeners are notified asynchronously. + */ + public interface OnConnectionManagerStateListener { + public void onAdapterStateChanged(OcConnectivityType type, boolean enabled); + public void onConnectionStateChanged(OcConnectivityType type, String address, + boolean connected); + } + + private static void initCheckForConnectionManager() { + if (!isConnectionManagerInitialized) { + throw new IllegalStateException("ConnectionManager must be started by making " + + "a call to CaInterface.startManagerService before any other API " + + "calls are permitted"); + } + } + + private static void caManagerInitialize( + OnConnectionManagerStateListener onConnectionManagerStateListener) {} + private static void caManagerTerminate() {} + private static void caManagerSetAutoConnectionDeviceInfo(String address) {} + private static void caManagerUnsetAutoConnectionDeviceInfo(String address) {} + + /** + * start bluetooth pairing service. + * @param context application context + */ + public synchronized static void startBtPairingService( + OnBtDeviceFoundListener listener) { + if (!isBtPairingInitialized) { + /* TODO */ + CaInterface.caBtPairingInitialize(listener); + + isBtPairingInitialized = true; + } + } + + /** + * stop bluetooth pairing service. + */ + public synchronized static void stopBtPairingService() { + if (isBtPairingInitialized) { + CaInterface.caBtPairingTerminate(); + + isBtPairingInitialized = false; + } + } + + /** + * start bluetooth device scan. + */ + public synchronized static void startScan() + throws OcException { + CaInterface.initCheckForBtPairingUtil(); + CaInterface.caBtPairingStartScan(); + } + + /** + * stop bluetooth device scan. + */ + public synchronized static void stopScan() + throws OcException { + CaInterface.initCheckForBtPairingUtil(); + CaInterface.caBtPairingStopScan(); + } + + /** + * create bond + */ + public synchronized static void createBond(BluetoothDevice device) + throws OcException { + CaInterface.initCheckForBtPairingUtil(); + CaInterface.caBtPairingCreateBond(device); + } + + public interface OnBtDeviceFoundListener { + public void onBtDeviceFound(BluetoothDevice device) throws OcException; + } + + private static void initCheckForBtPairingUtil() { + if (!isBtPairingInitialized) { + throw new IllegalStateException("BT pairing Util must be started by making " + + "a call to CaInterface.startBtPairingService before any other API " + + "calls are permitted"); + } + } + + private static void caBtPairingInitialize( + OnBtDeviceFoundListener listener) {} + private static void caBtPairingTerminate() {} + private static void caBtPairingStartScan() {} + private static void caBtPairingStopScan() {} + private static void caBtPairingCreateBond(BluetoothDevice device) {} +} diff --git a/java/iotivity-linux/src/main/java/org/iotivity/ca/CaIpInterface.java b/java/iotivity-linux/src/main/java/org/iotivity/ca/CaIpInterface.java new file mode 100644 index 0000000..a452121 --- /dev/null +++ b/java/iotivity-linux/src/main/java/org/iotivity/ca/CaIpInterface.java @@ -0,0 +1,58 @@ +/****************************************************************** + * + * 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. + * + ******************************************************************/ + +package org.iotivity.ca; + +public class CaIpInterface { + + public enum WifiAPState{ + WIFI_AP_STATE_DISABLING (10), + WIFI_AP_STATE_DISABLED (11), + WIFI_AP_STATE_ENABLING (12), + WIFI_AP_STATE_ENABLED (13), + WIFI_AP_STATE_FAILED (14) + ; // semicolon needed when fields / methods follow + + + private final int apstate; + + WifiAPState(int apstate) + { + this.apstate = apstate; + } + public int getIntValue() { + return this.apstate; + } + } + + private CaIpInterface() { + registerIpStateReceiver(); + } + + private void registerIpStateReceiver() { + } + + public static void destroyIpInterface() { + } + + private native static void caIpStateEnabled(); + + private native static void caIpStateDisabled(); +} diff --git a/android/android_api/base/jni/JniCaInterface.c b/java/jni/JniCaInterface.c similarity index 89% rename from android/android_api/base/jni/JniCaInterface.c rename to java/jni/JniCaInterface.c index d641f3d..2df633e 100644 --- a/android/android_api/base/jni/JniCaInterface.c +++ b/java/jni/JniCaInterface.c @@ -21,7 +21,7 @@ */ #include -#include +#include "logger.h" #include #include "cainterface.h" #include "JniCaInterface.h" @@ -29,8 +29,8 @@ #include "cacommon.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__) +#define LOGI(...) OIC_LOG_V(OC_LOG_INFO, LOG_TAG, __VA_ARGS__) +#define LOGE(...) OIC_LOG_V(OC_LOG_ERROR, LOG_TAG, __VA_ARGS__) static jobject g_foundDeviceListenerObject = NULL; static jobject g_listenerObject = NULL; @@ -50,6 +50,7 @@ void JNI_OnUnload(JavaVM *jvm, void *reserved) return; } +#ifdef __ANDROID__ JNIEXPORT void JNICALL Java_org_iotivity_ca_CaInterface_initialize (JNIEnv *env, jclass clazz, jobject activity, jobject context) @@ -59,6 +60,14 @@ Java_org_iotivity_ca_CaInterface_initialize CANativeSetActivity(env, activity); CANativeJNISetContext(env, context); } +#else +JNIEXPORT void JNICALL +Java_org_iotivity_ca_CaInterface_initialize +(JNIEnv *env, jclass clazz) +{ + LOGI("CaInterface_initialize"); +} +#endif void CAManagerConnectionStateChangedCB(CATransportAdapter_t adapter, const char *remote_address, @@ -215,6 +224,7 @@ exit_error: LOGI("OUT - CAManagerAdapterStateChangedCB"); } +#ifdef __ANDROID__ JNIEXPORT void JNICALL Java_org_iotivity_ca_CaInterface_caManagerInitialize(JNIEnv *env, jclass clazz, jobject context, jobject listener) @@ -228,6 +238,19 @@ Java_org_iotivity_ca_CaInterface_caManagerInitialize(JNIEnv *env, jclass clazz, CARegisterNetworkMonitorHandler(CAManagerAdapterStateChangedCB, CAManagerConnectionStateChangedCB); } +#else +JNIEXPORT void JNICALL +Java_org_iotivity_ca_CaInterface_caManagerInitialize(JNIEnv *env, jclass clazz, + jobject listener) +{ + LOGI("CaManagere_initialize"); + + g_listenerObject = (*env)->NewGlobalRef(env, listener); + + CARegisterNetworkMonitorHandler(CAManagerAdapterStateChangedCB, + CAManagerConnectionStateChangedCB); +} +#endif JNIEXPORT void JNICALL Java_org_iotivity_ca_CaInterface_caManagerTerminate(JNIEnv *env, jclass clazz) @@ -281,6 +304,7 @@ Java_org_iotivity_ca_CaInterface_caManagerUnsetAutoConnectionDeviceInfo(JNIEnv * (*env)->ReleaseStringUTFChars(env, jaddress, address); } +#ifdef __ANDROID__ JNIEXPORT void JNICALL Java_org_iotivity_ca_CaInterface_caBtPairingInitialize(JNIEnv *env, jclass clazz, jobject context, jobject listener) @@ -293,6 +317,20 @@ Java_org_iotivity_ca_CaInterface_caBtPairingInitialize(JNIEnv *env, jclass clazz g_foundDeviceListenerObject = (*env)->NewGlobalRef(env, listener); CAUtilSetFoundDeviceListener(g_foundDeviceListenerObject); } +#else +JNIEXPORT void JNICALL +Java_org_iotivity_ca_CaInterface_caBtPairingInitialize(JNIEnv *env, jclass clazz, + jobject listener) +{ + LOGI("caBtPairingInitialize"); + (void)clazz; + + CAUtilClientInitialize(env, g_jvm); + + g_foundDeviceListenerObject = (*env)->NewGlobalRef(env, listener); + CAUtilSetFoundDeviceListener(g_foundDeviceListenerObject); +} +#endif JNIEXPORT void JNICALL Java_org_iotivity_ca_CaInterface_caBtPairingTerminate(JNIEnv *env, jclass clazz) diff --git a/android/android_api/base/jni/JniCaInterface.h b/java/jni/JniCaInterface.h similarity index 83% rename from android/android_api/base/jni/JniCaInterface.h rename to java/jni/JniCaInterface.h index 20dc995..c5cecfa 100644 --- a/android/android_api/base/jni/JniCaInterface.h +++ b/java/jni/JniCaInterface.h @@ -36,6 +36,7 @@ extern "C" { void CAManagerAdapterStateChangedCB(CATransportAdapter_t adapter, bool enabled); +#ifdef __ANDROID__ /* * Class: Java_org_iotivity_ca_CaInterface_caManagerInitialize * Method: caManagerInitialize @@ -44,6 +45,16 @@ extern "C" { JNIEXPORT void JNICALL Java_org_iotivity_ca_CaInterface_caManagerInitialize(JNIEnv *env, jclass clazz, jobject context, jobject listener); +#else + /* + * Class: Java_org_iotivity_ca_CaInterface_caManagerInitialize + * Method: caManagerInitialize + * Signature: ()V + */ + JNIEXPORT void JNICALL + Java_org_iotivity_ca_CaInterface_caManagerInitialize(JNIEnv *env, jclass clazz, + jobject listener); +#endif /* * Class: Java_org_iotivity_ca_CaInterface_caManagerTerminate @@ -73,6 +84,7 @@ extern "C" { jclass clazz, jstring jaddress); +#ifdef __ANDROID__ /* * Class: Java_org_iotivity_ca_CaInterface_caBtPairingInitialize * Method: caBtPairingInitialize @@ -80,6 +92,15 @@ extern "C" { */ JNIEXPORT void JNICALL Java_org_iotivity_ca_CaInterface_caBtPairingInitialize(JNIEnv *, jclass, jobject, jobject); +#else + /* + * Class: Java_org_iotivity_ca_CaInterface_caBtPairingInitialize + * Method: caBtPairingInitialize + * Signature: ()V + */ + JNIEXPORT void JNICALL + Java_org_iotivity_ca_CaInterface_caBtPairingInitialize(JNIEnv *, jclass, jobject); +#endif /* * Class: Java_org_iotivity_ca_CaInterface_caBtPairingTerminate @@ -113,6 +134,7 @@ extern "C" { JNIEXPORT void JNICALL Java_org_iotivity_ca_CaInterface_caBtPairingCreateBond(JNIEnv *, jclass, jobject); +#ifdef __ANDROID__ /* * Class: org_iotivity_ca_CaInterface_Initialize * Method: Initialize @@ -120,6 +142,15 @@ extern "C" { */ JNIEXPORT void JNICALL Java_org_iotivity_ca_CaInterface_initialize (JNIEnv *, jclass, jobject, jobject); +#else + /* + * Class: org_iotivity_ca_CaInterface_Initialize + * Method: Initialize + * Signature: ()V + */ + JNIEXPORT void JNICALL Java_org_iotivity_ca_CaInterface_initialize + (JNIEnv *, jclass); +#endif #ifdef __cplusplus } diff --git a/android/android_api/base/jni/JniDisplayPinListener.cpp b/java/jni/JniDisplayPinListener.cpp similarity index 100% rename from android/android_api/base/jni/JniDisplayPinListener.cpp rename to java/jni/JniDisplayPinListener.cpp diff --git a/android/android_api/base/jni/JniDisplayPinListener.h b/java/jni/JniDisplayPinListener.h similarity index 100% rename from android/android_api/base/jni/JniDisplayPinListener.h rename to java/jni/JniDisplayPinListener.h diff --git a/android/android_api/base/jni/JniEntityHandler.cpp b/java/jni/JniEntityHandler.cpp similarity index 100% rename from android/android_api/base/jni/JniEntityHandler.cpp rename to java/jni/JniEntityHandler.cpp diff --git a/android/android_api/base/jni/JniEntityHandler.h b/java/jni/JniEntityHandler.h similarity index 100% rename from android/android_api/base/jni/JniEntityHandler.h rename to java/jni/JniEntityHandler.h diff --git a/android/android_api/base/jni/JniListenerManager.h b/java/jni/JniListenerManager.h similarity index 100% rename from android/android_api/base/jni/JniListenerManager.h rename to java/jni/JniListenerManager.h diff --git a/android/android_api/base/jni/JniOcPlatform.cpp b/java/jni/JniOcPlatform.cpp similarity index 99% rename from android/android_api/base/jni/JniOcPlatform.cpp rename to java/jni/JniOcPlatform.cpp index 93029c9..8d7d08d 100644 --- a/android/android_api/base/jni/JniOcPlatform.cpp +++ b/java/jni/JniOcPlatform.cpp @@ -1211,7 +1211,6 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_registerPlatformInfo0( return; } - // __android_log_print(ANDROID_LOG_INFO, "Rahul", "platformID = %s", platformID); try { OCStackResult result = OCPlatform::registerPlatformInfo(platformInfo); @@ -1916,7 +1915,6 @@ JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_constructResourceObj } JniOcResource *jniOcResource = new JniOcResource(resource); - jlong handle = reinterpret_cast(jniOcResource); jobject jResource = env->NewObject(g_cls_OcResource, g_mid_OcResource_ctor); if (!jResource) diff --git a/android/android_api/base/jni/JniOcPlatform.h b/java/jni/JniOcPlatform.h similarity index 100% rename from android/android_api/base/jni/JniOcPlatform.h rename to java/jni/JniOcPlatform.h diff --git a/android/android_api/base/jni/JniOcPresenceHandle.cpp b/java/jni/JniOcPresenceHandle.cpp similarity index 100% rename from android/android_api/base/jni/JniOcPresenceHandle.cpp rename to java/jni/JniOcPresenceHandle.cpp diff --git a/android/android_api/base/jni/JniOcPresenceHandle.h b/java/jni/JniOcPresenceHandle.h similarity index 100% rename from android/android_api/base/jni/JniOcPresenceHandle.h rename to java/jni/JniOcPresenceHandle.h diff --git a/android/android_api/base/jni/JniOcProvisioning.cpp b/java/jni/JniOcProvisioning.cpp similarity index 100% rename from android/android_api/base/jni/JniOcProvisioning.cpp rename to java/jni/JniOcProvisioning.cpp diff --git a/android/android_api/base/jni/JniOcProvisioning.h b/java/jni/JniOcProvisioning.h similarity index 100% rename from android/android_api/base/jni/JniOcProvisioning.h rename to java/jni/JniOcProvisioning.h diff --git a/android/android_api/base/jni/JniOcRepresentation.cpp b/java/jni/JniOcRepresentation.cpp similarity index 100% rename from android/android_api/base/jni/JniOcRepresentation.cpp rename to java/jni/JniOcRepresentation.cpp diff --git a/android/android_api/base/jni/JniOcRepresentation.h b/java/jni/JniOcRepresentation.h similarity index 100% rename from android/android_api/base/jni/JniOcRepresentation.h rename to java/jni/JniOcRepresentation.h diff --git a/android/android_api/base/jni/JniOcRequestHandle.cpp b/java/jni/JniOcRequestHandle.cpp similarity index 100% rename from android/android_api/base/jni/JniOcRequestHandle.cpp rename to java/jni/JniOcRequestHandle.cpp diff --git a/android/android_api/base/jni/JniOcRequestHandle.h b/java/jni/JniOcRequestHandle.h similarity index 100% rename from android/android_api/base/jni/JniOcRequestHandle.h rename to java/jni/JniOcRequestHandle.h diff --git a/android/android_api/base/jni/JniOcResource.cpp b/java/jni/JniOcResource.cpp similarity index 100% rename from android/android_api/base/jni/JniOcResource.cpp rename to java/jni/JniOcResource.cpp diff --git a/android/android_api/base/jni/JniOcResource.h b/java/jni/JniOcResource.h similarity index 100% rename from android/android_api/base/jni/JniOcResource.h rename to java/jni/JniOcResource.h diff --git a/android/android_api/base/jni/JniOcResourceHandle.cpp b/java/jni/JniOcResourceHandle.cpp similarity index 100% rename from android/android_api/base/jni/JniOcResourceHandle.cpp rename to java/jni/JniOcResourceHandle.cpp diff --git a/android/android_api/base/jni/JniOcResourceHandle.h b/java/jni/JniOcResourceHandle.h similarity index 100% rename from android/android_api/base/jni/JniOcResourceHandle.h rename to java/jni/JniOcResourceHandle.h diff --git a/android/android_api/base/jni/JniOcResourceIdentifier.cpp b/java/jni/JniOcResourceIdentifier.cpp similarity index 100% rename from android/android_api/base/jni/JniOcResourceIdentifier.cpp rename to java/jni/JniOcResourceIdentifier.cpp diff --git a/android/android_api/base/jni/JniOcResourceIdentifier.h b/java/jni/JniOcResourceIdentifier.h similarity index 100% rename from android/android_api/base/jni/JniOcResourceIdentifier.h rename to java/jni/JniOcResourceIdentifier.h diff --git a/android/android_api/base/jni/JniOcResourceRequest.cpp b/java/jni/JniOcResourceRequest.cpp similarity index 100% rename from android/android_api/base/jni/JniOcResourceRequest.cpp rename to java/jni/JniOcResourceRequest.cpp diff --git a/android/android_api/base/jni/JniOcResourceRequest.h b/java/jni/JniOcResourceRequest.h similarity index 100% rename from android/android_api/base/jni/JniOcResourceRequest.h rename to java/jni/JniOcResourceRequest.h diff --git a/android/android_api/base/jni/JniOcResourceResponse.cpp b/java/jni/JniOcResourceResponse.cpp similarity index 100% rename from android/android_api/base/jni/JniOcResourceResponse.cpp rename to java/jni/JniOcResourceResponse.cpp diff --git a/android/android_api/base/jni/JniOcResourceResponse.h b/java/jni/JniOcResourceResponse.h similarity index 100% rename from android/android_api/base/jni/JniOcResourceResponse.h rename to java/jni/JniOcResourceResponse.h diff --git a/android/android_api/base/jni/JniOcSecureResource.cpp b/java/jni/JniOcSecureResource.cpp similarity index 100% rename from android/android_api/base/jni/JniOcSecureResource.cpp rename to java/jni/JniOcSecureResource.cpp diff --git a/android/android_api/base/jni/JniOcSecureResource.h b/java/jni/JniOcSecureResource.h similarity index 100% rename from android/android_api/base/jni/JniOcSecureResource.h rename to java/jni/JniOcSecureResource.h diff --git a/android/android_api/base/jni/JniOcSecurity.cpp b/java/jni/JniOcSecurity.cpp similarity index 100% rename from android/android_api/base/jni/JniOcSecurity.cpp rename to java/jni/JniOcSecurity.cpp diff --git a/android/android_api/base/jni/JniOcSecurity.h b/java/jni/JniOcSecurity.h similarity index 100% rename from android/android_api/base/jni/JniOcSecurity.h rename to java/jni/JniOcSecurity.h diff --git a/android/android_api/base/jni/JniOcStack.cpp b/java/jni/JniOcStack.cpp similarity index 100% rename from android/android_api/base/jni/JniOcStack.cpp rename to java/jni/JniOcStack.cpp diff --git a/android/android_api/base/jni/JniOcStack.h b/java/jni/JniOcStack.h similarity index 93% rename from android/android_api/base/jni/JniOcStack.h rename to java/jni/JniOcStack.h index 79ede36..66bd234 100644 --- a/android/android_api/base/jni/JniOcStack.h +++ b/java/jni/JniOcStack.h @@ -20,7 +20,7 @@ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */ #include -#include +#include "logger.h" #include "OCApi.h" #ifndef _Included_org_iotivity_base_ocstack @@ -30,9 +30,9 @@ #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 LOGI(...) OIC_LOG_V(INFO, TAG, __VA_ARGS__) +#define LOGD(...) OIC_LOG_V(DEBUG, TAG, __VA_ARGS__) +#define LOGE(...) OIC_LOG_V(ERROR, TAG, __VA_ARGS__) #define JNI_EXCEPTION 1000 #define JNI_NO_NATIVE_POINTER 1001 @@ -156,7 +156,11 @@ static JNIEnv* GetJNIEnv(jint& ret) case JNI_OK: return env; case JNI_EDETACHED: +// AttachCurrentThread API changed in JNI 1.7 which is not a defined version +#pragma GCC diagnostic push +#pragma GCC diagnostic warning "-fpermissive" if (g_jvm->AttachCurrentThread(&env, nullptr) < 0) +#pragma GCC diagnostic push { LOGE("Failed to get the environment"); return nullptr; @@ -180,4 +184,4 @@ static void DuplicateString(char ** targetString, std::string sourceString) strncpy(*targetString, sourceString.c_str(), (sourceString.length() + 1)); } -#endif // _Included_org_iotivity_base_ocstack \ No newline at end of file +#endif // _Included_org_iotivity_base_ocstack diff --git a/android/android_api/base/jni/JniOnDeleteListener.cpp b/java/jni/JniOnDeleteListener.cpp similarity index 100% rename from android/android_api/base/jni/JniOnDeleteListener.cpp rename to java/jni/JniOnDeleteListener.cpp diff --git a/android/android_api/base/jni/JniOnDeleteListener.h b/java/jni/JniOnDeleteListener.h similarity index 100% rename from android/android_api/base/jni/JniOnDeleteListener.h rename to java/jni/JniOnDeleteListener.h diff --git a/android/android_api/base/jni/JniOnDeviceInfoListener.cpp b/java/jni/JniOnDeviceInfoListener.cpp similarity index 100% rename from android/android_api/base/jni/JniOnDeviceInfoListener.cpp rename to java/jni/JniOnDeviceInfoListener.cpp diff --git a/android/android_api/base/jni/JniOnDeviceInfoListener.h b/java/jni/JniOnDeviceInfoListener.h similarity index 100% rename from android/android_api/base/jni/JniOnDeviceInfoListener.h rename to java/jni/JniOnDeviceInfoListener.h diff --git a/android/android_api/base/jni/JniOnGetListener.cpp b/java/jni/JniOnGetListener.cpp similarity index 100% rename from android/android_api/base/jni/JniOnGetListener.cpp rename to java/jni/JniOnGetListener.cpp diff --git a/android/android_api/base/jni/JniOnGetListener.h b/java/jni/JniOnGetListener.h similarity index 100% rename from android/android_api/base/jni/JniOnGetListener.h rename to java/jni/JniOnGetListener.h diff --git a/android/android_api/base/jni/JniOnObserveListener.cpp b/java/jni/JniOnObserveListener.cpp similarity index 100% rename from android/android_api/base/jni/JniOnObserveListener.cpp rename to java/jni/JniOnObserveListener.cpp diff --git a/android/android_api/base/jni/JniOnObserveListener.h b/java/jni/JniOnObserveListener.h similarity index 100% rename from android/android_api/base/jni/JniOnObserveListener.h rename to java/jni/JniOnObserveListener.h diff --git a/android/android_api/base/jni/JniOnPlatformInfoListener.cpp b/java/jni/JniOnPlatformInfoListener.cpp similarity index 100% rename from android/android_api/base/jni/JniOnPlatformInfoListener.cpp rename to java/jni/JniOnPlatformInfoListener.cpp diff --git a/android/android_api/base/jni/JniOnPlatformInfoListener.h b/java/jni/JniOnPlatformInfoListener.h similarity index 100% rename from android/android_api/base/jni/JniOnPlatformInfoListener.h rename to java/jni/JniOnPlatformInfoListener.h diff --git a/android/android_api/base/jni/JniOnPostListener.cpp b/java/jni/JniOnPostListener.cpp similarity index 100% rename from android/android_api/base/jni/JniOnPostListener.cpp rename to java/jni/JniOnPostListener.cpp diff --git a/android/android_api/base/jni/JniOnPostListener.h b/java/jni/JniOnPostListener.h similarity index 100% rename from android/android_api/base/jni/JniOnPostListener.h rename to java/jni/JniOnPostListener.h diff --git a/android/android_api/base/jni/JniOnPresenceListener.cpp b/java/jni/JniOnPresenceListener.cpp similarity index 100% rename from android/android_api/base/jni/JniOnPresenceListener.cpp rename to java/jni/JniOnPresenceListener.cpp diff --git a/android/android_api/base/jni/JniOnPresenceListener.h b/java/jni/JniOnPresenceListener.h similarity index 100% rename from android/android_api/base/jni/JniOnPresenceListener.h rename to java/jni/JniOnPresenceListener.h diff --git a/android/android_api/base/jni/JniOnPutListener.cpp b/java/jni/JniOnPutListener.cpp similarity index 100% rename from android/android_api/base/jni/JniOnPutListener.cpp rename to java/jni/JniOnPutListener.cpp diff --git a/android/android_api/base/jni/JniOnPutListener.h b/java/jni/JniOnPutListener.h similarity index 100% rename from android/android_api/base/jni/JniOnPutListener.h rename to java/jni/JniOnPutListener.h diff --git a/android/android_api/base/jni/JniOnResourceFoundListener.cpp b/java/jni/JniOnResourceFoundListener.cpp similarity index 100% rename from android/android_api/base/jni/JniOnResourceFoundListener.cpp rename to java/jni/JniOnResourceFoundListener.cpp diff --git a/android/android_api/base/jni/JniOnResourceFoundListener.h b/java/jni/JniOnResourceFoundListener.h similarity index 100% rename from android/android_api/base/jni/JniOnResourceFoundListener.h rename to java/jni/JniOnResourceFoundListener.h diff --git a/android/android_api/base/jni/JniPinCheckListener.cpp b/java/jni/JniPinCheckListener.cpp similarity index 100% rename from android/android_api/base/jni/JniPinCheckListener.cpp rename to java/jni/JniPinCheckListener.cpp diff --git a/android/android_api/base/jni/JniPinCheckListener.h b/java/jni/JniPinCheckListener.h similarity index 100% rename from android/android_api/base/jni/JniPinCheckListener.h rename to java/jni/JniPinCheckListener.h diff --git a/android/android_api/base/jni/JniProvisionResultListner.cpp b/java/jni/JniProvisionResultListner.cpp similarity index 100% rename from android/android_api/base/jni/JniProvisionResultListner.cpp rename to java/jni/JniProvisionResultListner.cpp diff --git a/android/android_api/base/jni/JniProvisionResultListner.h b/java/jni/JniProvisionResultListner.h similarity index 100% rename from android/android_api/base/jni/JniProvisionResultListner.h rename to java/jni/JniProvisionResultListner.h diff --git a/android/android_api/base/jni/JniSecureUtils.cpp b/java/jni/JniSecureUtils.cpp similarity index 100% rename from android/android_api/base/jni/JniSecureUtils.cpp rename to java/jni/JniSecureUtils.cpp diff --git a/android/android_api/base/jni/JniSecureUtils.h b/java/jni/JniSecureUtils.h similarity index 100% rename from android/android_api/base/jni/JniSecureUtils.h rename to java/jni/JniSecureUtils.h diff --git a/android/android_api/base/jni/JniUtils.cpp b/java/jni/JniUtils.cpp similarity index 100% rename from android/android_api/base/jni/JniUtils.cpp rename to java/jni/JniUtils.cpp diff --git a/android/android_api/base/jni/JniUtils.h b/java/jni/JniUtils.h similarity index 100% rename from android/android_api/base/jni/JniUtils.h rename to java/jni/JniUtils.h diff --git a/java/jni/SConscript b/java/jni/SConscript new file mode 100644 index 0000000..6353c98 --- /dev/null +++ b/java/jni/SConscript @@ -0,0 +1,125 @@ +#****************************************************************** +# +# Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved. +# +#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +## +# Examples build script +## +Import('env') +# Add third party libraries +lib_env = env.Clone() +SConscript(env.get('SRC_DIR') + '/resource/third_party_libs.scons', 'lib_env') + +jni_env = lib_env.Clone() + +###################################################################### +# Build flags +###################################################################### +jni_env.AppendUnique(CPPPATH = [ + env.get('SRC_DIR') + '/resource/csdk/connectivity/api', + env.get('SRC_DIR') + '/resource/include', + env.get('SRC_DIR') + '/resource/c_common', + env.get('SRC_DIR') + '/resource/c_common/oic_string/include', + env.get('SRC_DIR') + '/resource/c_common/oic_malloc/include', + env.get('SRC_DIR') + '/resource/csdk/stack/include', + env.get('SRC_DIR') + '/resource/csdk/ocsocket/include', + env.get('SRC_DIR') + '/resource/oc_logger/include', + env.get('SRC_DIR') + '/resource/csdk/logger/include', + env.get('SRC_DIR') + '/resource/../extlibs/boost/boost_1_58_0', + env.get('SRC_DIR') + '/resource/../build_common/android/compatibility', + env.get('SRC_DIR') + '/resource/csdk/security/provisioning/include', + env.get('SRC_DIR') + '/resource/csdk/security/provisioning/include/oxm', + env.get('SRC_DIR') + '/resource/csdk/security/provisioning/include/internal', + env.get('SRC_DIR') + '/resource/csdk/security/include' + ]) + + +target_os = env.get('TARGET_OS') +jni_env.AppendUnique(CCFLAGS = ['-Wno-error', '-Wno-comment', '-Wno-unused-function', '-Wno-unused-parameter']) +if target_os not in ['windows', 'winrt']: + jni_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread']) + + # Note: 'pthread' is in libc for android. On other platform, if use + # new gcc(>4.9?) it isn't required, otherwise, it's required + if target_os != 'android': + jni_env.AppendUnique(LIBS = ['-lpthread']) + +jni_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')]) +jni_env.AppendUnique(RPATH = [env.get('BUILD_DIR')]) +jni_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'connectivity_abstraction']) +if env.get('SECURED') == '1': + jni_env.AppendUnique(LIBS = ['tinydtls', 'ocprovision', 'ocpmapi']) + +if target_os == 'android': + jni_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions']) + jni_env.AppendUnique(LIBS = ['gnustl_shared']) + + if not env.get('RELEASE'): + jni_env.AppendUnique(LIBS = ['log']) + +if target_os in ['darwin', 'ios']: + jni_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE']) + +###################################################################### +# Source files and Targets +###################################################################### + + +ca_interface = jni_env.SharedLibrary('ca-interface', ['JniCaInterface.c']) + +ocstack_files = [ + 'JniOcStack.cpp', + 'JniUtils.cpp', + 'JniEntityHandler.cpp', + 'JniOnResourceFoundListener.cpp', + 'JniOnDeviceInfoListener.cpp', + 'JniOnPlatformInfoListener.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', + 'JniOcSecurity.cpp' + ] +if env.get('SECURED') == '1': + ocstack_files += [ + 'JniOcSecureResource.cpp', + 'JniOcProvisioning.cpp', + 'JniSecureUtils.cpp', + 'JniProvisionResultListner.cpp', + 'JniPinCheckListener.cpp', + 'JniDisplayPinListener.cpp' + ] + +ocstack_jni = jni_env.SharedLibrary('ocstack-jni', ocstack_files) + +jni_env.InstallTarget(ocstack_jni, 'ocstack-jni') +jni_env.InstallTarget(ca_interface, 'ca-interface') + +env.AppendTarget('ocstack-jni') diff --git a/android/android_api/settings.gradle b/java/settings.gradle similarity index 95% rename from android/android_api/settings.gradle rename to java/settings.gradle index 5d0d834..afa139a 100755 --- a/android/android_api/settings.gradle +++ b/java/settings.gradle @@ -19,5 +19,3 @@ * *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */ - -include ':base' diff --git a/resource/csdk/connectivity/api/cautilinterface.h b/resource/csdk/connectivity/api/cautilinterface.h index cdd377b..057916f 100644 --- a/resource/csdk/connectivity/api/cautilinterface.h +++ b/resource/csdk/connectivity/api/cautilinterface.h @@ -22,7 +22,7 @@ #define CA_UTILS_INTERFACE_H_ #include "cacommon.h" -#ifdef __ANDROID__ +#ifdef __JAVA__ #include "jni.h" #endif #ifdef __cplusplus @@ -70,6 +70,7 @@ CAResult_t CASetAutoConnectionDeviceInfo(const char* address); */ CAResult_t CAUnsetAutoConnectionDeviceInfo(const char* address); +#ifdef __JAVA__ #ifdef __ANDROID__ /** * initialize util client for android @@ -80,6 +81,16 @@ CAResult_t CAUnsetAutoConnectionDeviceInfo(const char* address); * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED */ CAResult_t CAUtilClientInitialize(JNIEnv *env, JavaVM *jvm, jobject context); +#else +/** + * initialize util client for android + * @param[in] env JNI interface pointer. + * @param[in] jvm invocation inferface for JAVA virtual machine. + * + * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED + */ +CAResult_t CAUtilClientInitialize(JNIEnv *env, JavaVM *jvm); +#endif /** * terminate util client for android @@ -109,7 +120,6 @@ CAResult_t CAUtilStopScan(JNIEnv *env); */ CAResult_t CAUtilCreateBond(JNIEnv *env, jobject device); - /** * set callback listener of found device. * @param[in] listener callback listener diff --git a/resource/csdk/connectivity/inc/caadapterutils.h b/resource/csdk/connectivity/inc/caadapterutils.h index cd3f102..8d26887 100644 --- a/resource/csdk/connectivity/inc/caadapterutils.h +++ b/resource/csdk/connectivity/inc/caadapterutils.h @@ -28,7 +28,7 @@ #define CA_ADAPTER_UTILS_H_ #include -#ifdef __ANDROID__ +#ifdef __JAVA__ #include #endif @@ -209,15 +209,7 @@ void CAConvertAddrToName(const struct sockaddr_storage *sockAddr, socklen_t sock void CAConvertNameToAddr(const char *host, uint16_t port, struct sockaddr_storage *sockaddr); #endif /* WITH_ARDUINO */ -#ifdef __ANDROID__ -/** - * To set context of JNI Application. - * This must be called by the Android API before CA Initialization. - * @param[in] env JNI interface pointer. - * @param[in] context context object. - */ -void CANativeJNISetContext(JNIEnv *env, jobject context); - +#ifdef __JAVA__ /** * To set jvm object. * This must be called by the Android API before CA Initialization. @@ -226,13 +218,6 @@ void CANativeJNISetContext(JNIEnv *env, jobject context); void CANativeJNISetJavaVM(JavaVM *jvm); /** - * To get context. - * Called by adapters to get Application context. - * @return context object. - */ -jobject CANativeJNIGetContext(); - -/** * To get JVM object. * Called from adapters to get JavaVM object. * @return JVM object. @@ -240,21 +225,6 @@ jobject CANativeJNIGetContext(); JavaVM *CANativeJNIGetJavaVM(); /** - * To set Activity to JNI. - * This must be called by the Android API before CA Initialization. - * @param[in] env JNI Environment pointer. - * @param[in] activity Activity object. - */ -void CANativeSetActivity(JNIEnv *env, jobject activity); - -/** - * To get Activity. - * Called from adapters to get Activity. - * @return Activity object. - */ -jobject *CANativeGetActivity(); - -/** * get method ID for method Name and class * @param[in] env JNI interface pointer. * @param[in] className android class. @@ -272,6 +242,37 @@ jmethodID CAGetJNIMethodID(JNIEnv *env, const char* className, */ void CADeleteGlobalReferences(); +#ifdef __ANDROID__ +/** + * To set context of JNI Application. + * This must be called by the Android API before CA Initialization. + * @param[in] env JNI interface pointer. + * @param[in] context context object. + */ +void CANativeJNISetContext(JNIEnv *env, jobject context); + +/** + * To set Activity to JNI. + * This must be called by the Android API before CA Initialization. + * @param[in] env JNI Environment pointer. + * @param[in] activity Activity object. + */ +void CANativeSetActivity(JNIEnv *env, jobject activity); + +/** + * To get context. + * Called by adapters to get Application context. + * @return context object. + */ +jobject CANativeJNIGetContext(); + +/** + * To get Activity. + * Called from adapters to get Activity. + * @return Activity object. + */ +jobject *CANativeGetActivity(); +#endif #endif #ifdef __cplusplus diff --git a/resource/csdk/connectivity/src/adapter_util/caadapterutils.c b/resource/csdk/connectivity/src/adapter_util/caadapterutils.c index 83f24eb..6408562 100644 --- a/resource/csdk/connectivity/src/adapter_util/caadapterutils.c +++ b/resource/csdk/connectivity/src/adapter_util/caadapterutils.c @@ -32,19 +32,16 @@ #include #endif -#ifdef __ANDROID__ +#ifdef __JAVA__ #include -#endif - -#define CA_ADAPTER_UTILS_TAG "OIC_CA_ADAP_UTILS" -#ifdef __ANDROID__ /** * @var g_jvm * @brief pointer to store JavaVM */ static JavaVM *g_jvm = NULL; +#ifdef __ANDROID__ /** * @var gContext * @brief pointer to store context for android callback interface @@ -52,6 +49,9 @@ static JavaVM *g_jvm = NULL; static jobject g_Context = NULL; static jobject g_Activity = NULL; #endif +#endif + +#define CA_ADAPTER_UTILS_TAG "OIC_CA_ADAP_UTILS" #ifdef WITH_ARDUINO CAResult_t CAParseIPv4AddressInternal(const char *ipAddrStr, uint8_t *ipAddr, @@ -193,66 +193,33 @@ void CAConvertNameToAddr(const char *host, uint16_t port, struct sockaddr_storag } #endif // WITH_ARDUINO -#ifdef __ANDROID__ -void CANativeJNISetContext(JNIEnv *env, jobject context) -{ - OIC_LOG_V(DEBUG, CA_ADAPTER_UTILS_TAG, "CANativeJNISetContext"); - - if (!context) - { - OIC_LOG(ERROR, CA_ADAPTER_UTILS_TAG, "context is null"); - return; - } - - if (!g_Context) - { - g_Context = (*env)->NewGlobalRef(env, context); - } - else - { - OIC_LOG(INFO, CA_ADAPTER_UTILS_TAG, "context is already set"); - } -} - +#ifdef __JAVA__ void CANativeJNISetJavaVM(JavaVM *jvm) { OIC_LOG_V(DEBUG, CA_ADAPTER_UTILS_TAG, "CANativeJNISetJavaVM"); g_jvm = jvm; } -jobject CANativeJNIGetContext() -{ - return g_Context; -} - JavaVM *CANativeJNIGetJavaVM() { return g_jvm; } -void CANativeSetActivity(JNIEnv *env, jobject activity) +void CADeleteGlobalReferences(JNIEnv *env) { - OIC_LOG_V(DEBUG, CA_ADAPTER_UTILS_TAG, "CANativeSetActivity"); - - if (!activity) +#ifdef __ANDROID__ + if (g_Context) { - OIC_LOG(ERROR, CA_ADAPTER_UTILS_TAG, "activity is null"); - return; + (*env)->DeleteGlobalRef(env, g_Context); + g_Context = NULL; } - if (!g_Activity) - { - g_Activity = (*env)->NewGlobalRef(env, activity); - } - else + if (g_Activity) { - OIC_LOG(INFO, CA_ADAPTER_UTILS_TAG, "activity is already set"); + (*env)->DeleteGlobalRef(env, g_Activity); + g_Activity = NULL; } -} - -jobject *CANativeGetActivity() -{ - return g_Activity; +#endif } jmethodID CAGetJNIMethodID(JNIEnv *env, const char* className, @@ -283,18 +250,55 @@ jmethodID CAGetJNIMethodID(JNIEnv *env, const char* className, return jni_midID; } -void CADeleteGlobalReferences(JNIEnv *env) +#ifdef __ANDROID__ +void CANativeJNISetContext(JNIEnv *env, jobject context) { - if (g_Context) + OIC_LOG_V(DEBUG, CA_ADAPTER_UTILS_TAG, "CANativeJNISetContext"); + + if (!context) { - (*env)->DeleteGlobalRef(env, g_Context); - g_Context = NULL; + OIC_LOG(ERROR, CA_ADAPTER_UTILS_TAG, "context is null"); + return; } - if (g_Activity) + if (!g_Context) { - (*env)->DeleteGlobalRef(env, g_Activity); - g_Activity = NULL; + g_Context = (*env)->NewGlobalRef(env, context); + } + else + { + OIC_LOG(INFO, CA_ADAPTER_UTILS_TAG, "context is already set"); + } +} + +jobject CANativeJNIGetContext() +{ + return g_Context; +} + +void CANativeSetActivity(JNIEnv *env, jobject activity) +{ + OIC_LOG_V(DEBUG, CA_ADAPTER_UTILS_TAG, "CANativeSetActivity"); + + if (!activity) + { + OIC_LOG(ERROR, CA_ADAPTER_UTILS_TAG, "activity is null"); + return; + } + + if (!g_Activity) + { + g_Activity = (*env)->NewGlobalRef(env, activity); + } + else + { + OIC_LOG(INFO, CA_ADAPTER_UTILS_TAG, "activity is already set"); } } + +jobject *CANativeGetActivity() +{ + return g_Activity; +} +#endif #endif diff --git a/resource/csdk/connectivity/util/src/cautilinterface.c b/resource/csdk/connectivity/util/src/cautilinterface.c index 83513f7..c6630af 100644 --- a/resource/csdk/connectivity/util/src/cautilinterface.c +++ b/resource/csdk/connectivity/util/src/cautilinterface.c @@ -67,6 +67,7 @@ CAResult_t CAUnsetAutoConnectionDeviceInfo(const char *address) #endif } +#ifdef __JAVA__ #ifdef __ANDROID__ /** * initialize client connection manager @@ -96,6 +97,36 @@ CAResult_t CAUtilClientInitialize(JNIEnv *env, JavaVM *jvm, jobject context) #endif return res; } +#else +/** + * initialize client connection manager + * @param[in] env JNI interface pointer. + * @param[in] jvm invocation inferface for JAVA virtual machine. + */ +CAResult_t CAUtilClientInitialize(JNIEnv *env, JavaVM *jvm) +{ + OIC_LOG(DEBUG, TAG, "CAUtilClientInitialize"); + + CAResult_t res = CA_STATUS_OK; +#ifdef LE_ADAPTER + if (CA_STATUS_OK != CAManagerLEClientInitialize(env, jvm)) + { + OIC_LOG(ERROR, TAG, "CAManagerLEClientInitialize has failed"); + res = CA_STATUS_FAILED; + } +#endif + +#ifdef EDR_ADAPTER + if (CA_STATUS_OK != CABTPairingInitialize(env, jvm)) + { + OIC_LOG(ERROR, TAG, "CABTPairingInitialize has failed"); + res = CA_STATUS_FAILED; + } +#endif + return res; +} + +#endif /** * terminate client connection manager -- 2.7.4