Merge branch '1.1-rel'
authorThiago Macieira <thiago.macieira@intel.com>
Mon, 16 May 2016 20:09:22 +0000 (13:09 -0700)
committerThiago Macieira <thiago.macieira@intel.com>
Mon, 16 May 2016 20:09:22 +0000 (13:09 -0700)
Conflicts:
android/examples/settings.gradle
android/examples/simplebase/simplebase.iml
android/examples/simplebase/src/main/AndroidManifest.xml
android/examples/simplebase/src/main/res/values-w820dp/dimens.xml
android/examples/simplebase/src/main/res/values/dimens.xml
plugins/samples/linux/IotivityandZigbeeClient.c
resource/csdk/connectivity/inc/cablockwisetransfer.h
resource/csdk/connectivity/src/bt_edr_adapter/android/caedrserver.c
resource/csdk/connectivity/src/bt_le_adapter/android/caleclient.c
resource/csdk/connectivity/src/bt_le_adapter/android/caleserver.c
resource/csdk/connectivity/src/bt_le_adapter/android/caleutils.c
resource/csdk/connectivity/src/bt_le_adapter/android/caleutils.h
resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c
resource/csdk/connectivity/src/cablockwisetransfer.c
resource/csdk/connectivity/src/ip_adapter/caipserver.c
resource/csdk/connectivity/src/tcp_adapter/catcpserver.c
resource/csdk/connectivity/util/src/camanager/android/caleconnectionmanager.c
resource/csdk/connectivity/util/src/camanager/tizen/caleconnectionmanager.c
resource/csdk/security/SConscript
resource/csdk/security/include/internal/aclresource.h
resource/csdk/security/include/internal/dpairingresource.h
resource/csdk/security/include/internal/pconfresource.h
resource/csdk/security/include/internal/pstatresource.h
resource/csdk/security/include/internal/srmresourcestrings.h
resource/csdk/security/include/securevirtualresourcetypes.h
resource/csdk/security/provisioning/ck_manager/sample/provisioningclient.c
resource/csdk/security/provisioning/sample/SConscript
resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks.json
resource/csdk/security/provisioning/sample/oic_svr_db_server_randompin.json
resource/csdk/security/provisioning/src/credentialgenerator.c
resource/csdk/security/provisioning/src/ownershiptransfermanager.c
resource/csdk/security/provisioning/src/secureresourceprovider.c
resource/csdk/security/provisioning/unittest/ocprovisioningmanager.cpp
resource/csdk/security/provisioning/unittest/secureresourceprovider.cpp
resource/csdk/security/src/aclresource.c
resource/csdk/security/src/amaclresource.c
resource/csdk/security/src/base64.c
resource/csdk/security/src/credresource.c
resource/csdk/security/src/directpairing.c
resource/csdk/security/src/doxmresource.c
resource/csdk/security/src/dpairingresource.c
resource/csdk/security/src/pconfresource.c
resource/csdk/security/src/psinterface.c
resource/csdk/security/src/pstatresource.c
resource/csdk/security/src/resourcemanager.c
resource/csdk/security/src/secureresourcemanager.c
resource/csdk/security/src/srmresourcestrings.c
resource/csdk/security/src/svcresource.c
resource/csdk/security/unittest/aclresourcetest.cpp
resource/csdk/security/unittest/credentialresource.cpp
resource/csdk/security/unittest/doxmresource.cpp
resource/csdk/stack/include/octypes.h
resource/csdk/stack/samples/linux/secure/SConscript
resource/csdk/stack/samples/linux/secure/occlientdirectpairing.cpp
resource/csdk/stack/samples/linux/secure/oic_svr_db_client_directpairing.json
resource/csdk/stack/src/ocpayload.c
resource/csdk/stack/src/ocpayloadparse.c
resource/csdk/stack/src/ocresource.c
resource/csdk/stack/src/ocstack.c
resource/docs/cpp-doc/Doxyfile
resource/docs/cpp-doc/devdox/mainpage.dox
resource/provisioning/examples/SConscript
resource/provisioning/examples/provisioningclient.cpp
resource/unittests/OCPlatformTest.cpp
service/easy-setup/enrollee/arduino/onboarding.cpp
service/easy-setup/enrollee/inc/onboarding.h
service/easy-setup/enrollee/src/easysetup.c
service/easy-setup/enrollee/src/easysetupcallbacks.h
service/easy-setup/enrollee/src/onboarding.h
service/easy-setup/enrollee/src/resourcehandler.c
service/easy-setup/enrollee/src/resourcehandler.h
service/easy-setup/enrollee/src/softap.c
service/easy-setup/enrollee/src/softap.h
service/easy-setup/mediator/csdk/unittests/MediatorCSDKTest.cpp
service/easy-setup/mediator/richsdk/unittests/MediatorRichTest.cpp
service/easy-setup/sampleapp/enrollee/linux/enrolleewifi.c
service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/assets/oic_svr_db_client.dat
service/easy-setup/sampleapp/mediator/linux/richsdk_sample/mediator_cpp.cpp
service/resource-encapsulation/examples/tizen/RESampleClientApp/src/reclient.cpp
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/MetaPropertiesView.java
tools/tizen/iotivity.spec
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/MetaPropertiesView.java

Change-Id: I912131cd6905e5758a143fa71d0e32ef4201abab
Signed-off-by: Markus Jung <markus.jung@samsung.com>
Signed-off-by: Jee Hyeok Kim <jihyeok13.kim@samsung.com>
Signed-off-by: Markus Jung <jay.sharma@samsung.com>
Signed-off-by: Randeep Singh <randeep.s@samsung.com>
Signed-off-by: jihwan.seo <jihwan.seo@samsung.com>
Signed-off-by: hyuna0213.jo <hyuna0213.jo@samsung.com>
Signed-off-by: Habib Virji <habib.virji@samsung.com>
Signed-off-by: jihwan.seo <jihwan.seo@samsung.com>
Signed-off-by: Jaewook Jung <jw0213.jung@samsung.com>
Signed-off-by: Saurabh Sharma <saurabh.s9@samsung.com>
Signed-off-by: Jay Sharma <jay.sharma@samsung.com>
Signed-off-by: jihwan.seo <jihwan.seo@samsung.com>
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
327 files changed:
android/android_api/base/build.gradle
android/android_api/base/src/androidTest/java/org/iotivity/base/OcRepresentationTest.java
android/android_api/base/src/androidTest/java/org/iotivity/base/SmokeTest.java
android/android_api/base/src/main/java/org/iotivity/base/CredType.java
android/android_api/base/src/main/java/org/iotivity/base/DeviceStatus.java
android/android_api/base/src/main/java/org/iotivity/base/EntityHandlerResult.java
android/android_api/base/src/main/java/org/iotivity/base/ErrorCode.java
android/android_api/base/src/main/java/org/iotivity/base/KeySize.java
android/android_api/base/src/main/java/org/iotivity/base/ModeType.java
android/android_api/base/src/main/java/org/iotivity/base/ObservationInfo.java
android/android_api/base/src/main/java/org/iotivity/base/ObserveAction.java
android/android_api/base/src/main/java/org/iotivity/base/ObserveType.java
android/android_api/base/src/main/java/org/iotivity/base/OcConnectivityType.java
android/android_api/base/src/main/java/org/iotivity/base/OcDeviceInfo.java
android/android_api/base/src/main/java/org/iotivity/base/OcException.java
android/android_api/base/src/main/java/org/iotivity/base/OcHeaderOption.java
android/android_api/base/src/main/java/org/iotivity/base/OcPlatform.java
android/android_api/base/src/main/java/org/iotivity/base/OcPlatformInfo.java
android/android_api/base/src/main/java/org/iotivity/base/OcPlatformStatus.java
android/android_api/base/src/main/java/org/iotivity/base/OcPresenceHandle.java
android/android_api/base/src/main/java/org/iotivity/base/OcPresenceStatus.java
android/android_api/base/src/main/java/org/iotivity/base/OcProvisioning.java
android/android_api/base/src/main/java/org/iotivity/base/OcRepresentation.java
android/android_api/base/src/main/java/org/iotivity/base/OcRequestHandle.java
android/android_api/base/src/main/java/org/iotivity/base/OcResource.java
android/android_api/base/src/main/java/org/iotivity/base/OcResourceHandle.java
android/android_api/base/src/main/java/org/iotivity/base/OcResourceIdentifier.java
android/android_api/base/src/main/java/org/iotivity/base/OcResourceRequest.java
android/android_api/base/src/main/java/org/iotivity/base/OcResourceResponse.java
android/android_api/base/src/main/java/org/iotivity/base/OcSecureResource.java
android/android_api/base/src/main/java/org/iotivity/base/OicSecAcl.java
android/android_api/base/src/main/java/org/iotivity/base/OwnedStatus.java
android/android_api/base/src/main/java/org/iotivity/base/OxmType.java
android/android_api/base/src/main/java/org/iotivity/base/PlatformConfig.java
android/android_api/base/src/main/java/org/iotivity/base/QualityOfService.java
android/android_api/base/src/main/java/org/iotivity/base/RequestHandlerFlag.java
android/android_api/base/src/main/java/org/iotivity/base/RequestType.java
android/android_api/base/src/main/java/org/iotivity/base/ResourceProperty.java
android/android_api/base/src/main/java/org/iotivity/base/ServiceType.java
android/android_api/base/src/main/java/org/iotivity/ca/CaEdrInterface.java
android/android_api/base/src/main/java/org/iotivity/ca/CaInterface.java
android/android_api/base/src/main/java/org/iotivity/ca/CaIpInterface.java
android/android_api/base/src/main/java/org/iotivity/ca/CaLeClientInterface.java
android/android_api/build.gradle
android/android_api/settings.gradle
android/examples/devicediscoveryclient/src/main/java/org/iotivity/base/examples/DeviceDiscoveryClient.java
android/examples/devicediscoveryserver/src/main/java/org/iotivity/base/examples/DeviceDiscoveryServer.java
android/examples/fridgeclient/src/main/java/org/iotivity/base/examples/FridgeClient.java
android/examples/fridgegroupclient/src/main/java/org/iotivity/base/examples/FridgeGroupClient.java
android/examples/fridgegroupserver/src/main/java/org/iotivity/base/examples/DoorResource.java
android/examples/fridgegroupserver/src/main/java/org/iotivity/base/examples/FridgeGroupServer.java
android/examples/fridgegroupserver/src/main/java/org/iotivity/base/examples/FridgeResource.java
android/examples/fridgegroupserver/src/main/java/org/iotivity/base/examples/LightResource.java
android/examples/fridgegroupserver/src/main/java/org/iotivity/base/examples/Refrigerator.java
android/examples/fridgegroupserver/src/main/java/org/iotivity/base/examples/Resource.java
android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DeviceResource.java
android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DoorResource.java
android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/FridgeServer.java
android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/LightResource.java
android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Refrigerator.java
android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Resource.java
android/examples/groupclient/src/main/java/org/iotivity/base/examples/GroupClient.java
android/examples/groupserver/src/main/java/org/iotivity/base/examples/GroupServer.java
android/examples/presenceclient/src/main/java/org/iotivity/base/examples/PresenceClient.java
android/examples/presenceserver/src/main/java/org/iotivity/base/examples/PresenceServer.java
android/examples/simplebase/.gitignore [new file with mode: 0644]
android/examples/simplebase/build.gradle [new file with mode: 0644]
android/examples/simplebase/libs/android-support-v4.jar [new file with mode: 0644]
android/examples/simplebase/proguard-rules.pro [new file with mode: 0644]
android/examples/simplebase/simplebase.iml [new file with mode: 0644]
android/examples/simplebase/src/main/AndroidManifest.xml [new file with mode: 0644]
android/examples/simplebase/src/main/java/org/iotivity/base/examples/BluetoothFragment.java [new file with mode: 0644]
android/examples/simplebase/src/main/java/org/iotivity/base/examples/Common.java [new file with mode: 0644]
android/examples/simplebase/src/main/java/org/iotivity/base/examples/DrawerFragment.java [new file with mode: 0644]
android/examples/simplebase/src/main/java/org/iotivity/base/examples/MessageFragment.java [new file with mode: 0644]
android/examples/simplebase/src/main/java/org/iotivity/base/examples/SimpleBase.java [new file with mode: 0644]
android/examples/simplebase/src/main/java/org/iotivity/base/examples/TemplateFragment.java [new file with mode: 0644]
android/examples/simplebase/src/main/res/drawable-hdpi/drawer_shadow.9.png [new file with mode: 0644]
android/examples/simplebase/src/main/res/drawable-hdpi/ic_drawer.png [new file with mode: 0644]
android/examples/simplebase/src/main/res/drawable-mdpi/drawer_shadow.9.png [new file with mode: 0644]
android/examples/simplebase/src/main/res/drawable-mdpi/ic_drawer.png [new file with mode: 0644]
android/examples/simplebase/src/main/res/drawable-xhdpi/drawer_shadow.9.png [new file with mode: 0644]
android/examples/simplebase/src/main/res/drawable-xhdpi/ic_drawer.png [new file with mode: 0644]
android/examples/simplebase/src/main/res/drawable-xxhdpi/drawer_shadow.9.png [new file with mode: 0644]
android/examples/simplebase/src/main/res/drawable-xxhdpi/ic_drawer.png [new file with mode: 0644]
android/examples/simplebase/src/main/res/drawable/iotivityicon.png [new file with mode: 0644]
android/examples/simplebase/src/main/res/drawable/iotivitylogo.png [new file with mode: 0644]
android/examples/simplebase/src/main/res/layout/activity_simplebase.xml [new file with mode: 0644]
android/examples/simplebase/src/main/res/layout/fragment_bluetooth.xml [new file with mode: 0644]
android/examples/simplebase/src/main/res/layout/fragment_drawer.xml [new file with mode: 0644]
android/examples/simplebase/src/main/res/layout/fragment_message.xml [new file with mode: 0644]
android/examples/simplebase/src/main/res/layout/fragment_template.xml [new file with mode: 0644]
android/examples/simplebase/src/main/res/layout/tcp_input.xml [new file with mode: 0755]
android/examples/simplebase/src/main/res/mipmap-hdpi/iotivityicon.png [new file with mode: 0644]
android/examples/simplebase/src/main/res/mipmap-mdpi/iotivityicon.png [new file with mode: 0644]
android/examples/simplebase/src/main/res/mipmap-xhdpi/iotivityicon.png [new file with mode: 0644]
android/examples/simplebase/src/main/res/mipmap-xxhdpi/iotivityicon.png [new file with mode: 0644]
android/examples/simplebase/src/main/res/values-v21/styles.xml [new file with mode: 0644]
android/examples/simplebase/src/main/res/values-w820dp/dimens.xml [new file with mode: 0644]
android/examples/simplebase/src/main/res/values/dimens.xml [new file with mode: 0644]
android/examples/simplebase/src/main/res/values/strings.xml [new file with mode: 0644]
android/examples/simplebase/src/main/res/values/styles.xml [new file with mode: 0644]
android/examples/simpleclient/src/main/java/org/iotivity/base/examples/Light.java
android/examples/simpleclient/src/main/java/org/iotivity/base/examples/SimpleClient.java
android/examples/simpleserver/src/main/java/org/iotivity/base/examples/Light.java
android/examples/simpleserver/src/main/java/org/iotivity/base/examples/SimpleServer.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/AccountServer.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/AccountServerManager.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/Constants.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/db/AccountDBManager.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/db/MongoDB.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/db/UserDevice.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/db/UserSession.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/oauth/GitHub.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/oauth/OAuthServer.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/resources/AccountResource.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/resources/AuthResource.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/resources/ResponseObject.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/util/CoapMessageBuilder.java
cloud/interface/src/main/java/org/iotivity/cloud/ciserver/CloudInterfaceServer.java
cloud/interface/src/main/java/org/iotivity/cloud/ciserver/Constants.java
cloud/interface/src/main/java/org/iotivity/cloud/ciserver/protocols/CoapRelayHandler.java
cloud/interface/src/main/java/org/iotivity/cloud/ciserver/resources/KeepAliveResource.java
cloud/resourcedirectory/src/main/java/org/iotivity/cloud/rdserver/Constants.java
cloud/resourcedirectory/src/main/java/org/iotivity/cloud/rdserver/MongoDB.java
cloud/resourcedirectory/src/main/java/org/iotivity/cloud/rdserver/ResourceDirectoryServer.java
cloud/resourcedirectory/src/main/java/org/iotivity/cloud/rdserver/resources/LinksPayloadFormat.java
cloud/resourcedirectory/src/main/java/org/iotivity/cloud/rdserver/resources/PublishPayloadFormat.java
cloud/resourcedirectory/src/main/java/org/iotivity/cloud/rdserver/resources/ResourceDirectoryResource.java
cloud/resourcedirectory/src/test/java/org/iotivity/cloud/testrdserver/RDServerTest.java
cloud/stack/src/main/java/org/iotivity/cloud/base/CoapClient.java
cloud/stack/src/main/java/org/iotivity/cloud/base/CoapServer.java
cloud/stack/src/main/java/org/iotivity/cloud/base/HttpClient.java
cloud/stack/src/main/java/org/iotivity/cloud/base/HttpServer.java
cloud/stack/src/main/java/org/iotivity/cloud/base/Resource.java
cloud/stack/src/main/java/org/iotivity/cloud/base/ResourceManager.java
cloud/stack/src/main/java/org/iotivity/cloud/base/SessionManager.java
cloud/stack/src/main/java/org/iotivity/cloud/base/protocols/coap/CoapDecoder.java
cloud/stack/src/main/java/org/iotivity/cloud/base/protocols/coap/CoapEncoder.java
cloud/stack/src/main/java/org/iotivity/cloud/base/protocols/coap/CoapMessage.java
cloud/stack/src/main/java/org/iotivity/cloud/base/protocols/coap/CoapRequest.java
cloud/stack/src/main/java/org/iotivity/cloud/base/protocols/coap/CoapResponse.java
cloud/stack/src/main/java/org/iotivity/cloud/base/protocols/proxy/CoapHttpProxyHandler.java
cloud/stack/src/main/java/org/iotivity/cloud/util/Cbor.java
cloud/stack/src/main/java/org/iotivity/cloud/util/CoapLogHandler.java
cloud/stack/src/main/java/org/iotivity/cloud/util/JSONUtil.java
cloud/stack/src/main/java/org/iotivity/cloud/util/Logger.java
cloud/stack/src/test/java/org/iotivity/cloud/base/CoapClientTest.java
cloud/stack/src/test/java/org/iotivity/cloud/base/CoapServerTest.java
examples/OICMiddle/SConscript
examples/OICSensorBoard/Makefile
extlibs/timer/timer.c
extlibs/tinydtls/SConscript
plugins/samples/linux/IotivityandZigbeeClient.c
resource/SConscript
resource/c_common/platform_features.h
resource/csdk/SConscript
resource/csdk/connectivity/SConscript
resource/csdk/connectivity/api/cacommon.h
resource/csdk/connectivity/api/cainterface.h
resource/csdk/connectivity/build/tizen/gbsbuild.sh
resource/csdk/connectivity/build/tizen/scons/SConscript
resource/csdk/connectivity/common/inc/camutex.h
resource/csdk/connectivity/common/src/camutex_noop.c
resource/csdk/connectivity/common/src/camutex_pthreads.c
resource/csdk/connectivity/common/src/cathreadpool_pthreads.c
resource/csdk/connectivity/inc/caadapterinterface.h
resource/csdk/connectivity/inc/caadapterutils.h
resource/csdk/connectivity/inc/cablockwisetransfer.h
resource/csdk/connectivity/inc/caedradapter.h
resource/csdk/connectivity/inc/caedradapter_singlethread.h
resource/csdk/connectivity/inc/cagattservice.h
resource/csdk/connectivity/inc/cainterfacecontroller.h
resource/csdk/connectivity/inc/cainterfacecontroller_singlethread.h
resource/csdk/connectivity/inc/caipadapter.h
resource/csdk/connectivity/inc/caipinterface.h
resource/csdk/connectivity/inc/caleadapter.h
resource/csdk/connectivity/inc/canfcadapter.h
resource/csdk/connectivity/inc/caraadapter.h
resource/csdk/connectivity/inc/catcpadapter.h
resource/csdk/connectivity/inc/catcpinterface.h
resource/csdk/connectivity/lib/arduino/arduino_libraries.patch
resource/csdk/connectivity/lib/libcoap-4.1.1/SConscript
resource/csdk/connectivity/lib/libcoap-4.1.1/net.c
resource/csdk/connectivity/lib/libcoap-4.1.1/option.c
resource/csdk/connectivity/lib/libcoap-4.1.1/pdu.c
resource/csdk/connectivity/lib/libcoap-4.1.1/pdu.h
resource/csdk/connectivity/lib/libcoap-4.1.1/resource.c
resource/csdk/connectivity/src/SConscript
resource/csdk/connectivity/src/adapter_util/caadapterutils.c
resource/csdk/connectivity/src/bt_edr_adapter/android/caedrclient.c
resource/csdk/connectivity/src/bt_edr_adapter/android/caedrnwmonitor.c
resource/csdk/connectivity/src/bt_edr_adapter/android/caedrserver.c
resource/csdk/connectivity/src/bt_edr_adapter/android/caedrserver.h
resource/csdk/connectivity/src/bt_edr_adapter/android/caedrutils.c
resource/csdk/connectivity/src/bt_edr_adapter/android/caedrutils.h
resource/csdk/connectivity/src/bt_edr_adapter/android/org_iotivity_ca_CaEdrInterface.h
resource/csdk/connectivity/src/bt_edr_adapter/caedradapter.c
resource/csdk/connectivity/src/bt_edr_adapter/linux/SConscript [deleted file]
resource/csdk/connectivity/src/bt_edr_adapter/linux/caedradapter.c [deleted file]
resource/csdk/connectivity/src/bt_edr_adapter/tizen/caedrnwmonitor.c
resource/csdk/connectivity/src/bt_le_adapter/android/caleclient.c
resource/csdk/connectivity/src/bt_le_adapter/android/caleclient.h
resource/csdk/connectivity/src/bt_le_adapter/android/calenwmonitor.c
resource/csdk/connectivity/src/bt_le_adapter/android/caleserver.c
resource/csdk/connectivity/src/bt_le_adapter/android/caleutils.c
resource/csdk/connectivity/src/bt_le_adapter/android/caleutils.h
resource/csdk/connectivity/src/bt_le_adapter/android/org_iotivity_ca_CaLeClientInterface.h
resource/csdk/connectivity/src/bt_le_adapter/android/org_iotivity_ca_CaLeServerInterface.h
resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c
resource/csdk/connectivity/src/bt_le_adapter/linux/descriptor.c
resource/csdk/connectivity/src/bt_le_adapter/tizen/calenwmonitor.c
resource/csdk/connectivity/src/bt_le_adapter/tizen/caleserver.c
resource/csdk/connectivity/src/bt_le_adapter/tizen/caleutil.c
resource/csdk/connectivity/src/cablockwisetransfer.c
resource/csdk/connectivity/src/caconnectivitymanager.c
resource/csdk/connectivity/src/cainterfacecontroller.c
resource/csdk/connectivity/src/camessagehandler.c
resource/csdk/connectivity/src/caprotocolmessage.c
resource/csdk/connectivity/src/caqueueingthread.c
resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c
resource/csdk/connectivity/src/ip_adapter/caipadapter.c
resource/csdk/connectivity/src/ip_adapter/caipserver.c
resource/csdk/connectivity/src/ip_adapter/linux/caipnwmonitor.c
resource/csdk/connectivity/src/ip_adapter/tizen/caipnwmonitor.c
resource/csdk/connectivity/src/nfc_adapter/android/canfcserver.c
resource/csdk/connectivity/src/nfc_adapter/canfcadapter.c
resource/csdk/connectivity/src/ra_adapter/caraadapter.c
resource/csdk/connectivity/src/tcp_adapter/SConscript
resource/csdk/connectivity/src/tcp_adapter/arduino/SConscript [new file with mode: 0644]
resource/csdk/connectivity/src/tcp_adapter/arduino/catcpadapterutils_eth.cpp [new file with mode: 0644]
resource/csdk/connectivity/src/tcp_adapter/arduino/catcpadapterutils_eth.h [new file with mode: 0644]
resource/csdk/connectivity/src/tcp_adapter/arduino/catcpserver_eth.cpp [new file with mode: 0644]
resource/csdk/connectivity/src/tcp_adapter/catcpadapter.c
resource/csdk/connectivity/src/tcp_adapter/catcpserver.c
resource/csdk/connectivity/test/SConscript
resource/csdk/connectivity/test/ca_api_unittest.cpp
resource/csdk/connectivity/test/cablocktransfertest.cpp [new file with mode: 0644]
resource/csdk/connectivity/test/camutex_tests.cpp
resource/csdk/connectivity/util/SConscript
resource/csdk/connectivity/util/inc/camanagerleinterface.h
resource/csdk/connectivity/util/src/btpairing/android/cabtpairing.h
resource/csdk/connectivity/util/src/camanager/android/caleautoconnector.c
resource/csdk/connectivity/util/src/camanager/android/caleconnectionmanager.c
resource/csdk/connectivity/util/src/camanager/android/camanagerdevice.c
resource/csdk/connectivity/util/src/camanager/android/camanagerdevice.h
resource/csdk/connectivity/util/src/camanager/android/camanagerleutil.c
resource/csdk/connectivity/util/src/camanager/android/camanagerleutil.h
resource/csdk/connectivity/util/src/camanager/arduino/caleconnectionmanager.c [deleted file]
resource/csdk/connectivity/util/src/camanager/linux/caleconnectionmanager.c [deleted file]
resource/csdk/connectivity/util/src/cautilinterface.c
resource/csdk/logger/include/logger.h
resource/csdk/logger/src/logger.c
resource/csdk/security/README-building-and-running-secure-IoTivity-stack.txt
resource/csdk/security/include/internal/amsmgr.h
resource/csdk/security/provisioning/README.txt
resource/csdk/security/provisioning/ck_manager/sample/README.txt
resource/csdk/security/provisioning/include/internal/secureresourceprovider.h
resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks.json [changed mode: 0644->0755]
resource/csdk/security/src/amsmgr.c
resource/csdk/security/src/dpairingresource.c [changed mode: 0644->0755]
resource/csdk/security/src/policyengine.c
resource/csdk/stack/include/internal/oickeepalive.h
resource/csdk/stack/include/ocpayload.h
resource/csdk/stack/include/ocstackconfig.h
resource/csdk/stack/include/octypes.h
resource/csdk/stack/samples/linux/secure/occlientdirectpairing.cpp
resource/csdk/stack/samples/linux/secure/oic_svr_db_client_directpairing.json
resource/csdk/stack/src/occollection.c
resource/csdk/stack/src/ocpayload.c
resource/csdk/stack/src/ocpayloadconvert.c
resource/csdk/stack/src/ocpayloadparse.c [changed mode: 0644->0755]
resource/csdk/stack/src/ocresource.c
resource/csdk/stack/src/ocstack.c
resource/csdk/stack/src/oickeepalive.c
resource/csdk/stack/test/stacktests.cpp
resource/docs/cpp-doc/Doxyfile
resource/examples/SConscript
resource/examples/groupclient.cpp
resource/include/OCHeaderOption.h
resource/include/OCSerialization.h
resource/include/StringConstants.h
resource/oc_logger/SConscript
resource/src/SConscript
resource/unittests/OCHeaderOptionTest.cpp
service/easy-setup/enrollee/arduino/resourcehandler.cpp [changed mode: 0644->0755]
service/easy-setup/enrollee/src/easysetupcallbacks.h
service/easy-setup/enrollee/src/resourcehandler.c [changed mode: 0644->0755]
service/easy-setup/enrollee/src/softap.c
service/easy-setup/mediator/csdk/unittests/MediatorCSDKTest.cpp
service/easy-setup/mediator/richsdk/SConscript
service/easy-setup/mediator/richsdk/unittests/SConscript
service/easy-setup/sampleapp/mediator/linux/richsdk_sample/SConscript
service/resource-container/SConscript
service/resource-container/android/settings.gradle
service/resource-container/examples/BMISensorBundle/src/inputSensors/HeightSensorApp/SConscript
service/resource-container/examples/BMISensorBundle/src/inputSensors/WeightSensorApp/SConscript
service/resource-container/examples/DiscomfortIndexSensorBundle/src/inputSensors/THSensorApp/SConscript
service/resource-container/examples/DiscomfortIndexSensorBundle/src/inputSensors/THSensorApp1/SConscript
service/resource-container/src/ResourceContainerImpl.cpp
service/resource-encapsulation/android/service/src/androidTest/java/org/iotivity/service/TestBase.java [changed mode: 0644->0755]
service/resource-encapsulation/android/settings.gradle
service/resource-encapsulation/examples/linux/SConscript
service/resource-encapsulation/examples/linux/secureResourceExample/SConscript
service/resource-encapsulation/src/resourceBroker/src/DevicePresence.cpp
service/resource-encapsulation/src/resourceBroker/unittest/SConscript
service/resource-encapsulation/src/serverBuilder/unittests/RCSResourceObjectTest.cpp
service/resource-encapsulation/unittests/SConscript
service/resource-hosting/SampleApp/android/SampleProviderApp/src/com/example/sample/provider/IMessageLogger.java
service/resource-hosting/SampleApp/linux/SConscript
service/resource-hosting/unittest/HostingObjectUnitTest.cpp
service/resource-hosting/unittest/ResourceHostingUnitTest.cpp
service/scene-manager/SConscript
service/scene-manager/sampleapp/linux/SConscript
service/scene-manager/sampleapp/linux/sceneclient.cpp
service/scene-manager/src/SceneUtils.cpp
service/simulator/java/eclipse-plugin/README.txt
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/manager/ResourceManager.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/ResourceManagerView.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/CreateResourceWizard.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/LoadRamlPage.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/ResourceWizardDialog.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/UpdateMultiInstanceCreationPropertiesPage.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/UpdatePropertiesPage.java
service/simulator/src/server/simulator_resource_factory.cpp
service/things-manager/sampleapp/linux/configuration/SConscript
service/things-manager/unittests/SConscript

index 7deb01c..3e67020 100755 (executable)
@@ -1,23 +1,23 @@
 /*\r
- * //******************************************************************\r
- * //\r
- * // Copyright 2015 Intel Corporation.\r
- * //\r
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
- * //\r
- * // Licensed under the Apache License, Version 2.0 (the "License");\r
- * // you may not use this file except in compliance with the License.\r
- * // You may obtain a copy of the License at\r
- * //\r
- * //      http://www.apache.org/licenses/LICENSE-2.0\r
- * //\r
- * // Unless required by applicable law or agreed to in writing, software\r
- * // distributed under the License is distributed on an "AS IS" BASIS,\r
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * // See the License for the specific language governing permissions and\r
- * // limitations under the License.\r
- * //\r
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ *******************************************************************\r
+ *\r
+ * Copyright 2015 Intel Corporation.\r
+ *\r
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
  */\r
 \r
 apply plugin: 'com.android.library'\r
index c7b5f30..8a7b93d 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
@@ -580,4 +580,4 @@ public class OcRepresentationTest extends InstrumentationTestCase {
             }
         }
     }
-}
\ No newline at end of file
+}
index 9645343..3ab7dd2 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index bbaeda7..87a33eb 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015  Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015  Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  */
 
 package org.iotivity.base;
index b569da8..0eefcaf 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  */
 
 package org.iotivity.base;
index 17fe3f4..3306230 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index bba664e..a6603ae 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index 6243db6..83c5799 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  */
 
 package org.iotivity.base;
index 52dfb66..d12cab7 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index 89876e1..064eeaf 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index 085ddf3..5506749 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index 13b5b18..ca990a9 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index 2d42a3e..0eb951a 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
@@ -131,4 +131,4 @@ public enum OcConnectivityType {
                 return CT_DEFAULT;
         }
     }
-}
\ No newline at end of file
+}
index 4a89856..acb4cfa 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index 1d56947..23af6ae 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index d672bf0..bcabc66 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
@@ -30,19 +30,30 @@ import java.security.InvalidParameterException;
  * After creating instances of OcHeaderOptions, use setHeaderOptions API
  * (in OcResource) to set header Options.
  * NOTE: optionId  is an integer value which MUST be within
- * range of 2048 to 3000 inclusive of lower and upper bound.
+ * range of 2048 to 3000 inclusive of lower and upper bound
+ * except for a few options including If-Match with empty(num : 1),
+ * If-None-Match(num : 5), Location-Path(num : 8),
+ * Location-Query(num : 20) CoAP option.
  * HeaderOption instance creation fails if above condition is not satisfied.
  */
 public class OcHeaderOption {
 
     public static final int MIN_HEADER_OPTION_ID = 2048;
     public static final int MAX_HEADER_OPTION_ID = 3000;
+    public static final int IF_MATCH_OPTION_ID = 1;
+    public static final int IF_NONE_MATCH_OPTION_ID = 5;
+    public static final int LOCATION_PATH_OPTION_ID = 8;
+    public static final int LOCATION_QUERY_OPTION_ID = 20;
 
     private int mOptionId;
     private String mOptionData;
 
     public OcHeaderOption(int optionId, String optionData) {
-        if (!(optionId >= MIN_HEADER_OPTION_ID && optionId <= MAX_HEADER_OPTION_ID)) {
+        if (!(optionId >= MIN_HEADER_OPTION_ID && optionId <= MAX_HEADER_OPTION_ID)
+                && optionId != IF_MATCH_OPTION_ID
+                && optionId != IF_NONE_MATCH_OPTION_ID
+                && optionId != LOCATION_PATH_OPTION_ID
+                && optionId != LOCATION_QUERY_OPTION_ID) {
             throw new InvalidParameterException("Option ID range is invalid");
         }
 
index c8678ff..d08b1c6 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index 89af6a2..e896428 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index 3087e5a..c41eb37 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index ae7ed15..1107854 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index 02b774f..4bc4baa 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index e7debe7..33eef2d 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  */
 
 package org.iotivity.base;
index 309ab70..a752f09 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
@@ -355,4 +355,4 @@ public class OcRepresentation {
 
     private long mNativeHandle;
     private boolean mNativeNeedsDelete;
-}
\ No newline at end of file
+}
index 7e021dc..69216a8 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index bb22465..b74c2e5 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index b55ce65..ac6e098 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index b1ce94a..751d37b 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index 7e0367f..b94689c 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index 0356b85..4e0879f 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index 218b9e2..368eda9 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  */
 
 package org.iotivity.base;
index a47ffaa..abd3a5a 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  */
 
 package org.iotivity.base;
index 1c90578..4abfc3e 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 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.base;
index 177105e..c8247de 100755 (executable)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  */
 
 package org.iotivity.base;
index 487f6a9..b41b65c 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index e6d6659..5da2be1 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index b67cee8..3536f78 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index 832c891..8c55a74 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index 71e8b6f..705565b 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index 929c4da..4d9027e 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index 7a07b24..a24e1f3 100644 (file)
@@ -26,6 +26,7 @@ import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
+import android.util.Log;
 
 public class CaEdrInterface {
     private static Context mContext;
@@ -39,6 +40,7 @@ public class CaEdrInterface {
         IntentFilter filter = new IntentFilter();
         filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
         filter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
+        filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED);
         mContext.registerReceiver(mReceiver, filter);
         return filter;
     }
@@ -52,6 +54,8 @@ public class CaEdrInterface {
 
     private native static void caEdrBondStateChangedCallback(String addr);
 
+    private native static void caEdrConnectionStateChangedCallback(String addr, int isConnected);
+
     private static final BroadcastReceiver mReceiver = new BroadcastReceiver() {
 
         @Override
@@ -87,6 +91,15 @@ public class CaEdrInterface {
                     }
                 }
             }
+
+            if (action != null && action.equals(BluetoothDevice.ACTION_ACL_DISCONNECTED)) {
+                BluetoothDevice device
+                    = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
+                if (BluetoothDevice.DEVICE_TYPE_CLASSIC == device.getType())
+                {
+                    caEdrConnectionStateChangedCallback(device.getAddress(), 0);
+                }
+            }
         }
     };
 }
index 3711f97..7771ba1 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
@@ -177,4 +177,4 @@ public class CaInterface {
     private static native void caBtPairingStartScan();
     private static native void caBtPairingStopScan();
     private static native void caBtPairingCreateBond(BluetoothDevice device);
-}
\ No newline at end of file
+}
index 81ab7d5..2314df9 100644 (file)
@@ -73,16 +73,16 @@ public class CaIpInterface {
     private static BroadcastReceiver mReceiver = new BroadcastReceiver() {\r
         @Override\r
         public void onReceive(Context context, Intent intent) {\r
-            if (intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,\r
-                WifiManager.WIFI_STATE_UNKNOWN) == WifiManager.WIFI_STATE_DISABLED) {\r
-                caIpStateDisabled();\r
-            } else if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {\r
+            if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {\r
                 ConnectivityManager manager = (ConnectivityManager)\r
                         mContext.getSystemService(Context.CONNECTIVITY_SERVICE);\r
-                NetworkInfo nwInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);\r
+                NetworkInfo wifiInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);\r
+                NetworkInfo mobileInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);\r
 \r
-                if(nwInfo.isConnected()) {\r
+                if (mobileInfo != null && mobileInfo.isConnected() || wifiInfo.isConnected()) {\r
                     caIpStateEnabled();\r
+                } else {\r
+                    caIpStateDisabled();\r
                 }\r
             }\r
 \r
index 0801bdb..6fc8294 100644 (file)
@@ -91,6 +91,11 @@ public class CaLeClientInterface {
 
     private native static void caLeGattServicesDiscoveredCallback(BluetoothGatt gatt, int status);
 
+    private native static void caLeGattNWServicesDiscoveredCallback(BluetoothGatt gatt,
+                                                                    int status);
+
+    private native static void caLeGattNWDescriptorWriteCallback(BluetoothGatt gatt, int status);
+
     private native static void caLeGattCharacteristicWriteCallback(
             BluetoothGatt gatt, byte[] data, int status);
 
@@ -211,6 +216,7 @@ public class CaLeClientInterface {
 
             caLeGattServicesDiscoveredCallback(gatt, status);
             caManagerLeServicesDiscoveredCallback(gatt, status);
+            caLeGattNWServicesDiscoveredCallback(gatt, status);
         }
 
         @Override
@@ -247,6 +253,7 @@ public class CaLeClientInterface {
             super.onDescriptorWrite(gatt, descriptor, status);
 
             caLeGattDescriptorWriteCallback(gatt, status);
+            caLeGattNWDescriptorWriteCallback(gatt, status);
         }
 
         @Override
index b8a6bed..cfcb3a2 100755 (executable)
@@ -1,23 +1,23 @@
 /*\r
- * //******************************************************************\r
- * //\r
- * // Copyright 2014 Intel Corporation.\r
- * //\r
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
- * //\r
- * // Licensed under the Apache License, Version 2.0 (the "License");\r
- * // you may not use this file except in compliance with the License.\r
- * // You may obtain a copy of the License at\r
- * //\r
- * //      http://www.apache.org/licenses/LICENSE-2.0\r
- * //\r
- * // Unless required by applicable law or agreed to in writing, software\r
- * // distributed under the License is distributed on an "AS IS" BASIS,\r
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * // See the License for the specific language governing permissions and\r
- * // limitations under the License.\r
- * //\r
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ *******************************************************************\r
+ *\r
+ * Copyright 2014 Intel Corporation.\r
+ *\r
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
  */\r
 \r
 // Top-level build file where you can add configuration options common to all sub-projects/modules.\r
index d1bcc8a..5d0d834 100755 (executable)
@@ -1,23 +1,23 @@
 /*\r
- * //******************************************************************\r
- * //\r
- * // Copyright 2015 Intel Corporation.\r
- * //\r
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
- * //\r
- * // Licensed under the Apache License, Version 2.0 (the "License");\r
- * // you may not use this file except in compliance with the License.\r
- * // You may obtain a copy of the License at\r
- * //\r
- * //      http://www.apache.org/licenses/LICENSE-2.0\r
- * //\r
- * // Unless required by applicable law or agreed to in writing, software\r
- * // distributed under the License is distributed on an "AS IS" BASIS,\r
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * // See the License for the specific language governing permissions and\r
- * // limitations under the License.\r
- * //\r
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ *******************************************************************\r
+ *\r
+ * Copyright 2015 Intel Corporation.\r
+ *\r
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
  */\r
 \r
 include ':base'\r
index 309fc3b..6c2d317 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
 
index b022f0c..a2920f4 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
 
index 503382b..3095ecf 100755 (executable)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
@@ -245,4 +245,4 @@ public class FridgeClient extends Activity implements
 
     private static String TAG = "FridgeClient: ";
     private TextView mConsoleTextView;
-}
\ No newline at end of file
+}
index 19c245e..961f00e 100755 (executable)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
@@ -255,4 +255,4 @@ public class FridgeGroupClient extends Activity implements
         });
         Log.i(TAG, text);
     }
-}
\ No newline at end of file
+}
index d86e1c7..dd3ce9d 100755 (executable)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
@@ -169,4 +169,4 @@ public class DoorResource extends Resource implements OcPlatform.EntityHandler {
         intent.putExtra(Resource.MESSAGE, msg);
         mContext.sendBroadcast(intent);
     }
-}
\ No newline at end of file
+}
index 32c90f6..4ee0aca 100755 (executable)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index c925e0f..dc10327 100755 (executable)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index dcb1423..79f8347 100755 (executable)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index b81c07b..5b1f861 100755 (executable)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
@@ -59,4 +59,4 @@ public class Refrigerator {
         mRightDoor.bindTo(mFridge.getHandle());
         mRandomDoor.bindTo(mFridge.getHandle());
     }
-}
\ No newline at end of file
+}
index 070cacc..41d8d53 100755 (executable)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
@@ -56,4 +56,4 @@ public abstract class Resource {
     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
+}
index 6ce3c35..b4338fa 100755 (executable)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index 332abba..86e83fe 100755 (executable)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
@@ -166,4 +166,4 @@ public class DoorResource extends Resource implements OcPlatform.EntityHandler {
         intent.putExtra(FridgeServer.MESSAGE, msg);
         mContext.sendBroadcast(intent);
     }
-}
\ No newline at end of file
+}
index 2f1fa51..5f0c962 100755 (executable)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index e33083e..cf3d549 100755 (executable)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index 8639f38..6717650 100755 (executable)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index 676cae8..937e4b8 100755 (executable)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
@@ -58,4 +58,4 @@ public class Resource {
     }
 
     public static final int SUCCESS = 200;
-}
\ No newline at end of file
+}
index 4bfa9ee..1cabcf9 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
 
index 06089b0..85658f4 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
 
@@ -330,4 +330,4 @@ public class GroupServer extends Activity implements OcPlatform.OnResourceFoundL
             }
         });
     }
-}
\ No newline at end of file
+}
index 2a9b0f0..3e7db0b 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
 
@@ -237,4 +237,4 @@ public class PresenceClient extends Activity implements
             }
         });
     }
-}
\ No newline at end of file
+}
index 0c61f27..6be053e 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
 
@@ -216,4 +216,4 @@ public class PresenceServer extends Activity {
             }
         });
     }
-}
\ No newline at end of file
+}
diff --git a/android/examples/simplebase/.gitignore b/android/examples/simplebase/.gitignore
new file mode 100644 (file)
index 0000000..3543521
--- /dev/null
@@ -0,0 +1 @@
+/build\r
diff --git a/android/examples/simplebase/build.gradle b/android/examples/simplebase/build.gradle
new file mode 100644 (file)
index 0000000..d84d82c
--- /dev/null
@@ -0,0 +1,38 @@
+apply plugin: 'com.android.application'
+
+android {
+    compileSdkVersion 21
+    buildToolsVersion "20.0.0"
+
+    defaultConfig {
+        applicationId "org.iotivity.base.examples.simplebase"
+        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 "../../android_api/base/build/outputs/aar/"
+    }
+}
+
+try {
+    dependencies {
+        compile files('libs/android-support-v4.jar')
+        compile ":iotivity-base-${TARGET_ARCH}-${RELEASE}@aar"
+    }
+} catch (all) {
+    print "${ERROR_MSG}"
+    assert all
+}
diff --git a/android/examples/simplebase/libs/android-support-v4.jar b/android/examples/simplebase/libs/android-support-v4.jar
new file mode 100644 (file)
index 0000000..2ff47f4
Binary files /dev/null and b/android/examples/simplebase/libs/android-support-v4.jar differ
diff --git a/android/examples/simplebase/proguard-rules.pro b/android/examples/simplebase/proguard-rules.pro
new file mode 100644 (file)
index 0000000..e209e11
--- /dev/null
@@ -0,0 +1,17 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in /home/iotivity/sdk/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
diff --git a/android/examples/simplebase/simplebase.iml b/android/examples/simplebase/simplebase.iml
new file mode 100644 (file)
index 0000000..d925a1e
--- /dev/null
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module external.linked.project.id=":simplebase" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="examples" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
+  <component name="FacetManager">
+    <facet type="android-gradle" name="Android-Gradle">
+      <configuration>
+        <option name="GRADLE_PROJECT_PATH" value=":simplebase" />
+      </configuration>
+    </facet>
+    <facet type="android" name="Android">
+      <configuration>
+        <option name="SELECTED_BUILD_VARIANT" value="debug" />
+        <option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
+        <option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
+        <option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
+        <option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
+        <option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugAndroidTestSources" />
+        <afterSyncTasks>
+          <task>generateDebugAndroidTestSources</task>
+          <task>generateDebugSources</task>
+        </afterSyncTasks>
+        <option name="ALLOW_USER_CONFIGURATION" value="false" />
+        <option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
+        <option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
+        <option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
+        <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
+      </configuration>
+    </facet>
+  </component>
+  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
+    <output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
+    <output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/debug" />
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
+      <excludeFolder url="file://$MODULE_DIR$/build/outputs" />
+      <excludeFolder url="file://$MODULE_DIR$/build/reports" />
+      <excludeFolder url="file://$MODULE_DIR$/build/test-results" />
+      <excludeFolder url="file://$MODULE_DIR$/build/tmp" />
+    </content>
+    <orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="library" exported="" name="iotivity-base-armeabi-release-" level="project" />
+    <orderEntry type="library" exported="" name="android-android-21" level="project" />
+  </component>
+</module>
diff --git a/android/examples/simplebase/src/main/AndroidManifest.xml b/android/examples/simplebase/src/main/AndroidManifest.xml
new file mode 100644 (file)
index 0000000..64b68bb
--- /dev/null
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="org.iotivity.base.examples" >
+    <uses-feature android:name="android.hardware.nfc" />
+    <uses-feature
+        android:name="android.hardware.bluetooth_le"
+        android:required="true" />
+
+    <uses-permission android:name="android.permission.BLUETOOTH" />
+    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
+    <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+    <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
+    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
+    <uses-permission android:name="android.permission.NFC" />
+
+    <application
+        android:allowBackup="true"
+        android:icon="@mipmap/iotivityicon"
+        android:label="@string/app_name"
+        android:theme="@style/AppTheme" >
+        <activity
+            android:screenOrientation="portrait"
+            android:name=".SimpleBase"
+            android:label="@string/app_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+    </application>
+
+</manifest>
diff --git a/android/examples/simplebase/src/main/java/org/iotivity/base/examples/BluetoothFragment.java b/android/examples/simplebase/src/main/java/org/iotivity/base/examples/BluetoothFragment.java
new file mode 100644 (file)
index 0000000..30b3d0e
--- /dev/null
@@ -0,0 +1,383 @@
+/*
+ * ******************************************************************
+ *
+ * Copyright 2016 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.base.examples;
+
+import android.app.Activity;
+import android.app.Fragment;
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothDevice;
+import android.bluetooth.BluetoothGatt;
+import android.bluetooth.BluetoothManager;
+import android.bluetooth.le.BluetoothLeScanner;
+import android.bluetooth.le.ScanCallback;
+import android.bluetooth.le.ScanFilter;
+import android.bluetooth.le.ScanResult;
+import android.bluetooth.le.ScanSettings;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.ParcelUuid;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.ListView;
+
+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 org.iotivity.ca.CaBtPairingInterface;
+import org.iotivity.ca.CaInterface;
+
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.List;
+
+/**
+ * This class is for testing of Bluetooth util.
+ */
+public class BluetoothFragment extends Fragment implements
+        CaInterface.OnBtDeviceFoundListener,
+        CaInterface.OnConnectionManagerStateListener {
+
+    private static final String      TAG                  = "OCF_SIMPLE_BLUETOOTH";
+    private static final String      CA_GATT_SERVICE_UUID = "ADE3D529-C784-4F63-A987-EB69F70EE816";
+
+    private Activity                   mActivity;
+    private Context                    mContext;
+    private BluetoothAdapter           mBluetoothAdapter;
+    private static final int           REQUEST_ENABLE_BT  = 1;
+    private static final long          SCAN_PERIOD        = 10000;
+    private BluetoothLeScanner         mLEScanner;
+    private ScanSettings               mScanSettings;
+    private List<ScanFilter>           mScanFilters;
+    private BluetoothGatt              mGatt;
+    private ArrayList<String>          mItems;
+    private ArrayList<BluetoothDevice> mBluetoothDevices;
+    private ArrayAdapter<String>       mAdapters;
+
+    private boolean                    mIsScanning;
+    private boolean                    mIsBTSelected;
+
+    private Button                     mBtButton;
+    private Button                     mLeButton;
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+                             Bundle savedInstanceState) {
+        View rootView = inflater.inflate(R.layout.fragment_bluetooth, container, false);
+        mBtButton = (Button) rootView.findViewById(R.id.btn_bt);
+        mBtButton.setOnClickListener(scanButtonListener(true));
+
+        mLeButton = (Button) rootView.findViewById(R.id.btn_le);
+        mLeButton.setOnClickListener(scanButtonListener(false));
+
+        ListView listView = (ListView) rootView.findViewById(R.id.list_view);
+        mItems = new ArrayList<String>();
+        mAdapters = new ArrayAdapter<String>(mActivity, android.R.layout.simple_list_item_1, mItems);
+        listView.setAdapter(mAdapters);
+        listView.setOnItemClickListener(itemClickListener);
+        listView.setOnItemLongClickListener(itemLongClickListener);
+
+        return rootView;
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        mActivity = getActivity();
+        mContext = mActivity.getBaseContext();
+
+        mBluetoothDevices = new ArrayList<BluetoothDevice>();
+
+        if (!mActivity.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
+            Common.showToast(mContext, "BLE Not Supported");
+        }
+        final BluetoothManager bluetoothManager = (BluetoothManager) mActivity
+                                                  .getSystemService(Context.BLUETOOTH_SERVICE);
+        mBluetoothAdapter = bluetoothManager.getAdapter();
+
+        PlatformConfig cfg = new PlatformConfig(mActivity, mContext,
+                                                ServiceType.IN_PROC,
+                                                ModeType.CLIENT,
+                                                Common.IP_ADDRESS,
+                                                Common.IP_PORT,
+                                                QualityOfService.LOW);
+
+        OcPlatform.Configure(cfg);
+        CaInterface.startBtPairingService(mContext, this);
+        CaInterface.startManagerService(mContext, this);
+    }
+
+    @Override
+    public void onResume() {
+        super.onResume();
+        if (mBluetoothAdapter == null || !mBluetoothAdapter.isEnabled()) {
+            Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
+            startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
+        } else {
+            if (Build.VERSION.SDK_INT >= 21) {
+                mLEScanner = mBluetoothAdapter.getBluetoothLeScanner();
+                if (mScanSettings == null) {
+                    mScanSettings = new ScanSettings.Builder()
+                                               .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
+                                               .build();
+                }
+
+                if (mScanFilters == null) {
+                    mScanFilters = new ArrayList<ScanFilter>();
+                    ScanFilter scanFilter = new ScanFilter.Builder()
+                            .setServiceUuid(ParcelUuid.fromString(CA_GATT_SERVICE_UUID)).build();
+                    mScanFilters.add(scanFilter);
+                }
+            }
+        }
+    }
+
+    @Override
+    public void onPause() {
+        super.onPause();
+        if (mBluetoothAdapter != null && mBluetoothAdapter.isEnabled()) {
+            scanLeDevice(false);
+        }
+    }
+
+    @Override
+    public void onDestroy() {
+        super.onDestroy();
+        CaInterface.stopBtPairingService();
+        CaInterface.stopManagerService();
+        CaBtPairingInterface.destroyEdrInterface();
+        if (mGatt != null) {
+            mGatt.close();
+            mGatt = null;
+        }
+    }
+
+    @Override
+    public void onActivityResult(int requestCode, int resultCode, Intent data) {
+        if (requestCode == REQUEST_ENABLE_BT) {
+            if (resultCode == Activity.RESULT_CANCELED) {
+                mActivity.finish();
+                return;
+            }
+        }
+        super.onActivityResult(requestCode, resultCode, data);
+    }
+
+    View.OnClickListener scanButtonListener(final boolean isBT) {
+        return new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                if (!mIsScanning) {
+                    mItems.clear();
+                    mBluetoothDevices.clear();
+                    mAdapters.notifyDataSetChanged();
+                    mIsBTSelected = isBT;
+                }
+
+                if (isBT) {
+                    if (mIsScanning) {
+                        // BT Stop
+                        try {
+                            CaInterface.stopScan();
+                        } catch (OcException e) {
+                            e.printStackTrace();
+                        }
+                        mBtButton.setText(R.string.bt_scan);
+                        mLeButton.setVisibility(View.VISIBLE);
+                    } else {
+                        // BT Scan
+                        try {
+                            CaInterface.startScan();
+                        } catch (OcException e) {
+                            e.printStackTrace();
+                        }
+                        mBtButton.setText(R.string.stop_scan);
+                        mLeButton.setVisibility(View.GONE);
+                    }
+                } else {
+                    if (mIsScanning) {
+                        // LE Stop
+                        mLeButton.setText(R.string.le_scan);
+                        mBtButton.setVisibility(View.VISIBLE);
+                    } else {
+                        // LE Scan
+                        mLeButton.setText(R.string.stop_scan);
+                        mBtButton.setVisibility(View.GONE);
+                    }
+                    scanLeDevice(!mIsScanning);
+                }
+                mIsScanning = !mIsScanning;
+            }
+        };
+    }
+
+    @Override
+    public synchronized void onBtDeviceFound(BluetoothDevice device) throws OcException {
+        Log.i(TAG, "onBtDeviceFound address : " + device.getAddress());
+
+        addItemToList(device);
+    }
+
+    private AdapterView.OnItemClickListener itemClickListener = new AdapterView
+                                                                .OnItemClickListener() {
+        public void onItemClick(AdapterView<?> adapterView, View clickedView, int pos, long id) {
+            StringBuilder sb = new StringBuilder();
+
+            if (mIsBTSelected) {
+                sb.append("Pairing with : ");
+                try {
+                    CaInterface.createBond(mBluetoothDevices.get(pos));
+                } catch (OcException e) {
+                    e.printStackTrace();
+                }
+            } else {
+                sb.append("Set Connect with : ");
+                try {
+                    final String address = mBluetoothDevices.get(pos).getAddress();
+                    CaInterface.setAutoConnectionDevice(address);
+                    OcPlatform.OnResourceFoundListener resourceFoundListener =
+                            new OcPlatform.OnResourceFoundListener() {
+                        @Override
+                        public void onResourceFound(OcResource ocResource) {
+                            Log.i(TAG, "onResourceFound : " + ocResource.getUri());
+                        }
+                    };
+                    OcPlatform.findResource("", address + OcPlatform.WELL_KNOWN_QUERY,
+                                            EnumSet.of(OcConnectivityType.CT_ADAPTER_GATT_BTLE),
+                                            resourceFoundListener, QualityOfService.LOW);
+                } catch (OcException e) {
+                    e.printStackTrace();
+                }
+            }
+            Common.showToast(mContext, sb.append(mItems.get(pos)).toString());
+        }
+    };
+
+    private AdapterView.OnItemLongClickListener itemLongClickListener = new AdapterView
+                                                                        .OnItemLongClickListener() {
+        @Override
+        public boolean onItemLongClick(AdapterView<?> adapterView, View view, int pos, long id) {
+            StringBuilder sb = new StringBuilder();
+
+            if (!mIsBTSelected) {
+                sb.append("Unset Connect with : ");
+                try {
+                    CaInterface.unsetAutoConnectionDevice(mBluetoothDevices.get(pos).getAddress());
+                } catch (OcException e) {
+                    e.printStackTrace();
+                }
+            }
+            Common.showToast(mContext, sb.append(mItems.get(pos)).toString());
+
+            return true;
+        }
+    };
+
+    private void scanLeDevice(final boolean enable) {
+        if (enable) {
+            new Handler().postDelayed(new Runnable() {
+                @Override
+                public void run() {
+                    mLEScanner.stopScan(mScanCallback);
+                }
+            }, SCAN_PERIOD);
+
+            mLEScanner.startScan(mScanFilters, mScanSettings, mScanCallback);
+        } else {
+            mLEScanner.stopScan(mScanCallback);
+        }
+    }
+
+    private ScanCallback mScanCallback = new ScanCallback() {
+        @Override
+        public void onScanResult(int callbackType, ScanResult result) {
+            Log.i(TAG, "onScanResult : " + result.toString());
+
+            addItemToList(result.getDevice());
+        }
+
+        @Override
+        public void onScanFailed(int errorCode) {
+            Log.e(TAG, "Scan Failed, Error Code : " + errorCode);
+        }
+    };
+
+    private void addItemToList(BluetoothDevice btDevice) {
+        StringBuilder sb = new StringBuilder(btDevice.toString());
+        sb.append(" (");
+        if (btDevice.getName() != null) {
+            sb.append(btDevice.getName().toString());
+        } else {
+            sb.append("NULL");
+        }
+        sb.append(")");
+
+        if (mItems.contains(sb.toString())) {
+            // Duplicate
+        } else {
+            // add item
+            mItems.add(sb.toString());
+            mBluetoothDevices.add(btDevice);
+            mAdapters.notifyDataSetChanged();
+        }
+    }
+
+    @Override
+    public void onAdapterStateChanged(OcConnectivityType type, boolean enabled) {
+        final String msg = getString(R.string.action_onadapterstatechanged) + enabled;
+        Log.i(TAG, msg);
+        mActivity.runOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                Common.showToast(mContext, msg);
+            }
+        });
+    }
+
+    @Override
+    public void onConnectionStateChanged(OcConnectivityType type,
+                                         String address, boolean connected) {
+        Log.i(TAG, "onConnectionStateChanged address: " + address);
+        final String msg = getString(R.string.action_onconnectionstatechanged) + connected;
+        Log.i(TAG, msg);
+        mActivity.runOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                Common.showToast(mContext, msg);
+            }
+        });
+    }
+}
diff --git a/android/examples/simplebase/src/main/java/org/iotivity/base/examples/Common.java b/android/examples/simplebase/src/main/java/org/iotivity/base/examples/Common.java
new file mode 100644 (file)
index 0000000..96f90c6
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * ******************************************************************
+ *
+ * Copyright 2016 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.base.examples;
+
+import android.content.Context;
+import android.widget.Toast;
+
+import org.iotivity.base.OcPlatform;
+import org.iotivity.base.ResourceProperty;
+
+import java.text.DateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.EnumSet;
+import java.util.Locale;
+
+/**
+ * This class charge of common part.
+ */
+public class Common {
+
+    public static final int    DATA_SIZE          = 3000;
+    public static final String COAP_TCP           = "coap+tcp://";
+    public static String       TCP_ADDRESS        = "192.168.0.1";
+    public static final String TCP_PORT           = ":8000";
+    public static final String IP_ADDRESS         = "0.0.0.0";
+    public static final int    IP_PORT            = 0;
+    public static final String GET_COMMAND        = "get_command";
+    public static final String STATE_KEY          = "state_key";
+    public static final String STATE_GET          = "state_get";
+    public static final String LARGE_KEY          = "large_key";
+    public static final String LARGE_GET          = "large_get";
+    public static final String RESOURCE_URI       = "/a/light";
+    public static final String RESOURCE_TYPE      = "core.light";
+    public static final String RESOURCE_INTERFACE = OcPlatform.DEFAULT_INTERFACE;
+    public static final EnumSet<ResourceProperty> RESOURCE_PROPERTIES =
+            EnumSet.of(ResourceProperty.DISCOVERABLE, ResourceProperty.OBSERVABLE);
+
+    public static String getDateCurrentTimeZone() {
+        StringBuilder sb = new StringBuilder();
+        try {
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTimeInMillis(System.currentTimeMillis());
+            DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.DEFAULT,
+                                                                   DateFormat.DEFAULT,
+                                                                   Locale.getDefault());
+            Date currentTimeZone = calendar.getTime();
+            sb.append(dateFormat.format(currentTimeZone));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return sb.toString();
+    }
+
+    public static void showToast(Context context, String msg) {
+        Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
+    }
+}
diff --git a/android/examples/simplebase/src/main/java/org/iotivity/base/examples/DrawerFragment.java b/android/examples/simplebase/src/main/java/org/iotivity/base/examples/DrawerFragment.java
new file mode 100644 (file)
index 0000000..ca7d5cd
--- /dev/null
@@ -0,0 +1,202 @@
+/*
+ * ******************************************************************
+ *
+ * Copyright 2016 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.base.examples;
+
+import android.app.ActionBar;
+import android.app.Activity;
+import android.app.Fragment;
+import android.content.res.Configuration;
+import android.os.Bundle;
+import android.support.v4.app.ActionBarDrawerToggle;
+import android.support.v4.view.GravityCompat;
+import android.support.v4.widget.DrawerLayout;
+import android.view.LayoutInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+
+/**
+ * Through a drawer able to move to another menu.
+ */
+public class DrawerFragment extends Fragment {
+
+    private static final String   STATE_SELECTED_POSITION  = "selected_navigation_drawer_position";
+    private DrawerCallbacks       mCallbacks;
+
+    private ActionBarDrawerToggle mDrawerToggle;
+
+    private DrawerLayout          mDrawerLayout;
+    private ListView              mDrawerListView;
+    private View                  mFragmentContainerView;
+
+    private int                   mCurrentSelectedPosition = 0;
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        if (savedInstanceState != null) {
+            mCurrentSelectedPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION);
+        }
+
+        selectItem(mCurrentSelectedPosition);
+    }
+
+    @Override
+    public void onActivityCreated(Bundle savedInstanceState) {
+        super.onActivityCreated(savedInstanceState);
+        setHasOptionsMenu(true);
+    }
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+            Bundle savedInstanceState) {
+        mDrawerListView = (ListView) inflater.inflate(R.layout.fragment_drawer,
+                                                      container, false);
+        mDrawerListView
+                .setOnItemClickListener(new AdapterView.OnItemClickListener() {
+                    @Override
+                    public void onItemClick(AdapterView<?> parent, View view,
+                                            int position, long id) {
+                        selectItem(position);
+                    }
+                });
+        mDrawerListView.setAdapter(new ArrayAdapter<String>(getActionBar()
+                .getThemedContext(),
+                android.R.layout.simple_list_item_activated_1,
+                android.R.id.text1, new String[] {
+                        getString(R.string.title_message),
+                        getString(R.string.title_bluetooth),
+                        getString(R.string.title_template), }));
+        mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);
+
+        return mDrawerListView;
+    }
+
+    public void setUp(int fragmentId, DrawerLayout drawerLayout) {
+        mFragmentContainerView = getActivity().findViewById(fragmentId);
+        mDrawerLayout = drawerLayout;
+
+        mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow,
+                                      GravityCompat.START);
+
+        ActionBar actionBar = getActionBar();
+        actionBar.setDisplayHomeAsUpEnabled(true);
+        actionBar.setHomeButtonEnabled(true);
+        mDrawerToggle = new ActionBarDrawerToggle(getActivity(),
+                                                  mDrawerLayout,
+                                                  R.drawable.ic_drawer,
+                                                  R.string.navigation_drawer_open,
+                                                  R.string.navigation_drawer_close) {
+            @Override
+            public void onDrawerClosed(View drawerView) {
+                super.onDrawerClosed(drawerView);
+                if (!isAdded()) {
+                    return;
+                }
+
+                getActivity().invalidateOptionsMenu();
+            }
+
+            @Override
+            public void onDrawerOpened(View drawerView) {
+                super.onDrawerOpened(drawerView);
+                if (!isAdded()) {
+                    return;
+                }
+
+                getActivity().invalidateOptionsMenu();
+            }
+        };
+
+        mDrawerLayout.post(new Runnable() {
+            @Override
+            public void run() {
+                mDrawerToggle.syncState();
+            }
+        });
+
+        mDrawerLayout.setDrawerListener(mDrawerToggle);
+    }
+
+    private void selectItem(int position) {
+        mCurrentSelectedPosition = position;
+        if (mDrawerListView != null) {
+            mDrawerListView.setItemChecked(position, true);
+        }
+        if (mDrawerLayout != null) {
+            mDrawerLayout.closeDrawer(mFragmentContainerView);
+        }
+        if (mCallbacks != null) {
+            mCallbacks.onDrawerItemSelected(position);
+        }
+    }
+
+    @Override
+    public void onAttach(Activity activity) {
+        super.onAttach(activity);
+        try {
+            mCallbacks = (DrawerCallbacks) activity;
+        } catch (ClassCastException e) {
+            throw new ClassCastException("Activity must implement DrawerCallbacks.");
+        }
+    }
+
+    @Override
+    public void onDetach() {
+        super.onDetach();
+        mCallbacks = null;
+    }
+
+    @Override
+    public void onSaveInstanceState(Bundle outState) {
+        super.onSaveInstanceState(outState);
+        outState.putInt(STATE_SELECTED_POSITION, mCurrentSelectedPosition);
+    }
+
+    @Override
+    public void onConfigurationChanged(Configuration newConfig) {
+        super.onConfigurationChanged(newConfig);
+        mDrawerToggle.onConfigurationChanged(newConfig);
+    }
+
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+        if (mDrawerToggle.onOptionsItemSelected(item)) {
+            return true;
+        }
+
+        return super.onOptionsItemSelected(item);
+    }
+
+    private ActionBar getActionBar() {
+        return getActivity().getActionBar();
+    }
+
+    public static interface DrawerCallbacks {
+        void onDrawerItemSelected(int position);
+    }
+}
diff --git a/android/examples/simplebase/src/main/java/org/iotivity/base/examples/MessageFragment.java b/android/examples/simplebase/src/main/java/org/iotivity/base/examples/MessageFragment.java
new file mode 100644 (file)
index 0000000..1264a83
--- /dev/null
@@ -0,0 +1,641 @@
+/*
+ * ******************************************************************
+ *
+ * Copyright 2016 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.base.examples;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Fragment;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.nfc.NfcAdapter;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.CompoundButton;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+import android.widget.Toast;
+import android.widget.ToggleButton;
+
+import org.iotivity.base.EntityHandlerResult;
+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.OcResourceHandle;
+import org.iotivity.base.OcResourceRequest;
+import org.iotivity.base.OcResourceResponse;
+import org.iotivity.base.PlatformConfig;
+import org.iotivity.base.QualityOfService;
+import org.iotivity.base.ServiceType;
+import org.iotivity.ca.CaEdrInterface;
+import org.iotivity.ca.CaIpInterface;
+import org.iotivity.ca.CaLeClientInterface;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * This class is for messaging between the server and the client.
+ * It can handle message manually.
+ */
+public class MessageFragment extends Fragment implements OcResource.OnGetListener,
+                                                         OcResource.OnPutListener {
+
+    private static final String TAG          = "OIC_SIMPLE_MESSAGE";
+    private final String        EOL          = System.getProperties().getProperty("line.separator");
+    private final double        MILLI_PER_SEC = 1000.0;
+
+    private Activity            mActivity;
+    private Context             mContext;
+
+    OcPlatform.EntityHandler    mEntityHandler;
+    private OcResourceHandle    mResourceHandle;
+    private OcResource          mFoundResource;
+
+    private QualityOfService    mQos         = QualityOfService.LOW;
+
+    private LinearLayout        mServerLayout;
+    private LinearLayout        mClientLayout;
+    private TextView            mResourceText;
+    private TextView            mActionLog;
+    private TextView            mResultLog;
+    private ToggleButton        mQosToggle;
+    private Button              mRegisterButton;
+    private Button              mGetButton;
+    private Button              mPutButton;
+    private Button              mLargeButton;
+    private Button              mDiscoverIPButton;
+    private Button              mDiscoverBTButton;
+    private Button              mDiscoverLEButton;
+    private Button              mDiscoverTCPButton;
+    private Button              mDiscoverNFCButton;
+
+    private String              mLargeData;
+    private boolean             mState;
+    private long                mStartTime;
+    private long                mEndTime;
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        mActivity = getActivity();
+        mContext = mActivity.getBaseContext();
+    }
+
+    View.OnClickListener getButtonListener() {
+        return new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                if (mFoundResource != null) {
+                    mStartTime = System.currentTimeMillis();
+                    sendGetToFoundResource(Common.STATE_GET);
+                } else {
+                    Common.showToast(mContext, "Please discovery first");
+                    Log.e(TAG, "get() : resource is null");
+                }
+            }
+        };
+    }
+
+    View.OnClickListener putButtonListener() {
+        return new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                if (mFoundResource != null) {
+                    mStartTime = System.currentTimeMillis();
+                    sendPutToFoundResource();
+                } else {
+                    Common.showToast(mContext, "Please discovery first");
+                    Log.e(TAG, "put() : resource is null");
+                }
+            }
+        };
+    }
+
+    View.OnClickListener getLargeListener() {
+        return new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                if (mFoundResource != null) {
+                    mStartTime = System.currentTimeMillis();
+                    sendGetToFoundResource(Common.LARGE_GET);
+                } else {
+                    Common.showToast(mContext, "Please discovery first");
+                    Log.e(TAG, "large() : resource is null");
+                }
+            }
+        };
+    }
+
+    View.OnClickListener discoverButtonListener(
+            final OcConnectivityType connectivityType) {
+        return new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                initOcPlatform(ModeType.CLIENT);
+                mFoundResource = null;
+
+                if (OcConnectivityType.CT_ADAPTER_TCP == connectivityType) {
+                    showTCPInput();
+                } else {
+                    try {
+                        Log.i(TAG, "discoverButtonListener");
+                        OcPlatform.findResource("",
+                                                OcPlatform.WELL_KNOWN_QUERY,
+                                                EnumSet.of(connectivityType),
+                                                resourceFoundListener, mQos);
+
+                        mActivity.runOnUiThread(new Runnable() {
+                            @Override
+                            public void run() {
+                                mActionLog.setText("[Action Log]" + EOL);
+                                mActionLog.append("Find resource()" + EOL);
+                                mActionLog.append("Connectivity : " + connectivityType + EOL);
+
+                                mResultLog.setText("[Result Log]" + EOL);
+                                mResultLog.append("Start Time : ");
+                                mResultLog.append(Common.getDateCurrentTimeZone() + EOL);
+                                mStartTime = System.currentTimeMillis();
+                            }
+                        });
+                    } catch (OcException e) {
+                        e.printStackTrace();
+                    }
+                }
+                mServerLayout.setVisibility(View.GONE);
+            }
+        };
+    }
+
+    void makeTCPResource(String address) {
+
+        List<String> resourceTypeList = new ArrayList<String>();
+        List<String> resourceInterfaceList = new ArrayList<String>();
+        resourceInterfaceList.add(Common.RESOURCE_INTERFACE);
+        resourceTypeList.add(Common.RESOURCE_TYPE);
+        try {
+            mFoundResource = OcPlatform.constructResourceObject(address,
+                    Common.RESOURCE_URI,
+                    EnumSet.of(OcConnectivityType.CT_ADAPTER_TCP), false,
+                    resourceTypeList, resourceInterfaceList);
+
+            mActionLog.setText("[Action Log]" + EOL);
+            mActionLog.append("Found resource()" + EOL);
+            mActionLog.append("Connectivity : " + OcConnectivityType.CT_ADAPTER_TCP + EOL);
+            mActionLog.append(mFoundResource.getHost() + Common.RESOURCE_URI);
+
+            mResultLog.setText("[Result Log]" + EOL);
+
+        } catch (OcException e) {
+            e.printStackTrace();
+        }
+    }
+
+    void sendGetToFoundResource(String command) {
+        try {
+            Log.i(TAG, "sendGetToFoundResource");
+
+            Map<String, String> queryParameters = new HashMap<String, String>();
+            queryParameters.put(Common.GET_COMMAND, command);
+
+            mFoundResource.get(queryParameters, this, mQos);
+
+            mActionLog.setText("[Action Log]" + EOL + "Send get()"+ EOL + "To : ");
+            mActionLog.append(mFoundResource.getHost() + mFoundResource.getUri() + EOL);
+        } catch (OcException e) {
+            e.printStackTrace();
+        }
+    }
+
+    void sendPutToFoundResource() {
+        try {
+            Log.i(TAG, "sendPutToFoundResource");
+
+            OcRepresentation rep = new OcRepresentation();
+            rep.setValue(Common.STATE_KEY, !mState);
+
+            Map<String, String> queryParams = new HashMap<>();
+
+            mFoundResource.put(rep, queryParams, this);
+            mActionLog.setText("[Action Log]" + EOL);
+            mActionLog.append("Send put()" + EOL + "To : ");
+            mActionLog.append(mFoundResource.getHost() + mFoundResource.getUri() + EOL);
+        } catch (OcException e) {
+            e.printStackTrace();
+        }
+    }
+
+    OcPlatform.OnResourceFoundListener resourceFoundListener =
+                                           new OcPlatform.OnResourceFoundListener() {
+        @Override
+        public void onResourceFound(OcResource ocResource) {
+            synchronized (mActivity) {
+                final String resourceUri = ocResource.getUri();
+                Log.i(TAG, "onResourceFound : " + ocResource.getUri());
+
+                if (resourceUri.contains(Common.RESOURCE_URI)) {
+                    mFoundResource = ocResource;
+                    mActivity.runOnUiThread(new Runnable() {
+                        @Override
+                        public void run() {
+                            mEndTime = System.currentTimeMillis();
+                            double flightTime = (double) (mEndTime - mStartTime) / MILLI_PER_SEC;
+                            mResultLog.append("Discovery Time : ");
+                            mResultLog.append(String.format("%.3f", flightTime) + "sec" + EOL);
+                            mActionLog.append(mFoundResource.getHost() + resourceUri + EOL);
+                        }
+                    });
+                }
+            }
+        }
+    };
+
+    @Override
+    public void onGetCompleted(List<OcHeaderOption> list, OcRepresentation ocRepresentation) {
+        String repUri = ocRepresentation.getUri();
+        Log.i(TAG, "onGetCompleted : " + repUri);
+
+        try {
+            final String command = ocRepresentation.getValue(Common.GET_COMMAND);
+
+            if (command == null || command.isEmpty()) {
+                Log.e(TAG, "Get command is null");
+                return;
+            } else if (command.equals(Common.STATE_GET)) {
+                mState = ocRepresentation.getValue(Common.STATE_KEY);
+                mLargeData = "";
+            } else if (command.equals(Common.LARGE_GET)) {
+                mLargeData = ocRepresentation.getValue(Common.LARGE_KEY);
+            }
+        } catch (OcException e) {
+            e.printStackTrace();
+        }
+
+        mActivity.runOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                mEndTime = System.currentTimeMillis();
+                double flightTime = (double) (mEndTime - mStartTime) / MILLI_PER_SEC;
+
+                if (mLargeData == null || mLargeData.isEmpty()) {
+                    mResultLog.append(EOL + "Get Light State : " + mState + EOL);
+                } else {
+                    mResultLog.append(EOL + "Payload Size : " + mLargeData.length() + EOL);
+                }
+
+                mResultLog.append("Get Time : " + String.format("%.3f", flightTime) + "sec" + EOL);
+            }
+        });
+    }
+
+    @Override
+    public void onGetFailed(Throwable throwable) {
+        Log.e(TAG, "Get failed");
+    }
+
+    @Override
+    public void onPutCompleted(List<OcHeaderOption> list, OcRepresentation ocRepresentation) {
+        String repUri = ocRepresentation.getUri();
+        Log.i(TAG, "onPutCompleted : " + repUri);
+
+        try {
+            mState = ocRepresentation.getValue(Common.STATE_KEY);
+        } catch (OcException e) {
+            e.printStackTrace();
+        }
+
+        mActivity.runOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                mEndTime = System.currentTimeMillis();
+                double flightTime = (double) (mEndTime - mStartTime) / MILLI_PER_SEC;
+                mResultLog.append(EOL + "Set Light State : " + !mState + EOL + "Put Time : ");
+                mResultLog.append(String.format("%.3f", flightTime) + "sec" + EOL);
+            }
+        });
+    }
+
+    @Override
+    public void onPutFailed(Throwable throwable) {
+        Log.e(TAG, "Put failed");
+    }
+
+    // ******************************************************************************
+    // End of the OCF Client specific code
+    // ******************************************************************************
+
+    private void createResource() {
+        mEntityHandler = new OcPlatform.EntityHandler() {
+            @Override
+            public EntityHandlerResult handleEntity(
+                    OcResourceRequest ocResourceRequest) {
+                return mEntityHandler(ocResourceRequest);
+            }
+        };
+
+        try {
+            mResourceHandle = OcPlatform.registerResource(Common.RESOURCE_URI,
+                                 Common.RESOURCE_TYPE, Common.RESOURCE_INTERFACE,
+                                 mEntityHandler, Common.RESOURCE_PROPERTIES);
+
+        } catch (OcException e) {
+            String errString = "Error : " + e.getErrorCode().toString();
+            Log.e(TAG, errString);
+            StringWriter sw = new StringWriter();
+            e.printStackTrace(new PrintWriter(sw));
+            String exceptionAsString = sw.toString();
+            Log.e(TAG, exceptionAsString);
+            mResourceText.setText(errString);
+        }
+
+        StringBuilder sb = new StringBuilder();
+        for (int i = 0; i < Common.DATA_SIZE; i++) {
+            sb.append('j');
+        }
+        mLargeData = sb.toString();
+
+        sb.setLength(0);
+        sb.append("URI :   " + Common.RESOURCE_URI + EOL);
+        sb.append("Type :   " + Common.RESOURCE_TYPE + EOL);
+        sb.append("Interface :   " + Common.RESOURCE_INTERFACE + EOL);
+        sb.append("Properties :   " + Common.RESOURCE_PROPERTIES.toString() + EOL);
+        mResourceText.setText(sb.toString());
+        mActionLog.setText("");
+        mResultLog.setText("Created resource" + EOL);
+    }
+
+    protected EntityHandlerResult mEntityHandler(OcResourceRequest ocResourceRequest) {
+        EntityHandlerResult result = EntityHandlerResult.ERROR;
+        final StringBuilder sb = new StringBuilder();
+        switch (ocResourceRequest.getRequestType()) {
+            case GET:
+                sb.append("Type :   GET");
+                if (sendGetResponse(ocResourceRequest)) {
+                    result = EntityHandlerResult.OK;
+                }
+                break;
+            case PUT:
+                sb.append("Type :   PUT");
+                if (sendPutResponse(ocResourceRequest)) {
+                    result = EntityHandlerResult.OK;
+                }
+                break;
+            case DELETE:
+                sb.append("Type :   DELETE");
+                break;
+            case POST:
+                sb.append("Type :   POST");
+                break;
+            default:
+                break;
+        }
+        sb.append(EOL + "Light State :   " + mState);
+        sb.append(EOL + "Time :   " + Common.getDateCurrentTimeZone());
+        if (result == EntityHandlerResult.ERROR) {
+            sb.append(EOL + "!! Error occurred during sending the response !!");
+        }
+
+        mActivity.runOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                mResultLog.setText(sb.toString());
+            }
+        });
+
+        return result;
+    }
+
+    private boolean sendGetResponse(OcResourceRequest ocResourceRequest) {
+        mActivity.runOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                Common.showToast(mContext, "received get command, send response");
+            }
+        });
+
+        Map<String, String> queryParameters = ocResourceRequest.getQueryParameters();
+        final String command = queryParameters.get(Common.GET_COMMAND);
+
+        if (command == null
+                || (!command.equals(Common.STATE_GET) && !command.equals(Common.LARGE_GET))) {
+            return false;
+        }
+
+        OcRepresentation rep = new OcRepresentation();
+        try {
+            rep.setValue(Common.GET_COMMAND, command);
+            if (command.equals(Common.STATE_GET)) {
+                rep.setValue(Common.STATE_KEY, mState);
+            } else if (command.equals(Common.LARGE_GET)) {
+                rep.setValue(Common.LARGE_KEY, mLargeData);
+            }
+        } catch (OcException e) {
+            e.printStackTrace();
+        }
+
+        OcResourceResponse response = new OcResourceResponse();
+
+        response.setRequestHandle(ocResourceRequest.getRequestHandle());
+        response.setResourceHandle(ocResourceRequest.getResourceHandle());
+        response.setResourceRepresentation(rep);
+        try {
+            OcPlatform.sendResponse(response);
+            return true;
+        } catch (OcException e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    private boolean sendPutResponse(OcResourceRequest ocResourceRequest) {
+        mActivity.runOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                Common.showToast(mContext, "received put command, send response");
+            }
+        });
+
+        try {
+            OcRepresentation rep = ocResourceRequest.getResourceRepresentation();
+            if (rep.hasAttribute(Common.STATE_KEY)) {
+                mState = rep.getValue(Common.STATE_KEY);
+            }
+        } catch (OcException e) {
+            e.printStackTrace();
+        }
+
+        OcResourceResponse response = new OcResourceResponse();
+        OcRepresentation rep = new OcRepresentation();
+
+        response.setRequestHandle(ocResourceRequest.getRequestHandle());
+        response.setResourceHandle(ocResourceRequest.getResourceHandle());
+        response.setResourceRepresentation(rep);
+        try {
+            OcPlatform.sendResponse(response);
+            return true;
+        } catch (OcException e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    // ******************************************************************************
+    // End of the OCF Server specific code
+    // ******************************************************************************
+
+    private void initOcPlatform(ModeType type) {
+        PlatformConfig cfg = new PlatformConfig(mActivity, mContext,
+                                                ServiceType.IN_PROC,
+                                                type,
+                                                Common.IP_ADDRESS,
+                                                Common.IP_PORT,
+                                                mQos);
+        OcPlatform.Configure(cfg);
+    }
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+            Bundle savedInstanceState) {
+        View rootView = inflater.inflate(R.layout.fragment_message, container, false);
+
+        mServerLayout = (LinearLayout) rootView.findViewById(R.id.server_layout);
+        mClientLayout = (LinearLayout) rootView.findViewById(R.id.client_layout);
+
+        mResourceText = (TextView) rootView.findViewById(R.id.resource_view);
+        mActionLog = (TextView) rootView.findViewById(R.id.action_log_view);
+        mResultLog = (TextView) rootView.findViewById(R.id.result_log_view);
+
+        mDiscoverIPButton = (Button) rootView.findViewById(R.id.ip_button);
+        mDiscoverBTButton = (Button) rootView.findViewById(R.id.bt_button);
+        mDiscoverLEButton = (Button) rootView.findViewById(R.id.le_button);
+        mDiscoverTCPButton = (Button) rootView.findViewById(R.id.tcp_button);
+        mDiscoverNFCButton = (Button) rootView.findViewById(R.id.nfc_button);
+
+        mRegisterButton = (Button) rootView.findViewById(R.id.register_button);
+        mGetButton = (Button) rootView.findViewById(R.id.get_button);
+        mPutButton = (Button) rootView.findViewById(R.id.put_button);
+        mLargeButton = (Button) rootView.findViewById(R.id.large_button);
+
+        mQosToggle = (ToggleButton) rootView.findViewById(R.id.qos_toggle_button);
+
+        mDiscoverIPButton.setOnClickListener(
+                discoverButtonListener(OcConnectivityType.CT_ADAPTER_IP));
+        mDiscoverBTButton.setOnClickListener(
+                discoverButtonListener(OcConnectivityType.CT_ADAPTER_RFCOMM_BTEDR));
+        mDiscoverLEButton.setOnClickListener(
+                discoverButtonListener(OcConnectivityType.CT_ADAPTER_GATT_BTLE));
+        mDiscoverTCPButton.setOnClickListener(
+                discoverButtonListener(OcConnectivityType.CT_ADAPTER_TCP));
+        mDiscoverNFCButton.setOnClickListener(
+                discoverButtonListener(OcConnectivityType.CT_ADAPTER_NFC));
+
+        mRegisterButton.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                if (mResourceHandle == null) {
+                    initOcPlatform(ModeType.SERVER);
+                    createResource();
+                    mClientLayout.setVisibility(View.GONE);
+                } else {
+                    Common.showToast(mContext, "Already created resource");
+                }
+            }
+        });
+        mGetButton.setOnClickListener(getButtonListener());
+        mPutButton.setOnClickListener(putButtonListener());
+        mLargeButton.setOnClickListener(getLargeListener());
+
+        mQosToggle
+                .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+                    @Override
+                    public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
+                        if (b) {
+                            mQos = QualityOfService.HIGH;
+                        } else {
+                            mQos = QualityOfService.LOW;
+                        }
+                    }
+                });
+
+        return rootView;
+    }
+
+    private void showTCPInput() {
+
+        LayoutInflater layoutInflater = LayoutInflater.from(mContext);
+        View inputView = layoutInflater.inflate(R.layout.tcp_input, null);
+        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mActivity);
+        alertDialogBuilder.setView(inputView);
+
+        final EditText editText = (EditText) inputView.getRootView().findViewById(R.id.ipText);
+        editText.setText(Common.TCP_ADDRESS);
+        alertDialogBuilder
+                .setCancelable(false)
+                .setPositiveButton("OK", new DialogInterface.OnClickListener() {
+                    public void onClick(DialogInterface dialog, int id) {
+                        if (editText.getText().length() != 0) {
+                            Common.TCP_ADDRESS = editText.getText().toString();
+
+                            StringBuilder sb = new StringBuilder();
+                            sb.append(Common.COAP_TCP);
+                            sb.append(Common.TCP_ADDRESS);
+                            sb.append(Common.TCP_PORT);
+                            makeTCPResource(sb.toString());
+                        }
+                    }
+                })
+                .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
+                    public void onClick(DialogInterface dialog, int id) {
+                        dialog.cancel();
+                    }
+                });
+
+        AlertDialog alert = alertDialogBuilder.create();
+        alert.show();
+    }
+
+    @Override
+    public void onResume() {
+        super.onResume();
+    }
+
+    @Override
+    public void onDestroy() {
+        super.onDestroy();
+    }
+}
diff --git a/android/examples/simplebase/src/main/java/org/iotivity/base/examples/SimpleBase.java b/android/examples/simplebase/src/main/java/org/iotivity/base/examples/SimpleBase.java
new file mode 100644 (file)
index 0000000..b6ae56b
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * ******************************************************************
+ *
+ * Copyright 2016 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.base.examples;
+
+import android.app.Activity;
+import android.app.Fragment;
+import android.content.Intent;
+import android.nfc.NfcAdapter;
+import android.os.Bundle;
+import android.support.v4.widget.DrawerLayout;
+import android.util.Log;
+
+/**
+ * SimpleBase is a sample OCF Base layer application.
+ * It can handle message and bluetooth manually.
+ */
+public class SimpleBase extends Activity implements DrawerFragment.DrawerCallbacks {
+
+    private static final String TAG = "OIC_SIMPLE_BASE";
+    private DrawerFragment      mDrawerFragment;
+
+    private CharSequence        mTitle;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_simplebase);
+
+        mDrawerFragment = (DrawerFragment) getFragmentManager()
+                .findFragmentById(R.id.navigation_drawer);
+        mTitle = getTitle();
+
+        mDrawerFragment.setUp(R.id.navigation_drawer,
+                (DrawerLayout) findViewById(R.id.drawer_layout));
+    }
+
+    @Override
+    public void onDrawerItemSelected(int position) {
+        Fragment fragment;
+        switch (position) {
+            case 0:
+                mTitle = getString(R.string.title_message);
+                fragment = new MessageFragment();
+                break;
+            case 1:
+                mTitle = getString(R.string.title_bluetooth);
+                fragment = new BluetoothFragment();
+                break;
+            case 2:
+                mTitle = getString(R.string.title_template);
+                fragment = new TemplateFragment();
+                break;
+            default:
+                mTitle = getString(R.string.title_message);
+                fragment = new MessageFragment();
+                break;
+        }
+        getFragmentManager().beginTransaction()
+                            .replace(R.id.container, fragment)
+                            .commit();
+
+        getActionBar().setTitle(mTitle);
+    }
+
+    @Override
+    public void onNewIntent(Intent intent) {
+        super.onNewIntent(intent);
+        Log.d(TAG, "onNewIntent with changes sending broadcast IN ");
+
+        Intent i = new Intent();
+        i.setAction(intent.getAction());
+        i.putExtra(NfcAdapter.EXTRA_NDEF_MESSAGES,
+                intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES));
+        sendBroadcast(i);
+        Log.d(TAG, "Initialize Context again resetting");
+    }
+}
diff --git a/android/examples/simplebase/src/main/java/org/iotivity/base/examples/TemplateFragment.java b/android/examples/simplebase/src/main/java/org/iotivity/base/examples/TemplateFragment.java
new file mode 100644 (file)
index 0000000..3f8b122
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * ******************************************************************
+ *
+ * Copyright 2016 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.base.examples;
+
+import android.app.Activity;
+import android.app.Fragment;
+import android.content.Context;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+
+/**
+ * This class the template for the test.
+ */
+public class TemplateFragment extends Fragment implements View.OnClickListener {
+
+    private Activity mActivity;
+    private Context  mContext;
+
+    Button           buttonA;
+    Button           buttonB;
+    Button           buttonC;
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+                             Bundle savedInstanceState) {
+        View rootView = inflater.inflate(R.layout.fragment_template, container, false);
+
+        buttonA = (Button) rootView.findViewById(R.id.btn_A);
+        buttonB = (Button) rootView.findViewById(R.id.btn_B);
+        buttonC = (Button) rootView.findViewById(R.id.btn_C);
+
+        buttonA.setOnClickListener(this);
+        buttonB.setOnClickListener(this);
+        buttonC.setOnClickListener(this);
+
+        return rootView;
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        mActivity = getActivity();
+        mContext = mActivity.getBaseContext();
+    }
+
+    @Override
+    public void onResume() {
+        super.onResume();
+    }
+
+    @Override
+    public void onPause() {
+        super.onPause();
+    }
+
+    @Override
+    public void onDestroy() {
+        super.onDestroy();
+    }
+
+    @Override
+    public void onClick(View view) {
+        StringBuilder sb = new StringBuilder(getString(R.string.action_onclick));
+        switch (view.getId()) {
+            case R.id.btn_A:
+                sb.append(getString(R.string.button_A));
+                break;
+            case R.id.btn_B:
+                sb.append(getString(R.string.button_B));
+                break;
+            case R.id.btn_C:
+                sb.append(getString(R.string.button_C));
+                break;
+        }
+        Common.showToast(mContext, sb.toString());
+    }
+}
\ No newline at end of file
diff --git a/android/examples/simplebase/src/main/res/drawable-hdpi/drawer_shadow.9.png b/android/examples/simplebase/src/main/res/drawable-hdpi/drawer_shadow.9.png
new file mode 100644 (file)
index 0000000..236bff5
Binary files /dev/null and b/android/examples/simplebase/src/main/res/drawable-hdpi/drawer_shadow.9.png differ
diff --git a/android/examples/simplebase/src/main/res/drawable-hdpi/ic_drawer.png b/android/examples/simplebase/src/main/res/drawable-hdpi/ic_drawer.png
new file mode 100644 (file)
index 0000000..c59f601
Binary files /dev/null and b/android/examples/simplebase/src/main/res/drawable-hdpi/ic_drawer.png differ
diff --git a/android/examples/simplebase/src/main/res/drawable-mdpi/drawer_shadow.9.png b/android/examples/simplebase/src/main/res/drawable-mdpi/drawer_shadow.9.png
new file mode 100644 (file)
index 0000000..ffe3a28
Binary files /dev/null and b/android/examples/simplebase/src/main/res/drawable-mdpi/drawer_shadow.9.png differ
diff --git a/android/examples/simplebase/src/main/res/drawable-mdpi/ic_drawer.png b/android/examples/simplebase/src/main/res/drawable-mdpi/ic_drawer.png
new file mode 100644 (file)
index 0000000..1ed2c56
Binary files /dev/null and b/android/examples/simplebase/src/main/res/drawable-mdpi/ic_drawer.png differ
diff --git a/android/examples/simplebase/src/main/res/drawable-xhdpi/drawer_shadow.9.png b/android/examples/simplebase/src/main/res/drawable-xhdpi/drawer_shadow.9.png
new file mode 100644 (file)
index 0000000..fabe9d9
Binary files /dev/null and b/android/examples/simplebase/src/main/res/drawable-xhdpi/drawer_shadow.9.png differ
diff --git a/android/examples/simplebase/src/main/res/drawable-xhdpi/ic_drawer.png b/android/examples/simplebase/src/main/res/drawable-xhdpi/ic_drawer.png
new file mode 100644 (file)
index 0000000..a5fa74d
Binary files /dev/null and b/android/examples/simplebase/src/main/res/drawable-xhdpi/ic_drawer.png differ
diff --git a/android/examples/simplebase/src/main/res/drawable-xxhdpi/drawer_shadow.9.png b/android/examples/simplebase/src/main/res/drawable-xxhdpi/drawer_shadow.9.png
new file mode 100644 (file)
index 0000000..b91e9d7
Binary files /dev/null and b/android/examples/simplebase/src/main/res/drawable-xxhdpi/drawer_shadow.9.png differ
diff --git a/android/examples/simplebase/src/main/res/drawable-xxhdpi/ic_drawer.png b/android/examples/simplebase/src/main/res/drawable-xxhdpi/ic_drawer.png
new file mode 100644 (file)
index 0000000..9c4685d
Binary files /dev/null and b/android/examples/simplebase/src/main/res/drawable-xxhdpi/ic_drawer.png differ
diff --git a/android/examples/simplebase/src/main/res/drawable/iotivityicon.png b/android/examples/simplebase/src/main/res/drawable/iotivityicon.png
new file mode 100644 (file)
index 0000000..e1e4aa7
Binary files /dev/null and b/android/examples/simplebase/src/main/res/drawable/iotivityicon.png differ
diff --git a/android/examples/simplebase/src/main/res/drawable/iotivitylogo.png b/android/examples/simplebase/src/main/res/drawable/iotivitylogo.png
new file mode 100644 (file)
index 0000000..a7d3115
Binary files /dev/null and b/android/examples/simplebase/src/main/res/drawable/iotivitylogo.png differ
diff --git a/android/examples/simplebase/src/main/res/layout/activity_simplebase.xml b/android/examples/simplebase/src/main/res/layout/activity_simplebase.xml
new file mode 100644 (file)
index 0000000..03bf88b
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/drawer_layout"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context=".SimpleBase" >
+
+    <FrameLayout
+        android:id="@+id/container"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent" />
+
+    <fragment
+        android:id="@+id/navigation_drawer"
+        android:name="org.iotivity.base.examples.DrawerFragment"
+        android:layout_width="@dimen/navigation_drawer_width"
+        android:layout_height="match_parent"
+        android:layout_gravity="start"
+        tools:layout="@layout/fragment_drawer" />
+
+</android.support.v4.widget.DrawerLayout>
\ No newline at end of file
diff --git a/android/examples/simplebase/src/main/res/layout/fragment_bluetooth.xml b/android/examples/simplebase/src/main/res/layout/fragment_bluetooth.xml
new file mode 100644 (file)
index 0000000..765c2b8
--- /dev/null
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:paddingBottom="@dimen/activity_vertical_margin"
+    android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:paddingTop="@dimen/activity_vertical_margin"
+    tools:context=".BluetoothFragment" >
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:orientation="vertical" >
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_horizontal"
+            android:gravity="center_horizontal"
+            android:orientation="horizontal" >
+
+            <Button
+                android:id="@+id/btn_bt"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center_horizontal"
+                android:layout_marginTop="10dp"
+                android:layout_weight="1"
+                android:text="@string/bt_scan" />
+
+            <Button
+                android:id="@+id/btn_le"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center_horizontal"
+                android:layout_marginTop="10dp"
+                android:layout_weight="1"
+                android:text="@string/le_scan" />
+        </LinearLayout>
+
+        <ListView
+            android:id="@+id/list_view"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:choiceMode="singleChoice"
+            android:divider="#cfcfcf"
+            android:dividerHeight="1.5dp" />
+    </LinearLayout>
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/android/examples/simplebase/src/main/res/layout/fragment_drawer.xml b/android/examples/simplebase/src/main/res/layout/fragment_drawer.xml
new file mode 100644 (file)
index 0000000..a4afe63
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ListView xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="#cccc"
+    android:choiceMode="singleChoice"
+    android:divider="@android:color/transparent"
+    android:dividerHeight="0dp"
+    tools:context=".DrawerFragment" />
\ No newline at end of file
diff --git a/android/examples/simplebase/src/main/res/layout/fragment_message.xml b/android/examples/simplebase/src/main/res/layout/fragment_message.xml
new file mode 100644 (file)
index 0000000..e2f1830
--- /dev/null
@@ -0,0 +1,220 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical"
+    android:paddingBottom="@dimen/activity_vertical_margin"
+    android:paddingLeft="0dp"
+    android:paddingRight="0dp"
+    android:paddingTop="@dimen/activity_vertical_margin"
+    tools:context=".MessageFragment" >
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:orientation="vertical" >
+
+        <LinearLayout
+            android:id="@+id/server_layout"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_horizontal"
+            android:focusable="true"
+            android:focusableInTouchMode="true"
+            android:gravity="center_horizontal"
+            android:orientation="vertical" >
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:background="#AAAAAA"
+                android:gravity="center_vertical"
+                android:paddingLeft="10dp"
+                android:text="Resource Server Information"
+                android:textColor="#FFFFFF"
+                android:textSize="14sp" />
+
+            <TextView
+                android:id="@+id/resource_view"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:paddingBottom="20dp"
+                android:paddingLeft="20dp"
+                android:paddingTop="5dp"
+                android:text="@string/resource_view" />
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:background="#AAAAAA"
+                android:gravity="center_vertical"
+                android:paddingLeft="10dp"
+                android:text="Server Buttons"
+                android:textColor="#FFFFFF"
+                android:textSize="14sp" />
+
+            <Button
+                android:id="@+id/register_button"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center_horizontal"
+                android:layout_marginLeft="6dp"
+                android:layout_marginTop="10dp"
+                android:text="Register Resource" />
+        </LinearLayout>
+
+        <LinearLayout
+            android:id="@+id/client_layout"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_horizontal"
+            android:focusable="true"
+            android:focusableInTouchMode="true"
+            android:gravity="center_horizontal"
+            android:orientation="vertical" >
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:background="#AAAAAA"
+                android:gravity="center_vertical"
+                android:paddingLeft="10dp"
+                android:text="Client Buttons"
+                android:textColor="#FFFFFF"
+                android:textSize="14sp" />
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center_horizontal"
+                android:layout_marginTop="10dp"
+                android:gravity="center_horizontal"
+                android:orientation="horizontal" >
+
+                <Button
+                    android:id="@+id/ip_button"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="center_horizontal"
+                    android:layout_weight="1"
+                    android:text="IP" />
+
+                <Button
+                    android:id="@+id/bt_button"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="center_horizontal"
+                    android:layout_weight="1"
+                    android:text="BT" />
+
+                <Button
+                    android:id="@+id/le_button"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="center_horizontal"
+                    android:layout_weight="1"
+                    android:text="LE" />
+
+                <Button
+                    android:id="@+id/tcp_button"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="center_horizontal"
+                    android:layout_weight="1"
+                    android:text="TCP/IP" />
+
+                <Button
+                    android:id="@+id/nfc_button"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="center_horizontal"
+                    android:layout_weight="1"
+                    android:text="NFC" />
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center_horizontal"
+                android:layout_marginBottom="10dp"
+                android:gravity="center_horizontal"
+                android:orientation="horizontal" >
+
+                <Button
+                    android:id="@+id/get_button"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="center"
+                    android:text="Get()" />
+
+                <Button
+                    android:id="@+id/put_button"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="center"
+                    android:text="Put()" />
+
+                <Button
+                    android:id="@+id/large_button"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="center"
+                    android:text="Large()" />
+
+                <TextView
+                    android:id="@+id/textView"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="center"
+                    android:layout_marginLeft="10dp"
+                    android:text="QoS:"
+                    android:textAppearance="?android:attr/textAppearanceSmall" />
+
+                <ToggleButton
+                    android:id="@+id/qos_toggle_button"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="center"
+                    android:checked="false"
+                    android:text="QoS Toggle Button"
+                    android:textOff="NON"
+                    android:textOn="CON"
+                    android:textSize="12sp" />
+            </LinearLayout>
+        </LinearLayout>
+
+        <TextView
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:background="#AAAAAA"
+            android:gravity="center_vertical"
+            android:paddingLeft="10dp"
+            android:text="Log"
+            android:textColor="#FFFFFF"
+            android:textSize="14sp" />
+
+        <TextView
+            android:id="@+id/action_log_view"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:paddingBottom="5dp"
+            android:paddingLeft="20dp"
+            android:paddingTop="5dp"
+            android:text="@string/action_log_view" />
+
+        <ScrollView
+            android:layout_width="fill_parent"
+            android:layout_height="fill_parent" >
+
+            <TextView
+                android:id="@+id/result_log_view"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:paddingLeft="20dp"
+                android:paddingTop="5dp"
+                android:text="@string/result_log_view" />
+        </ScrollView>
+    </LinearLayout>
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/android/examples/simplebase/src/main/res/layout/fragment_template.xml b/android/examples/simplebase/src/main/res/layout/fragment_template.xml
new file mode 100644 (file)
index 0000000..45159e5
--- /dev/null
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:paddingBottom="@dimen/activity_vertical_margin"
+    android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:paddingTop="@dimen/activity_vertical_margin"
+    tools:context=".TemplateFragment" >
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:orientation="vertical" >
+
+        <Button
+            android:id="@+id/btn_A"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_horizontal"
+            android:layout_marginTop="10dp"
+            android:text="@string/button_A" />
+
+        <Button
+            android:id="@+id/btn_B"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_horizontal"
+            android:layout_marginTop="10dp"
+            android:text="@string/button_B" />
+
+        <Button
+            android:id="@+id/btn_C"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_horizontal"
+            android:layout_marginTop="10dp"
+            android:text="@string/button_C" />
+    </LinearLayout>
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/android/examples/simplebase/src/main/res/layout/tcp_input.xml b/android/examples/simplebase/src/main/res/layout/tcp_input.xml
new file mode 100755 (executable)
index 0000000..056a347
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical"
+    android:padding="@dimen/activity_vertical_margin" >
+
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="Input Server IP"
+        android:textAppearance="?android:attr/textAppearanceMedium" />
+
+    <EditText
+        android:id="@+id/ipText"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:padding="@dimen/activity_vertical_margin" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/android/examples/simplebase/src/main/res/mipmap-hdpi/iotivityicon.png b/android/examples/simplebase/src/main/res/mipmap-hdpi/iotivityicon.png
new file mode 100644 (file)
index 0000000..e1e4aa7
Binary files /dev/null and b/android/examples/simplebase/src/main/res/mipmap-hdpi/iotivityicon.png differ
diff --git a/android/examples/simplebase/src/main/res/mipmap-mdpi/iotivityicon.png b/android/examples/simplebase/src/main/res/mipmap-mdpi/iotivityicon.png
new file mode 100644 (file)
index 0000000..2e7bce6
Binary files /dev/null and b/android/examples/simplebase/src/main/res/mipmap-mdpi/iotivityicon.png differ
diff --git a/android/examples/simplebase/src/main/res/mipmap-xhdpi/iotivityicon.png b/android/examples/simplebase/src/main/res/mipmap-xhdpi/iotivityicon.png
new file mode 100644 (file)
index 0000000..afa486b
Binary files /dev/null and b/android/examples/simplebase/src/main/res/mipmap-xhdpi/iotivityicon.png differ
diff --git a/android/examples/simplebase/src/main/res/mipmap-xxhdpi/iotivityicon.png b/android/examples/simplebase/src/main/res/mipmap-xxhdpi/iotivityicon.png
new file mode 100644 (file)
index 0000000..3e6bc6a
Binary files /dev/null and b/android/examples/simplebase/src/main/res/mipmap-xxhdpi/iotivityicon.png differ
diff --git a/android/examples/simplebase/src/main/res/values-v21/styles.xml b/android/examples/simplebase/src/main/res/values-v21/styles.xml
new file mode 100644 (file)
index 0000000..dba3c41
--- /dev/null
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <style name="AppTheme" parent="android:Theme.Material.Light">
+    </style>
+</resources>
diff --git a/android/examples/simplebase/src/main/res/values-w820dp/dimens.xml b/android/examples/simplebase/src/main/res/values-w820dp/dimens.xml
new file mode 100644 (file)
index 0000000..63fc816
--- /dev/null
@@ -0,0 +1,6 @@
+<resources>
+    <!-- Example customization of dimensions originally defined in res/values/dimens.xml
+         (such as screen margins) for screens with more than 820dp of available width. This
+         would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
+    <dimen name="activity_horizontal_margin">64dp</dimen>
+</resources>
diff --git a/android/examples/simplebase/src/main/res/values/dimens.xml b/android/examples/simplebase/src/main/res/values/dimens.xml
new file mode 100644 (file)
index 0000000..406d795
--- /dev/null
@@ -0,0 +1,7 @@
+<resources>
+    <!-- Default screen margins, per the Android Design guidelines. -->
+    <dimen name="activity_horizontal_margin">16dp</dimen>
+    <dimen name="activity_vertical_margin">16dp</dimen>
+
+    <dimen name="navigation_drawer_width">240dp</dimen>
+</resources>
diff --git a/android/examples/simplebase/src/main/res/values/strings.xml b/android/examples/simplebase/src/main/res/values/strings.xml
new file mode 100644 (file)
index 0000000..9a9ac7f
--- /dev/null
@@ -0,0 +1,26 @@
+<resources>
+    <string name="app_name">Simple Base</string>
+
+    <string name="title_message">Message</string>
+    <string name="title_bluetooth">Bluetooth</string>
+    <string name="title_template">Template</string>
+
+    <string name="resource_view">[Resource View]</string>
+    <string name="action_log_view">[Action Log View]</string>
+    <string name="result_log_view">[Result Log View]</string>
+
+    <string name="bt_scan">BT SCAN</string>
+    <string name="le_scan">LE SCAN</string>
+    <string name="stop_scan">STOP SCAN</string>
+
+    <string name="action_onadapterstatechanged">onAdapterStateChanged : </string>
+    <string name="action_onconnectionstatechanged">onConnectionStateChanged : </string>
+    <string name="action_onclick">onClick : </string>
+
+    <string name="button_A">Button A</string>
+    <string name="button_B">Button B</string>
+    <string name="button_C">Button C</string>
+
+    <string name="navigation_drawer_open">Open navigation drawer</string>
+    <string name="navigation_drawer_close">Close navigation drawer</string>
+</resources>
diff --git a/android/examples/simplebase/src/main/res/values/styles.xml b/android/examples/simplebase/src/main/res/values/styles.xml
new file mode 100644 (file)
index 0000000..ff6c9d2
--- /dev/null
@@ -0,0 +1,8 @@
+<resources>
+
+    <!-- Base application theme. -->
+    <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
+        <!-- Customize your theme here. -->
+    </style>
+
+</resources>
index 651d6a5..d40c196 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
 
index a9d06a2..5eafe56 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
 
index e9b1fb4..23ee5db 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
 
@@ -380,4 +380,4 @@ public class Light implements OcPlatform.EntityHandler {
     private boolean mIsListOfObservers = false;
     private Thread mObserverNotifier;
     private Context mContext;
-}
\ No newline at end of file
+}
index 707e1a1..1571ef7 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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;
index a9d6925..5a0e32b 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.accountserver;
 
index b2b29a8..5749a7a 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.accountserver;
 
index 2d8ab4f..c350789 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.accountserver;
 
index 8569753..dbb0e20 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.accountserver.db;
 
index 049a3f3..191d17a 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.accountserver.db;
 
index b0cc3c6..f42bc7c 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.accountserver.db;
 
@@ -47,4 +47,4 @@ public class UserDevice {
     public String getDeviceId() {
         return this.deviceId;
     }
-}
\ No newline at end of file
+}
index f254dcc..96f6d39 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.accountserver.db;
 
@@ -47,4 +47,4 @@ public class UserSession {
     public String getSessionCode() {
         return this.sessionCode;
     }
-}
\ No newline at end of file
+}
index e682257..8e00566 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.accountserver.oauth;
 
index a6f3efc..c3c6cc7 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.accountserver.oauth;
 
index bde32bf..72f9226 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.accountserver.resources;
 
index a88bcf8..71448e4 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.accountserver.resources;
 
index 4a506e8..4871641 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.accountserver.resources;
 
index 47cbe58..30029dc 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.accountserver.util;
 
index ca6aa00..a165393 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.ciserver;
 
index 918fab8..164c9e8 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.ciserver;
 
index 97c6051..533811e 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.ciserver.protocols;
 
index c809850..804bf81 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.ciserver.resources;
 
index 9aa54b0..4e14fb6 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.rdserver;
 
index 890e116..889b9ce 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.rdserver;
 
index 8f58000..c420525 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.rdserver;
 
index 0f6a6c5..7a173d3 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.rdserver.resources;
 
@@ -144,4 +144,4 @@ public class LinksPayloadFormat {
     public void setMt(ArrayList<String> mt) {
         this.mt = mt;
     }
-}
\ No newline at end of file
+}
index 1fe0191..e7b3140 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.rdserver.resources;
 
index 09d3471..ce96b64 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.rdserver.resources;
 
index bf8ada3..5295d35 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.testrdserver;
 
index d038565..0cf6142 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.base;
 
index 9274f1e..849701d 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.base;
 
index add75a4..e71fb19 100644 (file)
@@ -1,16 +1,23 @@
 /*
- * //****************************************************************** // //
- * Copyright 2016 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. //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.base;
 //
index 3f4498f..55b5ab8 100644 (file)
@@ -1,16 +1,23 @@
 /*
- * //****************************************************************** // //
- * Copyright 2016 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. //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.base;
 //
index cdf249c..9683bff 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.base;
 
index 0ca806f..c2700df 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.base;
 
index ca371f7..9b795c3 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.base;
 
index 46d618f..283d214 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.base.protocols.coap;
 
index 2aee0dd..654ce1a 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.base.protocols.coap;
 
index fb77b06..e1db80c 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.base.protocols.coap;
 
index 3a1f013..4f80e4e 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.base.protocols.coap;
 
@@ -117,4 +117,4 @@ public class CoapRequest extends CoapMessage {
             uri_path.clear();
         }
     }
-}
\ No newline at end of file
+}
index d4b07cb..8d970d6 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.base.protocols.coap;
 
index 2ac4109..bdc1282 100644 (file)
@@ -1,16 +1,23 @@
 /*
- * //****************************************************************** // //
- * Copyright 2016 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. //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.base.protocols.proxy;
 //
index 565cfe9..9fdfc74 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.util;
 
@@ -60,4 +60,4 @@ public class Cbor<T> {
         }
         return cborData;
     }
-}
\ No newline at end of file
+}
index f12a807..56633a0 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.util;
 
index 3f7e061..2e99157 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.util;
 
index fce3f51..f34816b 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.util;
 
index 4003cfe..6aa7b6f 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.base;
 
index f2162ec..3e9876a 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2016 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 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.cloud.base;
 
index 8c1152d..e8ed300 100644 (file)
@@ -49,8 +49,13 @@ if target_os not in ['windows', 'winrt']:
                examples_env.AppendUnique(LIBS = ['-lpthread'])
 
 examples_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-examples_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'connectivity_abstraction',
-        'coap', 'rt'])
+examples_env.PrependUnique(LIBS = ['coap'])
+examples_env.AppendUnique(LIBS = ['connectivity_abstraction'])
+examples_env.AppendUnique(LIBS = ['oc_logger'])
+examples_env.AppendUnique(LIBS = ['octbstack'])
+examples_env.AppendUnique(LIBS = ['oc'])
+examples_env.AppendUnique(LIBS = ['rt'])
+
 if env.get('SECURED') == '1':
     examples_env.AppendUnique(LIBS = ['tinydtls'])
 
index ab12e21..2e7acb5 100644 (file)
@@ -1,13 +1,13 @@
 #Set the two variables below for the client build.
-CLIENTARCH=x86
-BUILDTYPE=release
+CLIENTARCH?=x86
+BUILDTYPE?=release
 ##
 
 YOCTOCXXFLAGS=-I$(SDKTARGETSYSROOT)/usr/include/iotivity/resource/ -I$(SDKTARGETSYSROOT)/usr/include/iotivity/resource/stack -I$(SDKTARGETSYSROOT)/usr/include/iotivity/resource/ocrandom -I$(SDKTARGETSYSROOT)/usr/include/iotivity/resource/logger -I$(SDKTARGETSYSROOT)/usr/include/iotivity/resource/oc_logger
 
 YOCTOLDFLAGS=-loc -loctbstack -loc_logger -lmraa
 
-CXXFLAGS=-I../../resource/include -I../../resource/csdk/stack/include -I../../resource/c_common/ocrandom/include -I../../resource/csdk/logger/include -I../../resource/oc_logger/include
+CXXFLAGS=-I../../resource/include -I../../resource/c_common -I../../resource/csdk/stack/include -I../../resource/c_common/ocrandom/include -I../../resource/csdk/logger/include -I../../resource/oc_logger/include
 
 LDFLAGS=-L../../out/linux/$(CLIENTARCH)/$(BUILDTYPE) -loc -loctbstack -loc_logger
 
index 5686d19..43043a6 100755 (executable)
@@ -242,6 +242,7 @@ void checkTimeout()
 
 void *loop(void *threadid)
 {
+    (void)threadid;
     while (1)
     {
         sleep(SECOND);
index 901a94c..5d186a2 100644 (file)
@@ -33,13 +33,15 @@ if(target_os) == 'arduino':
 root_dir = './'
 tinydtls_src_path = root_dir
 
-env.AppendUnique(CPPPATH = [root_dir])
-env.AppendUnique(CPPPATH = [root_dir+'aes/'])
-env.AppendUnique(CPPPATH = [root_dir+'ecc/'])
-env.AppendUnique(CPPPATH = [root_dir+'sha2/'])
+dtls_env = env.Clone()
+
+dtls_env.PrependUnique(CPPPATH = [root_dir])
+dtls_env.AppendUnique(CPPPATH = [root_dir+'aes/'])
+dtls_env.AppendUnique(CPPPATH = [root_dir+'ecc/'])
+dtls_env.AppendUnique(CPPPATH = [root_dir+'sha2/'])
 
 if target_os not in ['arduino', 'windows', 'winrt']:
-       env.AppendUnique(CPPDEFINES = ['HAVE_SYS_TIME_H'])
+       dtls_env.AppendUnique(CPPDEFINES = ['HAVE_SYS_TIME_H'])
 
 ######################################################################
 # Source files and Target(s)
@@ -58,20 +60,18 @@ tinydtls_src = [
                 'sha2/sha2.c',
         ]
 
-env.AppendUnique(TINYDTLS_SRC = tinydtls_src)
-
-if not env.get('RELEASE'):
+if not dtls_env.get('RELEASE'):
        if(target_os) not in ['arduino']:
-               env.AppendUnique(TINYDTLS_SRC = ['debug.c'])
+               tinydtls_src += ['debug.c']
        else:
-               env.AppendUnique(CPPDEFINES = ['NDEBUG'])
+               dtls_env.AppendUnique(CPPDEFINES = ['NDEBUG'])
 else:
-       env.AppendUnique(CPPDEFINES = ['NDEBUG'])
-
-env.AppendUnique(CPPDEFINES = ['DTLSV12',  'WITH_SHA256', 'DTLS_CHECK_CONTENTTYPE', 'SHA2_USE_INTTYPES_H'])
+       dtls_env.AppendUnique(CPPDEFINES = ['NDEBUG'])
 
+dtls_env.AppendUnique(CPPDEFINES = ['DTLSV12',  'WITH_SHA256', 'DTLS_CHECK_CONTENTTYPE', 'SHA2_USE_INTTYPES_H'])
+env.AppendUnique(CPPDEFINES = ['SHA2_USE_INTTYPES_H'])
 
-libtinydtls = env.StaticLibrary('libtinydtls', env.get('TINYDTLS_SRC'), OBJPREFIX='libtinydtls_')
+libtinydtls = dtls_env.StaticLibrary('tinydtls', tinydtls_src, OBJPREFIX='libtinydtls_')
 
 ######################################################################
 # Generate tinydtls samples
@@ -82,7 +82,7 @@ libtinydtls = env.StaticLibrary('libtinydtls', env.get('TINYDTLS_SRC'), OBJPREFI
 # IOT-395
 ######################################################################
 if not env.get('RELEASE'):
-       samples_env = env.Clone()
+       samples_env = dtls_env.Clone()
 
        if target_os not in ['arduino', 'windows', 'winrt']:
                samples_env.AppendUnique(CPPDEFINES = ['_GNU_SOURCE'])
@@ -97,5 +97,5 @@ if not env.get('RELEASE'):
 
        samples_env.AppendTarget('samples')
 
-env.InstallTarget(libtinydtls, 'libtinydtls');
+dtls_env.InstallTarget(libtinydtls, 'tinydtls');
 
index c781891..2c39b90 100644 (file)
@@ -199,7 +199,8 @@ OCPayload* getChangeBulbTempLevelPayload(uint32_t level)
     errno = 0;
     size_t sizeValue = sizeof(value);
     int strRet = snprintf(value, sizeValue, "%d", level);
-    if (strRet < 0 || (size_t)strRet >= sizeValue)
+
+    if (strRet < 0 || strRet >= (int)sizeValue)
     {
         OIC_LOG_V(ERROR, TAG, "Failed to parse string due to errno: %d", errno);
         exit(1);
index 3637717..b07bc95 100644 (file)
@@ -30,9 +30,8 @@ Import('env')
 target_os = env.get('TARGET_OS')
 src_dir = env.get('SRC_DIR')
 
-if target_os not in ['tizen']:
-       # Build liblogger
-       SConscript('csdk/logger/SConscript')
+# Build liblogger
+SConscript('csdk/logger/SConscript')
 
 if target_os not in ['arduino', 'darwin', 'ios', 'android']:
        env.AppendUnique(LIBS=['rt'])
index 8f39e19..3f712a3 100644 (file)
@@ -35,7 +35,7 @@
 #endif
 
 #if (__STDC_VERSION__ >= 201112L)
-    #include <stdassert.h>
+    #include <assert.h>
     #define OC_STATIC_ASSERT(condition, msg) static_assert(condition, msg)
 #else
     #define OC_STATIC_ASSERT(condition, msg) ((void)sizeof(char[2*!!(condition) - 1]))
index 37dc29b..a9ea0f9 100644 (file)
@@ -100,6 +100,8 @@ if target_os in ['darwin', 'ios']:
        liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
 if target_os not in ['arduino']:
        liboctbstack_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
+if target_os == 'android':
+    liboctbstack_env.AppendUnique(LINKFLAGS = ['-Wl,-soname,liboctbstack.so'])
 
 if env.get('SECURED') == '1':
        liboctbstack_env.AppendUnique(LIBS = ['tinydtls'])
index 893dc5c..d533f71 100644 (file)
@@ -62,7 +62,7 @@ else:
                env.AppendUnique(CPPDEFINES = ['NO_IP_ADAPTER'])
 
        if with_tcp == True:
-               if target_os in ['linux', 'tizen', 'android']:
+               if target_os in ['linux', 'tizen', 'android', 'arduino']:
                        env.AppendUnique(CPPDEFINES = ['TCP_ADAPTER', 'WITH_TCP'])
                        print "CA Transport is TCP"
                else:
@@ -82,19 +82,3 @@ else:
                env.AppendUnique(CPPDEFINES = ['NO_NFC_ADAPTER'])
 
 env.SConscript('./src/SConscript')
-
-if build_sample == 'ON':
-       if target_os in ['linux', 'arduino', 'darwin']:
-               target_path = target_os
-
-               if target_os == 'darwin':
-                       target_path = 'linux'
-               env.SConscript('./samples/' + target_path + '/SConscript')
-
-       elif target_os in ['android']:
-               env.SConscript('./samples/' + target_os + '/SConscript')
-
-               #to build sample apk, uncomment below line after ca libraries are built
-               #while building ca libraries comment the below line, to avoid build errors
-
-               #env.SConscript('./samples/' + target_os + '/casample/SConscript')
index 464f24b..aa36d61 100644 (file)
 #ifndef CA_COMMON_H_
 #define CA_COMMON_H_
 
+#ifndef WITH_ARDUINO
 #ifdef TCP_ADAPTER
 #define HAVE_SYS_POLL_H
 #endif
+#endif
 
 #include <stdint.h>
 #include <stdlib.h>
@@ -514,6 +516,8 @@ typedef struct
     struct tcpsockets
     {
         void *threadpool;       /**< threadpool between Initialize and Start */
+        CASocket_t ipv4;        /**< IPv4 accept socket */
+        CASocket_t ipv6;        /**< IPv6 accept socket */
         void *svrlist;          /**< unicast IPv4 TCP server information*/
         int selectTimeout;      /**< in seconds */
         int listenBacklog;      /**< backlog counts*/
@@ -523,6 +527,7 @@ typedef struct
         bool started;           /**< the TCP adapter has started */
         bool terminate;         /**< the TCP adapter needs to stop */
         bool ipv4tcpenabled;    /**< IPv4 TCP enabled by OCInit flags */
+        bool ipv6tcpenabled;    /**< IPv6 TCP enabled by OCInit flags */
     } tcp;
 #endif
 } CAGlobals_t;
index a253846..5d50d8d 100644 (file)
@@ -69,22 +69,14 @@ typedef struct
  * Callback function to pass the connection information from CA to RI.
  * @param[out]   object           remote device information.
  */
-typedef void (*CAKeepAliveConnectedCallback)(const CAEndpoint_t *object);
+typedef void (*CAKeepAliveConnectionCallback)(const CAEndpoint_t *object, bool isConnected);
 
 /**
- * Callback function to pass the disconnection information from CA to RI.
- * @param[out]   object           remote device information.
- */
-typedef void (*CAKeepAliveDisconnectedCallback)(const CAEndpoint_t *object);
-
-/**
- * Register connected callback and disconnected callback to process KeepAlive.
+ * Register connection status changes callback to process KeepAlive.
  * connection informations are delivered these callbacks.
- * @param[in]   ConnHandler     Connected callback.
- * @param[in]   DisconnHandler  Disconnected Callback.
+ * @param[in]   ConnHandler     Connection status changes callback.
  */
-void CARegisterKeepAliveHandler(CAKeepAliveConnectedCallback ConnHandler,
-                                CAKeepAliveDisconnectedCallback DisconnHandler);
+void CARegisterKeepAliveHandler(CAKeepAliveConnectionCallback ConnHandler);
 #endif
 /**
  * Initialize the connectivity abstraction module.
index 14c6f90..d7c12a6 100755 (executable)
@@ -58,6 +58,8 @@ cp -R ./extlibs/timer/ $sourcedir/tmp/con/extlibs/
 mkdir -p $sourcedir/tmp/con/c_common
 cp -R ./resource/c_common/* $sourcedir/tmp/con/c_common/
 cp -R ./resource/csdk/logger/include/* $sourcedir/tmp/con/common/inc/
+mkdir ./tmp/con/logger/
+cp -R ./resource/csdk/logger/* $sourcedir/tmp/con/logger
 
 # copy dependency RPMs and conf files for tizen build
 cp ./tools/tizen/*.rpm $sourcedir/tmp
index a06d5ee..aee4ce3 100644 (file)
@@ -52,3 +52,4 @@ else:
 env.SConscript(['../con/lib/libcoap-4.1.1/SConscript'])
 env.SConscript(['../con/SConscript'])
 env.SConscript(['../con/c_common/SConscript'])
+env.SConscript(['../con/logger/SConscript'])
\ No newline at end of file
index 29d42d8..5a1c00f 100644 (file)
@@ -64,16 +64,6 @@ ca_mutex ca_mutex_new(void);
 void ca_mutex_lock(ca_mutex mutex);
 
 /**
- * Checks if the mutex can be locked.
- *
- * @param  mutex  The mutex to be locked.
- *
- * @return  true if the mutex is not locked currently, otherwise false.
- *
- */
-bool ca_mutex_trylock(ca_mutex mutex);
-
-/**
  * Unlock the mutex.
  *
  * @param  mutex  The mutex to be unlocked.
index 2250cb3..d725980 100644 (file)
@@ -70,11 +70,6 @@ void ca_mutex_lock(ca_mutex mutex)
     return;
 }
 
-bool ca_mutex_trylock(ca_mutex mutex)
-{
-    return true;
-}
-
 void ca_mutex_unlock(ca_mutex mutex)
 {
     return;
index bc0dc28..834886c 100644 (file)
@@ -152,37 +152,6 @@ void ca_mutex_lock(ca_mutex mutex)
     }
 }
 
-bool ca_mutex_trylock(ca_mutex mutex)
-{
-    if (NULL == mutex)
-    {
-        OIC_LOG_V(ERROR, TAG, "%s Invalid mutex !", __func__);
-        return false;
-    }
-
-    bool bRet = false;
-
-    ca_mutex_internal *mutexInfo = (ca_mutex_internal*) mutex;
-
-    int result = pthread_mutex_trylock(&mutexInfo->mutex);
-
-    switch (result)
-    {
-        case 0:
-            // Success
-            bRet = true;
-            break;
-        case EINVAL:
-            OIC_LOG_V(ERROR, TAG, "%s: Invalid mutex !", __func__);
-            break;
-        case EBUSY:
-        default:
-            break;
-    }
-
-    return bRet;
-}
-
 void ca_mutex_unlock(ca_mutex mutex)
 {
     ca_mutex_internal *mutexInfo = (ca_mutex_internal*) mutex;
index 636036e..0fb57de 100644 (file)
@@ -109,10 +109,7 @@ CAResult_t ca_thread_pool_init(int32_t num_of_threads, ca_thread_pool_t *thread_
     if(!(*thread_pool)->details->list_lock)
     {
         OIC_LOG(ERROR, TAG, "Failed to create thread-pool mutex");
-        OICFree((*thread_pool)->details);
-        OICFree(*thread_pool);
-        *thread_pool = NULL;
-        return CA_STATUS_FAILED;
+        goto exit;
     }
 
     (*thread_pool)->details->threads_list = u_arraylist_create();
@@ -124,15 +121,17 @@ CAResult_t ca_thread_pool_init(int32_t num_of_threads, ca_thread_pool_t *thread_
         {
             OIC_LOG(ERROR, TAG, "Failed to free thread-pool mutex");
         }
-
-        OICFree((*thread_pool)->details);
-        OICFree(*thread_pool);
-        *thread_pool = NULL;
-        return CA_STATUS_FAILED;
+        goto exit;
     }
 
     OIC_LOG(DEBUG, TAG, "OUT");
     return CA_STATUS_OK;
+
+exit:
+    OICFree((*thread_pool)->details);
+    OICFree(*thread_pool);
+    *thread_pool = NULL;
+    return CA_STATUS_FAILED;
 }
 
 CAResult_t ca_thread_pool_add_task(ca_thread_pool_t thread_pool, ca_thread_func method,
index 8e029ad..144f383 100644 (file)
@@ -188,9 +188,13 @@ typedef void (*CANetworkPacketReceivedCallback)(const CASecureEndpoint_t *sep,
 
 /**
  * This will be used to notify network changes to the connectivity common logic layer.
- * @see SendUnicastData(), SendMulticastData()
  */
-typedef void (*CANetworkChangeCallback)(const CAEndpoint_t *info, CANetworkStatus_t status);
+typedef void (*CAAdapterChangeCallback)(CATransportAdapter_t adapter, CANetworkStatus_t status);
+
+/**
+ * This will be used to notify connection changes to the connectivity common logic layer.
+ */
+typedef void (*CAConnectionChangeCallback)(const CAEndpoint_t *info, bool isConnected);
 
 /**
  * This will be used to notify error result to the connectivity common logic layer.
index aec4ea7..cd3f102 100644 (file)
@@ -255,6 +255,18 @@ void CANativeSetActivity(JNIEnv *env, jobject activity);
 jobject *CANativeGetActivity();
 
 /**
+ * get method ID for method Name and class
+ * @param[in]   env              JNI interface pointer.
+ * @param[in]   className        android class.
+ * @param[in]   methodName       android method name.
+ * @param[in]   methodFormat     method type of methodName.
+ * @return      jmethodID        iD of the method.
+ */
+jmethodID CAGetJNIMethodID(JNIEnv *env, const char* className,
+                           const char* methodName,
+                           const char* methodFormat);
+
+/**
  * To Delete other Global References
  * Called during CATerminate to remove global references
  */
index b9ee8a7..51677e6 100644 (file)
 #include "uarraylist.h"
 #include "cacommon.h"
 #include "caprotocolmessage.h"
+#include "camessagehandler.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
 
 /**
  * Callback to send block data.
@@ -110,11 +116,6 @@ typedef enum
     CA_BLOCK_RECEIVED_ALREADY
 } CABlockState_t;
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
 /**
  * Initializes the block-wise transfer context.
  * @param[in]  CASendThreadFunc    function point to add data in send queue thread.
@@ -253,7 +254,7 @@ CAResult_t CASetNextBlockOption2(coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
  * @return ::CASTATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
  */
 CAResult_t CANegotiateBlockSize(CABlockData_t *currData, coap_block_t *block,
-                                coap_pdu_t *pdu, uint16_t blockType);
+                                const coap_pdu_t *pdu, uint16_t blockType);
 
 /**
  * Update the block option in block-wise transfer list.
@@ -550,12 +551,20 @@ CABlockData_t *CACreateNewBlockData(const CAData_t *sendData);
 CAResult_t CARemoveBlockDataFromList(const CABlockDataID_t *blockID);
 
 /**
- * Check if data exist in block-wise transfer list.
- * @param[in]   blockID     ID set of CABlockData.
- * @return true or false.
+ * Remove all block data in block-wise transfer list.
+ * @return ::CASTATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
  */
-bool CAIsBlockDataInList(const CABlockDataID_t *blockID);
+CAResult_t CARemoveAllBlockDataFromList();
 
+/**
+ * Find the block data with seed info and remove it from block-wise transfer list.
+ * @param[in]   token         token of the message.
+ * @param[in]   tokenLength   token length of the message.
+ * @param[in]   portNumber    port.
+ * @return ::CASTATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+ */
+CAResult_t CARemoveBlockDataFromListWithSeed(const CAToken_t token, uint8_t tokenLength,
+                                             uint16_t portNumber);
 
 #ifdef __cplusplus
 } /* extern "C" */
index 88794e3..bec17b7 100644 (file)
@@ -44,7 +44,9 @@ extern "C"
  *                                 Abstraction Layer.
  * @param[in]   reqRespCallback    Callback to notify request and response messages from
  *                                 server(s) started at Connectivity Abstraction Layer.
- * @param[in]   netCallback        Callback to notify the network additions to Connectivity
+ * @param[in]   netCallback        Callback to notify the adapter changes to Connectivity
+ *                                 Abstraction Layer.
+ * @param[in]   connCallback       Callback to notify the connection changes to Connectivity
  *                                 Abstraction Layer.
  * @param[in]   errorCallback      errorCallback to notify error to connectivity common logic
  *                                 layer from adapter.
@@ -52,8 +54,9 @@ extern "C"
  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
  */
 CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
-                           CANetworkPacketReceivedCallback reqRespCallback,
-                           CANetworkChangeCallback netCallback,
+                           CANetworkPacketReceivedCallback packetReceivedCallback,
+                           CAAdapterChangeCallback netCallback,
+                           CAConnectionChangeCallback connCallback,
                            CAErrorHandleCallback errorCallback, ca_thread_pool_t handle);
 
 /**
index f2422ae..f1cba26 100644 (file)
@@ -55,7 +55,7 @@ extern "C"
  */
 CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
                            CANetworkPacketReceivedCallback reqRespCallback,
-                           CANetworkChangeCallback netCallback);
+                           CAAdapterChangeCallback netCallback);
 
 /**
  * @brief  Starting EDR connectivity adapters. As its peer to peer it doesnot require to start
index a6ad4d5..b587218 100644 (file)
@@ -46,7 +46,7 @@
  * OIC Transport Profile GATT request characteristic user description
  * descriptor value.
  */
-#define CA_GATT_REQUEST_USER_DESCRIPTION "OIC Node Request"
+#define CA_GATT_REQUEST_USER_DESCRIPTION "OCF Node Request"
 
 /// OIC Transport Profile GATT response characteristic UUID.
 #define CA_GATT_RESPONSE_CHRC_UUID "E9241982-4580-42C4-8831-95048216B256"
@@ -55,7 +55,7 @@
  * OIC Transport Profile GATT response characteristic user description
  * descriptor value.
  */
-#define CA_GATT_RESPONSE_USER_DESCRIPTION "OIC Node Response"
+#define CA_GATT_RESPONSE_USER_DESCRIPTION "OCF Node Response"
 
 /**
  * Standard Bluetooth GATT client characteristic configuration
index 477674f..edf060f 100644 (file)
@@ -67,11 +67,12 @@ void CASetPacketReceivedCallback(CANetworkPacketReceivedCallback callback);
 void CASetErrorHandleCallback(CAErrorHandleCallback errorCallback);
 
 /**
- * Set the network status changed callback for message handler.
- * @param[in]   callback         message handler network status callback
- *                               to receive network changes.
+ * Set the network status changed callback for CAUtil.
+ * @param[in]   adapterCB       CAUtil callback to receive adapter status changes.
+ * @param[in]   connCB          CAUtil callback to receive connection status changes.
  */
-void CASetNetworkChangeCallback(CANetworkChangeCallback callback);
+void CASetNetworkMonitorCallbacks(CAAdapterChangeCallback adapterCB,
+                                  CAConnectionChangeCallback connCB);
 
 /**
  * Starting different connectivity adapters based on the network selection.
index b8234f9..6ab085e 100644 (file)
@@ -51,12 +51,12 @@ void CAInitializeAdapters();
 void CASetPacketReceivedCallback(CANetworkPacketReceivedCallback callback);
 
 /**
- * @brief   Set the network status changed callback for message handler
+ * @brief   Set the adapter status changed callback for message handler
  * @param   callback        [IN]    message handler network status callback to receive network
  *                                  changes.
  * @return   none
  */
-void CASetNetworkChangeCallback(CANetworkChangeCallback callback);
+void CASetNetworkChangeCallback(CAAdapterChangeCallback callback);
 
 /**
  * @brief   Set the error handler callback for message handler
index e7fa8c0..d4ec30a 100644 (file)
@@ -50,7 +50,7 @@ extern "C"
  */
 CAResult_t CAInitializeIP(CARegisterConnectivityCallback registerCallback,
                           CANetworkPacketReceivedCallback networkPacketCallback,
-                          CANetworkChangeCallback netCallback,
+                          CAAdapterChangeCallback netCallback,
                           CAErrorHandleCallback errorCallback, ca_thread_pool_t handle);
 
 /**
index 2caf5b1..1dc028f 100644 (file)
@@ -187,6 +187,30 @@ typedef struct
     uint32_t ipv4addr;        /**< used for IPv4 only. */
 } CAInterface_t;
 
+
+/**
+ * Callback to be notified when IP adapter connection state changes.
+ *
+ * @param[in]  adapter      Transport adapter.
+ * @param[in]  status       Connection status either ::CA_INTERFACE_UP or ::CA_INTERFACE_DOWN.
+ * @see CAIPSetConnectionStateChangeCallback() for registration.
+ */
+typedef void (*CAIPConnectionStateChangeCallback)(CATransportAdapter_t adapter, CANetworkStatus_t status);
+
+/**
+ * Set callback for receiving local IP adapter connection status.
+ *
+ * @param[in]  adapter      Callback to be notified when IP adapter connection state changes.
+ */
+void CAIPSetConnectionStateChangeCallback(CAIPConnectionStateChangeCallback callback);
+
+/**
+ * Set callback for receiving local IP adapter connection status.
+ *
+ * @param[in]  callback     Callback to be notified when IP adapter connection state changes.
+ */
+void CAIPSetNetworkMonitorCallback(CAIPConnectionStateChangeCallback callback);
+
 /**
  * Get a list of CAInterface_t items.
  *
@@ -195,14 +219,14 @@ typedef struct
 u_arraylist_t *CAIPGetInterfaceInformation(int desiredIndex);
 
 /**
- * @brief   Find a new network interface.
+ * Find a new network interface.
  *
  * @return  Description of interface (or NULL if no change)
  */
 CAInterface_t *CAFindInterfaceChange();
 
 /**
- * @brief   Let the network monitor update the polling interval.
+ * Let the network monitor update the polling interval.
  * @param   [in] current polling interval
  *
  * @return  desired polling interval
@@ -210,7 +234,7 @@ CAInterface_t *CAFindInterfaceChange();
 int CAGetPollingInterval(int interval);
 
 /**
- * @brief   Tell the IP server an interface has been added.
+ * Tell the IP server an interface has been added.
  */
 void CAWakeUpForChange();
 
@@ -229,7 +253,7 @@ CAResult_t CAIPStartNetworkMonitor();
 CAResult_t CAIPStopNetworkMonitor();
 
 /**
- * @brief  Set callback for error handling.
+ * Set callback for error handling.
  *
  * @param[in]  ipErrorCallback  callback to notify error to the ipadapter.
  */
index bf85d27..11a0b79 100644 (file)
@@ -40,7 +40,9 @@ extern "C"
  * @param[in]  reqRespCallback  Callback to notify request and response
  *                              messages from server(s) started at
  *                              Connectivity Abstraction Layer.
- * @param[in]  netCallback      Callback to notify the network additions
+ * @param[in]  netCallback      Callback to notify the adapter changes
+ *                              to Connectivity Abstraction Layer.
+ * @param[in]  connCallback     Callback to notify the connection changes
  *                              to Connectivity Abstraction Layer.
  * @param[in]  errorCallback    errorCallback to notify error to
  *                              connectivity common logic layer from adapter.
@@ -50,7 +52,8 @@ extern "C"
  */
 CAResult_t CAInitializeLE(CARegisterConnectivityCallback registerCallback,
                           CANetworkPacketReceivedCallback reqRespCallback,
-                          CANetworkChangeCallback netCallback,
+                          CAAdapterChangeCallback netCallback,
+                          CAConnectionChangeCallback connCallback,
                           CAErrorHandleCallback errorCallback,
                           ca_thread_pool_t handle);
 
index 3e8fb48..3083ab3 100644 (file)
@@ -49,7 +49,7 @@ extern "C"
  */\r
 CAResult_t CAInitializeNFC(CARegisterConnectivityCallback registerCallback,\r
                           CANetworkPacketReceivedCallback networkPacketCallback,\r
-                          CANetworkChangeCallback netCallback,\r
+                          CAAdapterChangeCallback netCallback,\r
                           CAErrorHandleCallback errorCallback, ca_thread_pool_t handle);\r
 \r
 /**\r
index 7dd0940..ed730f0 100644 (file)
@@ -51,7 +51,7 @@ extern "C"
  */
 CAResult_t CAInitializeRA(CARegisterConnectivityCallback registerCallback,
                           CANetworkPacketReceivedCallback networkPacketCallback,
-                          CANetworkChangeCallback netCallback,
+                          CAAdapterChangeCallback netCallback,
                           ca_thread_pool_t handle);
 
 
index 2528df1..9e9fde5 100644 (file)
@@ -29,6 +29,7 @@
 #include "caadapterinterface.h"
 #include "cathreadpool.h"
 #include "cainterface.h"
+#include "pdu.h"
 
 #ifdef __cplusplus
 extern "C"
@@ -54,7 +55,9 @@ typedef struct
  * @param[in] networkPacketCallback Callback to notify request and
  *                                  response messages from server(s)
  *                                  started at Connectivity Abstraction Layer.
- * @param[in] netCallback           Callback to notify the network additions
+ * @param[in] netCallback           Callback to notify the adapter changes
+ *                                  to Connectivity Abstraction Layer.
+ * @param[in] connCallback          Callback to notify the connection changes
  *                                  to Connectivity Abstraction Layer.
  * @param[in] errorCallback         Callback to notify the network errors to
  *                                  Connectivity Abstraction Layer.
@@ -63,7 +66,8 @@ typedef struct
  */
 CAResult_t CAInitializeTCP(CARegisterConnectivityCallback registerCallback,
                            CANetworkPacketReceivedCallback networkPacketCallback,
-                           CANetworkChangeCallback netCallback,
+                           CAAdapterChangeCallback netCallback,
+                           CAConnectionChangeCallback connCallback,
                            CAErrorHandleCallback errorCallback, ca_thread_pool_t handle);
 
 /**
@@ -152,13 +156,11 @@ CAResult_t CAStopTCP();
 void CATerminateTCP();
 
 /**
- * Set connected callback and disconnected callback to process KeepAlive.
+ * Set connection status changes callback to process KeepAlive.
  * connection informations are delivered these callbacks.
- * @param[in]   ConnHandler     Connected callback.
- * @param[in]   DisconnHandler  Disconnected Callback.
+ * @param[in]   ConnHandler     Connection status changes callback.
  */
-void CATCPSetKeepAliveCallbacks(CAKeepAliveConnectedCallback ConnHandler,
-                                CAKeepAliveDisconnectedCallback DisconnHandler);
+void CATCPSetKeepAliveCallbacks(CAKeepAliveConnectionCallback ConnHandler);
 
 #ifdef __cplusplus
 } /* extern "C" */
index 38efb00..a9463ab 100644 (file)
@@ -70,7 +70,7 @@ typedef void (*CATCPErrorHandleCallback)(const CAEndpoint_t *endpoint, const voi
   * @param[in]  isConnected    Whether keepalive message needs to be sent.
   * @see  Callback must be registered using CATCPSetKeepAliveCallback().
  */
-typedef void (*CATCPKeepAliveHandleCallback)(const char *addr, uint16_t port, bool isConnected);
+typedef void (*CATCPConnectionHandleCallback)(const char *addr, uint16_t port, bool isConnected);
 
 /**
  * set error callback to notify error in TCP adapter.
@@ -80,13 +80,41 @@ typedef void (*CATCPKeepAliveHandleCallback)(const char *addr, uint16_t port, bo
  */
 void CATCPSetErrorHandler(CATCPErrorHandleCallback errorHandleCallback);
 
+#ifdef SINGLE_THREAD
+
+CAResult_t CATCPStartServer();
+
+/**
+ * Pull the Received Data.
+ */
+void CATCPPullData();
+
+/**
+ * Get TCP Header Details.
+ * @param[in]    recvBuffer   index of array list.
+ * @param[out]   transport    TCP Server address.
+ * @param[out]   headerlen    TCP Server port.
+ */
+void CAGetTCPHeaderDetails(unsigned char *recvBuffer, coap_transport_type *transport,
+                           size_t *headerlen);
+
+/**
+ * Get total length from CoAP over TCP header.
+ *
+ * @param[in]   recvBuffer    received header data.
+ * @param[in]   size          length of buffer.
+ * @return  total data length
+ */
+size_t CAGetTotalLengthFromPacketHeader(const unsigned char *recvBuffer, size_t size);
+
+#else
 /**
  * set keepalive callback to notify connection information in TCP adapter.
  *
  * @param[in]  keepaliveHandler Callback function to notify the connection information.
  * in the TCP adapter.
  */
-void CATCPSetKeepAliveCallback(CATCPKeepAliveHandleCallback keepaliveHandler);
+void CATCPSetKeepAliveCallback(CAKeepAliveConnectionCallback keepaliveHandler);
 
 /**
  * Start TCP server.
@@ -99,6 +127,8 @@ void CATCPSetKeepAliveCallback(CATCPKeepAliveHandleCallback keepaliveHandler);
  */
 CAResult_t CATCPStartServer(const ca_thread_pool_t threadPool);
 
+#endif
+
 /**
  * Stop TCP server.
  */
index 507aa99..7eb9718 100644 (file)
@@ -11,7 +11,53 @@ diff -rupN ./libraries/Ethernet/src/Ethernet.cpp ./arduino-1.5.8/libraries/Ether
  {
 -  static DhcpClass s_dhcp;
    _dhcp = &s_dhcp;
+   
+
+diff -rupN ./libraries/Ethernet/src/EthernetClient.cpp ./arduino-1.5.8/libraries/Ethernet/src/EthernetClient.cpp
+--- ./libraries/Ethernet/src/EthernetClient.cpp        2014-10-01 20:45:35.000000000 +0530
++++ ./arduino-1.5.8/libraries/Ethernet/src/EthernetClient.cpp  2015-02-05 15:51:09.000000000 +0530
+@@ -92,6 +92,16 @@ int EthernetClient::available() {
+   return 0;
+ }
  
++void EthernetClient::getTCPClientIP(uint8_t *addr) {
++  if (_sock != MAX_SOCK_NUM)
++    W5100.readSnDIPR(_sock, addr);
++}
++
++void EthernetClient::getTCPClientPort(uint16_t *port) {
++  if (_sock != MAX_SOCK_NUM)
++    W5100.readSnDPORT(_sock);
++}
++
+ int EthernetClient::read() {
+   uint8_t b;
+   if ( recv(_sock, &b, 1) > 0 )
+diff -rupN ./libraries/Ethernet/src/EthernetClient.h ./arduino-1.5.8/libraries/Ethernet/src/EthernetClient.h
+--- ./libraries/Ethernet/src/EthernetClient.h  2014-10-01 20:45:35.000000000 +0530
++++ ./arduino-1.5.8/libraries/Ethernet/src/EthernetClient.h    2015-02-05 15:51:09.000000000 +0530
+@@ -1,6 +1,6 @@
+ #ifndef ethernetclient_h
+ #define ethernetclient_h
+-#include "Arduino.h"  
++#include "Arduino.h"
+ #include "Print.h"
+ #include "Client.h"
+ #include "IPAddress.h"
+@@ -26,9 +26,11 @@ public:
+   virtual operator bool();
+   virtual bool operator==(const EthernetClient&);
+   virtual bool operator!=(const EthernetClient& rhs) { return !this->operator==(rhs); };
++  virtual void getTCPClientIP(uint8_t *addr);
++  virtual void getTCPClientPort(uint16_t *port);
+   friend class EthernetServer;
+-  
++
+   using Print::write;
+
+ private:
+
  
 diff -rupN ./libraries/Ethernet/src/utility/socket.cpp ./arduino-1.5.8/libraries/Ethernet/src/utility/socket.cpp
 --- ./libraries/Ethernet/src/utility/socket.cpp        2014-10-01 20:45:35.000000000 +0530
index bf892ec..03713c5 100644 (file)
@@ -37,7 +37,7 @@ if target_os not in ['windows', 'winrt']:
        libcoap_env.AppendUnique(CFLAGS = ['-Wall', '-ffunction-sections',
                        '-fdata-sections', '-fno-exceptions'])
 
-if target_os in ['linux', 'tizen', 'android', 'ios']:
+if target_os in ['linux', 'tizen', 'android', 'ios', 'arduino']:
        if with_tcp == True:
                libcoap_env.AppendUnique(CPPDEFINES = ['WITH_TCP'])
 
index d3ea2ec..580729b 100644 (file)
@@ -324,20 +324,23 @@ coap_new_context(const coap_address_t *listen_addr)
 #if defined(WITH_POSIX)
     coap_context_t *c = coap_malloc( sizeof( coap_context_t ) );
     int reuse = 1;
-#endif /* WITH_POSIX */
-#ifdef WITH_LWIP
-    coap_context_t *c = memp_malloc(MEMP_COAP_CONTEXT);
-#endif /* WITH_LWIP */
-#ifdef WITH_CONTIKI
-    coap_context_t *c;
-
+#elif WITH_CONTIKI
+    coap_context_t *c =NULL;
     if (initialized)
-    return NULL;
-#endif /* WITH_CONTIKI */
-
+    {
+        return NULL;
+    }
+#elif WITH_LWIP
+    coap_context_t *c = memp_malloc(MEMP_COAP_CONTEXT);
+#endif /* WITH_POSIX */
     if (!listen_addr)
     {
         coap_log(LOG_EMERG, "no listen address specified\n");
+#if defined(WITH_POSIX)
+        coap_free_context(c);
+#elif WITH_LWIP
+        memp_free(c);
+#endif
         return NULL;
     }
 
index 8cf2ae6..ea60aab 100644 (file)
@@ -74,7 +74,9 @@ size_t coap_opt_parse(const coap_opt_t *opt, size_t length, coap_option_t *resul
     {
         case 15:
             if (*opt != COAP_PAYLOAD_START)
+            {
                 debug("ignored reserved option delta 15\n");
+            }
             return 0;
         case 14:
             /* Handle two-byte value: First, the MSB + 269 is stored as delta value.
index 1da4034..1b36674 100644 (file)
@@ -427,13 +427,13 @@ unsigned int coap_get_tcp_header_length_for_transport(coap_transport_type transp
         case coap_tcp:
             length = COAP_TCP_HEADER_NO_FIELD;
             break;
-        case coap_tcp_8bit:
+        case coap_tcp_8bit:   /* len(4bit) + TKL(4bit) + Len+bytes(1byte) + Code(1byte) */
             length = COAP_TCP_HEADER_8_BIT;
             break;
-        case coap_tcp_16bit:
+        case coap_tcp_16bit:  /* len(4bit) + TKL(4bit) + Len+bytes(2byte) + Code(1byte) */
             length = COAP_TCP_HEADER_16_BIT;
             break;
-        case coap_tcp_32bit:
+        case coap_tcp_32bit:  /* len(4bit) + TKL(4bit) + Len+bytes(4byte) + Code(1byte) */
             length = COAP_TCP_HEADER_32_BIT;
             break;
         default:
index d461913..c375416 100644 (file)
@@ -398,7 +398,7 @@ int coap_pdu_parse(unsigned char *data, size_t length, coap_pdu_t *pdu,
 
 #ifdef WITH_TCP
 /**
- * Get total message length from header.
+ * Get total pdu size including header + option + payload (with marker) from pdu data.
  *
  * @param data   The raw data to parse as CoAP PDU.
  * @param size   payload size of pdu.
@@ -407,7 +407,8 @@ int coap_pdu_parse(unsigned char *data, size_t length, coap_pdu_t *pdu,
 size_t coap_get_total_message_length(const unsigned char *data, size_t size);
 
 /**
- * Get transport type of coap header for coap over tcp through payload size.
+ * Get transport type of coap header for coap over tcp
+ * through payload size(including payload marker) + option size.
  *
  * @param size   payload size of pdu.
  * @return The transport type.
@@ -415,7 +416,8 @@ size_t coap_get_total_message_length(const unsigned char *data, size_t size);
 coap_transport_type coap_get_tcp_header_type_from_size(unsigned int size);
 
 /**
- * Get transport type of coap header for coap over tcp through init-byte.
+ * Get transport type of coap header for coap over tcp
+ * through first nibble(0~E) of init-byte .
  *
  * @param legnth   length value of init byte.
 * @return The transport type.
@@ -423,7 +425,8 @@ coap_transport_type coap_get_tcp_header_type_from_size(unsigned int size);
 coap_transport_type coap_get_tcp_header_type_from_initbyte(unsigned int length);
 
 /**
- * Add length value in field of coap header for coap over tcp.
+ * Add length of option/payload into 'Len+ byte...' field of coap header
+ * for coap over tcp.
  *
  * @param pdu  The pdu pointer.
  * @param transport The transport type.
@@ -433,7 +436,7 @@ void coap_add_length(const coap_pdu_t *pdu, coap_transport_type transport,
                      unsigned int length);
 
 /**
- * Get the value of length field of coap header for coap over tcp.
+ * Get the length of option/payload field of coap header for coap over tcp.
  *
  * @param pdu  The pdu pointer.
  * @param transport The transport type.
@@ -442,15 +445,16 @@ void coap_add_length(const coap_pdu_t *pdu, coap_transport_type transport,
 unsigned int coap_get_length(const coap_pdu_t *pdu, coap_transport_type transport);
 
 /**
- * Get pdu length from header of coap over tcp.
+ * Get the length of option/payload field of coap header for coap over tcp.
  *
  * @param header   The header to parse.
  * @return transport The transport type.
  */
-unsigned int coap_get_length_from_header(const unsigned char *header, coap_transport_type transport);
+unsigned int coap_get_length_from_header(const unsigned char *header,
+                                         coap_transport_type transport);
 
 /**
- * Get length of header for coap over tcp.
+ * Get length of header including len, TKL, Len+bytes, Code, token bytes for coap over tcp.
  *
  * @param data   The raw data to parse as CoAP PDU
  * @return header length + token length
@@ -458,7 +462,8 @@ unsigned int coap_get_length_from_header(const unsigned char *header, coap_trans
 unsigned int coap_get_tcp_header_length(unsigned char *data);
 
 /**
- * Get length of header without token length for coap over tcp.
+ * Get length of header including len, TKL, Len+bytes, Code
+ * without token bytes for coap over tcp.
  *
  * @param transport The transport type.
  * @return header length.
index 26c2f1b..3954517 100644 (file)
@@ -376,7 +376,7 @@ coap_attr_t *
 coap_add_attr(coap_resource_t *resource, const unsigned char *name, size_t nlen,
         const unsigned char *val, size_t vlen, int flags)
 {
-    coap_attr_t *attr;
+    coap_attr_t *attr = NULL;
 
     if (!resource || !name)
         return NULL;
@@ -487,8 +487,8 @@ void coap_add_resource(coap_context_t *context, coap_resource_t *resource)
 
 int coap_delete_resource(coap_context_t *context, coap_key_t key)
 {
-    coap_resource_t *resource;
-    coap_attr_t *attr, *tmp;
+    coap_resource_t *resource = NULL;
+    coap_attr_t *attr = NULL, *tmp = NULL;
 #ifdef WITH_CONTIKI
     coap_subscription_t *obs;
 #endif
index 897e390..3c671a3 100644 (file)
@@ -131,6 +131,11 @@ if 'ALL' in ca_transport:
 
 if 'IP' in ca_transport:
        env.SConscript(os.path.join(ca_path, 'ip_adapter/SConscript'))
+       if ca_os == 'arduino':
+               if with_tcp:
+                       transports = [ 'ip_adapter', 'tcp_adapter']
+                       env.SConscript(dirs = [
+                               os.path.join(ca_path, d) for d in transports ])
 
 if 'BT' in ca_transport:
        env.SConscript(os.path.join(ca_path, 'bt_edr_adapter/SConscript'))
@@ -152,15 +157,21 @@ if ca_os in ['linux', 'tizen', 'android', 'arduino', 'ios']:
 
 print "Include path is %s" % env.get('CPPPATH')
 print "Files path is %s" % env.get('CA_SRC')
+               
+lib_env = env.Clone()
+
+if ca_os == 'android':
+    lib_env.AppendUnique(LINKFLAGS = ['-Wl,-soname,libconnectivity_abstraction.so'])
+
 if ca_os in ['android', 'tizen']:
-       env.AppendUnique(LIBS = ['coap'])
-       if env.get('SECURED') == '1':
-               env.AppendUnique(LIBS = ['tinydtls'])
-               env.AppendUnique(LIBS = ['timer'])
+       lib_env.AppendUnique(LIBS = ['coap'])
+       if lib_env.get('SECURED') == '1':
+               lib_env.AppendUnique(LIBS = ['tinydtls'])
+               lib_env.AppendUnique(LIBS = ['timer'])
        if ca_os != 'android':
-               env.AppendUnique(LIBS = ['rt'])
-       calib = env.SharedLibrary('connectivity_abstraction', env.get('CA_SRC'))
+               lib_env.AppendUnique(LIBS = ['rt'])
+       calib = lib_env.SharedLibrary('connectivity_abstraction', lib_env.get('CA_SRC'))
 else:
-       calib = env.StaticLibrary('connectivity_abstraction', env.get('CA_SRC'))
-env.InstallTarget(calib, 'libconnectivity_abstraction')
-env.UserInstallTargetLib(calib, 'libconnectivity_abstraction')
+       calib = lib_env.StaticLibrary('connectivity_abstraction', lib_env.get('CA_SRC'))
+lib_env.InstallTarget(calib, 'libconnectivity_abstraction')
+lib_env.UserInstallTargetLib(calib, 'libconnectivity_abstraction')
index bb79375..83f24eb 100644 (file)
@@ -255,6 +255,34 @@ jobject *CANativeGetActivity()
     return g_Activity;
 }
 
+jmethodID CAGetJNIMethodID(JNIEnv *env, const char* className,
+                           const char* methodName,
+                           const char* methodFormat)
+{
+    VERIFY_NON_NULL_RET(env, CA_ADAPTER_UTILS_TAG, "env", NULL);
+    VERIFY_NON_NULL_RET(className, CA_ADAPTER_UTILS_TAG, "className", NULL);
+    VERIFY_NON_NULL_RET(methodName, CA_ADAPTER_UTILS_TAG, "methodName", NULL);
+    VERIFY_NON_NULL_RET(methodFormat, CA_ADAPTER_UTILS_TAG, "methodFormat", NULL);
+
+    jclass jni_cid = (*env)->FindClass(env, className);
+    if (!jni_cid)
+    {
+        OIC_LOG_V(ERROR, CA_ADAPTER_UTILS_TAG, "jni_cid [%s] is null", className);
+        return NULL;
+    }
+
+    jmethodID jni_midID = (*env)->GetMethodID(env, jni_cid, methodName, methodFormat);
+    if (!jni_midID)
+    {
+        OIC_LOG_V(ERROR, CA_ADAPTER_UTILS_TAG, "jni_midID [%s] is null", methodName);
+        (*env)->DeleteLocalRef(env, jni_cid);
+        return NULL;
+    }
+
+    (*env)->DeleteLocalRef(env, jni_cid);
+    return jni_midID;
+}
+
 void CADeleteGlobalReferences(JNIEnv *env)
 {
     if (g_Context)
index 16e588a..bdcc44e 100644 (file)
@@ -54,36 +54,6 @@ static JavaVM *g_jvm;
 static jobject g_context;
 
 /**
- * @var g_mutexUnicastServer
- * @brief Mutex to synchronize unicast server
- */
-static ca_mutex g_mutexUnicastServer = NULL;
-
-/**
- * @var g_stopUnicast
- * @brief Flag to control the Receive Unicast Data Thread
- */
-static bool g_stopUnicast = false;
-
-/**
- * @var g_mutexMulticastServer
- * @brief Mutex to synchronize secure multicast server
- */
-static ca_mutex g_mutexMulticastServer = NULL;
-
-/**
- * @var g_stopMulticast
- * @brief Flag to control the Receive Multicast Data Thread
- */
-static bool g_stopMulticast = false;
-
-/**
- * @var g_stopAccept
- * @brief Flag to control the Accept Thread
- */
-static bool g_stopAccept = false;
-
-/**
  * @var g_mutexStateList
  * @brief Mutex to synchronize device state list
  */
@@ -288,20 +258,21 @@ CAResult_t CAEDRCreateJNIInterfaceObject(jobject context)
         return CA_STATUS_FAILED;
     }
 
-    //getApplicationContext
-    jclass contextClass = (*env)->FindClass(env, CLASSPATH_CONTEXT);
-    if (!contextClass)
+
+    jmethodID mid_getApplicationContext = CAGetJNIMethodID(env, CLASSPATH_CONTEXT,
+                                                           "getApplicationContext",
+                                                           METHODID_CONTEXTNONPARAM);
+    if (!mid_getApplicationContext)
     {
-        OIC_LOG(ERROR, TAG, "Could not get context object class");
+        OIC_LOG(ERROR, TAG, "Could not get getApplicationContext method");
         return CA_STATUS_FAILED;
     }
 
-    jmethodID getApplicationContextMethod = (*env)->GetMethodID(env, contextClass,
-                                                                "getApplicationContext",
-                                                                METHODID_CONTEXTNONPARAM);
-    if (!getApplicationContextMethod)
+    jobject jApplicationContext = (*env)->CallObjectMethod(env, context,
+                                                           mid_getApplicationContext);
+    if (!jApplicationContext)
     {
-        OIC_LOG(ERROR, TAG, "Could not get getApplicationContext method");
+        OIC_LOG(ERROR, TAG, "Could not get application context");
         return CA_STATUS_FAILED;
     }
 
@@ -321,7 +292,7 @@ CAResult_t CAEDRCreateJNIInterfaceObject(jobject context)
         return CA_STATUS_FAILED;
     }
 
-    (*env)->NewObject(env, EDRJniInterface, EDRInterfaceConstructorMethod, context);
+    (*env)->NewObject(env, EDRJniInterface, EDRInterfaceConstructorMethod, jApplicationContext);
     OIC_LOG(DEBUG, TAG, "NewObject Success");
 
     return CA_STATUS_OK;
@@ -329,18 +300,6 @@ CAResult_t CAEDRCreateJNIInterfaceObject(jobject context)
 
 static void CAEDRDestroyMutex()
 {
-    if (g_mutexUnicastServer)
-    {
-        ca_mutex_free(g_mutexUnicastServer);
-        g_mutexUnicastServer = NULL;
-    }
-
-    if (g_mutexMulticastServer)
-    {
-        ca_mutex_free(g_mutexMulticastServer);
-        g_mutexMulticastServer = NULL;
-    }
-
     if (g_mutexStateList)
     {
         ca_mutex_free(g_mutexStateList);
@@ -356,22 +315,6 @@ static void CAEDRDestroyMutex()
 
 static CAResult_t CAEDRCreateMutex()
 {
-    g_mutexUnicastServer = ca_mutex_new();
-    if (!g_mutexUnicastServer)
-    {
-        OIC_LOG(ERROR, TAG, "Failed to created mutex!");
-        return CA_STATUS_FAILED;
-    }
-
-    g_mutexMulticastServer = ca_mutex_new();
-    if (!g_mutexMulticastServer)
-    {
-        OIC_LOG(ERROR, TAG, "Failed to created mutex!");
-
-        CAEDRDestroyMutex();
-        return CA_STATUS_FAILED;
-    }
-
     g_mutexStateList = ca_mutex_new();
     if (!g_mutexStateList)
     {
@@ -476,10 +419,6 @@ void CAEDRTerminate()
         isAttached = true;
     }
 
-    g_stopAccept = true;
-    g_stopMulticast = true;
-    g_stopUnicast = true;
-
     if (isAttached)
     {
         (*g_jvm)->DetachCurrentThread(g_jvm);
@@ -488,6 +427,7 @@ void CAEDRTerminate()
     if (g_context)
     {
         (*env)->DeleteGlobalRef(env, g_context);
+        g_context = NULL;
     }
 
     CAEDRNativeSocketCloseToAll(env);
@@ -613,8 +553,6 @@ CAResult_t CAEDRSendMulticastMessage(const uint8_t* data, uint32_t dataLen)
         return result;
     }
 
-    OIC_LOG(DEBUG, TAG, "sent data");
-
     if (isAttached)
     {
         OIC_LOG(DEBUG, TAG, "DetachCurrentThread");
@@ -852,7 +790,7 @@ CAResult_t CAEDRNativeSendData(JNIEnv *env, const char *address, const uint8_t *
     if (STATE_DISCONNECTED == CAEDRIsConnectedDevice(address))
     {
         // connect before send data
-        OIC_LOG(DEBUG, TAG, "connect before send data");
+        OIC_LOG_V(DEBUG, TAG, "try to connect with [%s] before sending data", address);
 
         CAResult_t res = CAEDRNativeConnect(env, address);
         if (CA_STATUS_OK != res)
@@ -964,7 +902,6 @@ CAResult_t CAEDRNativeSendData(JNIEnv *env, const char *address, const uint8_t *
 CAResult_t CAEDRNativeConnect(JNIEnv *env, const char *address)
 {
     VERIFY_NON_NULL(address, TAG, "address is null");
-    OIC_LOG(DEBUG, TAG, "btConnect..");
 
     if (!CAEDRNativeIsEnableBTAdapter(env))
     {
@@ -1138,7 +1075,7 @@ CAResult_t CAEDRNativeConnect(JNIEnv *env, const char *address)
     CAEDRUpdateDeviceState(STATE_CONNECTED, address);
     ca_mutex_unlock(g_mutexStateList);
 
-    OIC_LOG(DEBUG, TAG, "connected");
+    OIC_LOG(DEBUG, TAG, "successfully connected");
 
     return CA_STATUS_OK;
 }
@@ -1186,7 +1123,7 @@ void CAEDRNativeSocketClose(JNIEnv *env, const char *address)
     CAEDRUpdateDeviceState(STATE_DISCONNECTED, address);
     ca_mutex_unlock(g_mutexStateList);
 
-    OIC_LOG(DEBUG, TAG, "disconnected");
+    OIC_LOG_V(DEBUG, TAG, "disconnected with [%s]", address);
 }
 
 CAResult_t CAEDRClientInitialize()
index de187d8..425469e 100644 (file)
@@ -59,8 +59,6 @@ void CAEDRNetworkMonitorJniInit()
 
 CAResult_t CAEDRInitializeNetworkMonitor(const ca_thread_pool_t threadPool)
 {
-    OIC_LOG(DEBUG, TAG, "IN");
-
     if (!threadPool)
     {
         return CA_STATUS_FAILED;
@@ -71,7 +69,6 @@ CAResult_t CAEDRInitializeNetworkMonitor(const ca_thread_pool_t threadPool)
         CANativeJNIGetJavaVM();
     }
 
-    OIC_LOG(DEBUG, TAG, "OUT");
     return CA_STATUS_OK;
 }
 
@@ -83,32 +80,20 @@ void CAEDRSetNetworkChangeCallback(CAEDRNetworkStatusCallback networkChangeCallb
 
 void CAEDRTerminateNetworkMonitor(void)
 {
-    OIC_LOG(DEBUG, TAG, "IN");
-
-    OIC_LOG(DEBUG, TAG, "OUT");
 }
 
 CAResult_t CAEDRStartNetworkMonitor()
 {
-    OIC_LOG(DEBUG, TAG, "IN");
-
-    OIC_LOG(DEBUG, TAG, "OUT");
     return CA_STATUS_OK;
 }
 
 CAResult_t CAEDRStopNetworkMonitor()
 {
-    OIC_LOG(DEBUG, TAG, "IN");
-
-    OIC_LOG(DEBUG, TAG, "OUT");
     return CA_STATUS_OK;
 }
 
 CAResult_t CAEDRClientSetCallbacks(void)
 {
-    OIC_LOG(DEBUG, TAG, "IN");
-
-    OIC_LOG(DEBUG, TAG, "OUT");
     return CA_STATUS_OK;
 }
 
@@ -134,21 +119,21 @@ Java_org_iotivity_ca_CaEdrInterface_caEdrStateChangedCallback(JNIEnv *env, jobje
     jclass jni_cid_BTAdapter = (*env)->FindClass(env, CLASSPATH_BT_ADPATER);
     if (!jni_cid_BTAdapter)
     {
-        OIC_LOG(ERROR, TAG, "[EDR][Native] jni_cid_BTAdapter is null");
+        OIC_LOG(ERROR, TAG, "jni_cid_BTAdapter is null");
         return;
     }
 
     jfieldID id_state_on = (*env)->GetStaticFieldID(env, jni_cid_BTAdapter, "STATE_ON", "I");
     if (!id_state_on)
     {
-        OIC_LOG(ERROR, TAG, "[EDR][Native] id_state_on is null");
+        OIC_LOG(ERROR, TAG, "id_state_on is null");
         return;
     }
 
     jfieldID id_state_off = (*env)->GetStaticFieldID(env, jni_cid_BTAdapter, "STATE_OFF", "I");
     if (!id_state_off)
     {
-        OIC_LOG(ERROR, TAG, "[EDR][Native] id_state_off is null");
+        OIC_LOG(ERROR, TAG, "id_state_off is null");
         return;
     }
 
@@ -159,10 +144,10 @@ Java_org_iotivity_ca_CaEdrInterface_caEdrStateChangedCallback(JNIEnv *env, jobje
     {
         CANetworkStatus_t newStatus = CA_INTERFACE_UP;
 
-        CAResult_t res = CAEDRStartUnicastServer(false);
+        CAResult_t res = CAEDRStartReceiveThread(false);
         if (CA_STATUS_OK != res)
         {
-            OIC_LOG(ERROR, TAG, "CAEDRStartUnicastServer failed");
+            OIC_LOG(ERROR, TAG, "Failed to CAEDRStartReceiveThread");
             return;
         }
         CAEDRServerStartAcceptThread();
@@ -197,3 +182,32 @@ Java_org_iotivity_ca_CaEdrInterface_caEdrBondStateChangedCallback(JNIEnv *env, j
         CAEDRNativeRemoveDevice(addr);
     }
 }
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_ca_CaEdrInterface_caEdrConnectionStateChangedCallback(JNIEnv *env,
+                                                                        jobject obj,
+                                                                        jstring addr,
+                                                                        jint isConnected)
+{
+    if (!env || !obj || !addr)
+    {
+        OIC_LOG(ERROR, TAG, "parameter is null");
+        return;
+    }
+
+    OIC_LOG_V(DEBUG, TAG, "CaEdrInterface - Connection State Changed : %d", isConnected);
+
+    if (!isConnected)
+    {
+        const char *address = (*env)->GetStringUTFChars(env, addr, NULL);
+        if (!address)
+        {
+            OIC_LOG(ERROR, TAG, "address is null");
+            return;
+        }
+
+        CAEDRNativeRemoveDeviceSocketBaseAddr(env, addr);
+        CAEDRNativeRemoveDevice(address);
+        (*env)->ReleaseStringUTFChars(env, addr, address);
+    }
+}
index 66decf1..3d4dcb6 100644 (file)
@@ -39,6 +39,7 @@
 static const char METHODID_OBJECTNONPARAM[] = "()Landroid/bluetooth/BluetoothAdapter;";
 static const char CLASSPATH_BT_ADPATER[] = "android/bluetooth/BluetoothAdapter";
 static const char CLASSPATH_BT_UUID[] = "java/util/UUID";
+static const char CLASSPATH_BT_SERVER_SOCKET[] = "android/bluetooth/BluetoothServerSocket";
 
 static ca_thread_pool_t g_threadPoolHandle = NULL;
 
@@ -51,14 +52,9 @@ static JavaVM *g_jvm;
 #define EDR_MAX_HEADER_LEN  6
 
 /**
- * server socket instance.
+ * Mutex to synchronize receive server.
  */
-static jobject g_serverSocketObject = NULL;
-
-/**
- * Mutex to synchronize unicast server.
- */
-static ca_mutex g_mutexUnicastServer = NULL;
+static ca_mutex g_mutexReceiveServer = NULL;
 
 /**
  * Flag to control the Receive Unicast Data Thread.
@@ -66,16 +62,6 @@ static ca_mutex g_mutexUnicastServer = NULL;
 static bool g_stopUnicast = false;
 
 /**
- * Mutex to synchronize secure multicast server.
- */
-static ca_mutex g_mutexMulticastServer = NULL;
-
-/**
- * Flag to control the Receive Multicast Data Thread.
- */
-static bool g_stopMulticast = false;
-
-/**
  * Mutex to synchronize accept server.
  */
 static ca_mutex g_mutexAcceptServer = NULL;
@@ -90,6 +76,9 @@ static bool g_stopAccept = false;
  */
 static ca_mutex g_mutexServerSocket = NULL;
 
+/**
+ * Flag to control the server socket.
+ */
 static jobject g_serverSocket = NULL;
 
 /**
@@ -180,14 +169,14 @@ static void CAAcceptHandler(void *data)
 {
     OIC_LOG(DEBUG, TAG, "AcceptThread start");
 
-    VERIFY_NON_NULL_VOID(data, TAG, "CAAcceptHandler: data is null");
+    VERIFY_NON_NULL_VOID(data, TAG, "data is null");
 
     bool isAttached = false;
     JNIEnv* env;
     jint res = (*g_jvm)->GetEnv(g_jvm, (void**) &env, JNI_VERSION_1_6);
     if (JNI_OK != res)
     {
-        OIC_LOG(DEBUG, TAG, "CAAcceptHandler - Could not get JNIEnv pointer");
+        OIC_LOG(DEBUG, TAG, "Could not get JNIEnv pointer");
         res = (*g_jvm)->AttachCurrentThread(g_jvm, &env, NULL);
 
         if (JNI_OK != res)
@@ -201,7 +190,7 @@ static void CAAcceptHandler(void *data)
     jobject jni_obj_BTServerSocket = CAEDRNativeListen(env);
     if (!jni_obj_BTServerSocket)
     {
-        OIC_LOG(ERROR, TAG, "AcceptThread: jni_obj_BTServerSocket is null");
+        OIC_LOG(ERROR, TAG, "jni_obj_BTServerSocket is null");
 
         if (isAttached)
         {
@@ -224,8 +213,6 @@ static void CAAcceptHandler(void *data)
 
     while (true != *(ctx->stopFlag))
     {
-        OIC_LOG(DEBUG, TAG, "AcceptThread running");
-
         // when BT state is changed with Off. its thread will be stopped
         if (!CAEDRNativeIsEnableBTAdapter(env))
         {
@@ -265,13 +252,16 @@ CAResult_t CAEDRServerStart()
         return CA_STATUS_NOT_INITIALIZED;
     }
 
-    CAEDRServerStartAcceptThread();
-    CAResult_t res = CAEDRStartUnicastServer(false);
-    if (CA_STATUS_OK != res)
+    CAResult_t res = CAEDRServerStartAcceptThread();
+    if (CA_STATUS_OK == res)
     {
-        OIC_LOG(ERROR, TAG, "CAEDRStartUnicastServer failed");
-        CAEDRServerStop();
-        return CA_STATUS_FAILED;
+        res = CAEDRStartReceiveThread(false);
+        if (CA_STATUS_OK != res)
+        {
+            OIC_LOG(ERROR, TAG, "failed to start receive thread");
+            CAEDRServerStop();
+            return CA_STATUS_FAILED;
+        }
     }
 
     return res;
@@ -279,8 +269,7 @@ CAResult_t CAEDRServerStart()
 
 CAResult_t CAEDRServerStop()
 {
-    CAEDRStopUnicastServer();
-    CAEDRStopMulticastServer();
+    CAEDRStopReceiveThread();
 
     ca_mutex_lock(g_mutexAcceptServer);
     g_stopAccept = true;
@@ -325,16 +314,10 @@ void CAEDRSetPacketReceivedCallback(CAEDRDataReceivedCallback packetReceivedCall
 
 static void CAEDRServerDestroyMutex()
 {
-    if (g_mutexUnicastServer)
-    {
-        ca_mutex_free(g_mutexUnicastServer);
-        g_mutexUnicastServer = NULL;
-    }
-
-    if (g_mutexMulticastServer)
+    if (g_mutexReceiveServer)
     {
-        ca_mutex_free(g_mutexMulticastServer);
-        g_mutexMulticastServer = NULL;
+        ca_mutex_free(g_mutexReceiveServer);
+        g_mutexReceiveServer = NULL;
     }
 
     if (g_mutexAcceptServer)
@@ -364,22 +347,13 @@ static void CAEDRServerDestroyMutex()
 
 static CAResult_t CAEDRServerCreateMutex()
 {
-    g_mutexUnicastServer = ca_mutex_new();
-    if (!g_mutexUnicastServer)
+    g_mutexReceiveServer = ca_mutex_new();
+    if (!g_mutexReceiveServer)
     {
         OIC_LOG(ERROR, TAG, "Failed to created mutex!");
         return CA_STATUS_FAILED;
     }
 
-    g_mutexMulticastServer = ca_mutex_new();
-    if (!g_mutexMulticastServer)
-    {
-        OIC_LOG(ERROR, TAG, "Failed to created mutex!");
-
-        CAEDRServerDestroyMutex();
-        return CA_STATUS_FAILED;
-    }
-
     g_mutexAcceptServer = ca_mutex_new();
     if (!g_mutexAcceptServer)
     {
@@ -429,12 +403,11 @@ CAResult_t CAEDRServerInitialize(ca_thread_pool_t handle)
 {
     OIC_LOG(DEBUG, TAG, "CAEDRServerInitialize");
     VERIFY_NON_NULL(handle, TAG, "handle is NULL");
+
     g_threadPoolHandle = handle;
     CAEDRServerJniInit();
 
-    // init mutex
-    CAResult_t result = CAEDRServerCreateMutex();
-    return result;
+    return CAEDRServerCreateMutex();
 }
 
 CAResult_t CAEDRServerStartAcceptThread()
@@ -533,11 +506,11 @@ void CAEDRServerTerminate()
     CAEDRServerDestroyMutex();
 }
 
-CAResult_t CAEDRStartUnicastServer(bool isSecured)
+CAResult_t CAEDRStartReceiveThread(bool isSecured)
 {
-    OIC_LOG(DEBUG, TAG, "CAEDRStartUnicastServer");
+    OIC_LOG(DEBUG, TAG, "CAEDRStartReceiveThread");
 
-    ca_mutex_lock(g_mutexUnicastServer);
+    ca_mutex_lock(g_mutexReceiveServer);
 
     /**
      * The task to listen for data from unicast is added to the thread pool.
@@ -551,93 +524,38 @@ CAResult_t CAEDRStartUnicastServer(bool isSecured)
     if (!ctx)
     {
         OIC_LOG(ERROR, TAG, "Out of memory!");
-        ca_mutex_unlock(g_mutexUnicastServer);
+        ca_mutex_unlock(g_mutexReceiveServer);
         return CA_MEMORY_ALLOC_FAILED;
     }
 
+    g_stopUnicast = false;
     ctx->stopFlag = &g_stopUnicast;
     ctx->type = isSecured ? CA_SECURED_UNICAST_SERVER : CA_UNICAST_SERVER;
     if (CA_STATUS_OK != ca_thread_pool_add_task(g_threadPoolHandle, CAReceiveHandler, (void *) ctx))
     {
         OIC_LOG(ERROR, TAG, "Failed to create read thread!");
-        ca_mutex_unlock(g_mutexUnicastServer);
-        OICFree((void *) ctx);
-        return CA_STATUS_FAILED;
-    }
-    ca_mutex_unlock(g_mutexUnicastServer);
-
-    OIC_LOG(DEBUG, TAG, "OUT");
-    return CA_STATUS_OK;
-}
-
-CAResult_t CAEDRStartMulticastServer()
-{
-    OIC_LOG(DEBUG, TAG, "CAEDRStartMulticastServer");
-
-    ca_mutex_lock(g_mutexMulticastServer);
-
-    /**
-     * The task to listen to data from multicast socket is added to the thread pool.
-     * This is a blocking call is made where we try to receive some data.
-     * We will keep waiting until some data is received.
-     * This task will be terminated when thread pool is freed on stopping the adapters.
-     * Thread context will be freed by thread on exit.
-     */
-    CAAdapterReceiveThreadContext_t *ctx = (CAAdapterReceiveThreadContext_t *) OICMalloc(
-            sizeof(CAAdapterReceiveThreadContext_t));
-    if (!ctx)
-    {
-        OIC_LOG(ERROR, TAG, "Out of memory!");
-        ca_mutex_unlock(g_mutexMulticastServer);
-
-        return CA_MEMORY_ALLOC_FAILED;
-    }
-
-    ctx->stopFlag = &g_stopMulticast;
-    ctx->type = CA_MULTICAST_SERVER;
-
-    g_stopMulticast = false;
-    if (CA_STATUS_OK != ca_thread_pool_add_task(g_threadPoolHandle, CAReceiveHandler, (void *) ctx))
-    {
-        OIC_LOG(ERROR, TAG, "thread_pool_add_task failed!");
-
-        g_stopMulticast = true;
-        ca_mutex_unlock(g_mutexMulticastServer);
+        ca_mutex_unlock(g_mutexReceiveServer);
         OICFree((void *) ctx);
-
         return CA_STATUS_FAILED;
     }
-    ca_mutex_unlock(g_mutexMulticastServer);
+    ca_mutex_unlock(g_mutexReceiveServer);
 
     OIC_LOG(DEBUG, TAG, "OUT");
     return CA_STATUS_OK;
 }
 
-CAResult_t CAEDRStopUnicastServer()
+CAResult_t CAEDRStopReceiveThread()
 {
-    OIC_LOG(DEBUG, TAG, "CAEDRStopUnicastServer");
+    OIC_LOG(DEBUG, TAG, "CAEDRStopReceiveThread");
 
-    ca_mutex_lock(g_mutexUnicastServer);
+    ca_mutex_lock(g_mutexReceiveServer);
     g_stopUnicast = true;
-    ca_mutex_unlock(g_mutexUnicastServer);
+    ca_mutex_unlock(g_mutexReceiveServer);
 
     return CA_STATUS_OK;
 }
 
-CAResult_t CAEDRStopMulticastServer()
-{
-    OIC_LOG(DEBUG, TAG, "CAEDRStopMulticastServer");
-
-    ca_mutex_lock(g_mutexMulticastServer);
-    g_stopMulticast = true;
-    ca_mutex_unlock(g_mutexMulticastServer);
-
-    OIC_LOG(INFO, TAG, "Multicast server stopped");
-
-    return CA_STATUS_OK;
-}
-
-CAResult_t CAEDRNativeReadData(JNIEnv *env, uint32_t id)
+CAResult_t CAEDRNativeReadData(JNIEnv *env, uint32_t idx)
 {
     if ((*env)->ExceptionCheck(env))
     {
@@ -647,71 +565,36 @@ CAResult_t CAEDRNativeReadData(JNIEnv *env, uint32_t id)
         return CA_STATUS_FAILED;
     }
 
-    // check whether this socket object is connected or not.
-    jobject jni_obj_socket = CAEDRNativeGetDeviceSocket(id);
-    if (!jni_obj_socket)
-    {
-        return CA_STATUS_INVALID_PARAM;
-    }
-
-    // check it whether is still connected or not through google api
-    jboolean ret = CAEDRIsConnectedForSocket(env, jni_obj_socket);
-    if (!ret)
-    {
-        OIC_LOG(ERROR, TAG, "it is not connected yet.");
-
-        // remove socket to list
-        CAEDRNativeRemoveDeviceSocket(env, jni_obj_socket);
-        return CA_STATUS_FAILED;
-    }
-
-    // start to read through InputStream
-    jclass jni_cid_BTsocket = (*env)->FindClass(env, "android/bluetooth/BluetoothSocket");
-    if (!jni_cid_BTsocket)
-    {
-        OIC_LOG(ERROR, TAG, "jni_cid_BTsocket is null");
-        return CA_STATUS_FAILED;
-    }
-    jmethodID jni_mid_getInputStream = (*env)->GetMethodID(env, jni_cid_BTsocket,
-                                                           "getInputStream",
-                                                           "()Ljava/io/InputStream;");
-
-    jobject jni_obj_inputStream = (*env)->CallObjectMethod(env, jni_obj_socket,
-                                                           jni_mid_getInputStream);
+    jobject jni_obj_inputStream = CAEDRNativeGetInputStream(idx);
     if (!jni_obj_inputStream)
     {
         OIC_LOG(ERROR, TAG, "jni_obj_inputStream is null");
-        (*env)->DeleteLocalRef(env, jni_cid_BTsocket);
-        return CA_STATUS_FAILED;
-    }
-
-    jclass jni_cid_InputStream = (*env)->FindClass(env, "java/io/InputStream");
-    if (!jni_cid_InputStream)
-    {
-        OIC_LOG(ERROR, TAG, "jni_cid_InputStream is null");
-        (*env)->DeleteLocalRef(env, jni_obj_inputStream);
-        (*env)->DeleteLocalRef(env, jni_cid_BTsocket);
         return CA_STATUS_FAILED;
     }
 
-    jmethodID jni_mid_available = (*env)->GetMethodID(env, jni_cid_InputStream,
-                                                      "available", "()I");
+    jmethodID jni_mid_available = CAGetJNIMethodID(env, "java/io/InputStream", "available", "()I");
     if (!jni_mid_available)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_available is null");
-        goto exit;
+        return CA_STATUS_FAILED;
     }
 
     jint available = (*env)->CallIntMethod(env, jni_obj_inputStream, jni_mid_available);
 
-    CAConnectedDeviceInfo_t *deviceInfo = NULL;
     if (0 < available)
     {
+        jobject jni_obj_socket = CAEDRNativeGetDeviceSocket(idx);
+        if (!jni_obj_socket)
+        {
+            OIC_LOG(ERROR, TAG, "jni_obj_socket is null");
+            return CA_STATUS_FAILED;
+        }
+
         jstring jni_str_address = CAEDRNativeGetAddressFromDeviceSocket(env, jni_obj_socket);
         if (!jni_str_address)
         {
             OIC_LOG(ERROR, TAG, "jni_str_address is null");
-            goto exit;
+            return CA_STATUS_FAILED;
         }
 
         const char* address = (*env)->GetStringUTFChars(env, jni_str_address, NULL);
@@ -719,31 +602,21 @@ CAResult_t CAEDRNativeReadData(JNIEnv *env, uint32_t id)
         {
             OIC_LOG(ERROR, TAG, "address is null");
             (*env)->DeleteLocalRef(env, jni_str_address);
-            goto exit;
-        }
-
-        OIC_LOG_V(DEBUG, TAG, "get InputStream..%d, %s", id, address);
-        jmethodID jni_mid_read = (*env)->GetMethodID(env, jni_cid_InputStream,
-                                                     "read", "([BII)I");
-        if (!jni_mid_read)
-        {
-            OIC_LOG(ERROR, TAG, "jni_mid_read is null");
-            (*env)->ReleaseStringUTFChars(env, jni_str_address, address);
-            (*env)->DeleteLocalRef(env, jni_str_address);
-            goto exit;
+            return CA_STATUS_FAILED;
         }
 
-        deviceInfo = (CAConnectedDeviceInfo_t *) CAEDRGetDeviceInfoFromAddress(address);
+        CAConnectedDeviceInfo_t *deviceInfo =
+                (CAConnectedDeviceInfo_t *) CAEDRGetDeviceInfoFromAddress(address);
         if (!deviceInfo)
         {
             OIC_LOG(ERROR, TAG, "failed to get device info from list");
             (*env)->ReleaseStringUTFChars(env, jni_str_address, address);
             (*env)->DeleteLocalRef(env, jni_str_address);
-            goto exit;
+            return CA_STATUS_FAILED;
         }
 
-        jint bufSize = (deviceInfo->totalDataLen == 0) ?
-                EDR_MAX_HEADER_LEN : deviceInfo->totalDataLen;
+        jint bufSize = (deviceInfo->totalDataLen == 0) ? EDR_MAX_HEADER_LEN
+                                                       : deviceInfo->totalDataLen;
         if (!deviceInfo->recvData)
         {
             deviceInfo->recvData = OICCalloc(1, bufSize);
@@ -752,30 +625,50 @@ CAResult_t CAEDRNativeReadData(JNIEnv *env, uint32_t id)
                 OIC_LOG(ERROR, TAG, "out of memory");
                 (*env)->ReleaseStringUTFChars(env, jni_str_address, address);
                 (*env)->DeleteLocalRef(env, jni_str_address);
-                goto exit;
+                return CA_STATUS_FAILED;
             }
         }
 
-        jbyteArray jbuf = (*env)->NewByteArray(env, (jint) bufSize - deviceInfo->recvDataLen);
+        jint remainSize = (jint) bufSize - deviceInfo->recvDataLen;
+        if (0 >= remainSize)
+        {
+            OIC_LOG(ERROR, TAG, "remainSize value is invalid.");
+            (*env)->ReleaseStringUTFChars(env, jni_str_address, address);
+            (*env)->DeleteLocalRef(env, jni_str_address);
+            return CA_STATUS_FAILED;
+        }
+
+        jbyteArray jbuf = (*env)->NewByteArray(env, remainSize);
         if (!jbuf)
         {
             OIC_LOG(ERROR, TAG, "jbuf is null");
             (*env)->ReleaseStringUTFChars(env, jni_str_address, address);
             (*env)->DeleteLocalRef(env, jni_str_address);
-            goto exit;
+            return CA_STATUS_FAILED;
+        }
+
+        jmethodID jni_mid_read = CAGetJNIMethodID(env, "java/io/InputStream", "read", "([BII)I");
+        if (!jni_mid_read)
+        {
+            OIC_LOG(ERROR, TAG, "jni_mid_read is null");
+            (*env)->DeleteLocalRef(env, jbuf);
+            (*env)->ReleaseStringUTFChars(env, jni_str_address, address);
+            (*env)->DeleteLocalRef(env, jni_str_address);
+            return CA_STATUS_FAILED;
         }
 
+        OIC_LOG_V(DEBUG, TAG, "read InputStream (idx:%d, addr:%s)", idx, address);
         jint recvLen = (*env)->CallIntMethod(env, jni_obj_inputStream, jni_mid_read,
-                                             jbuf, (jint) 0,
-                                             (jint) bufSize - deviceInfo->recvDataLen);
+                                             jbuf, (jint) 0, remainSize);
         if (-1 == recvLen)
         {
             OIC_LOG(ERROR, TAG, "recvLen is -1");
             (*env)->DeleteLocalRef(env, jbuf);
             (*env)->ReleaseStringUTFChars(env, jni_str_address, address);
             (*env)->DeleteLocalRef(env, jni_str_address);
-            goto exit;
+            return CA_STATUS_FAILED;
         }
+        OIC_LOG_V(DEBUG, TAG, "read success (length: %d bytes)", recvLen);
 
         jbyte* buf = (*env)->GetByteArrayElements(env, jbuf, NULL);
         if (!buf)
@@ -784,12 +677,13 @@ CAResult_t CAEDRNativeReadData(JNIEnv *env, uint32_t id)
             (*env)->DeleteLocalRef(env, jbuf);
             (*env)->ReleaseStringUTFChars(env, jni_str_address, address);
             (*env)->DeleteLocalRef(env, jni_str_address);
-            goto exit;
+            return CA_STATUS_FAILED;
         }
         memcpy(deviceInfo->recvData + deviceInfo->recvDataLen, (const char*) buf, recvLen);
         deviceInfo->recvDataLen += recvLen;
 
-        OIC_LOG(DEBUG, TAG, "read something from InputStream");
+        (*env)->ReleaseByteArrayElements(env, jbuf, buf, 0);
+        (*env)->DeleteLocalRef(env, jbuf);
 
         if (!deviceInfo->totalDataLen)
         {
@@ -806,11 +700,9 @@ CAResult_t CAEDRNativeReadData(JNIEnv *env, uint32_t id)
                 if (!newBuf)
                 {
                     OIC_LOG(ERROR, TAG, "out of memory");
-                    (*env)->ReleaseByteArrayElements(env, jbuf, buf, 0);
-                    (*env)->DeleteLocalRef(env, jbuf);
                     (*env)->ReleaseStringUTFChars(env, jni_str_address, address);
                     (*env)->DeleteLocalRef(env, jni_str_address);
-                    goto exit;
+                    return CA_STATUS_FAILED;
                 }
                 deviceInfo->recvData = newBuf;
             }
@@ -830,17 +722,15 @@ CAResult_t CAEDRNativeReadData(JNIEnv *env, uint32_t id)
                 CAEDRUpdateDeviceState(STATE_DISCONNECTED, address);
                 ca_mutex_unlock(g_mutexStateList);
 
-                (*env)->ReleaseByteArrayElements(env, jbuf, buf, 0);
-                (*env)->DeleteLocalRef(env, jbuf);
                 (*env)->ReleaseStringUTFChars(env, jni_str_address, address);
                 (*env)->DeleteLocalRef(env, jni_str_address);
-                goto exit;
+                return CA_STATUS_FAILED;
             }
 
             if (g_edrPacketReceivedCallback)
             {
-                OIC_LOG_V(DEBUG, TAG,"data will be sent to callback routine: \
-                          %s, %d", deviceInfo->recvData, deviceInfo->recvDataLen);
+                OIC_LOG_V(DEBUG, TAG, "data will be sent to callback routine: %s, %d",
+                          deviceInfo->recvData, deviceInfo->recvDataLen);
 
                 uint32_t sentLength = 0;
                 g_edrPacketReceivedCallback(address, (void*) deviceInfo->recvData,
@@ -852,54 +742,12 @@ CAResult_t CAEDRNativeReadData(JNIEnv *env, uint32_t id)
                 deviceInfo->totalDataLen = 0;
             }
         }
-        (*env)->ReleaseByteArrayElements(env, jbuf, buf, 0);
-        (*env)->DeleteLocalRef(env, jbuf);
+
         (*env)->ReleaseStringUTFChars(env, jni_str_address, address);
         (*env)->DeleteLocalRef(env, jni_str_address);
     }
-    (*env)->DeleteLocalRef(env, jni_cid_InputStream);
-    (*env)->DeleteLocalRef(env, jni_obj_inputStream);
-    (*env)->DeleteLocalRef(env, jni_cid_BTsocket);
 
     return CA_STATUS_OK;
-
-exit:
-    (*env)->DeleteLocalRef(env, jni_cid_InputStream);
-    (*env)->DeleteLocalRef(env, jni_obj_inputStream);
-    (*env)->DeleteLocalRef(env, jni_cid_BTsocket);
-
-    return CA_STATUS_FAILED;
-}
-
-jboolean CAEDRIsConnectedForSocket(JNIEnv *env, jobject socket)
-{
-    if (!socket)
-    {
-        OIC_LOG(ERROR, TAG, "socket is null");
-        return JNI_FALSE;
-    }
-
-    jclass jni_cid_BTsocket = (*env)->FindClass(env, "android/bluetooth/BluetoothSocket");
-    if (!jni_cid_BTsocket)
-    {
-        OIC_LOG(ERROR, TAG, "jni_cid_BTsocket is null");
-        return JNI_FALSE;
-    }
-
-    jmethodID jni_mid_isConnected = (*env)->GetMethodID(env, jni_cid_BTsocket, "isConnected",
-                                                        "()Z");
-    if (!jni_mid_isConnected)
-    {
-        OIC_LOG(ERROR, TAG, "jni_mid_isConnected is null.");
-        (*env)->DeleteLocalRef(env, jni_cid_BTsocket);
-        return JNI_FALSE;
-    }
-
-    jboolean jni_isConnected = (*env)->CallBooleanMethod(env, socket, jni_mid_isConnected);
-
-    (*env)->DeleteLocalRef(env, jni_cid_BTsocket);
-
-    return jni_isConnected;
 }
 
 void CANativeStartListenTask(JNIEnv *env)
@@ -1006,8 +854,6 @@ jobject CAEDRNativeListen(JNIEnv *env)
         return NULL;
     }
 
-    g_serverSocketObject = (*env)->NewGlobalRef(env, jni_obj_BTServerSocket);
-
     OIC_LOG(DEBUG, TAG, "CAEDRNativeListen - OUT");
 
     return jni_obj_BTServerSocket;
@@ -1019,23 +865,16 @@ void CAEDRNativeAccept(JNIEnv *env, jobject serverSocketObject)
 
     if (NULL != serverSocketObject)
     {
-        jclass jni_cid_BTServerSocket = (*env)->FindClass(
-                env, "android/bluetooth/BluetoothServerSocket");
-        if (!jni_cid_BTServerSocket)
-        {
-            OIC_LOG(ERROR, TAG, "jni_cid_BTServerSocket is null");
-            return;
-        }
-
-        jmethodID jni_mid_accept = (*env)->GetMethodID(env, jni_cid_BTServerSocket, "accept",
-                                                       "()Landroid/bluetooth/BluetoothSocket;");
+        jmethodID jni_mid_accept = CAGetJNIMethodID(env, CLASSPATH_BT_SERVER_SOCKET,
+                                                    "accept",
+                                                    "()Landroid/bluetooth/BluetoothSocket;");
         if (!jni_mid_accept)
         {
             OIC_LOG(ERROR, TAG, "jni_mid_accept is null");
             return;
         }
 
-        OIC_LOG(DEBUG, TAG, "initiating accept...");
+        OIC_LOG(DEBUG, TAG, "waiting for the new connection request...");
 
         jobject jni_obj_BTSocket = (*env)->CallObjectMethod(env, serverSocketObject,
                                                             jni_mid_accept);
@@ -1061,15 +900,8 @@ void CAEDRNativeAccept(JNIEnv *env, jobject serverSocketObject)
         }
 
         const char* address = (*env)->GetStringUTFChars(env, j_str_address, NULL);
-        OIC_LOG_V(DEBUG, TAG, "address is %s", address);
-
-        // set socket to list
-        jobject jni_socket = (*env)->NewGlobalRef(env, jni_obj_BTSocket);
-        ca_mutex_lock(g_mutexObjectList);
-        CAEDRNativeAddDeviceSocketToList(env, jni_socket);
-        ca_mutex_unlock(g_mutexObjectList);
 
-        OIC_LOG(DEBUG, TAG, "Accepted!!");
+        OIC_LOG_V(INFO, TAG, "accept a new connection from [%s]", address);
 
         // update state
         ca_mutex_lock(g_mutexStateList);
@@ -1078,6 +910,22 @@ void CAEDRNativeAccept(JNIEnv *env, jobject serverSocketObject)
 
         (*env)->ReleaseStringUTFChars(env, j_str_address, address);
         (*env)->DeleteLocalRef(env, j_str_address);
+
+        // set socket to list
+        jobject jni_socket = (*env)->NewGlobalRef(env, jni_obj_BTSocket);
+        if (!jni_socket)
+        {
+            OIC_LOG(ERROR, TAG, "jni_socket is null");
+            (*env)->DeleteLocalRef(env, jni_obj_BTSocket);
+            return;
+        }
+
+        ca_mutex_lock(g_mutexObjectList);
+        CAEDRNativeAddDeviceSocketToList(env, jni_socket);
+        ca_mutex_unlock(g_mutexObjectList);
+
+        (*env)->DeleteGlobalRef(env, jni_socket);
+        (*env)->DeleteLocalRef(env, jni_obj_BTSocket);
     }
     else
     {
@@ -1096,21 +944,15 @@ void CAEDRNatvieCloseServerTask(JNIEnv* env)
     {
         OIC_LOG(DEBUG, TAG, "Accept Resource will be close");
 
-        jclass jni_cid_BTServerSocket = (*env)->FindClass(
-                env, "android/bluetooth/BluetoothServerSocket");
-        if (!jni_cid_BTServerSocket)
+        jmethodID jni_mid_close = CAGetJNIMethodID(env, CLASSPATH_BT_SERVER_SOCKET,
+                                                   "close", "()V");
+        if (!jni_mid_close)
         {
-            OIC_LOG(ERROR, TAG, "jni_cid_BTServerSocket is null");
+            OIC_LOG(ERROR, TAG, "jni_mid_close is null");
             return;
         }
 
-        jmethodID jni_mid_accept = (*env)->GetMethodID(env, jni_cid_BTServerSocket, "close", "()V");
-        if (!jni_mid_accept)
-        {
-            OIC_LOG(ERROR, TAG, "jni_mid_accept is null");
-            return;
-        }
-        (*env)->CallVoidMethod(env, g_serverSocket, jni_mid_accept);
+        (*env)->CallVoidMethod(env, g_serverSocket, jni_mid_close);
         (*env)->DeleteGlobalRef(env, g_serverSocket);
         g_serverSocket = NULL;
 
index 43edafa..483c90a 100644 (file)
@@ -50,29 +50,17 @@ void CAEDRServerJniInit();
 CAResult_t CAEDRServerStartAcceptThread();
 
 /**
- * Start unicast server.
+ * Start receive thread.
  * @param[in]   isSecured       unicast server type.
  * @return ::CA_STATUS_OK or Appropriate error code.
  */
-CAResult_t CAEDRStartUnicastServer(bool isSecured);
+CAResult_t CAEDRStartReceiveThread(bool isSecured);
 
 /**
- * Start multicast server.
+ * Stop receive thread.
  * @return ::CA_STATUS_OK or Appropriate error code.
  */
-CAResult_t CAEDRStartMulticastServer();
-
-/**
- * Stop unicast server.
- * @return ::CA_STATUS_OK or Appropriate error code.
- */
-CAResult_t CAEDRStopUnicastServer();
-
-/**
- * Stop multicast server.
- * @return ::CA_STATUS_OK or Appropriate error code.
- */
-CAResult_t CAEDRStopMulticastServer();
+CAResult_t CAEDRStopReceiveThread();
 
 /**
  * This function will read the data from remote device.
@@ -96,14 +84,6 @@ void CANativeStartListenTask(JNIEnv *env);
 jobject CAEDRNativeListen(JNIEnv *env);
 
 /**
- * This function will listen the connection from remote device.
- * @param[in]  env              JNI interface pointer.
- * @param[in]  socket           server socket object.
- * @return JNI_TRUE or JNI_FALSE.
- */
-jboolean CAEDRIsConnectedForSocket(JNIEnv *env, jobject socket);
-
-/**
  * This function will accept the connection from remote device.
  * @param[in]  env                  JNI interface pointer.
  * @param[in]  severSocketObject    server socket object.
index 5b682c7..6dc604d 100644 (file)
@@ -27,6 +27,7 @@
 #include "oic_string.h"
 #include "cathreadpool.h"
 #include "uarraylist.h"
+#include "caadapterutils.h"
 
 #define ERROR_CODE (-1)
 #define TAG PCF("OIC_CA_EDR_UTILS")
@@ -43,25 +44,13 @@ static u_arraylist_t *g_deviceObjectList = NULL;
 // get address from bluetooth socket
 jstring CAEDRNativeGetAddressFromDeviceSocket(JNIEnv *env, jobject bluetoothSocketObj)
 {
-    if (!bluetoothSocketObj)
-    {
-        OIC_LOG(ERROR, TAG, "bluetoothSocketObj is null");
-        return NULL;
-    }
+    VERIFY_NON_NULL_RET(bluetoothSocketObj, TAG, "bluetoothSocketObj", NULL);
 
-    jclass jni_cid_BTSocket = (*env)->FindClass(env, CLASSPATH_BT_SOCKET);
-    if (!jni_cid_BTSocket)
-    {
-        OIC_LOG(ERROR, TAG, "jni_cid_BTSocket is null");
-        return NULL;
-    }
-
-    jmethodID jni_mid_getRemoteDevice = (*env)->GetMethodID(
-            env, jni_cid_BTSocket, "getRemoteDevice", "()Landroid/bluetooth/BluetoothDevice;");
+    jmethodID jni_mid_getRemoteDevice = CAGetJNIMethodID(
+            env, CLASSPATH_BT_SOCKET, "getRemoteDevice", "()Landroid/bluetooth/BluetoothDevice;");
     if (!jni_mid_getRemoteDevice)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_getRemoteDevice is null");
-        (*env)->DeleteLocalRef(env, jni_cid_BTSocket);
         return NULL;
     }
 
@@ -70,42 +59,29 @@ jstring CAEDRNativeGetAddressFromDeviceSocket(JNIEnv *env, jobject bluetoothSock
     if (!jni_obj_remoteBTDevice)
     {
         OIC_LOG(ERROR, TAG, "jni_obj_remoteBTDevice is null");
-        (*env)->DeleteLocalRef(env, jni_cid_BTSocket);
         return NULL;
     }
 
-    jclass jni_cid_BTDevice = (*env)->FindClass(env, CLASSPATH_BT_DEVICE);
-    if (!jni_cid_BTDevice)
-    {
-        OIC_LOG(ERROR, TAG, "jni_cid_BTDevice is null");
-        (*env)->DeleteLocalRef(env, jni_obj_remoteBTDevice);
-        (*env)->DeleteLocalRef(env, jni_cid_BTSocket);
-        return NULL;
-    }
-    jmethodID j_mid_getAddress = (*env)->GetMethodID(env, jni_cid_BTDevice, "getAddress",
-                                                     METHODID_STRINGNONPARAM);
+    jmethodID j_mid_getAddress = CAGetJNIMethodID(env, CLASSPATH_BT_DEVICE,
+                                                  "getAddress",
+                                                  METHODID_STRINGNONPARAM);
     if (!j_mid_getAddress)
     {
         OIC_LOG(ERROR, TAG, "j_mid_getAddress is null");
         (*env)->DeleteLocalRef(env, jni_obj_remoteBTDevice);
-        (*env)->DeleteLocalRef(env, jni_cid_BTDevice);
-        (*env)->DeleteLocalRef(env, jni_cid_BTSocket);
         return NULL;
     }
 
-    jstring j_str_address = (*env)->CallObjectMethod(env, jni_obj_remoteBTDevice, j_mid_getAddress);
+    jstring j_str_address = (*env)->CallObjectMethod(env, jni_obj_remoteBTDevice,
+                                                     j_mid_getAddress);
     if (!j_str_address)
     {
         OIC_LOG(ERROR, TAG, "j_str_address is null");
         (*env)->DeleteLocalRef(env, jni_obj_remoteBTDevice);
-        (*env)->DeleteLocalRef(env, jni_cid_BTDevice);
-        (*env)->DeleteLocalRef(env, jni_cid_BTSocket);
         return NULL;
     }
 
     (*env)->DeleteLocalRef(env, jni_obj_remoteBTDevice);
-    (*env)->DeleteLocalRef(env, jni_cid_BTDevice);
-    (*env)->DeleteLocalRef(env, jni_cid_BTSocket);
 
     return j_str_address;
 }
@@ -215,15 +191,8 @@ jobjectArray CAEDRNativeGetBondedDevices(JNIEnv *env)
 
     // Convert the set to an object array
     // object[] array = Set<BluetoothDevice>.toArray();
-    jclass jni_cid_Set = (*env)->FindClass(env, "java/util/Set");
-    if (!jni_cid_Set)
-    {
-        OIC_LOG(ERROR, TAG, "jni_cid_Set is null");
-        goto exit;
-    }
-    jmethodID jni_mid_toArray = (*env)->GetMethodID(env, jni_cid_Set, "toArray",
-                                                    "()[Ljava/lang/Object;");
-
+    jmethodID jni_mid_toArray = CAGetJNIMethodID(env, "java/util/Set",
+                                                 "toArray", "()[Ljava/lang/Object;");
     if (!jni_mid_toArray)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_toArray is null");
@@ -325,20 +294,12 @@ jboolean CAEDRNativeIsEnableBTAdapter(JNIEnv *env)
 
 jstring CAEDRNativeGetAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice)
 {
-    if (!bluetoothDevice)
-    {
-        OIC_LOG(ERROR, TAG, "bluetoothDevice is null");
-        return NULL;
-    }
-    jclass jni_cid_device_list = (*env)->FindClass(env, "android/bluetooth/BluetoothDevice");
-    if (!jni_cid_device_list)
-    {
-        OIC_LOG(ERROR, TAG, "jni_cid_device_list is null");
-        return NULL;
-    }
+    VERIFY_NON_NULL_RET(bluetoothDevice, TAG, "bluetoothDevice", NULL);
 
-    jmethodID jni_mid_getAddress = (*env)->GetMethodID(env, jni_cid_device_list, "getAddress",
-                                                       METHODID_STRINGNONPARAM);
+    jmethodID jni_mid_getAddress = CAGetJNIMethodID(env,
+                                                    CLASSPATH_BT_DEVICE,
+                                                    "getAddress",
+                                                    METHODID_STRINGNONPARAM);
     if (!jni_mid_getAddress)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_getAddress is null");
@@ -373,11 +334,8 @@ void CAEDRNativeCreateDeviceStateList()
 
 void CAEDRUpdateDeviceState(CAConnectedState_t state, const char *address)
 {
-    if (!address)
-    {
-        OIC_LOG(ERROR, TAG, "address is null");
-        return;
-    }
+    VERIFY_NON_NULL_VOID(address, TAG, "address");
+
     CAConnectedDeviceInfo_t *deviceInfo =
             (CAConnectedDeviceInfo_t *) OICCalloc(1, sizeof(CAConnectedDeviceInfo_t));
     if (!deviceInfo)
@@ -393,11 +351,7 @@ void CAEDRUpdateDeviceState(CAConnectedState_t state, const char *address)
 
 void CAEDRNativeAddDeviceStateToList(CAConnectedDeviceInfo_t *deviceInfo)
 {
-    if (!deviceInfo)
-    {
-        OIC_LOG(ERROR, TAG, "device is null");
-        return;
-    }
+    VERIFY_NON_NULL_VOID(deviceInfo, TAG, "deviceInfo");
 
     if (!g_deviceStateList)
     {
@@ -411,16 +365,12 @@ void CAEDRNativeAddDeviceStateToList(CAConnectedDeviceInfo_t *deviceInfo)
         CAEDRNativeRemoveDevice((const char*) deviceInfo->address);
     }
     u_arraylist_add(g_deviceStateList, deviceInfo); // update new state
-    OIC_LOG_V(DEBUG, TAG, "Set State Info to List : %d", deviceInfo->state);
+    OIC_LOG_V(DEBUG, TAG, "add new device state[%d] to list", deviceInfo->state);
 }
 
 bool CAEDRNativeIsDeviceInList(const char* remoteAddress)
 {
-    if (!remoteAddress)
-    {
-        OIC_LOG(ERROR, TAG, "remoteAddress is null");
-        return false;
-    }
+    VERIFY_NON_NULL_RET(remoteAddress, TAG, "remoteAddress", false);
 
     jint length = u_arraylist_length(g_deviceStateList);
     for (jint index = 0; index < length; index++)
@@ -476,17 +426,13 @@ void CAEDRNativeRemoveAllDeviceState()
 void CAEDRNativeRemoveDevice(const char *remoteAddress)
 {
     OIC_LOG(DEBUG, TAG, "CAEDRNativeRemoveDeviceforStateList");
+    VERIFY_NON_NULL_VOID(remoteAddress, TAG, "remoteAddress");
 
     if (!g_deviceStateList)
     {
         OIC_LOG(ERROR, TAG, "gdeviceStateList is null");
         return;
     }
-    if (!remoteAddress)
-    {
-        OIC_LOG(ERROR, TAG, "remoteAddress is null");
-        return;
-    }
 
     jint length = u_arraylist_length(g_deviceStateList);
     for (jint index = 0; index < length; index++)
@@ -501,7 +447,7 @@ void CAEDRNativeRemoveDevice(const char *remoteAddress)
 
         if (!strcmp((const char*) deviceInfo->address, remoteAddress))
         {
-            OIC_LOG_V(DEBUG, TAG, "remove state : %s", remoteAddress);
+            OIC_LOG_V(DEBUG, TAG, "remove [%s] info from list", remoteAddress);
             OICFree(deviceInfo);
 
             u_arraylist_remove(g_deviceStateList, index);
@@ -514,12 +460,7 @@ void CAEDRNativeRemoveDevice(const char *remoteAddress)
 CAConnectedState_t CAEDRIsConnectedDevice(const char *remoteAddress)
 {
     OIC_LOG(DEBUG, TAG, "CAEDRIsConnectedDevice");
-
-    if (!remoteAddress)
-    {
-        OIC_LOG(ERROR, TAG, "remoteAddress is null");
-        return STATE_DISCONNECTED;
-    }
+    VERIFY_NON_NULL_RET(remoteAddress, TAG, "remoteAddress", STATE_DISCONNECTED);
 
     if (!g_deviceStateList)
     {
@@ -565,12 +506,7 @@ void CAEDRNativeCreateDeviceSocketList()
 void CAEDRNativeAddDeviceSocketToList(JNIEnv *env, jobject deviceSocket)
 {
     OIC_LOG(DEBUG, TAG, "CANativeAddDeviceobjToList");
-
-    if (!deviceSocket)
-    {
-        OIC_LOG(ERROR, TAG, "Device is null");
-        return;
-    }
+    VERIFY_NON_NULL_VOID(deviceSocket, TAG, "deviceSocket");
 
     if (!g_deviceObjectList)
     {
@@ -587,31 +523,71 @@ void CAEDRNativeAddDeviceSocketToList(JNIEnv *env, jobject deviceSocket)
 
     const char* remoteAddress = (*env)->GetStringUTFChars(env, jni_remoteAddress, NULL);
 
-    if (!CAEDRNativeIsDeviceSocketInList(env, remoteAddress))
+    if (CAEDRNativeIsDeviceSocketInList(env, remoteAddress))
     {
-        jobject gDeviceSocker = (*env)->NewGlobalRef(env, deviceSocket);
-        u_arraylist_add(g_deviceObjectList, gDeviceSocker);
-        OIC_LOG(DEBUG, TAG, "Set Socket Object to Array");
+        OIC_LOG(DEBUG, TAG, "the address exists in deviceObjectList. remove it to add new");
+        CAEDRNativeRemoveDeviceSocketBaseAddr(env, jni_remoteAddress);
     }
+
     (*env)->ReleaseStringUTFChars(env, jni_remoteAddress, remoteAddress);
     (*env)->DeleteLocalRef(env, jni_remoteAddress);
+
+    CAEDRSocketInfo_t *socketInfo = (CAEDRSocketInfo_t *) OICCalloc(1, sizeof(*socketInfo));
+    if (!socketInfo)
+    {
+        OIC_LOG(ERROR, TAG, "Out of memory");
+        return;
+    }
+
+    jmethodID jni_mid_getInputStream = CAGetJNIMethodID(env, "android/bluetooth/BluetoothSocket",
+                                                             "getInputStream",
+                                                             "()Ljava/io/InputStream;");
+    if (!jni_mid_getInputStream)
+    {
+        OIC_LOG(ERROR, TAG, "jni_mid_getInputStream is null");
+        return;
+    }
+
+    jobject jni_obj_inputStream = (*env)->CallObjectMethod(env, deviceSocket,
+                                                           jni_mid_getInputStream);
+    if (!jni_obj_inputStream)
+    {
+        OIC_LOG(ERROR, TAG, "jni_obj_inputStream is null");
+        return;
+    }
+
+    socketInfo->deviceSocket = (*env)->NewGlobalRef(env, deviceSocket);
+    socketInfo->inputStream = (*env)->NewGlobalRef(env, jni_obj_inputStream);
+    (*env)->DeleteLocalRef(env, jni_obj_inputStream);
+
+    bool result = u_arraylist_add(g_deviceObjectList, (void *) socketInfo);
+    if (!result)
+    {
+        OIC_LOG(ERROR, TAG, "u_arraylist_add failed.");
+        OICFree(socketInfo);
+        return;
+    }
+
+    OIC_LOG(DEBUG, TAG, "add new device socket object to list");
 }
 
 bool CAEDRNativeIsDeviceSocketInList(JNIEnv *env, const char* remoteAddress)
 {
     OIC_LOG(DEBUG, TAG, "CANativeIsDeviceObjInList");
+    VERIFY_NON_NULL_RET(remoteAddress, TAG, "remoteAddress", false);
 
-    if (!remoteAddress)
-    {
-        OIC_LOG(ERROR, TAG, "remoteAddress is null");
-        return false;
-    }
-
-    jint length = u_arraylist_length(g_deviceStateList);
+    jint length = u_arraylist_length(g_deviceObjectList);
     for (jint index = 0; index < length; index++)
     {
+        CAEDRSocketInfo_t *socketInfo = (CAEDRSocketInfo_t *) u_arraylist_get(g_deviceObjectList,
+                                                                              index);
+        if (!socketInfo)
+        {
+            OIC_LOG(DEBUG, TAG, "socketInfo is null");
+            return false;
+        }
 
-        jobject jarrayObj = (jobject) u_arraylist_get(g_deviceObjectList, index);
+        jobject jarrayObj = socketInfo->deviceSocket;
         if (!jarrayObj)
         {
             OIC_LOG(DEBUG, TAG, "jarrayObj is null");
@@ -645,7 +621,7 @@ bool CAEDRNativeIsDeviceSocketInList(JNIEnv *env, const char* remoteAddress)
         }
     }
 
-    OIC_LOG(DEBUG, TAG, "there are no the Device obejct in list. we can add");
+    OIC_LOG(DEBUG, TAG, "there are no the Device obejct in list");
     return false;
 }
 
@@ -659,21 +635,15 @@ void CAEDRNativeSocketCloseToAll(JNIEnv *env)
         return;
     }
 
-    jclass jni_cid_BTSocket = (*env)->FindClass(env, CLASSPATH_BT_SOCKET);
-    if (!jni_cid_BTSocket)
-    {
-        OIC_LOG(ERROR, TAG, "jni_cid_BTSocket is null");
-        return;
-    }
-
-    jmethodID jni_mid_close = (*env)->GetMethodID(env, jni_cid_BTSocket, "close", "()V");
+    jmethodID jni_mid_close = CAGetJNIMethodID(env, CLASSPATH_BT_SOCKET,
+                                               "close", "()V");
     if (!jni_mid_close)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_close is null");
         return;
     }
 
-    jint length = u_arraylist_length(g_deviceStateList);
+    jint length = u_arraylist_length(g_deviceObjectList);
     for (jint index = 0; index < length; index++)
     {
         jobject jni_obj_socket = (jobject) u_arraylist_get(g_deviceObjectList, index);
@@ -705,16 +675,28 @@ void CAEDRNativeRemoveAllDeviceSocket(JNIEnv *env)
         return;
     }
 
-    jint length = u_arraylist_length(g_deviceStateList);
+    jint length = u_arraylist_length(g_deviceObjectList);
     for (jint index = 0; index < length; index++)
     {
-        jobject jarrayObj = (jobject) u_arraylist_get(g_deviceObjectList, index);
-        if (!jarrayObj)
+        CAEDRSocketInfo_t *socketInfo = (CAEDRSocketInfo_t *) u_arraylist_get(g_deviceObjectList,
+                                                                              index);
+        if (!socketInfo)
         {
-            OIC_LOG(ERROR, TAG, "jarrayObj is null");
-            return;
+            OIC_LOG(ERROR, TAG, "socketInfo is null");
+            continue;
+        }
+
+        jobject jdeviceSocket = socketInfo->deviceSocket;
+        if (jdeviceSocket)
+        {
+            (*env)->DeleteGlobalRef(env, jdeviceSocket);
+        }
+
+        jobject jinputStream = socketInfo->inputStream;
+        if (jinputStream)
+        {
+            (*env)->DeleteGlobalRef(env, jinputStream);
         }
-        (*env)->DeleteGlobalRef(env, jarrayObj);
     }
 
     OICFree(g_deviceObjectList);
@@ -725,61 +707,24 @@ void CAEDRNativeRemoveAllDeviceSocket(JNIEnv *env)
 void CAEDRNativeRemoveDeviceSocket(JNIEnv *env, jobject deviceSocket)
 {
     OIC_LOG(DEBUG, TAG, "CAEDRNativeRemoveDeviceSocket");
+    VERIFY_NON_NULL_VOID(deviceSocket, TAG, "deviceSocket");
 
-    if (!g_deviceObjectList)
+    jstring jni_address = CAEDRNativeGetAddressFromDeviceSocket(env, deviceSocket);
+    if (!jni_address)
     {
-        OIC_LOG(ERROR, TAG, "gdeviceObjectList is null");
+        OIC_LOG(ERROR, TAG, "jni_address is null");
         return;
     }
 
-    jint length = u_arraylist_length(g_deviceStateList);
-    for (jint index = 0; index < length; index++)
-    {
-        jobject jarrayObj = (jobject) u_arraylist_get(g_deviceObjectList, index);
-        if (!jarrayObj)
-        {
-            OIC_LOG(DEBUG, TAG, "jarrayObj is null");
-            continue;
-        }
-
-        jstring jni_setAddress = CAEDRNativeGetAddressFromDeviceSocket(env, jarrayObj);
-        if (!jni_setAddress)
-        {
-            OIC_LOG(DEBUG, TAG, "jni_setAddress is null");
-            continue;
-        }
-
-        jstring jni_remoteAddress = CAEDRNativeGetAddressFromDeviceSocket(env, deviceSocket);
-        if (!jni_remoteAddress)
-        {
-            OIC_LOG(DEBUG, TAG, "jni_remoteAddress is null");
-            continue;
-        }
+    CAEDRNativeRemoveDeviceSocketBaseAddr(env, jni_address);
 
-        const char* setAddress = (*env)->GetStringUTFChars(env, jni_setAddress, NULL);
-        const char* remoteAddress = (*env)->GetStringUTFChars(env, jni_remoteAddress, NULL);
-
-        if (!strcmp(setAddress, remoteAddress))
-        {
-            OIC_LOG_V(DEBUG, TAG, "remove object : %s", remoteAddress);
-            (*env)->DeleteGlobalRef(env, jarrayObj);
-            (*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
-            (*env)->ReleaseStringUTFChars(env, jni_remoteAddress, remoteAddress);
-
-            u_arraylist_remove(g_deviceObjectList, index);
-            break;
-        }
-        (*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
-        (*env)->ReleaseStringUTFChars(env, jni_remoteAddress, remoteAddress);
-    }
-
-    OIC_LOG(DEBUG, TAG, "there are no target object");
     return;
 }
 
 void CAEDRNativeRemoveDeviceSocketBaseAddr(JNIEnv *env, jstring address)
 {
-    OIC_LOG(DEBUG, TAG, "CAEDRNativeRemoveDeviceSocket");
+    OIC_LOG(DEBUG, TAG, "CAEDRNativeRemoveDeviceSocketBaseAddr");
+    VERIFY_NON_NULL_VOID(address, TAG, "address");
 
     if (!g_deviceObjectList)
     {
@@ -787,10 +732,20 @@ void CAEDRNativeRemoveDeviceSocketBaseAddr(JNIEnv *env, jstring address)
         return;
     }
 
-    jint length = u_arraylist_length(g_deviceStateList);
+    const char* targetAddress = (*env)->GetStringUTFChars(env, address, NULL);
+
+    jint length = u_arraylist_length(g_deviceObjectList);
     for (jint index = 0; index < length; index++)
     {
-        jobject jarrayObj = (jobject) u_arraylist_get(g_deviceObjectList, index);
+        CAEDRSocketInfo_t *socketInfo = (CAEDRSocketInfo_t *) u_arraylist_get(g_deviceObjectList,
+                                                                              index);
+        if (!socketInfo)
+        {
+            OIC_LOG(ERROR, TAG, "socketInfo is null");
+            continue;
+        }
+
+        jobject jarrayObj = socketInfo->deviceSocket;
         if (!jarrayObj)
         {
             OIC_LOG(DEBUG, TAG, "jarrayObj is null");
@@ -803,28 +758,37 @@ void CAEDRNativeRemoveDeviceSocketBaseAddr(JNIEnv *env, jstring address)
             OIC_LOG(ERROR, TAG, "jni_setAddress is null");
             continue;
         }
+
         const char* setAddress = (*env)->GetStringUTFChars(env, jni_setAddress, NULL);
-        const char* remoteAddress = (*env)->GetStringUTFChars(env, address, NULL);
 
-        if (!strcmp(setAddress, remoteAddress))
+        if (!strcmp(setAddress, targetAddress))
         {
-            OIC_LOG_V(ERROR, TAG, "remove object : %s", remoteAddress);
+            OIC_LOG_V(DEBUG, TAG, "remove object : %s", targetAddress);
             (*env)->DeleteGlobalRef(env, jarrayObj);
+            jobject jinputStream = socketInfo->inputStream;
+            if (jinputStream)
+            {
+                (*env)->DeleteGlobalRef(env, jinputStream);
+            }
+            (*env)->ReleaseStringUTFChars(env, address, targetAddress);
             (*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
-            (*env)->ReleaseStringUTFChars(env, address, remoteAddress);
+            (*env)->DeleteLocalRef(env, jni_setAddress);
 
             u_arraylist_remove(g_deviceObjectList, index);
-            break;
+            return;
         }
         (*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
-        (*env)->ReleaseStringUTFChars(env, address, remoteAddress);
+        (*env)->DeleteLocalRef(env, jni_setAddress);
     }
 
-    OIC_LOG(DEBUG, TAG, "there are no target object");
+    OIC_LOG_V(DEBUG, TAG, "the target object doesn't exist in deviceObjectList (addr: %s)",
+              targetAddress);
+    (*env)->ReleaseStringUTFChars(env, address, targetAddress);
+
     return;
 }
 
-jobject CAEDRNativeGetDeviceSocket(uint32_t idx)
+jobject CAEDRNativeGetDeviceSocket(uint32_t index)
 {
     if (!g_deviceObjectList)
     {
@@ -832,7 +796,15 @@ jobject CAEDRNativeGetDeviceSocket(uint32_t idx)
         return NULL;
     }
 
-    jobject jarrayObj = (jobject) u_arraylist_get(g_deviceObjectList, idx);
+    CAEDRSocketInfo_t *socketInfo = (CAEDRSocketInfo_t *) u_arraylist_get(g_deviceObjectList,
+                                                                          index);
+    if (!socketInfo)
+    {
+        OIC_LOG(ERROR, TAG, "socketInfo is null");
+        return NULL;
+    }
+
+    jobject jarrayObj = socketInfo->deviceSocket;
     if (!jarrayObj)
     {
         OIC_LOG(ERROR, TAG, "jarrayObj is not available");
@@ -843,7 +815,8 @@ jobject CAEDRNativeGetDeviceSocket(uint32_t idx)
 
 jobject CAEDRNativeGetDeviceSocketBaseAddr(JNIEnv *env, const char* remoteAddress)
 {
-    OIC_LOG(DEBUG, TAG, "CAEDRNativeGetDeviceSocket");
+    OIC_LOG(DEBUG, TAG, "CAEDRNativeGetDeviceSocketBaseAddr");
+    VERIFY_NON_NULL_RET(remoteAddress, TAG, "remoteAddress", NULL);
 
     if (!g_deviceObjectList)
     {
@@ -851,10 +824,18 @@ jobject CAEDRNativeGetDeviceSocketBaseAddr(JNIEnv *env, const char* remoteAddres
         return NULL;
     }
 
-    jint length = u_arraylist_length(g_deviceStateList);
+    jint length = u_arraylist_length(g_deviceObjectList);
     for (jint index = 0; index < length; index++)
     {
-        jobject jarrayObj = (jobject) u_arraylist_get(g_deviceObjectList, index);
+        CAEDRSocketInfo_t *socketInfo = (CAEDRSocketInfo_t *) u_arraylist_get(g_deviceObjectList,
+                                                                              index);
+        if (!socketInfo)
+        {
+            OIC_LOG(ERROR, TAG, "socketInfo is null");
+            continue;
+        }
+
+        jobject jarrayObj = socketInfo->deviceSocket;
         if (!jarrayObj)
         {
             OIC_LOG(ERROR, TAG, "jarrayObj is null");
@@ -883,6 +864,31 @@ jobject CAEDRNativeGetDeviceSocketBaseAddr(JNIEnv *env, const char* remoteAddres
     return NULL;
 }
 
+jobject CAEDRNativeGetInputStream(uint32_t index)
+{
+    if (!g_deviceObjectList)
+    {
+        OIC_LOG(ERROR, TAG, "gdeviceObjectList is null");
+        return NULL;
+    }
+
+    CAEDRSocketInfo_t *socketInfo = (CAEDRSocketInfo_t *) u_arraylist_get(g_deviceObjectList,
+                                                                          index);
+    if (!socketInfo)
+    {
+        OIC_LOG(ERROR, TAG, "socketInfo is null");
+        return NULL;
+    }
+
+    jobject jarrayObj = socketInfo->inputStream;
+    if (!jarrayObj)
+    {
+        OIC_LOG(ERROR, TAG, "jarrayObj is not available");
+        return NULL;
+    }
+    return jarrayObj;
+}
+
 uint32_t CAEDRGetSocketListLength()
 {
     if (!g_deviceObjectList)
@@ -891,25 +897,19 @@ uint32_t CAEDRGetSocketListLength()
         return 0;
     }
 
-    uint32_t length = u_arraylist_length(g_deviceObjectList);
-
-    return length;
+    return u_arraylist_length(g_deviceObjectList);
 }
 
 CAConnectedDeviceInfo_t *CAEDRGetDeviceInfoFromAddress(const char *remoteAddress)
 {
     OIC_LOG(DEBUG, TAG, "CAEDRGetDeviceInfoFromAddress");
+    VERIFY_NON_NULL_RET(remoteAddress, TAG, "remoteAddress", NULL);
 
     if (!g_deviceStateList)
     {
         OIC_LOG(ERROR, TAG, "gdeviceStateList is null");
         return NULL;
     }
-    if (!remoteAddress)
-    {
-        OIC_LOG(ERROR, TAG, "remoteAddress is null");
-        return NULL;
-    }
 
     jint length = u_arraylist_length(g_deviceStateList);
     for (jint index = 0; index < length; index++)
index 7d1601e..6b83897 100644 (file)
@@ -36,6 +36,15 @@ extern "C"
 #endif
 
 /**
+ * EDR Socket Information for EDR transport
+ */
+typedef struct
+{
+    jobject deviceSocket;   /**< Bluetooth device socket info */
+    jobject inputStream;    /**< InputStream for read data */
+} CAEDRSocketInfo_t;
+
+/**
  * Get address from device socket.
  * @param[in]   env                 JNI interface pointer.
  * @param[in]   bluetoothSocketObj  bluetooth socket object.
@@ -170,10 +179,10 @@ void CAEDRNativeRemoveDeviceSocketBaseAddr(JNIEnv *env, jstring address);
 
 /**
  * Get device socket object from the list.
- * @param[in]  idx              index of device list.
+ * @param[in]  index            index of device list.
  * @return Device socket object or NULL.
  */
-jobject CAEDRNativeGetDeviceSocket(uint32_t idx);
+jobject CAEDRNativeGetDeviceSocket(uint32_t index);
 
 /**
  * Get device socket address.
@@ -184,6 +193,13 @@ jobject CAEDRNativeGetDeviceSocket(uint32_t idx);
 jobject CAEDRNativeGetDeviceSocketBaseAddr(JNIEnv *env, const char* remoteAddress);
 
 /**
+ * Get input stream object from the list.
+ * @param[in]   index           index of device list.
+ * @return Input stream object or NULL.
+ */
+jobject CAEDRNativeGetInputStream(uint32_t index);
+
+/**
  * Get length of device socket list.
  * @return length of list.
  */
index 1050749..eb79e93 100644 (file)
@@ -39,12 +39,21 @@ Java_org_iotivity_ca_CaEdrInterface_caEdrStateChangedCallback
 /*
  * Class:     org_iotivity_ca_CaEdrInterface
  * Method:    caEdrBondStateChangedCallback
- * Signature: (I)V
+ * Signature: (java/lang/String)V
  */
 JNIEXPORT void JNICALL
 Java_org_iotivity_ca_CaEdrInterface_caEdrBondStateChangedCallback
 (JNIEnv *, jobject, jstring);
 
+/*
+ * Class:     org_iotivity_ca_CaEdrInterface
+ * Method:    caEdrConnectionStateChangedCallback
+ * Signature: (java/lang/String;I)V
+ */
+JNIEXPORT void JNICALL
+Java_org_iotivity_ca_CaEdrInterface_caEdrConnectionStateChangedCallback
+(JNIEnv *, jobject, jstring, jint);
+
 #ifdef __cplusplus
 }
 #endif
index 9a1c018..f0b3fdf 100644 (file)
 #include "pdu.h"
 
 /**
- * @var EDR_ADAPTER_TAG
- * @brief Logging tag for module name.
+ * Logging tag for module name.
  */
-#define EDR_ADAPTER_TAG "OIC_CA_EDR_ADAP"
+#define TAG "OIC_CA_EDR_ADAP"
 
 /**
- * @var g_edrThreadPool
- * @brief Reference to threadpool.
+ * Reference to threadpool.
  */
 static ca_thread_pool_t g_edrThreadPool = NULL;
 
 /**
- * @var g_sendQueueHandle
- * @brief Queue handle for Send Data
+ * Queue handle for Send Data
  */
 static CAQueueingThread_t *g_sendQueueHandle = NULL;
 
 /**
- * @var g_recvQueueHandle
- * @brief Queue handle for Receive Data
+ * Queue handle for Receive Data
  */
 static CAQueueingThread_t *g_recvQueueHandle = NULL;
 
 /**
- * @var g_adapterState
- * @brief Storing Adapter state information
+ * Storing Adapter state information
  */
 static bool g_adapterState = true;
 
 /**
- * @var g_networkPacketReceivedCallback
- * @brief Maintains the callback to be notified on receival of network packets from other
- *          Bluetooth devices.
+ * Maintains the callback to be notified on receival of network packets from other
+ * Bluetooth devices.
  */
 static CANetworkPacketReceivedCallback g_networkPacketReceivedCallback = NULL;
 
 /**
- * @var g_networkChangeCallback
- * @brief Maintains the callback to be notified on local bluetooth adapter status change.
+ * Maintains the callback to be notified on local bluetooth adapter status change.
  */
-static CANetworkChangeCallback g_networkChangeCallback = NULL;
+static CAAdapterChangeCallback g_adapterChangeCallback = NULL;
 
 /**
- * @var g_errorCallback
- * @brief error Callback to CA adapter
+ * error Callback to CA adapter
  */
 static CAErrorHandleCallback g_errorCallback = NULL;
 
 /**
- * @var g_localConnectivity
- * @brief Information of local Bluetooth adapter.
+ * Information of local Bluetooth adapter.
  */
 static CAEndpoint_t *g_localConnectivity = NULL;
 
 /**
- * @var g_serverState
- * @brief Storing Rfcommserver state information
+ * Storing Rfcommserver state information
  */
 static bool g_serverState = false;
 
@@ -139,29 +129,28 @@ static void CAEDRErrorHandler(const char *remoteAddress, const uint8_t *data,
 
 CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
                            CANetworkPacketReceivedCallback packetReceivedCallback,
-                           CANetworkChangeCallback networkStateChangeCallback,
+                           CAAdapterChangeCallback netCallback,
+                           CAConnectionChangeCallback connCallback,
                            CAErrorHandleCallback errorCallback, ca_thread_pool_t handle)
 {
     // Input validation
-    VERIFY_NON_NULL(registerCallback, EDR_ADAPTER_TAG, "register callback is NULL");
-    VERIFY_NON_NULL(packetReceivedCallback, EDR_ADAPTER_TAG, "data receive callback is NULL");
-    VERIFY_NON_NULL(networkStateChangeCallback, EDR_ADAPTER_TAG,
-                    "network state change callback is NULL");
-    VERIFY_NON_NULL(handle, EDR_ADAPTER_TAG, "Thread pool handle is NULL");
+    VERIFY_NON_NULL(registerCallback, TAG, "register callback is NULL");
+    VERIFY_NON_NULL(packetReceivedCallback, TAG, "data receive callback is NULL");
+    VERIFY_NON_NULL(netCallback, TAG, "adapter state change callback is NULL");
+    VERIFY_NON_NULL(connCallback, TAG, "connection state change callback is NULL");
+    VERIFY_NON_NULL(handle, TAG, "Thread pool handle is NULL");
 
     // Register the callbacks
-
     g_edrThreadPool = handle;
     g_networkPacketReceivedCallback = packetReceivedCallback;
-    g_networkChangeCallback = networkStateChangeCallback;
+    g_adapterChangeCallback = netCallback;
     g_errorCallback = errorCallback;
 
     // Initialize EDR Network Monitor
     CAResult_t res = CAEDRInitializeNetworkMonitor(handle);
     if (CA_STATUS_OK != res)
     {
-        OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "EDR N/w Monitor Initialize failed!, error number [%d]",
-                  res);
+        OIC_LOG_V(ERROR, TAG, "EDR N/w Monitor Initialize failed!, error number [%d]", res);
         return res;
     }
 
@@ -171,14 +160,14 @@ CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
     res = CAEDRClientInitialize();
     if (CA_STATUS_OK != res)
     {
-        OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "EDR Client Initialize failed, error number [%d]", res);
+        OIC_LOG_V(ERROR, TAG, "EDR Client Initialize failed, error number [%d]", res);
         return res;
     }
 
     res = CAEDRServerInitialize(handle);
     if (CA_STATUS_OK != res)
     {
-        OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "EDR Server Initialize failed, error number [%d]", res);
+        OIC_LOG_V(ERROR, TAG, "EDR Server Initialize failed, error number [%d]", res);
         return res;
     }
 
@@ -198,7 +187,7 @@ CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
         };
     registerCallback(handler);
 
-    OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
+    OIC_LOG(DEBUG, TAG, "OUT");
     return CA_STATUS_OK;
 }
 
@@ -208,34 +197,34 @@ CAResult_t CAStartEDR()
     CAResult_t ret = CAEDRStartNetworkMonitor();
     if (CA_STATUS_OK != ret)
     {
-       OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to Start n/w monitor");
+       OIC_LOG(ERROR, TAG, "Failed to Start n/w monitor");
     }
 
     // Get Bluetooth adapter state
     bool adapterState = false;
     if (CA_STATUS_OK != CAEDRGetAdapterEnableState(&adapterState))
     {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to get adapter enable state");
+        OIC_LOG(ERROR, TAG, "Failed to get adapter enable state");
         return CA_STATUS_FAILED;
     }
 
     if (false == adapterState)
     {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Bluetooth adapter is disabled!");
+        OIC_LOG(ERROR, TAG, "Bluetooth adapter is disabled!");
         g_adapterState = false;
         return CA_ADAPTER_NOT_ENABLED;
     }
 
     if (CA_STATUS_OK != (ret = CAEDRClientSetCallbacks()))
     {
-        OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Start Network Monitor failed!, error number [%d] ",
+        OIC_LOG_V(ERROR, TAG, "Start Network Monitor failed!, error number [%d] ",
                   ret);
     }
 
     // Initialize Send/Receive data message queues
     if (CA_STATUS_OK != (ret = CAEDRInitializeQueueHandlers()))
     {
-        OIC_LOG_V(ERROR, EDR_ADAPTER_TAG,
+        OIC_LOG_V(ERROR, TAG,
                   "CAAdapterInitializeQueues failed!, error number [%d] ", ret);
         CATerminateEDR();
         return CA_STATUS_FAILED;
@@ -244,7 +233,7 @@ CAResult_t CAStartEDR()
     // Start Send/Receive data message queues
     if (CA_STATUS_OK != (ret = CAAdapterStartQueue()))
     {
-        OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "CAAdapterStartQueue failed!, error number [%d] ", ret);
+        OIC_LOG_V(ERROR, TAG, "CAAdapterStartQueue failed!, error number [%d] ", ret);
     }
 
     return ret;
@@ -267,7 +256,7 @@ CAResult_t CAStartEDRDiscoveryServer()
     CAResult_t result = CAEDRStartDeviceDiscovery();
     if(CA_STATUS_OK != result)
     {
-        OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "Failed to Start Device discovery");
+        OIC_LOG(DEBUG, TAG, "Failed to Start Device discovery");
     }
 #endif
 
@@ -278,18 +267,18 @@ int32_t CASendEDRUnicastData(const CAEndpoint_t *remoteEndpoint, const void *dat
                              uint32_t dataLength)
 {
     // Input validation
-    VERIFY_NON_NULL_RET(remoteEndpoint, EDR_ADAPTER_TAG, "Remote endpoint is null", -1);
-    VERIFY_NON_NULL_RET(data, EDR_ADAPTER_TAG, "Data is null", -1);
+    VERIFY_NON_NULL_RET(remoteEndpoint, TAG, "Remote endpoint is null", -1);
+    VERIFY_NON_NULL_RET(data, TAG, "Data is null", -1);
 
     if (0 == dataLength)
     {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Invalid input: data length is zero!");
+        OIC_LOG(ERROR, TAG, "Invalid input: data length is zero!");
         return -1;
     }
 
     if (0 == strlen(remoteEndpoint->addr))
     {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Invalid input: EDR Address is empty!");
+        OIC_LOG(ERROR, TAG, "Invalid input: EDR Address is empty!");
         return -1;
     }
 
@@ -299,7 +288,7 @@ int32_t CASendEDRUnicastData(const CAEndpoint_t *remoteEndpoint, const void *dat
     CAResult_t err = CAAdapterSendData(address, serviceUUID, data, dataLength, &sentLength);
     if (CA_STATUS_OK != err)
     {
-        OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Send unicast data failed!, error num [%d]", err);
+        OIC_LOG_V(ERROR, TAG, "Send unicast data failed!, error num [%d]", err);
         g_errorCallback(remoteEndpoint, data, dataLength, err);
         return -1;
     }
@@ -309,14 +298,14 @@ int32_t CASendEDRUnicastData(const CAEndpoint_t *remoteEndpoint, const void *dat
 
 int32_t CASendEDRMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLength)
 {
-    OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN - CASendEDRMulticastData");
+    OIC_LOG(DEBUG, TAG, "IN - CASendEDRMulticastData");
 
     // Input validation
-    VERIFY_NON_NULL_RET(data, EDR_ADAPTER_TAG, "Data is null", -1);
+    VERIFY_NON_NULL_RET(data, TAG, "Data is null", -1);
 
     if (0 == dataLength)
     {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Invalid input: data length is zero!");
+        OIC_LOG(ERROR, TAG, "Invalid input: data length is zero!");
         return -1;
     }
 
@@ -325,25 +314,24 @@ int32_t CASendEDRMulticastData(const CAEndpoint_t *endpoint, const void *data, u
     CAResult_t err = CAAdapterSendData(NULL, serviceUUID, data, dataLength, &sentLen);
     if (CA_STATUS_OK != err)
     {
-        OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Send multicast data failed!, error num [%d]", err);
+        OIC_LOG_V(ERROR, TAG, "Send multicast data failed!, error num [%d]", err);
         g_errorCallback(endpoint, data, dataLength, err);
         return -1;
     }
 
-    OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT - CASendEDRMulticastData");
+    OIC_LOG(DEBUG, TAG, "OUT - CASendEDRMulticastData");
     return sentLen;
 }
 
 CAResult_t CAGetEDRInterfaceInformation(CAEndpoint_t **info, uint32_t *size)
 {
-    VERIFY_NON_NULL(info, EDR_ADAPTER_TAG, "LocalConnectivity info is null");
+    VERIFY_NON_NULL(info, TAG, "LocalConnectivity info is null");
 
     CAResult_t err = CA_STATUS_OK;
     *size = 0;
     if (CA_STATUS_OK != (err = CAEDRGetInterfaceInformation(info)))
     {
-        OIC_LOG_V(ERROR, EDR_ADAPTER_TAG,
-                  "Failed to get local interface information!, error num [%d]", err);
+        OIC_LOG_V(ERROR, TAG, "Failed to get local interface information!, error num [%d]", err);
         return err;
     }
 
@@ -385,7 +373,7 @@ void CATerminateEDR()
     CAAdapterTerminateQueues();
 
     g_networkPacketReceivedCallback = NULL;
-    g_networkChangeCallback = NULL;
+    g_adapterChangeCallback = NULL;
 
     // Terminate thread pool
     g_edrThreadPool = NULL;
@@ -405,7 +393,7 @@ CAResult_t CAStartServer()
 {
     if (false == g_adapterState)
     {
-        OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "Bluetooth adapter is disabled!");
+        OIC_LOG(DEBUG, TAG, "Bluetooth adapter is disabled!");
         // Setting g_serverState for starting Rfcommserver when adapter starts
         g_serverState = true;
         return CA_STATUS_OK;
@@ -414,7 +402,7 @@ CAResult_t CAStartServer()
     CAResult_t err = CA_STATUS_OK;
     if (CA_STATUS_OK != (err = CAEDRServerStart()))
     {
-        OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Failed to start RFCOMM server!, error num [%d]",
+        OIC_LOG_V(ERROR, TAG, "Failed to start RFCOMM server!, error num [%d]",
                   err);
         return err;
     }
@@ -427,7 +415,7 @@ CAResult_t CAEDRInitializeQueueHandlers()
     if (CA_STATUS_OK == CAEDRInitializeSendHandler()
         && CA_STATUS_OK == CAEDRInitializeReceiveHandler())
     {
-        OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "Queue is initialized!");
+        OIC_LOG(DEBUG, TAG, "Queue is initialized!");
         return CA_STATUS_OK;
     }
 
@@ -439,21 +427,21 @@ CAResult_t CAEDRInitializeSendHandler()
     // Check if the message queue is already initialized
     if (g_sendQueueHandle)
     {
-        OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "Already queue is initialized!");
+        OIC_LOG(DEBUG, TAG, "Already queue is initialized!");
         return CA_STATUS_OK;
     }
 
     g_sendQueueHandle = (CAQueueingThread_t *) OICMalloc(sizeof(CAQueueingThread_t));
     if (!g_sendQueueHandle)
     {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Memory allocation failed!");
+        OIC_LOG(ERROR, TAG, "Memory allocation failed!");
         return CA_MEMORY_ALLOC_FAILED;
     }
 
     if (CA_STATUS_OK != CAQueueingThreadInitialize(g_sendQueueHandle, g_edrThreadPool,
                                                    CAAdapterDataSendHandler, CAEDRDataDestroyer))
     {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to Initialize send queue thread");
+        OIC_LOG(ERROR, TAG, "Failed to Initialize send queue thread");
         return CA_STATUS_FAILED;
     }
     return CA_STATUS_OK;
@@ -464,14 +452,14 @@ CAResult_t CAEDRInitializeReceiveHandler()
     // Check if the message queue is already initialized
     if (g_recvQueueHandle)
     {
-        OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "Already queue is initialized!");
+        OIC_LOG(DEBUG, TAG, "Already queue is initialized!");
         return CA_STATUS_OK;
     }
 
     g_recvQueueHandle = (CAQueueingThread_t *) OICMalloc(sizeof(CAQueueingThread_t));
     if (!g_recvQueueHandle)
     {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Memory allocation failed!");
+        OIC_LOG(ERROR, TAG, "Memory allocation failed!");
         return CA_MEMORY_ALLOC_FAILED;
     }
 
@@ -480,7 +468,7 @@ CAResult_t CAEDRInitializeReceiveHandler()
                                                    CAAdapterDataReceiverHandler,
                                                    CAEDRDataDestroyer))
     {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to Initialize send queue thread");
+        OIC_LOG(ERROR, TAG, "Failed to Initialize send queue thread");
         OICFree(g_recvQueueHandle);
         g_recvQueueHandle = NULL;
         return CA_STATUS_FAILED;
@@ -505,25 +493,25 @@ void CAAdapterTerminateQueues()
 
 void CAAdapterDataSendHandler(void *context)
 {
-    OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN - CAAdapterDataSendHandler");
+    OIC_LOG(DEBUG, TAG, "IN - CAAdapterDataSendHandler");
 
     CAEDRData *message = (CAEDRData *) context;
     if (!message)
     {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to get message!");
+        OIC_LOG(ERROR, TAG, "Failed to get message!");
         return;
     }
 
     if (!message->remoteEndpoint)
     {
-        OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "remoteEndpoint is not available");
+        OIC_LOG(DEBUG, TAG, "remoteEndpoint is not available");
         return;
     }
 
     const char *remoteAddress = message->remoteEndpoint->addr;
     if(!remoteAddress)
     {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "EDR Send Message error");
+        OIC_LOG(ERROR, TAG, "EDR Send Message error");
         //Error cannot be sent if remote address is NULL
         return;
     }
@@ -531,12 +519,12 @@ void CAAdapterDataSendHandler(void *context)
     CAResult_t result = CAEDRClientSendData(remoteAddress, message->data, message->dataLen);
     if(CA_STATUS_OK != result)
     {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "CAEDRClientSendData API failed");
+        OIC_LOG(ERROR, TAG, "CAEDRClientSendData API failed");
         CAEDRErrorHandler(remoteAddress, message->data, message->dataLen, result);
         return;
     }
 
-    OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
+    OIC_LOG(DEBUG, TAG, "OUT");
 }
 
 CAResult_t CAEDRClientSendData(const char *remoteAddress, const uint8_t *data,
@@ -550,18 +538,18 @@ CAResult_t CAEDRClientSendData(const char *remoteAddress, const uint8_t *data,
         result = CAEDRClientSendUnicastData(remoteAddress, data, dataLength);
         if (CA_STATUS_OK != result)
         {
-            OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to send unicast data !");
+            OIC_LOG(ERROR, TAG, "Failed to send unicast data !");
             return result;
         }
     }
     else
     {
-        OIC_LOG_V(DEBUG, EDR_ADAPTER_TAG, "sending multicast data : %s", data);
+        OIC_LOG_V(DEBUG, TAG, "sending multicast data : %s", data);
         result = CAEDRClientSendMulticastData(data, dataLength);
 
         if (CA_STATUS_OK != result)
         {
-            OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to send multicast data !");
+            OIC_LOG(ERROR, TAG, "Failed to send multicast data !");
             return result;
         }
     }
@@ -570,18 +558,18 @@ CAResult_t CAEDRClientSendData(const char *remoteAddress, const uint8_t *data,
 
 void CAAdapterDataReceiverHandler(void *context)
 {
-    OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN_CAAdapterDataReceiverHandler");
+    OIC_LOG(DEBUG, TAG, "IN_CAAdapterDataReceiverHandler");
 
     if (NULL == g_networkPacketReceivedCallback)
     {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "g_networkPacketReceivedCallback is NULL");
+        OIC_LOG(ERROR, TAG, "g_networkPacketReceivedCallback is NULL");
         return;
     }
 
     CAEDRData *message = (CAEDRData *) context;
     if (NULL == message || NULL == message->remoteEndpoint)
     {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to get message!");
+        OIC_LOG(ERROR, TAG, "Failed to get message!");
         return;
     }
 
@@ -592,11 +580,11 @@ void CAAdapterDataReceiverHandler(void *context)
 
     if (!remoteEndpoint)
     {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "remoteEndpoint is NULL");
+        OIC_LOG(ERROR, TAG, "remoteEndpoint is NULL");
         return;
     }
 
-    OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "Sending data up !");
+    OIC_LOG(DEBUG, TAG, "Sending data up !");
 
     const CASecureEndpoint_t sep = { .endpoint = *remoteEndpoint };
 
@@ -604,7 +592,7 @@ void CAAdapterDataReceiverHandler(void *context)
 
     CAFreeEndpoint(remoteEndpoint);
 
-    OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT_CAAdapterDataReceiverHandler");
+    OIC_LOG(DEBUG, TAG, "OUT_CAAdapterDataReceiverHandler");
 }
 
 CAResult_t CAAdapterStartQueue()
@@ -612,7 +600,7 @@ CAResult_t CAAdapterStartQueue()
     // Start send queue thread
     if (CA_STATUS_OK != CAQueueingThreadStart(g_sendQueueHandle))
     {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to Start Send Data Thread");
+        OIC_LOG(ERROR, TAG, "Failed to Start Send Data Thread");
         CAEDRClientUnsetCallbacks();
         //Disconnect all the client connections
         CAEDRClientDisconnectAll();
@@ -622,7 +610,7 @@ CAResult_t CAAdapterStartQueue()
     // Start receive queue thread
     if (CA_STATUS_OK != CAQueueingThreadStart(g_recvQueueHandle))
     {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to Start Receive Data Thread");
+        OIC_LOG(ERROR, TAG, "Failed to Start Receive Data Thread");
         CAEDRClientUnsetCallbacks();
         //Disconnect all the client connections
         CAEDRClientDisconnectAll();
@@ -648,14 +636,14 @@ void CAAdapterRecvData(const char *remoteAddress, const uint8_t *data, uint32_t
 {
     if (false == g_adapterState)
     {
-        OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Bluetooth adapter is disabled!");
+        OIC_LOG_V(ERROR, TAG, "Bluetooth adapter is disabled!");
         *sentLength = 0;
         return;
     }
 
     // Input validation
-    VERIFY_NON_NULL_VOID(data, EDR_ADAPTER_TAG, "Data is null");
-    VERIFY_NON_NULL_VOID(sentLength, EDR_ADAPTER_TAG, "Sent data length holder is null");
+    VERIFY_NON_NULL_VOID(data, TAG, "Data is null");
+    VERIFY_NON_NULL_VOID(sentLength, TAG, "Sent data length holder is null");
 
     // Create remote endpoint
     CAEndpoint_t *remoteEndpoint = CACreateEndpointObject(CA_DEFAULT_FLAGS,
@@ -663,7 +651,7 @@ void CAAdapterRecvData(const char *remoteAddress, const uint8_t *data, uint32_t
                                                           remoteAddress, 0);
     if (NULL == remoteEndpoint)
     {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to create remote endpoint !");
+        OIC_LOG(ERROR, TAG, "Failed to create remote endpoint !");
         return;
     }
 
@@ -680,14 +668,14 @@ void CAEDRErrorHandler(const char *remoteAddress, const uint8_t *data,
                        uint32_t dataLength, CAResult_t result)
 {
     // Input validation
-    VERIFY_NON_NULL_VOID(data, EDR_ADAPTER_TAG, "Data is null");
+    VERIFY_NON_NULL_VOID(data, TAG, "Data is null");
 
     // Create remote endpoint
     CAEndpoint_t *remoteEndpoint = CACreateEndpointObject(0, CA_ADAPTER_RFCOMM_BTEDR,
                                                            remoteAddress, 0);
     if (!remoteEndpoint)
     {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to create remote endpoint !");
+        OIC_LOG(ERROR, TAG, "Failed to create remote endpoint !");
         return;
     }
 
@@ -700,18 +688,18 @@ void CAEDRErrorHandler(const char *remoteAddress, const uint8_t *data,
 CAResult_t CAAdapterSendData(const char *remoteAddress, const char *serviceUUID, const uint8_t *data,
                              uint32_t dataLength, uint32_t *sentLength)
 {
-    OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN - CAAdapterSendData");
+    OIC_LOG(DEBUG, TAG, "IN - CAAdapterSendData");
 
     if (false == g_adapterState)
     {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Bluetooth adapter is disabled!");
+        OIC_LOG(ERROR, TAG, "Bluetooth adapter is disabled!");
         *sentLength = 0;
         return CA_ADAPTER_NOT_ENABLED;
     }
     // Input validation
-    VERIFY_NON_NULL(serviceUUID, EDR_ADAPTER_TAG, "service UUID is null");
-    VERIFY_NON_NULL(data, EDR_ADAPTER_TAG, "Data is null");
-    VERIFY_NON_NULL(sentLength, EDR_ADAPTER_TAG, "Sent data length holder is null");
+    VERIFY_NON_NULL(serviceUUID, TAG, "service UUID is null");
+    VERIFY_NON_NULL(data, TAG, "Data is null");
+    VERIFY_NON_NULL(sentLength, TAG, "Sent data length holder is null");
 
     // Create remote endpoint
     CAEndpoint_t *remoteEndpoint = CACreateEndpointObject(CA_DEFAULT_FLAGS,
@@ -719,7 +707,7 @@ CAResult_t CAAdapterSendData(const char *remoteAddress, const char *serviceUUID,
                                                           remoteAddress, 0);
     if (NULL == remoteEndpoint)
     {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to create remote endpoint !");
+        OIC_LOG(ERROR, TAG, "Failed to create remote endpoint !");
         return CA_MEMORY_ALLOC_FAILED;
     }
 
@@ -731,7 +719,7 @@ CAResult_t CAAdapterSendData(const char *remoteAddress, const char *serviceUUID,
     // Free remote endpoint
     CAFreeEndpoint(remoteEndpoint);
 
-    OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT - CAAdapterSendData");
+    OIC_LOG(DEBUG, TAG, "OUT - CAAdapterSendData");
     return CA_STATUS_OK;
 }
 
@@ -751,13 +739,13 @@ void CAEDRNotifyNetworkStatus(CANetworkStatus_t status)
             bool adapterState = false;
             if (CA_STATUS_OK != CAEDRGetAdapterEnableState(&adapterState))
             {
-                OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to get adapter enable state");
+                OIC_LOG(ERROR, TAG, "Failed to get adapter enable state");
                 return;
             }
 
             if (false == adapterState)
             {
-                OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Bluetooth adapter is disabled!");
+                OIC_LOG(ERROR, TAG, "Bluetooth adapter is disabled!");
                 g_adapterState = false;
                 return;
             }
@@ -778,7 +766,7 @@ void CAEDRNotifyNetworkStatus(CANetworkStatus_t status)
     }
 
     // Notify to upper layer
-    if (g_networkChangeCallback && g_localConnectivity && g_edrThreadPool)
+    if (g_adapterChangeCallback && g_localConnectivity && g_edrThreadPool)
     {
         // Add notification task to thread pool
         CAEDRNetworkEvent *event = CAEDRCreateNetworkEvent(g_localConnectivity, status);
@@ -787,7 +775,7 @@ void CAEDRNotifyNetworkStatus(CANetworkStatus_t status)
             if (CA_STATUS_OK != ca_thread_pool_add_task(g_edrThreadPool,
                                                         CAEDROnNetworkStatusChanged,event))
             {
-                OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to create threadpool!");
+                OIC_LOG(ERROR, TAG, "Failed to create threadpool!");
                 return;
             }
         }
@@ -798,16 +786,16 @@ void CAEDROnNetworkStatusChanged(void *context)
 {
     if (NULL == context)
     {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "context is NULL!");
+        OIC_LOG(ERROR, TAG, "context is NULL!");
         return;
     }
 
     CAEDRNetworkEvent *networkEvent = (CAEDRNetworkEvent *) context;
 
     // Notify to upper layer
-    if (g_networkChangeCallback)
+    if (g_adapterChangeCallback)
     {
-        g_networkChangeCallback(networkEvent->info, networkEvent->status);
+        g_adapterChangeCallback(networkEvent->info->adapter, networkEvent->status);
     }
 
     // Free the created Network event
@@ -817,13 +805,13 @@ void CAEDROnNetworkStatusChanged(void *context)
 CAEDRNetworkEvent *CAEDRCreateNetworkEvent(CAEndpoint_t *connectivity,
                                            CANetworkStatus_t status)
 {
-    VERIFY_NON_NULL_RET(connectivity, EDR_ADAPTER_TAG, "connectivity is NULL", NULL);
+    VERIFY_NON_NULL_RET(connectivity, TAG, "connectivity is NULL", NULL);
 
     // Create CAEDRNetworkEvent
     CAEDRNetworkEvent *event = (CAEDRNetworkEvent *) OICMalloc(sizeof(CAEDRNetworkEvent));
     if (NULL == event)
     {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to allocate memory to network event!");
+        OIC_LOG(ERROR, TAG, "Failed to allocate memory to network event!");
         return NULL;
     }
 
@@ -848,7 +836,7 @@ CAEDRData *CACreateEDRData(const CAEndpoint_t *remoteEndpoint,
     CAEDRData *edrData = (CAEDRData *) OICCalloc(1, sizeof(*edrData));
     if (!edrData)
     {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Memory allocation failed!");
+        OIC_LOG(ERROR, TAG, "Memory allocation failed!");
         return NULL;
     }
 
@@ -857,7 +845,7 @@ CAEDRData *CACreateEDRData(const CAEndpoint_t *remoteEndpoint,
     edrData->data = OICMalloc(dataLength);
     if (NULL == edrData->data)
     {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Memory allocation failed!");
+        OIC_LOG(ERROR, TAG, "Memory allocation failed!");
         CAFreeEDRData(edrData);
         return NULL;
     }
@@ -869,7 +857,7 @@ CAEDRData *CACreateEDRData(const CAEndpoint_t *remoteEndpoint,
 
 void CAFreeEDRData(CAEDRData *edrData)
 {
-    VERIFY_NON_NULL_VOID(edrData, EDR_ADAPTER_TAG, "edrData is NULL");
+    VERIFY_NON_NULL_VOID(edrData, TAG, "edrData is NULL");
 
     CAFreeEndpoint(edrData->remoteEndpoint);
     OICFree(edrData->data);
@@ -880,7 +868,7 @@ void CAEDRDataDestroyer(void *data, uint32_t size)
 {
     if ((size_t)size < sizeof(CAEDRData))
     {
-        OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Destroy data too small %p %d", data, size);
+        OIC_LOG_V(ERROR, TAG, "Destroy data too small %p %d", data, size);
     }
     CAEDRData *edrdata = (CAEDRData *) data;
 
diff --git a/resource/csdk/connectivity/src/bt_edr_adapter/linux/SConscript b/resource/csdk/connectivity/src/bt_edr_adapter/linux/SConscript
deleted file mode 100644 (file)
index 0e09967..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-##########################################
-#       Build BT EDR adapter for Linux
-##########################################
-
-Import('env')
-
-src_files = [ 'caedradapter.c']
-
-Return('src_files')
diff --git a/resource/csdk/connectivity/src/bt_edr_adapter/linux/caedradapter.c b/resource/csdk/connectivity/src/bt_edr_adapter/linux/caedradapter.c
deleted file mode 100644 (file)
index 4863861..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-/******************************************************************
- *
- * 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.
- *
- ******************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "caedradapter.h"
-#include "logger.h"
-
-#define TAG PCF("OIC_CA")
-
-static CANetworkPacketReceivedCallback g_edrReceivedCallback = NULL;
-static ca_thread_pool_t g_threadPoolHandle = NULL;
-
-CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
-                           CANetworkPacketReceivedCallback reqRespCallback,
-                           CANetworkChangeCallback networkStateChangeCallback,
-                           CAErrorHandleCallback errorCallback, ca_thread_pool_t handle)
-{
-    (void)networkStateChangeCallback;
-    (void)errorCallback;
-    OIC_LOG(DEBUG, TAG, "CAInitializeEDR");
-
-    g_edrReceivedCallback = reqRespCallback;
-    g_threadPoolHandle = handle;
-
-    // register handlers
-    CAConnectivityHandler_t handler = {
-        .startAdapter = CAStartEDR,
-        .startListenServer = CAStartEDRListeningServer,
-        .stopListenServer = CAStopEDRListeningServer,
-        .startDiscoveryServer = CAStartEDRDiscoveryServer,
-        .sendData = CASendEDRUnicastData,
-        .sendDataToAll = CASendEDRMulticastData,
-        .GetnetInfo = CAGetEDRInterfaceInformation,
-        .readData = CAReadEDRData,
-        .stopAdapter = CAStopEDR,
-        .terminate = CATerminateEDR,
-        .cType = CA_ADAPTER_RFCOMM_BTEDR
-    };
-
-    registerCallback(handler);
-
-    return CA_STATUS_OK;
-}
-
-CAResult_t CAStartEDR()
-{
-    OIC_LOG(DEBUG, TAG, "CAStartEDR");
-
-    return CA_STATUS_OK;
-}
-
-CAResult_t CAStartEDRListeningServer()
-{
-    OIC_LOG(DEBUG, TAG, "CAStartEDRListeningServer");
-
-    return CA_STATUS_OK;
-}
-
-CAResult_t CAStopEDRListeningServer()
-{
-    OIC_LOG(DEBUG, TAG, "CAStopEDRListeningServer");
-
-    return CA_STATUS_OK;
-}
-
-CAResult_t CAStartEDRDiscoveryServer()
-{
-    OIC_LOG(DEBUG, TAG, "CAStartEDRDiscoveryServer");
-
-    return CA_STATUS_OK;
-}
-
-int32_t CASendEDRUnicastData(const CAEndpoint_t *endpoint, const void *data,
-    uint32_t dataLen)
-{
-    (void)endpoint;
-    (void)data;
-    (void)dataLen;
-    OIC_LOG(DEBUG, TAG, "CASendEDRUnicastData");
-
-    return -1;
-}
-
-int32_t CASendEDRMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLen)
-{
-    (void)endpoint;
-    (void)data;
-    (void)dataLen;
-    OIC_LOG(DEBUG, TAG, "CASendEDRMulticastData");
-
-    return -1;
-}
-
-CAResult_t CAGetEDRInterfaceInformation(CAEndpoint_t **info, uint32_t *size)
-{
-    (void)info;
-    (void)size;
-    OIC_LOG(DEBUG, TAG, "CAGetEDRInterfaceInformation");
-
-    return CA_STATUS_OK;
-}
-
-CAResult_t CAReadEDRData()
-{
-    OIC_LOG(DEBUG, TAG, "Read EDR Data");
-
-    return CA_STATUS_OK;
-}
-
-CAResult_t CAStopEDR()
-{
-    OIC_LOG(DEBUG, TAG, "CAStopEDR");
-
-    return CA_STATUS_OK;
-}
-
-void CATerminateEDR()
-{
-    OIC_LOG(DEBUG, TAG, "CATerminateEDR");
-}
-
index 4958b43..49b521b 100644 (file)
 #include "caqueueingthread.h"
 #include "caremotehandler.h"
 
+#define MICROSECS_PER_SEC 1000000
+
+static uint64_t const INITIALIZE_TIMEOUT = 1 * MICROSECS_PER_SEC;
+
 static GMainLoop *g_mainloop = NULL;
 static ca_thread_pool_t g_threadPoolHandle = NULL;
 
@@ -45,6 +49,21 @@ static ca_thread_pool_t g_threadPoolHandle = NULL;
 static CAEDRNetworkStatusCallback g_edrNetworkChangeCallback = NULL;
 
 /**
+ * Mutex to synchronize access to
+ */
+static ca_mutex g_btinitializeMutex = NULL;
+
+/**
+ * Condition for gmainloop to run.
+ */
+static ca_cond g_initializeCond = NULL;
+
+/**
+ * Flag to check if BT stack is initialised.
+ */
+static bool g_isBTStackInitialised = false;
+
+/**
  * @fn CAEDRAdapterStateChangeCallback
  * @brief This callback is registered to receive bluetooth adapter state changes.
  */
@@ -53,13 +72,62 @@ static void CAEDRAdapterStateChangeCallback(int result, bt_adapter_state_e adapt
 
 void CAEDRMainLoopThread(void *param)
 {
+    OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
+    // Initialize Bluetooth service
+    int ret = bt_initialize();
+    if (BT_ERROR_NONE != ret)
+    {
+        OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Bluetooth initialization failed!, error num [%x]",
+                  ret);
+        return;
+    }
+
+    ret = bt_adapter_set_state_changed_cb(CAEDRAdapterStateChangeCallback, NULL);
+    if(BT_ERROR_NONE != ret)
+    {
+       OIC_LOG(ERROR, EDR_ADAPTER_TAG, "bt_adapter_set_state_changed_cb failed");
+       return;
+    }
+
+    g_mainloop = g_main_loop_new(g_main_context_default(), FALSE);
+
+    ca_mutex_lock(g_btinitializeMutex);
+    g_isBTStackInitialised = true;
+    ca_mutex_unlock(g_btinitializeMutex);
+    ca_cond_signal(g_initializeCond);
+
+    // Run gmainloop to handle the events from bt stack
     g_main_loop_run(g_mainloop);
+
+    OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
 }
 
 CAResult_t CAEDRInitializeNetworkMonitor(const ca_thread_pool_t threadPool)
 {
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
     g_threadPoolHandle = threadPool;
+
+    if (NULL == g_btinitializeMutex)
+    {
+        g_btinitializeMutex = ca_mutex_new();
+        if (NULL == g_btinitializeMutex)
+        {
+            OIC_LOG(ERROR, EDR_ADAPTER_TAG, "ca_mutex_new failed");
+            return CA_STATUS_FAILED;
+        }
+    }
+
+    if (NULL == g_initializeCond)
+    {
+        g_initializeCond = ca_cond_new();
+        if (NULL == g_initializeCond)
+        {
+            OIC_LOG(ERROR, EDR_ADAPTER_TAG, "ca_cond_new failed");
+            ca_mutex_free(g_btinitializeMutex);
+            return CA_STATUS_FAILED;
+        }
+    }
+
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
     return CA_STATUS_OK;
 }
@@ -70,8 +138,11 @@ void CAEDRTerminateNetworkMonitor(void)
 
     g_edrNetworkChangeCallback = NULL;
 
-    // Terminate Bluetooth service
-    bt_deinitialize();
+    ca_mutex_free(g_btinitializeMutex);
+    g_btinitializeMutex = NULL;
+
+    ca_cond_free(g_initializeCond);
+    g_initializeCond = NULL;
 
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
 }
@@ -80,35 +151,13 @@ CAResult_t CAEDRStartNetworkMonitor()
 {
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
 
-    g_mainloop = g_main_loop_new(NULL, 0);
-    if(!g_mainloop)
-    {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "g_main_loop_new failed\n");
-        return CA_STATUS_FAILED;
-    }
-
-    if (CA_STATUS_OK != ca_thread_pool_add_task(g_threadPoolHandle, CAEDRMainLoopThread, (void *) NULL))
+    if (CA_STATUS_OK != ca_thread_pool_add_task(g_threadPoolHandle, CAEDRMainLoopThread,
+                                                (void *) NULL))
     {
         OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to create thread!");
         return CA_STATUS_FAILED;
     }
 
-    // Initialize Bluetooth service
-    int err = bt_initialize();
-    if (BT_ERROR_NONE != err)
-    {
-        OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Bluetooth initialization failed!, error num [%x]",
-                  err);
-        return CA_STATUS_FAILED;
-    }
-
-    int ret = bt_adapter_set_state_changed_cb(CAEDRAdapterStateChangeCallback, NULL);
-    if(BT_ERROR_NONE != ret)
-    {
-       OIC_LOG(ERROR, EDR_ADAPTER_TAG, "bt_adapter_set_state_changed_cb failed");
-       return CA_STATUS_FAILED;
-    }
-
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
     return CA_STATUS_OK;
 }
@@ -124,6 +173,13 @@ CAResult_t CAEDRStopNetworkMonitor()
         return CA_STATUS_FAILED;
     }
 
+    ret = bt_deinitialize();
+    if (BT_ERROR_NONE != ret)
+    {
+        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "bt_deinitialize failed");
+        return CA_STATUS_FAILED;
+    }
+
     if (g_mainloop)
     {
         g_main_loop_quit(g_mainloop);
@@ -175,10 +231,22 @@ CAResult_t CAEDRGetInterfaceInformation(CAEndpoint_t **info)
 CAResult_t CAEDRGetAdapterEnableState(bool *state)
 {
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
-
-    // Input validation
     VERIFY_NON_NULL(state, EDR_ADAPTER_TAG, "state holder is NULL!");
 
+    ca_mutex_lock(g_btinitializeMutex);
+    if (!g_isBTStackInitialised)
+    {
+        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Wait till BT is initialised");
+        CAWaitResult_t ret = ca_cond_wait_for(g_initializeCond, g_btinitializeMutex,
+                                              INITIALIZE_TIMEOUT);
+        if (CA_WAIT_TIMEDOUT == ret)
+        {
+            OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Timeout before BT initialize");
+            ca_mutex_unlock(g_btinitializeMutex);
+            return CA_STATUS_FAILED;
+        }
+    }
+    ca_mutex_unlock(g_btinitializeMutex);
 
     bt_adapter_state_e adapterState;
     int err = bt_adapter_get_state(&adapterState);
index dd953de..338d679 100644 (file)
@@ -95,6 +95,7 @@ static ca_mutex g_deviceScanRetryDelayMutex = NULL;
 static ca_cond g_deviceScanRetryDelayCond = NULL;
 
 static ca_mutex g_scanMutex = NULL;
+static ca_mutex g_threadSendStateMutex = NULL;
 
 static CABLEDataReceivedCallback g_CABLEClientDataReceivedCallback = NULL;
 
@@ -169,6 +170,24 @@ CAResult_t CALECreateJniInterfaceObject()
         isAttached = true;
     }
 
+    jmethodID mid_getApplicationContext = CAGetJNIMethodID(env, "android/content/Context",
+                                                           "getApplicationContext",
+                                                           "()Landroid/content/Context;");
+
+    if (!mid_getApplicationContext)
+    {
+        OIC_LOG(ERROR, TAG, "Could not get getApplicationContext method");
+        return CA_STATUS_FAILED;
+    }
+
+    jobject jApplicationContext = (*env)->CallObjectMethod(env, g_context,
+                                                           mid_getApplicationContext);
+    if (!jApplicationContext)
+    {
+        OIC_LOG(ERROR, TAG, "Could not get application context");
+        return CA_STATUS_FAILED;
+    }
+
     jclass jni_LEInterface = (*env)->FindClass(env, "org/iotivity/ca/CaLeClientInterface");
     if (!jni_LEInterface)
     {
@@ -184,7 +203,7 @@ CAResult_t CALECreateJniInterfaceObject()
         goto error_exit;
     }
 
-    (*env)->NewObject(env, jni_LEInterface, LeInterfaceConstructorMethod, g_context);
+    (*env)->NewObject(env, jni_LEInterface, LeInterfaceConstructorMethod, jApplicationContext);
     OIC_LOG(DEBUG, TAG, "Create instance for CaLeClientInterface");
 
     if (isAttached)
@@ -781,12 +800,30 @@ CAResult_t CALEClientSendUnicastMessageImpl(const char* address, const uint8_t*
     {
         OIC_LOG(ERROR, TAG, "CALEClientStartScan has failed");
         ca_mutex_unlock(g_threadSendMutex);
-        return res;
+        return ret;
     }
 
     ca_mutex_unlock(g_threadSendMutex);
     OIC_LOG(INFO, TAG, "unicast - send logic has finished");
-    return CALECheckSendState(address);
+    if (CALEClientIsValidState(address, CA_LE_SEND_STATE,
+                               STATE_SEND_SUCCESS))
+    {
+        ret = CA_STATUS_OK;
+    }
+    else
+    {
+        ret = CA_SEND_FAILED;
+    }
+
+    // reset send state
+    ret = CALEClientUpdateDeviceState(address, CA_LE_SEND_STATE,
+                                      STATE_SEND_NONE);
+    if (CA_STATUS_OK != ret)
+    {
+        OIC_LOG(ERROR, TAG, "CALEClientUpdateDeviceState has failed");
+    }
+
+    return ret;
 
     // error label.
 error_exit:
@@ -801,7 +838,7 @@ error_exit:
         {
             (*g_jvm)->DetachCurrentThread(g_jvm);
         }
-        return res;
+        return ret;
     }
 
     if (isAttached)
@@ -809,10 +846,6 @@ error_exit:
         (*g_jvm)->DetachCurrentThread(g_jvm);
     }
 
-    if (g_clientErrorCallback)
-    {
-        g_clientErrorCallback(address, data, dataLen, CA_SEND_FAILED);
-    }
     ca_mutex_unlock(g_threadSendMutex);
     return CA_SEND_FAILED;
 }
@@ -934,31 +967,6 @@ error_exit:
     return CA_SEND_FAILED;
 }
 
-CAResult_t CALECheckSendState(const char* address)
-{
-    VERIFY_NON_NULL(address, TAG, "address is null");
-
-    ca_mutex_lock(g_deviceStateListMutex);
-    CALEState_t* state = CALEClientGetStateInfo(address);
-    if (NULL == state)
-    {
-        OIC_LOG(ERROR, TAG, "state is null");
-        ca_mutex_unlock(g_deviceStateListMutex);
-        return CA_SEND_FAILED;
-    }
-
-    if (STATE_SEND_SUCCESS != state->sendState)
-    {
-        OIC_LOG(ERROR, TAG, "sendstate is not STATE_SEND_SUCCESS");
-        ca_mutex_unlock(g_deviceStateListMutex);
-        return CA_SEND_FAILED;
-    }
-
-    OIC_LOG(INFO, TAG, "sendstate is STATE_SEND_SUCCESS");
-    ca_mutex_unlock(g_deviceStateListMutex);
-    return CA_STATUS_OK;
-}
-
 CAResult_t CALEClientSendData(JNIEnv *env, jobject device)
 {
     OIC_LOG(DEBUG, TAG, "IN - CALEClientSendData");
@@ -981,7 +989,6 @@ CAResult_t CALEClientSendData(JNIEnv *env, jobject device)
         ca_mutex_lock(g_deviceStateListMutex);
         state = CALEClientGetStateInfo(address);
         ca_mutex_unlock(g_deviceStateListMutex);
-        (*env)->ReleaseStringUTFChars(env, jni_address, address);
     }
 
     if (!state)
@@ -992,13 +999,6 @@ CAResult_t CALEClientSendData(JNIEnv *env, jobject device)
         // if there is gatt object in g_gattObjectList.
         if (jni_address)
         {
-            address = (char*)(*env)->GetStringUTFChars(env, jni_address, NULL);
-            if (!address)
-            {
-                OIC_LOG(ERROR, TAG, "address is not available");
-                return CA_STATUS_FAILED;
-            }
-
             jobject gatt = CALEClientGetGattObjInList(env, address);
             if (gatt)
             {
@@ -1022,21 +1022,10 @@ CAResult_t CALEClientSendData(JNIEnv *env, jobject device)
     }
     else
     {
-        if (STATE_CONNECTED == state->connectedState)
+        if (CALEClientIsValidState(address, CA_LE_CONNECTION_STATE,
+                                   STATE_SERVICE_CONNECTED))
         {
             OIC_LOG(INFO, TAG, "GATT has already connected");
-            if (!jni_address)
-            {
-                OIC_LOG(ERROR, TAG, "jni_address is not available");
-                return CA_STATUS_FAILED;
-            }
-
-            address = (char*)(*env)->GetStringUTFChars(env, jni_address, NULL);
-            if (!address)
-            {
-                OIC_LOG(ERROR, TAG, "address is not available");
-                return CA_STATUS_FAILED;
-            }
 
             jobject gatt = CALEClientGetGattObjInList(env, address);
             if (!gatt)
@@ -1055,7 +1044,13 @@ CAResult_t CALEClientSendData(JNIEnv *env, jobject device)
             }
             (*env)->ReleaseStringUTFChars(env, jni_address, address);
         }
-        else
+        else if(CALEClientIsValidState(address, CA_LE_CONNECTION_STATE,
+                                       STATE_CONNECTED))
+        {
+            OIC_LOG(INFO, TAG, "service connecting...");
+        }
+        else if(CALEClientIsValidState(address, CA_LE_CONNECTION_STATE,
+                                       STATE_DISCONNECTED))
         {
             OIC_LOG(INFO, TAG, "STATE_DISCONNECTED - start to connect LE");
 
@@ -1063,13 +1058,6 @@ CAResult_t CALEClientSendData(JNIEnv *env, jobject device)
             // if there is gatt object in g_gattObjectList.
             if (jni_address)
             {
-                address = (char*)(*env)->GetStringUTFChars(env, jni_address, NULL);
-                if (!address)
-                {
-                    OIC_LOG(ERROR, TAG, "address is not available");
-                    return CA_STATUS_FAILED;
-                }
-
                 jobject gatt = CALEClientGetGattObjInList(env, address);
                 if (gatt)
                 {
@@ -1084,7 +1072,9 @@ CAResult_t CALEClientSendData(JNIEnv *env, jobject device)
 
             OIC_LOG(DEBUG, TAG, "start to connect LE");
             jobject gatt = CALEClientConnect(env, device,
-                                             CALEClientGetAutoConnectFlag(env, jni_address));
+                                             CALEClientGetFlagFromState(env, jni_address,
+                                                                        CA_LE_AUTO_CONNECT_FLAG));
+
             if (NULL == gatt)
             {
                 OIC_LOG(ERROR, TAG, "CALEClientConnect has failed");
@@ -1101,8 +1091,8 @@ jstring CALEClientGetAddressFromGattObj(JNIEnv *env, jobject gatt)
     VERIFY_NON_NULL_RET(gatt, TAG, "gatt is null", NULL);
     VERIFY_NON_NULL_RET(env, TAG, "env is null", NULL);
 
-    jmethodID jni_mid_getDevice = CALEGetJNIMethodID(env, CLASSPATH_BT_GATT, "getDevice",
-                                                     "()Landroid/bluetooth/BluetoothDevice;");
+    jmethodID jni_mid_getDevice = CAGetJNIMethodID(env, CLASSPATH_BT_GATT, "getDevice",
+                                                   "()Landroid/bluetooth/BluetoothDevice;");
     if (!jni_mid_getDevice)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_getDevice is null");
@@ -1138,7 +1128,7 @@ CAResult_t CALEClientGattClose(JNIEnv *env, jobject bluetoothGatt)
 
     // get BluetoothGatt method
     OIC_LOG(DEBUG, TAG, "get BluetoothGatt method");
-    jmethodID jni_mid_closeGatt = CALEGetJNIMethodID(env, CLASSPATH_BT_GATT, "close", "()V");
+    jmethodID jni_mid_closeGatt = CAGetJNIMethodID(env, CLASSPATH_BT_GATT, "close", "()V");
     if (!jni_mid_closeGatt)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_closeGatt is null");
@@ -1277,15 +1267,16 @@ CAResult_t CALEClientStartScanImpl(JNIEnv *env, jobject callback)
     }
 
     // call start le scan method
+    OIC_LOG(INFO, TAG, "CALL API - startLeScan");
     jboolean jni_obj_startLeScan = (*env)->CallBooleanMethod(env, jni_obj_BTAdapter,
                                                              jni_mid_startLeScan, callback);
     if (!jni_obj_startLeScan)
     {
-        OIC_LOG(INFO, TAG, "startLeScan is failed");
+        OIC_LOG(INFO, TAG, "startLeScan has failed");
     }
     else
     {
-        OIC_LOG(DEBUG, TAG, "startLeScan is started");
+        OIC_LOG(DEBUG, TAG, "LeScan has started");
         CALEClientSetScanFlag(true);
     }
 
@@ -1341,15 +1332,16 @@ CAResult_t CALEClientStartScanWithUUIDImpl(JNIEnv *env, jobjectArray uuids, jobj
     }
 
     // call start le scan method
+    OIC_LOG(INFO, TAG, "CALL API - startLeScan (with UUID)");
     jboolean jni_obj_startLeScan = (*env)->CallBooleanMethod(env, jni_obj_BTAdapter,
                                                              jni_mid_startLeScan, uuids, callback);
     if (!jni_obj_startLeScan)
     {
-        OIC_LOG(INFO, TAG, "startLeScan With UUID is failed");
+        OIC_LOG(INFO, TAG, "startLeScan has failed");
     }
     else
     {
-        OIC_LOG(DEBUG, TAG, "startLeScan With UUID is started");
+        OIC_LOG(DEBUG, TAG, "LeScan has started");
         CALEClientSetScanFlag(true);
     }
 
@@ -1500,7 +1492,7 @@ CAResult_t CALEClientStopScanImpl(JNIEnv *env, jobject callback)
         return CA_STATUS_FAILED;
     }
 
-    OIC_LOG(DEBUG, TAG, "CALL API - request to stop LE Scan");
+    OIC_LOG(INFO, TAG, "CALL API - stopLeScan");
     // call start le scan method
     (*env)->CallVoidMethod(env, jni_obj_BTAdapter, jni_mid_stopLeScan, callback);
     if ((*env)->ExceptionCheck(env))
@@ -1514,9 +1506,9 @@ CAResult_t CALEClientStopScanImpl(JNIEnv *env, jobject callback)
     return CA_STATUS_OK;
 }
 
-CAResult_t CALEClientSetAutoConnectFlag(JNIEnv *env, jstring jni_address, jboolean flag)
+CAResult_t CALEClientSetFlagToState(JNIEnv *env, jstring jni_address, jint state_idx, jboolean flag)
 {
-    OIC_LOG(DEBUG, TAG, "IN - CALEClientSetAutoConnectFlag");
+    OIC_LOG(DEBUG, TAG, "IN - CALEClientSetFlagToState");
     VERIFY_NON_NULL(env, TAG, "env");
     VERIFY_NON_NULL(jni_address, TAG, "jni_address");
 
@@ -1539,20 +1531,30 @@ CAResult_t CALEClientSetAutoConnectFlag(JNIEnv *env, jstring jni_address, jboole
             ca_mutex_unlock(g_deviceStateListMutex);
             return CA_STATUS_FAILED;
         }
-        OIC_LOG_V(INFO, TAG, "auto connect flag is set %d", flag);
+        OIC_LOG_V(INFO, TAG, "%d flag is set : %d", state_idx, flag);
 
-        curState->autoConnectFlag = flag;
+        switch(state_idx)
+        {
+            case CA_LE_AUTO_CONNECT_FLAG:
+                curState->autoConnectFlag = flag;
+                break;
+            case CA_LE_DESCRIPTOR_FOUND:
+                curState->isDescriptorFound = flag;
+                break;
+            default:
+                break;
+        }
     }
 
     (*env)->ReleaseStringUTFChars(env, jni_address, address);
     ca_mutex_unlock(g_deviceStateListMutex);
-    OIC_LOG(DEBUG, TAG, "OUT - CALEClientSetAutoConnectFlag");
+    OIC_LOG(DEBUG, TAG, "OUT - CALEClientSetFlagToState");
     return CA_STATUS_OK;
 }
 
-jboolean CALEClientGetAutoConnectFlag(JNIEnv *env, jstring jni_address)
+jboolean CALEClientGetFlagFromState(JNIEnv *env, jstring jni_address, jint state_idx)
 {
-    OIC_LOG(DEBUG, TAG, "IN - CALEClientGetAutoConnectFlag");
+    OIC_LOG(DEBUG, TAG, "IN - CALEClientGetFlagFromState");
     VERIFY_NON_NULL_RET(env, TAG, "env", false);
     VERIFY_NON_NULL_RET(jni_address, TAG, "jni_address", false);
 
@@ -1562,24 +1564,36 @@ jboolean CALEClientGetAutoConnectFlag(JNIEnv *env, jstring jni_address)
     if (!address)
     {
         OIC_LOG(ERROR, TAG, "address is not available");
+        ca_mutex_unlock(g_deviceStateListMutex);
         return JNI_FALSE;
     }
 
     CALEState_t* curState = CALEClientGetStateInfo(address);
+    (*env)->ReleaseStringUTFChars(env, jni_address, address);
     if(!curState)
     {
         OIC_LOG(INFO, TAG, "there is no information. auto connect flag is false");
-        (*env)->ReleaseStringUTFChars(env, jni_address, address);
         ca_mutex_unlock(g_deviceStateListMutex);
         return JNI_FALSE;
     }
-    OIC_LOG_V(INFO, TAG, "auto connect flag is %d", curState->autoConnectFlag);
 
-    (*env)->ReleaseStringUTFChars(env, jni_address, address);
+    jboolean ret = JNI_FALSE;
+    switch(state_idx)
+    {
+        case CA_LE_AUTO_CONNECT_FLAG:
+            ret = curState->autoConnectFlag;
+            break;
+        case CA_LE_DESCRIPTOR_FOUND:
+            ret = curState->isDescriptorFound;
+            break;
+        default:
+            break;
+    }
     ca_mutex_unlock(g_deviceStateListMutex);
 
-    OIC_LOG(DEBUG, TAG, "OUT - CALEClientGetAutoConnectFlag");
-    return curState->autoConnectFlag;
+    OIC_LOG_V(INFO, TAG, "%d flag is %d", state_idx, ret);
+    OIC_LOG(DEBUG, TAG, "OUT - CALEClientGetFlagFromState");
+    return ret;
 }
 
 jobject CALEClientConnect(JNIEnv *env, jobject bluetoothDevice, jboolean autoconnect)
@@ -1668,11 +1682,11 @@ jobject CALEClientGattConnect(JNIEnv *env, jobject bluetoothDevice, jboolean aut
 
     // get BluetoothDevice method
     OIC_LOG(DEBUG, TAG, "get BluetoothDevice method");
-    jmethodID jni_mid_connectGatt = CALEGetJNIMethodID(env, "android/bluetooth/BluetoothDevice",
-                                                       "connectGatt",
-                                                       "(Landroid/content/Context;ZLandroid/"
-                                                       "bluetooth/BluetoothGattCallback;)"
-                                                       "Landroid/bluetooth/BluetoothGatt;");
+    jmethodID jni_mid_connectGatt = CAGetJNIMethodID(env, "android/bluetooth/BluetoothDevice",
+                                                     "connectGatt",
+                                                     "(Landroid/content/Context;ZLandroid/"
+                                                     "bluetooth/BluetoothGattCallback;)"
+                                                     "Landroid/bluetooth/BluetoothGatt;");
     if (!jni_mid_connectGatt)
     {
         OIC_LOG(ERROR, TAG, "bleConnect: jni_mid_connectGatt is null");
@@ -1783,8 +1797,8 @@ CAResult_t CALEClientDisconnect(JNIEnv *env, jobject bluetoothGatt)
 
     // get BluetoothGatt method
     OIC_LOG(DEBUG, TAG, "get gatt disconnect method");
-    jmethodID jni_mid_disconnectGatt  = CALEGetJNIMethodID(env, CLASSPATH_BT_GATT,
-                                                           "disconnect", "()V");
+    jmethodID jni_mid_disconnectGatt  = CAGetJNIMethodID(env, CLASSPATH_BT_GATT,
+                                                         "disconnect", "()V");
     if (!jni_mid_disconnectGatt)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_disconnectGatt is null");
@@ -1792,7 +1806,7 @@ CAResult_t CALEClientDisconnect(JNIEnv *env, jobject bluetoothGatt)
     }
 
     // call disconnect gatt method
-    OIC_LOG(DEBUG, TAG, "CALL API - request disconnect gatt");
+    OIC_LOG(INFO, TAG, "CALL API - disconnect");
     (*env)->CallVoidMethod(env, bluetoothGatt, jni_mid_disconnectGatt);
     if ((*env)->ExceptionCheck(env))
     {
@@ -1920,8 +1934,8 @@ CAResult_t CALEClientDiscoverServices(JNIEnv *env, jobject bluetoothGatt)
 
     // get BluetoothGatt.discoverServices method
     OIC_LOG(DEBUG, TAG, "get BluetoothGatt.discoverServices method");
-    jmethodID jni_mid_discoverServices = CALEGetJNIMethodID(env, CLASSPATH_BT_GATT,
-                                                            "discoverServices", "()Z");
+    jmethodID jni_mid_discoverServices = CAGetJNIMethodID(env, CLASSPATH_BT_GATT,
+                                                          "discoverServices", "()Z");
     if (!jni_mid_discoverServices)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_discoverServices is null");
@@ -1929,7 +1943,7 @@ CAResult_t CALEClientDiscoverServices(JNIEnv *env, jobject bluetoothGatt)
     }
 
     // call disconnect gatt method
-    OIC_LOG(DEBUG, TAG, "CALL API - request discovery gatt services");
+    OIC_LOG(INFO, TAG, "CALL API - discoverServices");
     jboolean ret = (*env)->CallBooleanMethod(env, bluetoothGatt, jni_mid_discoverServices);
     if (!ret)
     {
@@ -1975,9 +1989,49 @@ static void CALEWriteCharacteristicThread(void* object)
 
 CAResult_t CALESetValueAndWriteCharacteristic(JNIEnv* env, jobject gatt)
 {
+    OIC_LOG(DEBUG, TAG, "CALESetValueAndWriteCharacteristic");
+
     VERIFY_NON_NULL(gatt, TAG, "gatt is null");
     VERIFY_NON_NULL(env, TAG, "env is null");
 
+    jstring jni_address = CALEClientGetAddressFromGattObj(env, gatt);
+    if (!jni_address)
+    {
+        CALEClientSendFinish(env, gatt);
+        return CA_STATUS_FAILED;
+    }
+
+    const char* address = (*env)->GetStringUTFChars(env, jni_address, NULL);
+    if (!address)
+    {
+        CALEClientSendFinish(env, gatt);
+        return CA_STATUS_FAILED;
+    }
+
+    ca_mutex_lock(g_threadSendStateMutex);
+
+    if (CALEClientIsValidState(address, CA_LE_SEND_STATE, STATE_SENDING))
+    {
+        OIC_LOG(INFO, TAG, "current state is SENDING");
+        (*env)->ReleaseStringUTFChars(env, jni_address, address);
+        ca_mutex_unlock(g_threadSendStateMutex);
+        return CA_STATUS_OK;
+    }
+
+    if (CA_STATUS_OK != CALEClientUpdateDeviceState(address, CA_LE_SEND_STATE,
+                                                    STATE_SENDING))
+    {
+        OIC_LOG(ERROR, TAG, "CALEClientUpdateDeviceState has failed");
+        (*env)->ReleaseStringUTFChars(env, jni_address, address);
+        CALEClientSendFinish(env, gatt);
+        ca_mutex_unlock(g_threadSendStateMutex);
+        return CA_STATUS_FAILED;
+    }
+
+    (*env)->ReleaseStringUTFChars(env, jni_address, address);
+
+    ca_mutex_unlock(g_threadSendStateMutex);
+
     // send data
     jobject jni_obj_character = CALEClientCreateGattCharacteristic(env, gatt, g_sendBuffer);
     if (!jni_obj_character)
@@ -2051,10 +2105,10 @@ CAResult_t CALEClientWriteCharacteristicImpl(JNIEnv *env, jobject bluetoothGatt,
 
     // get BluetoothGatt.write characteristic method
     OIC_LOG(DEBUG, TAG, "write characteristic method");
-    jmethodID jni_mid_writeCharacteristic = CALEGetJNIMethodID(env, CLASSPATH_BT_GATT,
-                                                               "writeCharacteristic",
-                                                               "(Landroid/bluetooth/"
-                                                               "BluetoothGattCharacteristic;)Z");
+    jmethodID jni_mid_writeCharacteristic = CAGetJNIMethodID(env, CLASSPATH_BT_GATT,
+                                                             "writeCharacteristic",
+                                                             "(Landroid/bluetooth/"
+                                                             "BluetoothGattCharacteristic;)Z");
     if (!jni_mid_writeCharacteristic)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_writeCharacteristic is null");
@@ -2062,7 +2116,7 @@ CAResult_t CALEClientWriteCharacteristicImpl(JNIEnv *env, jobject bluetoothGatt,
     }
 
     // call disconnect gatt method
-    OIC_LOG(DEBUG, TAG, "CALL API - request to write gatt characteristic");
+    OIC_LOG(INFO, TAG, "CALL API - writeCharacteristic");
     jboolean ret = (jboolean)(*env)->CallBooleanMethod(env, bluetoothGatt,
                                                        jni_mid_writeCharacteristic,
                                                        gattCharacteristic);
@@ -2105,10 +2159,10 @@ CAResult_t CALEClientReadCharacteristic(JNIEnv *env, jobject bluetoothGatt)
     }
 
     OIC_LOG(DEBUG, TAG, "read characteristic method");
-    jmethodID jni_mid_readCharacteristic = CALEGetJNIMethodID(env, CLASSPATH_BT_GATT,
-                                                              "readCharacteristic",
-                                                              "(Landroid/bluetooth/"
-                                                              "BluetoothGattCharacteristic;)Z");
+    jmethodID jni_mid_readCharacteristic = CAGetJNIMethodID(env, CLASSPATH_BT_GATT,
+                                                            "readCharacteristic",
+                                                            "(Landroid/bluetooth/"
+                                                            "BluetoothGattCharacteristic;)Z");
     if (!jni_mid_readCharacteristic)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_readCharacteristic is null");
@@ -2116,7 +2170,7 @@ CAResult_t CALEClientReadCharacteristic(JNIEnv *env, jobject bluetoothGatt)
     }
 
     // call disconnect gatt method
-    OIC_LOG(DEBUG, TAG, "CALL API - request to read gatt characteristic");
+    OIC_LOG(INFO, TAG, "CALL API - readCharacteristic");
     jboolean ret = (*env)->CallBooleanMethod(env, bluetoothGatt, jni_mid_readCharacteristic,
                                              jni_obj_GattCharacteristic);
     if (ret)
@@ -2147,25 +2201,26 @@ CAResult_t CALEClientSetCharacteristicNotification(JNIEnv *env, jobject bluetoot
 
     // get BluetoothGatt.setCharacteristicNotification method
     OIC_LOG(DEBUG, TAG, "CALEClientSetCharacteristicNotification");
-    jmethodID jni_mid_setNotification = CALEGetJNIMethodID(env, CLASSPATH_BT_GATT,
-                                                              "setCharacteristicNotification",
-                                                              "(Landroid/bluetooth/"
-                                                              "BluetoothGattCharacteristic;Z)Z");
+    jmethodID jni_mid_setNotification = CAGetJNIMethodID(env, CLASSPATH_BT_GATT,
+                                                         "setCharacteristicNotification",
+                                                         "(Landroid/bluetooth/"
+                                                         "BluetoothGattCharacteristic;Z)Z");
     if (!jni_mid_setNotification)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_getService is null");
         return CA_STATUS_FAILED;
     }
 
+    OIC_LOG(INFO, TAG, "CALL API - setCharacteristicNotification");
     jboolean ret = (*env)->CallBooleanMethod(env, bluetoothGatt, jni_mid_setNotification,
                                              characteristic, JNI_TRUE);
     if (JNI_TRUE == ret)
     {
-        OIC_LOG(DEBUG, TAG, "CALL API - setCharacteristicNotification success");
+        OIC_LOG(DEBUG, TAG, "setCharacteristicNotification success");
     }
     else
     {
-        OIC_LOG(ERROR, TAG, "CALL API - setCharacteristicNotification has failed");
+        OIC_LOG(ERROR, TAG, "setCharacteristicNotification has failed");
         return CA_STATUS_FAILED;
     }
 
@@ -2186,10 +2241,10 @@ jobject CALEClientGetGattService(JNIEnv *env, jobject bluetoothGatt, jstring cha
 
     // get BluetoothGatt.getService method
     OIC_LOG(DEBUG, TAG, "BluetoothGatt.getService");
-    jmethodID jni_mid_getService = CALEGetJNIMethodID(env, CLASSPATH_BT_GATT,
-                                                      "getService",
-                                                      "(Ljava/util/UUID;)Landroid/bluetooth/"
-                                                      "BluetoothGattService;");
+    jmethodID jni_mid_getService = CAGetJNIMethodID(env, CLASSPATH_BT_GATT,
+                                                    "getService",
+                                                    "(Ljava/util/UUID;)Landroid/bluetooth/"
+                                                    "BluetoothGattService;");
     if (!jni_mid_getService)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_getService is null");
@@ -2214,12 +2269,12 @@ jobject CALEClientGetGattService(JNIEnv *env, jobject bluetoothGatt, jstring cha
     }
 
     // get bluetooth gatt service method
-    jmethodID jni_mid_getCharacteristic = CALEGetJNIMethodID(env, "android/bluetooth/"
-                                                      "BluetoothGattService",
-                                                      "getCharacteristic",
-                                                      "(Ljava/util/UUID;)"
-                                                      "Landroid/bluetooth/"
-                                                      "BluetoothGattCharacteristic;");
+    jmethodID jni_mid_getCharacteristic = CAGetJNIMethodID(env, "android/bluetooth/"
+                                                           "BluetoothGattService",
+                                                           "getCharacteristic",
+                                                           "(Ljava/util/UUID;)"
+                                                           "Landroid/bluetooth/"
+                                                           "BluetoothGattCharacteristic;");
     if (!jni_mid_getCharacteristic)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_getCharacteristic is null");
@@ -2342,9 +2397,9 @@ jbyteArray CALEClientGetValueFromCharacteristic(JNIEnv *env, jobject characteris
         return NULL;
     }
 
-    jmethodID jni_mid_getValue  = CALEGetJNIMethodID(env, "android/bluetooth/"
-                                                     "BluetoothGattCharacteristic",
-                                                     "getValue", "()[B");
+    jmethodID jni_mid_getValue  = CAGetJNIMethodID(env, "android/bluetooth/"
+                                                   "BluetoothGattCharacteristic",
+                                                   "getValue", "()[B");
     if (!jni_mid_getValue)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_getValue is null");
@@ -2438,11 +2493,11 @@ CAResult_t CALEClientSetUUIDToDescriptor(JNIEnv *env, jobject bluetoothGatt,
     }
 
     OIC_LOG(DEBUG, TAG, "CALEClientSetUUIDToDescriptor");
-    jmethodID jni_mid_getDescriptor  = CALEGetJNIMethodID(env, "android/bluetooth/"
-                                                          "BluetoothGattCharacteristic",
-                                                          "getDescriptor",
-                                                          "(Ljava/util/UUID;)Landroid/bluetooth/"
-                                                          "BluetoothGattDescriptor;");
+    jmethodID jni_mid_getDescriptor  = CAGetJNIMethodID(env, "android/bluetooth/"
+                                                        "BluetoothGattCharacteristic",
+                                                        "getDescriptor",
+                                                        "(Ljava/util/UUID;)Landroid/bluetooth/"
+                                                        "BluetoothGattDescriptor;");
     if (!jni_mid_getDescriptor)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_getDescriptor is null");
@@ -2504,17 +2559,17 @@ CAResult_t CALEClientSetUUIDToDescriptor(JNIEnv *env, jobject bluetoothGatt,
         return CA_STATUS_FAILED;
     }
 
-    jmethodID jni_mid_writeDescriptor  = CALEGetJNIMethodID(env, "android/bluetooth/BluetoothGatt",
-                                                            "writeDescriptor",
-                                                            "(Landroid/bluetooth/"
-                                                            "BluetoothGattDescriptor;)Z");
+    jmethodID jni_mid_writeDescriptor  = CAGetJNIMethodID(env, "android/bluetooth/BluetoothGatt",
+                                                          "writeDescriptor",
+                                                          "(Landroid/bluetooth/"
+                                                          "BluetoothGattDescriptor;)Z");
     if (!jni_mid_writeDescriptor)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_writeDescriptor is null");
         return CA_STATUS_FAILED;
     }
 
-    OIC_LOG(DEBUG, TAG, "request to write descriptor");
+    OIC_LOG(INFO, TAG, "CALL API - writeDescriptor");
     jboolean jni_ret = (*env)->CallBooleanMethod(env, bluetoothGatt, jni_mid_writeDescriptor,
                                                  jni_obj_descriptor);
     if (jni_ret)
@@ -2558,7 +2613,7 @@ CAResult_t CALEClientAddScanDeviceToList(JNIEnv *env, jobject device)
         OIC_LOG(ERROR, TAG, "gdevice_list is null");
 
         CALEClientSetScanFlag(false);
-        if(CA_STATUS_OK != CALEClientStopScan())
+        if (CA_STATUS_OK != CALEClientStopScan())
         {
             OIC_LOG(ERROR, TAG, "CALEClientStopScan has failed");
         }
@@ -2588,7 +2643,7 @@ CAResult_t CALEClientAddScanDeviceToList(JNIEnv *env, jobject device)
         jobject gdevice = (*env)->NewGlobalRef(env, device);
         u_arraylist_add(g_deviceList, gdevice);
         ca_cond_signal(g_deviceDescCond);
-        OIC_LOG_V(DEBUG, TAG, "Added this BT Device[%s] in the List", remoteAddress);
+        OIC_LOG_V(DEBUG, TAG, "Added a new BT Device in deviceList [%s]", remoteAddress);
     }
     (*env)->ReleaseStringUTFChars(env, jni_remoteAddress, remoteAddress);
 
@@ -2641,7 +2696,7 @@ bool CALEClientIsDeviceInScanDeviceList(JNIEnv *env, const char* remoteAddress)
         (*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
     }
 
-    OIC_LOG(DEBUG, TAG, "there are no the device in list. we can add");
+    OIC_LOG_V(DEBUG, TAG, "[%s] doesn't exist in scanned device list", remoteAddress);
 
     return false;
 }
@@ -2764,7 +2819,7 @@ CAResult_t CALEClientRemoveDeviceInScanDeviceList(JNIEnv *env, jstring address)
 
 CAResult_t CALEClientAddGattobjToList(JNIEnv *env, jobject gatt)
 {
-    OIC_LOG(INFO, TAG, "CALEClientAddGattobjToList");
+    OIC_LOG(DEBUG, TAG, "CALEClientAddGattobjToList");
     VERIFY_NON_NULL(env, TAG, "env is null");
     VERIFY_NON_NULL(gatt, TAG, "gatt is null");
 
@@ -2793,12 +2848,12 @@ CAResult_t CALEClientAddGattobjToList(JNIEnv *env, jobject gatt)
         return CA_STATUS_FAILED;
     }
 
-    OIC_LOG_V(INFO, TAG, "remote address : %s", remoteAddress);
+    OIC_LOG_V(DEBUG, TAG, "remote address : %s", remoteAddress);
     if (!CALEClientIsGattObjInList(env, remoteAddress))
     {
         jobject newGatt = (*env)->NewGlobalRef(env, gatt);
         u_arraylist_add(g_gattObjectList, newGatt);
-        OIC_LOG(INFO, TAG, "Set GATT Object to Array as Element");
+        OIC_LOG(INFO, TAG, "added a newGatt object to gattObjectList");
     }
 
     (*env)->ReleaseStringUTFChars(env, jni_remoteAddress, remoteAddress);
@@ -3098,7 +3153,7 @@ CAResult_t CALEClientRemoveGattObjForAddr(JNIEnv *env, jstring addr)
 
 jstring CALEClientGetLEAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice)
 {
-    OIC_LOG(DEBUG, TAG, "IN - CALEClientGetLEAddressFromBTDevice");
+    OIC_LOG(DEBUG, TAG, "CALEClientGetLEAddressFromBTDevice");
 
     VERIFY_NON_NULL_RET(env, TAG, "env", NULL);
     VERIFY_NON_NULL_RET(bluetoothDevice, TAG, "bluetoothDevice", NULL);
@@ -3119,8 +3174,8 @@ jstring CALEClientGetLEAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice)
     }
 
     // get method ID of getDevice()
-    jmethodID jni_mid_getDevice = CALEGetJNIMethodID(env, CLASSPATH_BT_GATT,
-                                                     "getDevice", METHODID_BT_DEVICE);
+    jmethodID jni_mid_getDevice = CAGetJNIMethodID(env, CLASSPATH_BT_GATT,
+                                                   "getDevice", METHODID_BT_DEVICE);
     if (!jni_mid_getDevice)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_getDevice is null");
@@ -3128,21 +3183,27 @@ jstring CALEClientGetLEAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice)
         return NULL;
     }
 
+    ca_mutex_lock(g_gattObjectMutex);
+
     size_t length = u_arraylist_length(g_gattObjectList);
+    OIC_LOG_V(DEBUG, TAG, "length of gattObjectList : %d", length);
+    OIC_LOG_V(DEBUG, TAG, "targetAddress : %s", targetAddress);
+
     for (size_t index = 0; index < length; index++)
     {
         jobject jarrayObj = (jobject) u_arraylist_get(g_gattObjectList, index);
         if (!jarrayObj)
         {
+            ca_mutex_unlock(g_gattObjectMutex);
             OIC_LOG(ERROR, TAG, "jarrayObj is null");
             (*env)->ReleaseStringUTFChars(env, jni_btTargetAddress, targetAddress);
             return NULL;
         }
 
-        OIC_LOG(DEBUG, TAG, "CALL API - bluetoothGatt.getDevice()");
         jobject jni_obj_device = (*env)->CallObjectMethod(env, jarrayObj, jni_mid_getDevice);
         if (!jni_obj_device)
         {
+            ca_mutex_unlock(g_gattObjectMutex);
             OIC_LOG(ERROR, TAG, "jni_obj_device is null");
             (*env)->ReleaseStringUTFChars(env, jni_btTargetAddress, targetAddress);
             return NULL;
@@ -3151,6 +3212,7 @@ jstring CALEClientGetLEAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice)
         jstring jni_btAddress = CALEGetAddressFromBTDevice(env, jni_obj_device);
         if (!jni_btAddress)
         {
+            ca_mutex_unlock(g_gattObjectMutex);
             OIC_LOG(ERROR, TAG, "CALEGetAddressFromBTDevice has failed");
             (*env)->ReleaseStringUTFChars(env, jni_btTargetAddress, targetAddress);
             return NULL;
@@ -3159,13 +3221,13 @@ jstring CALEClientGetLEAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice)
         const char* btAddress = (*env)->GetStringUTFChars(env, jni_btAddress, NULL);
         if (!btAddress)
         {
+            ca_mutex_unlock(g_gattObjectMutex);
             OIC_LOG(ERROR, TAG, "btAddress is not available");
             (*env)->ReleaseStringUTFChars(env, jni_btTargetAddress, targetAddress);
             return NULL;
         }
 
-        OIC_LOG_V(DEBUG, TAG, "targetAddress : %s", targetAddress);
-        OIC_LOG_V(DEBUG, TAG, "btAddress : %s", btAddress);
+        OIC_LOG_V(DEBUG, TAG, "btAddress : %s (idx: %d)", btAddress, index);
         if (!strcmp(targetAddress, btAddress))
         {
             OIC_LOG(DEBUG, TAG, "Found Gatt object from BT device");
@@ -3176,6 +3238,7 @@ jstring CALEClientGetLEAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice)
             {
                 OIC_LOG(ERROR, TAG, "jni_LEAddress is null");
             }
+            ca_mutex_unlock(g_gattObjectMutex);
             (*env)->ReleaseStringUTFChars(env, jni_btTargetAddress, targetAddress);
             (*env)->ReleaseStringUTFChars(env, jni_btAddress, btAddress);
             (*env)->DeleteLocalRef(env, jni_btAddress);
@@ -3186,8 +3249,10 @@ jstring CALEClientGetLEAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice)
         (*env)->DeleteLocalRef(env, jni_btAddress);
         (*env)->DeleteLocalRef(env, jni_obj_device);
     }
+    ca_mutex_unlock(g_gattObjectMutex);
 
-    OIC_LOG(DEBUG, TAG, "OUT - CALEClientGetLEAddressFromBTDevice");
+    (*env)->ReleaseStringUTFChars(env, jni_btTargetAddress, targetAddress);
+    OIC_LOG_V(DEBUG, TAG, "[%s] doesn't exist in gattObjectList", targetAddress);
     return NULL;
 }
 
@@ -3195,48 +3260,24 @@ jstring CALEClientGetLEAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice)
  * BT State List
  */
 
-CAResult_t CALEClientUpdateDeviceState(const char* address, uint32_t connectedState,
-                                       uint16_t notificationState, uint16_t sendState)
+CAResult_t CALEClientUpdateDeviceState(const char* address, uint16_t state_type,
+                                       uint16_t target_state)
 {
     VERIFY_NON_NULL(address, TAG, "address is null");
-
-    CALEState_t *newstate = (CALEState_t*) OICCalloc(1, sizeof(*newstate));
-    if (!newstate)
-    {
-        OIC_LOG(ERROR, TAG, "out of memory");
-        return CA_MEMORY_ALLOC_FAILED;
-    }
-
-    if (strlen(address) > CA_MACADDR_SIZE)
-    {
-        OIC_LOG(ERROR, TAG, "address is not proper");
-        OICFree(newstate);
-        return CA_STATUS_FAILED;
-    }
-
-    OICStrcpy(newstate->address, sizeof(newstate->address), address);
-    newstate->connectedState = connectedState;
-    newstate->notificationState = notificationState;
-    newstate->sendState = sendState;
-    return CALEClientAddDeviceStateToList(newstate);
-}
-
-CAResult_t CALEClientAddDeviceStateToList(CALEState_t* state)
-{
-    VERIFY_NON_NULL(state, TAG, "state is null");
-
-    ca_mutex_lock(g_deviceStateListMutex);
+    VERIFY_NON_NULL(address, TAG, "state_type is null");
+    VERIFY_NON_NULL(address, TAG, "target_state is null");
 
     if (!g_deviceStateList)
     {
         OIC_LOG(ERROR, TAG, "gdevice_list is null");
-        ca_mutex_unlock(g_deviceStateListMutex);
         return CA_STATUS_FAILED;
     }
 
-    if (CALEClientIsDeviceInList(state->address))
+    ca_mutex_lock(g_deviceStateListMutex);
+
+    if (CALEClientIsDeviceInList(address))
     {
-        CALEState_t* curState = CALEClientGetStateInfo(state->address);
+        CALEState_t* curState = CALEClientGetStateInfo(address);
         if(!curState)
         {
             OIC_LOG(ERROR, TAG, "curState is null");
@@ -3244,27 +3285,61 @@ CAResult_t CALEClientAddDeviceStateToList(CALEState_t* state)
             return CA_STATUS_FAILED;
         }
 
-        if (STATE_CHARACTER_NO_CHANGE == state->notificationState)
+        switch(state_type)
         {
-            state->notificationState = curState->notificationState;
+            case CA_LE_CONNECTION_STATE:
+                curState->connectedState = target_state;
+                break;
+            case CA_LE_SEND_STATE:
+                curState->sendState = target_state;
+                break;
+            default:
+                break;
+        }
+        OIC_LOG_V(INFO, TAG, "update state - addr : %s, conn : %d, send : %d, ACFlag : %d",
+                  curState->address, curState->connectedState, curState->sendState,
+                  curState->autoConnectFlag);
+    }
+    else /** state is added newly **/
+    {
+        if (strlen(address) > CA_MACADDR_SIZE)
+        {
+            OIC_LOG(ERROR, TAG, "address is not proper");
+            ca_mutex_unlock(g_deviceStateListMutex);
+            return CA_STATUS_INVALID_PARAM;
         }
-        state->autoConnectFlag = curState->autoConnectFlag;
 
-        // delete previous state for update new state
-        CAResult_t res = CALEClientRemoveDeviceState(state->address);
-        if (CA_STATUS_OK != res)
+        CALEState_t *newstate = (CALEState_t*) OICCalloc(1, sizeof(*newstate));
+        if (!newstate)
         {
-            OIC_LOG(ERROR, TAG, "CALEClientRemoveDeviceState has failed");
+            OIC_LOG(ERROR, TAG, "out of memory");
             ca_mutex_unlock(g_deviceStateListMutex);
-            return res;
+            return CA_MEMORY_ALLOC_FAILED;
         }
-    }
-    u_arraylist_add(g_deviceStateList, state); // update new state
-    OIC_LOG_V(INFO, TAG, "Set State Info to List : %d, %d, %s, %d",
-              state->connectedState, state->notificationState,
-              state->address, state->autoConnectFlag);
 
+        OICStrcpy(newstate->address, sizeof(newstate->address), address);
+
+        switch(state_type)
+        {
+            case CA_LE_CONNECTION_STATE:
+                newstate->connectedState = target_state;
+                newstate->sendState = STATE_SEND_NONE;
+                break;
+            case CA_LE_SEND_STATE:
+                newstate->connectedState = STATE_DISCONNECTED;
+                newstate->sendState = target_state;
+                break;
+            default:
+                break;
+        }
+        OIC_LOG_V(INFO, TAG, "add a new state to List - addr : %s, "
+                  "conn : %d, send : %d, ACFlag : %d",
+                  newstate->address, newstate->connectedState, newstate->sendState,
+                  newstate->autoConnectFlag);
+        u_arraylist_add(g_deviceStateList, newstate); // update new state
+    }
     ca_mutex_unlock(g_deviceStateListMutex);
+
     return CA_STATUS_OK;
 }
 
@@ -3359,7 +3434,6 @@ CAResult_t CALEClientResetDeviceStateForAll()
         // autoConnectFlag value will be not changed,
         // since it has reset only termination case.
         state->connectedState = STATE_DISCONNECTED;
-        state->notificationState = STATE_CHARACTER_UNSET;
         state->sendState = STATE_SEND_NONE;
     }
     ca_mutex_unlock(g_deviceStateListMutex);
@@ -3410,7 +3484,6 @@ CAResult_t CALEClientRemoveDeviceState(const char* remoteAddress)
 
 CALEState_t* CALEClientGetStateInfo(const char* remoteAddress)
 {
-    OIC_LOG(DEBUG, TAG, "CALEClientGetStateInfo");
     VERIFY_NON_NULL_RET(remoteAddress, TAG, "remoteAddress is null", NULL);
 
     if (!g_deviceStateList)
@@ -3420,7 +3493,8 @@ CALEState_t* CALEClientGetStateInfo(const char* remoteAddress)
     }
 
     uint32_t length = u_arraylist_length(g_deviceStateList);
-    OIC_LOG_V(DEBUG, TAG, "CALEClientGetStateInfo : %d", length);
+    OIC_LOG_V(DEBUG, TAG, "length of deviceStateList : %d", length);
+    OIC_LOG_V(DEBUG, TAG, "target address : %s", remoteAddress);
 
     for (uint32_t index = 0; index < length; index++)
     {
@@ -3431,21 +3505,24 @@ CALEState_t* CALEClientGetStateInfo(const char* remoteAddress)
             continue;
         }
 
-        OIC_LOG_V(DEBUG, TAG, "target address : %s", remoteAddress);
-        OIC_LOG_V(DEBUG, TAG, "state address : %s", state->address);
+        OIC_LOG_V(DEBUG, TAG, "state address : %s (idx: %d)", state->address, index);
 
         if (!strcmp(state->address, remoteAddress))
         {
-            OIC_LOG_V(DEBUG, TAG, "get state : %s", remoteAddress);
+            OIC_LOG(DEBUG, TAG, "found state");
             return state;
         }
     }
+
+    OIC_LOG_V(DEBUG, TAG, "[%s] doesn't exist in deviceStateList", remoteAddress);
     return NULL;
 }
 
-bool CALEClientIsConnectedDevice(const char* remoteAddress)
+bool CALEClientIsValidState(const char* remoteAddress, uint16_t state_type,
+                             uint16_t target_state)
 {
-    OIC_LOG(DEBUG, TAG, "CALEClientIsConnectedDevice");
+    OIC_LOG_V(DEBUG, TAG, "CALEClientIsValidState : type[%d], target state[%d]",
+              state_type, target_state);
     VERIFY_NON_NULL_RET(remoteAddress, TAG, "remoteAddress is null", false);
 
     ca_mutex_lock(g_deviceStateListMutex);
@@ -3456,74 +3533,36 @@ bool CALEClientIsConnectedDevice(const char* remoteAddress)
         return false;
     }
 
-    uint32_t length = u_arraylist_length(g_deviceStateList);
-    for (uint32_t index = 0; index < length; index++)
+    CALEState_t* state = CALEClientGetStateInfo(remoteAddress);
+    if (NULL == state)
     {
-        CALEState_t* state = (CALEState_t*) u_arraylist_get(g_deviceStateList, index);
-        if (!state)
-        {
-            OIC_LOG(ERROR, TAG, "CALEState_t object is null");
-            continue;
-        }
-
-        if (!strcmp(state->address, remoteAddress))
-        {
-            OIC_LOG(DEBUG, TAG, "check whether it is connected or not");
-
-            if (STATE_CONNECTED == state->connectedState)
-            {
-                ca_mutex_unlock(g_deviceStateListMutex);
-                return true;
-            }
-            else
-            {
-                ca_mutex_unlock(g_deviceStateListMutex);
-                return false;
-            }
-        }
+        OIC_LOG(ERROR, TAG, "state is null");
+        ca_mutex_unlock(g_deviceStateListMutex);
+        return false;
     }
-    ca_mutex_unlock(g_deviceStateListMutex);
-    return false;
-}
 
-bool CALEClientIsSetCharacteristic(const char* remoteAddress)
-{
-    OIC_LOG(DEBUG, TAG, "CALEClientIsSetCharacteristic");
-    VERIFY_NON_NULL_RET(remoteAddress, TAG, "remoteAddress is null", false);
+    uint16_t curValue = 0;
+    switch(state_type)
+    {
+        case CA_LE_CONNECTION_STATE:
+            curValue = state->connectedState;
+            break;
+        case CA_LE_SEND_STATE:
+            curValue = state->sendState;
+            break;
+        default:
+            break;
+    }
 
-    ca_mutex_lock(g_deviceStateListMutex);
-    if (!g_deviceStateList)
+    if (target_state == curValue)
     {
-        OIC_LOG(ERROR, TAG, "g_deviceStateList is null");
         ca_mutex_unlock(g_deviceStateListMutex);
-        return false;
+        return true;
     }
-
-    uint32_t length = u_arraylist_length(g_deviceStateList);
-    for (uint32_t index = 0; index < length; index++)
+    else
     {
-        CALEState_t* state = (CALEState_t*) u_arraylist_get(g_deviceStateList, index);
-        if (!state)
-        {
-            OIC_LOG(ERROR, TAG, "CALEState_t object is null");
-            continue;
-        }
-
-        if (!strcmp(state->address, remoteAddress))
-        {
-            OIC_LOG_V(DEBUG, TAG, "check whether it was set or not:%d", state->notificationState);
-
-            if (STATE_CHARACTER_SET == state->notificationState)
-            {
-                ca_mutex_unlock(g_deviceStateListMutex);
-                return true;
-            }
-            else
-            {
-                ca_mutex_unlock(g_deviceStateListMutex);
-                return false;
-            }
-        }
+        ca_mutex_unlock(g_deviceStateListMutex);
+        return false;
     }
 
     ca_mutex_unlock(g_deviceStateListMutex);
@@ -3702,6 +3741,16 @@ CAResult_t CALEClientInitGattMutexVaraibles()
         }
     }
 
+    if (NULL == g_threadSendStateMutex)
+    {
+        g_threadSendStateMutex = ca_mutex_new();
+        if (NULL == g_threadSendStateMutex)
+        {
+            OIC_LOG(ERROR, TAG, "ca_mutex_new has failed");
+            return CA_STATUS_FAILED;
+        }
+    }
+
     return CA_STATUS_OK;
 }
 
@@ -3733,6 +3782,9 @@ void CALEClientTerminateGattMutexVariables()
 
     ca_mutex_free(g_deviceScanRetryDelayMutex);
     g_deviceScanRetryDelayMutex = NULL;
+
+    ca_mutex_free(g_threadSendStateMutex);
+    g_threadSendStateMutex = NULL;
 }
 
 void CALEClientSetSendFinishFlag(bool flag)
@@ -3862,9 +3914,9 @@ void CATerminateLEGattClient()
     CALEClientTerminate();
 }
 
-CAResult_t  CAUpdateCharacteristicsToGattServer(const char *remoteAddress, const uint8_t  *data,
-                                                uint32_t dataLen, CALETransferType_t type,
-                                                int32_t position)
+CAResult_t CAUpdateCharacteristicsToGattServer(const char *remoteAddress, const uint8_t  *data,
+                                               uint32_t dataLen, CALETransferType_t type,
+                                               int32_t position)
 {
     OIC_LOG(DEBUG, TAG, "call CALEClientSendUnicastMessage");
     VERIFY_NON_NULL(data, TAG, "data is null");
@@ -3952,8 +4004,8 @@ static jstring CALEClientGetAddressFromGatt(JNIEnv *env, jobject gatt)
     VERIFY_NON_NULL_RET(env, TAG, "env is null", NULL);
     VERIFY_NON_NULL_RET(gatt, TAG, "gatt is null", NULL);
 
-    jmethodID jni_mid_getDevice = CALEGetJNIMethodID(env, CLASSPATH_BT_GATT,
-                                                     "getDevice", METHODID_BT_DEVICE);
+    jmethodID jni_mid_getDevice = CAGetJNIMethodID(env, CLASSPATH_BT_GATT,
+                                                   "getDevice", METHODID_BT_DEVICE);
     if (!jni_mid_getDevice)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_getDevice is null");
@@ -3985,87 +4037,81 @@ static jstring CALEClientGetAddressFromGatt(JNIEnv *env, jobject gatt)
  */
 JNIEXPORT void JNICALL
 Java_org_iotivity_ca_CaLeClientInterface_caLeGattConnectionStateChangeCallback(JNIEnv *env,
-                                                                                jobject obj,
-                                                                                jobject gatt,
-                                                                                jint status,
-                                                                                jint newstate)
+                                                                               jobject obj,
+                                                                               jobject gatt,
+                                                                               jint status,
+                                                                               jint newstate)
 {
-    OIC_LOG_V(DEBUG, TAG, "CALeGattConnectionStateChangeCallback - status %d, newstate %d", status,
-            newstate);
+    OIC_LOG_V(INFO, TAG, "CALeGattConnectionStateChangeCallback - status %d, newstate %d", status,
+              newstate);
     VERIFY_NON_NULL_VOID(env, TAG, "env is null");
     VERIFY_NON_NULL_VOID(obj, TAG, "obj is null");
     VERIFY_NON_NULL_VOID(gatt, TAG, "gatt is null");
 
     jint state_connected = CALEGetConstantsValue(env, CLASSPATH_BT_PROFILE, "STATE_CONNECTED");
-    jint state_disconnected = CALEGetConstantsValue(env, CLASSPATH_BT_PROFILE, "STATE_DISCONNECTED");
-    jint gatt_success = CALEGetConstantsValue(env, CLASSPATH_BT_GATT, "GATT_SUCCESS");
 
-    if (gatt_success == status && state_connected == newstate) // le connected
+    jstring jni_address = CALEClientGetAddressFromGattObj(env, gatt);
+    if (!jni_address)
     {
-        jstring jni_address = CALEClientGetAddressFromGattObj(env, gatt);
-        if (!jni_address)
-        {
-            goto error_exit;
-        }
+        OIC_LOG(ERROR, TAG, "CALEClientGetAddressFromGattObj has failed");
+        goto error_exit;
+    }
 
-        const char* address = (*env)->GetStringUTFChars(env, jni_address, NULL);
-        if (address)
+    const char* address = (*env)->GetStringUTFChars(env, jni_address, NULL);
+    if (!address)
+    {
+        OIC_LOG(ERROR, TAG, "address is null");
+        goto error_exit;
+    }
+    OIC_LOG_V(DEBUG, TAG, "CALeGattConnectionStateChangeCallback - address [%s]", address);
+
+    CAResult_t res;
+    if (state_connected == newstate)
+    {
+        OIC_LOG(DEBUG, TAG, "LE is connected");
+        if (GATT_SUCCESS == status)
         {
-            CAResult_t res = CALEClientUpdateDeviceState(address, STATE_CONNECTED,
-                                                         STATE_CHARACTER_NO_CHANGE,
-                                                         STATE_SEND_NONE);
+            res = CALEClientUpdateDeviceState(address, CA_LE_CONNECTION_STATE, STATE_CONNECTED);
+            (*env)->ReleaseStringUTFChars(env, jni_address, address);
             if (CA_STATUS_OK != res)
             {
                 OIC_LOG(ERROR, TAG, "CALEClientUpdateDeviceState has failed");
-                (*env)->ReleaseStringUTFChars(env, jni_address, address);
                 goto error_exit;
             }
-            OIC_LOG_V(INFO, TAG, "ConnectionStateCB - remote address : %s", address);
 
-            (*env)->ReleaseStringUTFChars(env, jni_address, address);
-        }
+            res = CALEClientAddGattobjToList(env, gatt);
+            if (CA_STATUS_OK != res)
+            {
+                OIC_LOG(ERROR, TAG, "CALEClientAddGattobjToList has failed");
+                goto error_exit;
+            }
 
-        CAResult_t res = CALEClientAddGattobjToList(env, gatt);
-        if (CA_STATUS_OK != res)
-        {
-            OIC_LOG(ERROR, TAG, "CALEClientAddGattobjToList has failed");
-            goto error_exit;
+            res = CALEClientDiscoverServices(env, gatt);
+            if (CA_STATUS_OK != res)
+            {
+                OIC_LOG(ERROR, TAG, "CALEClientDiscoverServices has failed");
+                goto error_exit;
+            }
         }
-
-        res = CALEClientDiscoverServices(env, gatt);
-        if (CA_STATUS_OK != res)
+        else
         {
-            OIC_LOG(ERROR, TAG, "CALEClientDiscoverServices has failed");
-            goto error_exit;
+            OIC_LOG(INFO, TAG, "unknown status");
+            (*env)->ReleaseStringUTFChars(env, jni_address, address);
         }
     }
-    else if (state_disconnected == newstate) // le disconnected
+    else // STATE_DISCONNECTED == newstate
     {
-        jstring jni_address = CALEClientGetAddressFromGattObj(env, gatt);
-        if (!jni_address)
-        {
-            OIC_LOG(ERROR, TAG, "CALEClientGetAddressFromGattObj has failed");
-            goto error_exit;
-        }
+        OIC_LOG(DEBUG, TAG, "LE is disconnected");
 
-        const char* address = (*env)->GetStringUTFChars(env, jni_address, NULL);
-        if (address)
+        res = CALEClientUpdateDeviceState(address, CA_LE_CONNECTION_STATE, STATE_DISCONNECTED);
+        (*env)->ReleaseStringUTFChars(env, jni_address, address);
+        if (CA_STATUS_OK != res)
         {
-            CAResult_t res = CALEClientUpdateDeviceState(address, STATE_DISCONNECTED,
-                                                                  STATE_CHARACTER_UNSET,
-                                                                  STATE_SEND_NONE);
-            if (CA_STATUS_OK != res)
-            {
-                OIC_LOG(ERROR, TAG, "CALEClientUpdateDeviceState has failed");
-                (*env)->ReleaseStringUTFChars(env, jni_address, address);
-                goto error_exit;
-            }
-            OIC_LOG_V(INFO, TAG, "ConnectionStateCB - remote address : %s", address);
-
-            (*env)->ReleaseStringUTFChars(env, jni_address, address);
+            OIC_LOG(ERROR, TAG, "CALEClientUpdateDeviceState has failed");
+            goto error_exit;
         }
 
-        CAResult_t res = CALEClientGattClose(env, gatt);
+        res = CALEClientGattClose(env, gatt);
         if (CA_STATUS_OK != res)
         {
             OIC_LOG(ERROR, TAG, "CALEClientGattClose has failed");
@@ -4112,7 +4158,7 @@ Java_org_iotivity_ca_CaLeClientInterface_caLeGattConnectionStateChangeCallback(J
             {
                 // other reason except for gatt_success is expected to running
                 // background connection in BT platform.
-                OIC_LOG(INFO, TAG, "unknown state or manual disconnected state");
+                OIC_LOG(INFO, TAG, "unknown status or manual disconnected state");
                 CALEClientUpdateSendCnt(env);
                 return;
             }
@@ -4128,7 +4174,6 @@ Java_org_iotivity_ca_CaLeClientInterface_caLeGattConnectionStateChangeCallback(J
 
     // error label.
 error_exit:
-
     CALEClientSendFinish(env, gatt);
     return;
 }
@@ -4140,16 +4185,16 @@ error_exit:
  */
 JNIEXPORT void JNICALL
 Java_org_iotivity_ca_CaLeClientInterface_caLeGattServicesDiscoveredCallback(JNIEnv *env,
-                                                                             jobject obj,
-                                                                             jobject gatt,
-                                                                             jint status)
+                                                                            jobject obj,
+                                                                            jobject gatt,
+                                                                            jint status)
 {
-    OIC_LOG_V(DEBUG, TAG, "CALeGattServicesDiscoveredCallback - status %d: ", status);
+    OIC_LOG_V(INFO, TAG, "CALeGattServicesDiscoveredCallback - status %d", status);
     VERIFY_NON_NULL_VOID(env, TAG, "env is null");
     VERIFY_NON_NULL_VOID(obj, TAG, "obj is null");
     VERIFY_NON_NULL_VOID(gatt, TAG, "gatt is null");
 
-    if (0 != status) // discovery error
+    if (GATT_SUCCESS != status) // discovery error
     {
         CALEClientSendFinish(env, gatt);
         return;
@@ -4169,55 +4214,48 @@ Java_org_iotivity_ca_CaLeClientInterface_caLeGattServicesDiscoveredCallback(JNIE
         return;
     }
 
-    if (!CALEClientIsSetCharacteristic(address))
+    jstring jni_uuid = (*env)->NewStringUTF(env, OIC_GATT_CHARACTERISTIC_RESPONSE_UUID);
+    if (!jni_uuid)
     {
-        jstring jni_uuid = (*env)->NewStringUTF(env, OIC_GATT_CHARACTERISTIC_RESPONSE_UUID);
-        if (!jni_uuid)
-        {
-            OIC_LOG(ERROR, TAG, "jni_uuid is null");
-            goto error_exit;
-        }
+        OIC_LOG(ERROR, TAG, "jni_uuid is null");
+        goto error_exit;
+    }
 
-        jobject jni_obj_GattCharacteristic = CALEClientGetGattService(env, gatt, jni_uuid);
-        if (!jni_obj_GattCharacteristic)
-        {
-            OIC_LOG(ERROR, TAG, "jni_obj_GattCharacteristic is null");
-            goto error_exit;
-        }
+    jobject jni_obj_GattCharacteristic = CALEClientGetGattService(env, gatt, jni_uuid);
+    if (!jni_obj_GattCharacteristic)
+    {
+        OIC_LOG(ERROR, TAG, "jni_obj_GattCharacteristic is null");
+        goto error_exit;
+    }
 
-        CAResult_t res = CALEClientSetCharacteristicNotification(env, gatt,
-                                                                 jni_obj_GattCharacteristic);
-        if (CA_STATUS_OK != res)
-        {
-            OIC_LOG(ERROR, TAG, "CALEClientSetCharacteristicNotification has failed");
-            goto error_exit;
-        }
+    CAResult_t res = CALEClientSetCharacteristicNotification(env, gatt,
+                                                             jni_obj_GattCharacteristic);
+    if (CA_STATUS_OK != res)
+    {
+        OIC_LOG(ERROR, TAG, "CALEClientSetCharacteristicNotification has failed");
+        goto error_exit;
+    }
+
+    res = CALEClientSetUUIDToDescriptor(env, gatt, jni_obj_GattCharacteristic);
+    if (CA_STATUS_OK != res)
+    {
+        OIC_LOG_V(INFO, TAG, "Descriptor is not found : %d", res);
 
-        res = CALEClientSetUUIDToDescriptor(env, gatt, jni_obj_GattCharacteristic);
+        res = CALEClientSetFlagToState(env, jni_address, CA_LE_DESCRIPTOR_FOUND, JNI_FALSE);
         if (CA_STATUS_OK != res)
         {
-            OIC_LOG_V(INFO, TAG, "Descriptor is not found : %d", res);
-            if (g_sendBuffer)
-            {
-                CAResult_t res = CALEClientWriteCharacteristic(env, gatt);
-                if (CA_STATUS_OK != res)
-                {
-                    OIC_LOG(ERROR, TAG, "CALEClientWriteCharacteristic has failed");
-                    goto error_exit;
-                }
-            }
+            OIC_LOG(ERROR, TAG, "CALEClientSetFlagToState has failed");
+            goto error_exit;
         }
 
-        res = CALEClientUpdateDeviceState(address, STATE_CONNECTED, STATE_CHARACTER_SET,
-                                          STATE_SEND_NONE);
+        res = CALEClientUpdateDeviceState(address, CA_LE_CONNECTION_STATE,
+                                          STATE_SERVICE_CONNECTED);
         if (CA_STATUS_OK != res)
         {
             OIC_LOG(ERROR, TAG, "CALEClientUpdateDeviceState has failed");
             goto error_exit;
         }
-    }
-    else
-    {
+
         if (g_sendBuffer)
         {
             CAResult_t res = CALEClientWriteCharacteristic(env, gatt);
@@ -4228,6 +4266,16 @@ Java_org_iotivity_ca_CaLeClientInterface_caLeGattServicesDiscoveredCallback(JNIE
             }
         }
     }
+    else
+    {
+        res = CALEClientSetFlagToState(env, jni_address, CA_LE_DESCRIPTOR_FOUND, JNI_TRUE);
+        if (CA_STATUS_OK != res)
+        {
+            OIC_LOG(ERROR, TAG, "CALEClientSetFlagToState has failed");
+            goto error_exit;
+        }
+    }
+
     OIC_LOG(INFO, TAG, "ServicesDiscovery is successful");
     (*env)->ReleaseStringUTFChars(env, jni_address, address);
     return;
@@ -4247,10 +4295,9 @@ error_exit:
  */
 JNIEXPORT void JNICALL
 Java_org_iotivity_ca_CaLeClientInterface_caLeGattCharacteristicWriteCallback(
-        JNIEnv *env, jobject obj, jobject gatt, jbyteArray data,
-        jint status)
+        JNIEnv *env, jobject obj, jobject gatt, jbyteArray data, jint status)
 {
-    OIC_LOG_V(DEBUG, TAG, "CALeGattCharacteristicWriteCallback - status : %d", status);
+    OIC_LOG_V(INFO, TAG, "CALeGattCharacteristicWriteCallback - status : %d", status);
     VERIFY_NON_NULL_VOID(env, TAG, "env is null");
     VERIFY_NON_NULL_VOID(obj, TAG, "obj is null");
     VERIFY_NON_NULL_VOID(gatt, TAG, "gatt is null");
@@ -4268,8 +4315,7 @@ Java_org_iotivity_ca_CaLeClientInterface_caLeGattCharacteristicWriteCallback(
         goto error_exit;
     }
 
-    jint gatt_success = CALEGetConstantsValue(env, CLASSPATH_BT_GATT, "GATT_SUCCESS");
-    if (gatt_success != status) // error case
+    if (GATT_SUCCESS != status) // error case
     {
         OIC_LOG(ERROR, TAG, "send failure");
 
@@ -4283,9 +4329,8 @@ Java_org_iotivity_ca_CaLeClientInterface_caLeGattCharacteristicWriteCallback(
             ca_cond_signal(g_threadWriteCharacteristicCond);
             ca_mutex_unlock(g_threadWriteCharacteristicMutex);
 
-            CAResult_t res = CALEClientUpdateDeviceState(address, STATE_CONNECTED,
-                                                         STATE_CHARACTER_SET,
-                                                         STATE_SEND_FAILED);
+            CAResult_t res = CALEClientUpdateDeviceState(address, CA_LE_SEND_STATE,
+                                                         STATE_SEND_FAIL);
             if (CA_STATUS_OK != res)
             {
                 OIC_LOG(ERROR, TAG, "CALEClientUpdateDeviceState has failed");
@@ -4297,14 +4342,14 @@ Java_org_iotivity_ca_CaLeClientInterface_caLeGattCharacteristicWriteCallback(
                 g_clientErrorCallback(address, data, length, CA_SEND_FAILED);
             }
 
-            CALEClientSendFinish(env, gatt);
+            (*env)->ReleaseStringUTFChars(env, jni_address, address);
             goto error_exit;
         }
     }
     else
     {
         OIC_LOG(DEBUG, TAG, "send success");
-        CAResult_t res = CALEClientUpdateDeviceState(address, STATE_CONNECTED, STATE_CHARACTER_SET,
+        CAResult_t res = CALEClientUpdateDeviceState(address, CA_LE_SEND_STATE,
                                                      STATE_SEND_SUCCESS);
         if (CA_STATUS_OK != res)
         {
@@ -4339,7 +4384,7 @@ JNIEXPORT void JNICALL
 Java_org_iotivity_ca_CaLeClientInterface_caLeGattCharacteristicChangedCallback(
         JNIEnv *env, jobject obj, jobject gatt, jbyteArray data)
 {
-    OIC_LOG(DEBUG, TAG, "CALeGattCharacteristicChangedCallback");
+    OIC_LOG(INFO, TAG, "CALeGattCharacteristicChangedCallback");
     VERIFY_NON_NULL_VOID(env, TAG, "env is null");
     VERIFY_NON_NULL_VOID(obj, TAG, "obj is null");
     VERIFY_NON_NULL_VOID(gatt, TAG, "gatt is null");
@@ -4383,10 +4428,9 @@ Java_org_iotivity_ca_CaLeClientInterface_caLeGattCharacteristicChangedCallback(
     OIC_LOG_V(DEBUG, TAG, "CALeGattCharacteristicChangedCallback - data. : %p, %d",
               receivedData, length);
 
-    ca_mutex_lock(g_bleServerBDAddressMutex);
     uint32_t sentLength = 0;
-    g_CABLEClientDataReceivedCallback(address, receivedData, length,
-                                      &sentLength);
+    ca_mutex_lock(g_bleServerBDAddressMutex);
+    g_CABLEClientDataReceivedCallback(address, receivedData, length, &sentLength);
     ca_mutex_unlock(g_bleServerBDAddressMutex);
 
     (*env)->ReleaseStringUTFChars(env, jni_address, address);
@@ -4402,14 +4446,34 @@ Java_org_iotivity_ca_CaLeClientInterface_caLeGattDescriptorWriteCallback(JNIEnv
                                                                          jobject gatt,
                                                                          jint status)
 {
-    OIC_LOG_V(DEBUG, TAG, "CALeGattDescriptorWriteCallback - status %d: ", status);
+    OIC_LOG_V(INFO, TAG, "CALeGattDescriptorWriteCallback - status %d", status);
     VERIFY_NON_NULL_VOID(env, TAG, "env is null");
     VERIFY_NON_NULL_VOID(obj, TAG, "obj is null");
     VERIFY_NON_NULL_VOID(gatt, TAG, "gatt is null");
 
-    jint gatt_success = CALEGetConstantsValue(env, CLASSPATH_BT_GATT, "GATT_SUCCESS");
-    if (gatt_success != status) // error
+    if (GATT_SUCCESS != status) // error
+    {
+        goto error_exit;
+    }
+
+    jstring jni_address = CALEClientGetAddressFromGattObj(env, gatt);
+    if (!jni_address)
+    {
+        goto error_exit;
+    }
+
+    const char* address = (*env)->GetStringUTFChars(env, jni_address, NULL);
+    if (!address)
+    {
+        goto error_exit;
+    }
+
+    CAResult_t res = CALEClientUpdateDeviceState(address, CA_LE_CONNECTION_STATE,
+                                                 STATE_SERVICE_CONNECTED);
+    (*env)->ReleaseStringUTFChars(env, jni_address, address);
+    if (CA_STATUS_OK != res)
     {
+        OIC_LOG(ERROR, TAG, "CALEClientUpdateDeviceState has failed");
         goto error_exit;
     }
 
index 10066e1..df49c44 100644 (file)
@@ -37,21 +37,18 @@ extern "C"
 
 static const uint16_t GATT_ERROR = 133;
 
-static const uint16_t STATE_CHARACTER_SET = 2;
-static const uint16_t STATE_CHARACTER_UNSET = 1;
-static const uint16_t STATE_CHARACTER_NO_CHANGE = 0;
-
-static const uint16_t STATE_SEND_NONE = 0;
-static const uint16_t STATE_SEND_SUCCESS = 1;
-static const uint16_t STATE_SEND_FAILED = 2;
+static const uint16_t STATE_SEND_NONE = 1;
+static const uint16_t STATE_SEND_SUCCESS = 2;
+static const uint16_t STATE_SEND_FAIL = 3;
+static const uint16_t STATE_SENDING = 4;
 
 typedef struct le_state_info
 {
     char address[CA_MACADDR_SIZE];
-    jint connectedState;
-    uint16_t notificationState;
+    uint16_t connectedState;
     uint16_t sendState;
     jboolean autoConnectFlag;
+    jboolean isDescriptorFound;
 } CALEState_t;
 
 /**
@@ -180,13 +177,6 @@ CAResult_t CALEClientSendMulticastMessageImpl(JNIEnv *env, const uint8_t *data,
                                               const uint32_t dataLen);
 
 /**
- * check whether it is connected or not with remote address.
- * @param[in]   address               remote address.
- * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
- */
-CAResult_t CALECheckSendState(const char* address);
-
-/**
  * send data to remote device.
  * if it isn't connected yet. connect LE before try to send data.
  * @param[in]   env                   JNI interface pointer.
@@ -272,20 +262,23 @@ void CALEClientSetScanFlag(bool flag);
 CAResult_t CALEClientStopScanImpl(JNIEnv *env, jobject callback);
 
 /**
- * set auto connect flag for connectGatt API.
+ * set flag into State List.
  * @param[in]   env                   JNI interface pointer.
  * @param[in]   jni_address           remote address.
+ * @param[in]   state_idx             state index.
  * @param[in]   flag                  auto connect flag.
  */
-CAResult_t CALEClientSetAutoConnectFlag(JNIEnv *env, jstring jni_address, jboolean flag);
+CAResult_t CALEClientSetFlagToState(JNIEnv *env, jstring jni_address,
+                                    jint state_idx, jboolean flag);
 
 /**
- * get auto connect flag.
+ * get flag from State List.
  * @param[in]   env                   JNI interface pointer.
  * @param[in]   jni_address           remote address.
- * @return  current auto connect flag;
+ * @param[in]   state_idx             state index.
+ * @return  current flag;
  */
-jboolean CALEClientGetAutoConnectFlag(JNIEnv *env, jstring jni_address);
+jboolean CALEClientGetFlagFromState(JNIEnv *env, jstring jni_address, jint state_idx);
 
 /**
  * connect to gatt server hosted.
@@ -505,20 +498,12 @@ jstring CALEClientGetLEAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice)
 /**
  * update new state information.
  * @param[in]   address               remote address.
- * @param[in]   connectedState        connection state.
- * @param[in]   notificationState     whether characteristic notification already set or not.
- * @param[in]   sendState             whether sending was success or not.
+ * @param[in]   state_type            state type.
+ * @param[in]   target_state          state index to update.
  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
  */
-CAResult_t CALEClientUpdateDeviceState(const char* address, uint32_t connectedState,
-                                       uint16_t notificationState, uint16_t sendState);
-
-/**
- * add new state to state list.
- * @param[in]   state                 new state.
- * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
- */
-CAResult_t CALEClientAddDeviceStateToList(CALEState_t* state);
+CAResult_t CALEClientUpdateDeviceState(const char* address, uint16_t state_type,
+                                       uint16_t target_state);
 
 /**
  * check whether the remote address is existed or not.
@@ -555,18 +540,14 @@ CAResult_t CALEClientRemoveDeviceState(const char* remoteAddress);
 CALEState_t* CALEClientGetStateInfo(const char* remoteAddress);
 
 /**
- * check whether the remote address is connected or not.
- * @param[in]   remoteAddress         remote address.
- * @return  true or false.
- */
-bool CALEClientIsConnectedDevice(const char* remoteAddress);
-
-/**
- * check whether the remote address set CharacteristicNotification or not.
+ * check whether the remote address has same state with target state.
  * @param[in]   remoteAddress         remote address.
+ * @param[in]   state_type            state_type.
+ * @param[in]   target_state          state index to check.
  * @return  true or false.
  */
-bool CALEClientIsSetCharacteristic(const char* remoteAddress);
+bool CALEClientIsValidState(const char* remoteAddress, uint16_t state_type,
+                            uint16_t target_state);
 
 /**
  * create scan device list.
index 758243e..cf75d87 100644 (file)
@@ -36,6 +36,8 @@
 
 #define TAG PCF("OIC_CA_LE_MONITOR")
 
+static const jint CONNECTION_FAILED_TO_BE_EASTABLISHED = 62;
+
 static JavaVM *g_jvm;
 
 /**
@@ -260,6 +262,33 @@ CAResult_t CAUnsetLENWConnectionStateChangedCb()
     return CA_STATUS_OK;
 }
 
+static CAResult_t CALEStateConnectedCallback(JNIEnv *env, jstring jni_address,
+                                             jboolean isDescriptorFound)
+{
+    VERIFY_NON_NULL(env, TAG, "env");
+    VERIFY_NON_NULL(jni_address, TAG, "jni_address");
+
+    if (CALEClientGetFlagFromState(env, jni_address, CA_LE_DESCRIPTOR_FOUND) == isDescriptorFound)
+    {
+        if (g_bleConnectionStateChangedCallback)
+        {
+            const char* address = (*env)->GetStringUTFChars(env, jni_address, NULL);
+            if (!address)
+            {
+                OIC_LOG(ERROR, TAG, "address is null");
+                return CA_STATUS_FAILED;
+            }
+
+            g_bleConnectionStateChangedCallback(CA_ADAPTER_GATT_BTLE, address, true);
+            OIC_LOG(DEBUG, TAG, "BLE is connected");
+
+            (*env)->ReleaseStringUTFChars(env, jni_address, address);
+        }
+    }
+
+    return CA_STATUS_OK;
+}
+
 JNIEXPORT void JNICALL
 Java_org_iotivity_ca_CaLeClientInterface_caLeStateChangedCallback(JNIEnv *env, jobject obj,
                                                                    jint status)
@@ -366,18 +395,17 @@ Java_org_iotivity_ca_CaLeClientInterface_caLeGattNWConnectionStateChangeCallback
                                                                                  jobject obj,
                                                                                  jobject gatt,
                                                                                  jint status,
-                                                                                 jint newstate)
+                                                                                 jint newState)
 {
-    VERIFY_NON_NULL_VOID(env, TAG, "env is null");
-    VERIFY_NON_NULL_VOID(obj, TAG, "obj is null");
-    VERIFY_NON_NULL_VOID(gatt, TAG, "gatt is null");
-
     OIC_LOG_V(DEBUG, TAG, "CALeGattNWConnectionStateChangeCallback - status %d, newstate %d",
-              status, newstate);
+              status, newState);
+    VERIFY_NON_NULL_VOID(env, TAG, "env");
+    VERIFY_NON_NULL_VOID(obj, TAG, "obj");
+    VERIFY_NON_NULL_VOID(gatt, TAG, "gatt");
 
     jint state_disconnected = CALEGetConstantsValue(env, CLASSPATH_BT_PROFILE,
                                                     "STATE_DISCONNECTED");
-    if (state_disconnected == newstate)
+    if (state_disconnected == newState)
     {
         jstring jni_address = CALEClientGetAddressFromGattObj(env, gatt);
         if (!jni_address)
@@ -393,9 +421,13 @@ Java_org_iotivity_ca_CaLeClientInterface_caLeGattNWConnectionStateChangeCallback
             return;
         }
 
-        if (g_bleConnectionStateChangedCallback)
+        if (CONNECTION_FAILED_TO_BE_EASTABLISHED != status)
         {
-            g_bleConnectionStateChangedCallback(CA_ADAPTER_GATT_BTLE, address, false);
+            if (g_bleConnectionStateChangedCallback)
+            {
+                OIC_LOG_V(DEBUG, TAG, "LE Disconnected state is %d, %s", newState, address);
+                g_bleConnectionStateChangedCallback(CA_ADAPTER_GATT_BTLE, address, false);
+            }
         }
 
         (*env)->ReleaseStringUTFChars(env, jni_address, address);
@@ -406,37 +438,112 @@ JNIEXPORT void JNICALL
 Java_org_iotivity_ca_CaLeServerInterface_caLeGattServerNWConnectionStateChangeCallback(
         JNIEnv *env, jobject obj, jobject device, jint status, jint newState)
 {
-    OIC_LOG(DEBUG, TAG, " Gatt Server NWConnectionStateChange Callback");
-
+    OIC_LOG_V(DEBUG, TAG, "caLeGattServerNWConnectionStateChangeCallback - status %d, newstate %d",
+              status, newState);
     VERIFY_NON_NULL_VOID(env, TAG, "env");
     VERIFY_NON_NULL_VOID(obj, TAG, "obj");
     VERIFY_NON_NULL_VOID(device, TAG, "device");
-    (void)status;
 
-    // STATE_DISCONNECTED
-    jint state_disconnected = CALEGetConstantsValue(env, CLASSPATH_BT_PROFILE,
-                                                    "STATE_DISCONNECTED");
-    if (state_disconnected == newState)
+    if (CONNECTION_FAILED_TO_BE_EASTABLISHED != status)
+    {
+        if (g_bleConnectionStateChangedCallback)
+        {
+            jstring jni_remoteAddress = CALEGetAddressFromBTDevice(env, device);
+            if (!jni_remoteAddress)
+            {
+                OIC_LOG(ERROR, TAG, "jni_remoteAddress is null");
+                return;
+            }
+
+            const char* address = (*env)->GetStringUTFChars(env, jni_remoteAddress, NULL);
+            if (!address)
+            {
+                OIC_LOG(ERROR, TAG, "address is null");
+                return;
+            }
+
+            // STATE_DISCONNECTED
+            jint state_disconnected = CALEGetConstantsValue(env, CLASSPATH_BT_PROFILE,
+                                                            "STATE_DISCONNECTED");
+
+            // STATE_CONNECTED
+            jint state_connected = CALEGetConstantsValue(env, CLASSPATH_BT_PROFILE,
+                                                         "STATE_CONNECTED");
+
+            if (state_disconnected == newState)
+            {
+                OIC_LOG_V(DEBUG, TAG, "LE Disconnected state is %d, %s", newState, address);
+                g_bleConnectionStateChangedCallback(CA_ADAPTER_GATT_BTLE, address, false);
+            }
+            else if (state_connected == newState)
+            {
+                OIC_LOG_V(DEBUG, TAG, "LE Connected state is %d, %s", newState, address);
+                g_bleConnectionStateChangedCallback(CA_ADAPTER_GATT_BTLE, address, true);
+            }
+            else
+            {
+                OIC_LOG_V(DEBUG, TAG, "Unknown state : %d, %s", newState, address);
+            }
+
+            (*env)->ReleaseStringUTFChars(env, jni_remoteAddress, address);
+        }
+    }
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_ca_CaLeClientInterface_caLeGattNWServicesDiscoveredCallback(JNIEnv *env,
+                                                                              jobject obj,
+                                                                              jobject gatt,
+                                                                              jint status)
+{
+    OIC_LOG_V(DEBUG, TAG, "caLeGattNWServicesDiscoveredCallback - status %d", status);
+    VERIFY_NON_NULL_VOID(env, TAG, "env");
+    VERIFY_NON_NULL_VOID(obj, TAG, "obj");
+    VERIFY_NON_NULL_VOID(gatt, TAG, "gatt");
+
+    if (GATT_SUCCESS == status)
     {
-        jstring jni_remoteAddress = CALEGetAddressFromBTDevice(env, device);
-        if (!jni_remoteAddress)
+        jstring jni_address = CALEGetAddressFromGatt(env, gatt);
+        if (!jni_address)
         {
-            OIC_LOG(ERROR, TAG, "jni_remoteAddress is null");
+            OIC_LOG(ERROR, TAG, "jni_address is null");
             return;
         }
 
-        const char* address = (*env)->GetStringUTFChars(env, jni_remoteAddress, NULL);
-        if (!address)
+        if (CA_STATUS_OK != CALEStateConnectedCallback(env, jni_address, JNI_FALSE))
         {
-            OIC_LOG(ERROR, TAG, "address is null");
+            OIC_LOG(ERROR, TAG, "CALEStateConnectedCallback has failed");
+        }
+
+        (*env)->DeleteLocalRef(env, jni_address);
+    }
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_ca_CaLeClientInterface_caLeGattNWDescriptorWriteCallback(JNIEnv *env,
+                                                                           jobject obj,
+                                                                           jobject gatt,
+                                                                           jint status)
+{
+    OIC_LOG_V(DEBUG, TAG, "caLeGattNWDescriptorWriteCallback - status %d", status);
+    VERIFY_NON_NULL_VOID(env, TAG, "env");
+    VERIFY_NON_NULL_VOID(obj, TAG, "obj");
+    VERIFY_NON_NULL_VOID(gatt, TAG, "gatt");
+
+    if (GATT_SUCCESS == status)
+    {
+        jstring jni_address = CALEGetAddressFromGatt(env, gatt);
+        if (!jni_address)
+        {
+            OIC_LOG(ERROR, TAG, "jni_address is null");
             return;
         }
 
-        if (g_bleConnectionStateChangedCallback)
+        if (CA_STATUS_OK != CALEStateConnectedCallback(env, jni_address, JNI_TRUE))
         {
-            g_bleConnectionStateChangedCallback(CA_ADAPTER_GATT_BTLE, address, false);
+            OIC_LOG(ERROR, TAG, "CALEStateConnectedCallback has failed");
         }
 
-        (*env)->ReleaseStringUTFChars(env, jni_remoteAddress, address);
+        (*env)->DeleteLocalRef(env, jni_address);
     }
 }
index 6237bac..c25157a 100644 (file)
@@ -38,6 +38,7 @@
 #define TAG PCF("OIC_CA_LE_SERVER")
 
 #define WAIT_TIME_WRITE_CHARACTERISTIC 10000000
+#define INVALID_STATE -1
 
 static JavaVM *g_jvm = NULL;
 static jobject g_context = NULL;
@@ -67,6 +68,9 @@ static ca_mutex g_threadSendNotifyMutex = NULL;
 static ca_cond g_threadSendNotifyCond = NULL;
 static bool g_isSignalSetFlag = false;
 
+static jint g_state_connected = INVALID_STATE;
+static jint g_state_disconnected = INVALID_STATE;
+
 static const char CLASSPATH_BT_ADVERTISE_CB[] = "android/bluetooth/le/AdvertiseCallback";
 static const char CLASSPATH_BT_GATTSERVER[] = "android/bluetooth/BluetoothGattServer";
 
@@ -162,10 +166,11 @@ static jint CALEServerGetConnectionState(JNIEnv *env, jobject device)
     VERIFY_NON_NULL_RET(env, TAG, "env", -1);
     VERIFY_NON_NULL_RET(device, TAG, "device", -1);
 
-    jmethodID jni_mid_getConnectionState = CALEGetJNIMethodID(env, "android/bluetooth/BluetoothManager",
-                                                              "getConnectionState",
-                                                              "(Landroid/bluetooth/BluetoothDevice"
-                                                              ";I)I");
+    jmethodID jni_mid_getConnectionState = CAGetJNIMethodID(env, "android/bluetooth"
+                                                            "/BluetoothManager",
+                                                            "getConnectionState",
+                                                            "(Landroid/bluetooth/BluetoothDevice"
+                                                            ";I)I");
     if (!jni_mid_getConnectionState)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_getConnectionState is null");
@@ -204,10 +209,10 @@ jobject CALEServerSetResponseData(JNIEnv *env, jbyteArray responseData)
     }
 
     OIC_LOG(DEBUG, TAG, "CALEServerSetResponseData");
-    jmethodID jni_mid_getService = CALEGetJNIMethodID(env, CLASSPATH_BT_GATTSERVER,
-                                                      "getService",
-                                                      "(Ljava/util/UUID;)Landroid/bluetooth/"
-                                                      "BluetoothGattService;");
+    jmethodID jni_mid_getService = CAGetJNIMethodID(env, CLASSPATH_BT_GATTSERVER,
+                                                    "getService",
+                                                    "(Ljava/util/UUID;)Landroid/bluetooth/"
+                                                    "BluetoothGattService;");
     if (!jni_mid_getService)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_getService is null");
@@ -230,12 +235,12 @@ jobject CALEServerSetResponseData(JNIEnv *env, jbyteArray responseData)
         return NULL;
     }
 
-    jmethodID jni_mid_getCharacteristic = CALEGetJNIMethodID(env, "android/bluetooth/"
-                                                             "BluetoothGattService",
-                                                             "getCharacteristic",
-                                                             "(Ljava/util/UUID;)"
-                                                             "Landroid/bluetooth/"
-                                                             "BluetoothGattCharacteristic;");
+    jmethodID jni_mid_getCharacteristic = CAGetJNIMethodID(env, "android/bluetooth/"
+                                                           "BluetoothGattService",
+                                                           "getCharacteristic",
+                                                           "(Ljava/util/UUID;)"
+                                                           "Landroid/bluetooth/"
+                                                           "BluetoothGattCharacteristic;");
     if (!jni_mid_getCharacteristic)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_getCharacteristic is null");
@@ -258,9 +263,9 @@ jobject CALEServerSetResponseData(JNIEnv *env, jbyteArray responseData)
         return NULL;
     }
 
-    jmethodID jni_mid_setValue = CALEGetJNIMethodID(env, "android/bluetooth/"
-                                                    "BluetoothGattCharacteristic",
-                                                    "setValue", "([B)Z");
+    jmethodID jni_mid_setValue = CAGetJNIMethodID(env, "android/bluetooth/"
+                                                  "BluetoothGattCharacteristic",
+                                                  "setValue", "([B)Z");
     if (!jni_mid_setValue)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_setValue is null");
@@ -292,13 +297,19 @@ CAResult_t CALEServerSendResponseData(JNIEnv *env, jobject device, jobject respo
         return CA_ADAPTER_NOT_ENABLED;
     }
 
-    if (STATE_CONNECTED != CALEServerGetConnectionState(env, device))
+    if (!g_bluetoothGattServer)
+    {
+        OIC_LOG(ERROR, TAG, "g_bluetoothGattServer is not available");
+        return CA_STATUS_FAILED;
+    }
+
+    if (g_state_connected != CALEServerGetConnectionState(env, device))
     {
         OIC_LOG(ERROR, TAG, "it is not connected state");
         return CA_STATUS_FAILED;
     }
 
-    jmethodID jni_mid_notifyCharacteristicChanged = CALEGetJNIMethodID(env,
+    jmethodID jni_mid_notifyCharacteristicChanged = CAGetJNIMethodID(env,
                                                       CLASSPATH_BT_GATTSERVER,
                                                       "notifyCharacteristicChanged",
                                                       "(Landroid/bluetooth/BluetoothDevice;"
@@ -357,10 +368,16 @@ CAResult_t CALEServerSendResponse(JNIEnv *env, jobject device, jint requestId, j
         return CA_ADAPTER_NOT_ENABLED;
     }
 
-    jmethodID jni_mid_sendResponse = CALEGetJNIMethodID(env, CLASSPATH_BT_GATTSERVER,
-                                                        "sendResponse",
-                                                        "(Landroid/bluetooth/BluetoothDevice;"
-                                                        "III[B)Z");
+    if (!g_bluetoothGattServer)
+    {
+        OIC_LOG(ERROR, TAG, "g_bluetoothGattServer is not available");
+        return CA_STATUS_FAILED;
+    }
+
+    jmethodID jni_mid_sendResponse = CAGetJNIMethodID(env, CLASSPATH_BT_GATTSERVER,
+                                                      "sendResponse",
+                                                      "(Landroid/bluetooth/BluetoothDevice;"
+                                                      "III[B)Z");
     if (!jni_mid_sendResponse)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_sendResponse is null");
@@ -690,18 +707,18 @@ CAResult_t CALEServerStartAdvertise(JNIEnv *env, jobject advertiseCallback)
         return CA_STATUS_FAILED;
     }
 
-    jmethodID jni_mid_startAdvertising = CALEGetJNIMethodID(env, "android/bluetooth/le/"
-                                                            "BluetoothLeAdvertiser",
-                                                            "startAdvertising",
-                                                            "(Landroid/bluetooth/le/"
-                                                            "AdvertiseSettings;Landroid/bluetooth/"
-                                                            "le/AdvertiseData;Landroid/bluetooth/"
-                                                            "le/AdvertiseData;Landroid/bluetooth/"
-                                                            "le/AdvertiseCallback;)V");
+    jmethodID jni_mid_startAdvertising = CAGetJNIMethodID(env, "android/bluetooth/le/"
+                                                          "BluetoothLeAdvertiser",
+                                                          "startAdvertising",
+                                                          "(Landroid/bluetooth/le/"
+                                                          "AdvertiseSettings;Landroid/bluetooth/"
+                                                          "le/AdvertiseData;Landroid/bluetooth/"
+                                                          "le/AdvertiseData;Landroid/bluetooth/"
+                                                          "le/AdvertiseCallback;)V");
     if (!jni_mid_startAdvertising)
     {
-        OIC_LOG(ERROR, TAG, "jni_mid_startAdvertising is null");
-        return CA_STATUS_FAILED;
+       OIC_LOG(ERROR, TAG, "jni_mid_startAdvertising is null");
+       return CA_STATUS_FAILED;
     }
 
     (*env)->CallVoidMethod(env, jni_obj_getBluetoothLeAdvertiser, jni_mid_startAdvertising,
@@ -761,11 +778,11 @@ CAResult_t CALEServerStopAdvertise(JNIEnv *env, jobject advertiseCallback)
         return CA_STATUS_FAILED;
     }
 
-    jmethodID jni_mid_stopAdvertising = CALEGetJNIMethodID(env, "android/bluetooth/le/"
-                                                           "BluetoothLeAdvertiser",
-                                                          "stopAdvertising",
-                                                          "(Landroid/bluetooth/le/"
-                                                          "AdvertiseCallback;)V");
+    jmethodID jni_mid_stopAdvertising = CAGetJNIMethodID(env, "android/bluetooth/le/"
+                                                         "BluetoothLeAdvertiser",
+                                                         "stopAdvertising",
+                                                         "(Landroid/bluetooth/le/"
+                                                         "AdvertiseCallback;)V");
     if (!jni_mid_stopAdvertising)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_stopAdvertising is null");
@@ -891,14 +908,14 @@ jobject CALEServerOpenGattServer(JNIEnv *env)
         return NULL;
     }
 
-    jmethodID jni_mid_openGattServer = CALEGetJNIMethodID(env, "android/bluetooth/"
-                                                          "BluetoothManager",
-                                                          "openGattServer",
-                                                          "(Landroid/content/Context;"
-                                                          "Landroid/bluetooth/"
-                                                          "BluetoothGattServerCallback;)"
-                                                          "Landroid/bluetooth/"
-                                                          "BluetoothGattServer;");
+    jmethodID jni_mid_openGattServer = CAGetJNIMethodID(env, "android/bluetooth/"
+                                                        "BluetoothManager",
+                                                        "openGattServer",
+                                                        "(Landroid/content/Context;"
+                                                        "Landroid/bluetooth/"
+                                                        "BluetoothGattServerCallback;)"
+                                                        "Landroid/bluetooth/"
+                                                        "BluetoothGattServer;");
     if (!jni_mid_openGattServer)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_openGattServer is null");
@@ -1229,10 +1246,10 @@ CAResult_t CALEServerAddGattService(JNIEnv *env, jobject bluetoothGattServer,
         return CA_ADAPTER_NOT_ENABLED;
     }
 
-    jmethodID jni_mid_addService = CALEGetJNIMethodID(env, CLASSPATH_BT_GATTSERVER,
-                                                      "addService",
-                                                      "(Landroid/bluetooth/BluetoothGattService;)"
-                                                      "Z");
+    jmethodID jni_mid_addService = CAGetJNIMethodID(env, CLASSPATH_BT_GATTSERVER,
+                                                    "addService",
+                                                    "(Landroid/bluetooth/BluetoothGattService;)"
+                                                    "Z");
      if (!jni_mid_addService)
      {
          OIC_LOG(ERROR, TAG, "jni_mid_addService is null");
@@ -1265,9 +1282,9 @@ CAResult_t CALEServerConnect(JNIEnv *env, jobject bluetoothDevice)
         return CA_ADAPTER_NOT_ENABLED;
     }
 
-    jmethodID jni_mid_connect = CALEGetJNIMethodID(env, CLASSPATH_BT_GATTSERVER,
-                                                   "connect",
-                                                   "(Landroid/bluetooth/BluetoothDevice;Z)Z");
+    jmethodID jni_mid_connect = CAGetJNIMethodID(env, CLASSPATH_BT_GATTSERVER,
+                                                 "connect",
+                                                 "(Landroid/bluetooth/BluetoothDevice;Z)Z");
     if (!jni_mid_connect)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_connect is null");
@@ -1336,10 +1353,10 @@ CAResult_t CALEServerDisconnect(JNIEnv *env, jobject bluetoothDevice)
         return CA_ADAPTER_NOT_ENABLED;
     }
 
-    jmethodID jni_mid_cancelConnection = CALEGetJNIMethodID(env, CLASSPATH_BT_GATTSERVER,
-                                                            "cancelConnection",
-                                                            "(Landroid/bluetooth/BluetoothDevice;)"
-                                                            "V");
+    jmethodID jni_mid_cancelConnection = CAGetJNIMethodID(env, CLASSPATH_BT_GATTSERVER,
+                                                          "cancelConnection",
+                                                          "(Landroid/bluetooth/BluetoothDevice;)"
+                                                          "V");
     if (!jni_mid_cancelConnection)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_cancelConnection is null");
@@ -1369,8 +1386,8 @@ CAResult_t CALEServerGattClose(JNIEnv *env, jobject bluetoothGattServer)
 
     // get BluetoothGatt class
     OIC_LOG(DEBUG, TAG, "get BluetoothGatt class");
-    jmethodID jni_mid_closeGatt = CALEGetJNIMethodID(env, CLASSPATH_BT_GATTSERVER,
-                                                     "close", "()V");
+    jmethodID jni_mid_closeGatt = CAGetJNIMethodID(env, CLASSPATH_BT_GATTSERVER,
+                                                   "close", "()V");
     if (!jni_mid_closeGatt)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_closeGatt is null");
@@ -1694,6 +1711,10 @@ CAResult_t CALEServerStartMulticastServer()
         OIC_LOG(ERROR, TAG, "CALEServerStartAdvertise has failed");
     }
 
+    // get Constants Value from Android Platform
+    g_state_connected = CALEGetConstantsValue(env, CLASSPATH_BT_PROFILE, "STATE_CONNECTED");
+    g_state_disconnected = CALEGetConstantsValue(env, CLASSPATH_BT_PROFILE, "STATE_DISCONNECTED");
+
     if (isAttached)
     {
         (*g_jvm)->DetachCurrentThread(g_jvm);
@@ -2207,13 +2228,7 @@ Java_org_iotivity_ca_CaLeServerInterface_caLeGattServerConnectionStateChangeCall
     VERIFY_NON_NULL_VOID(obj, TAG, "obj");
     VERIFY_NON_NULL_VOID(device, TAG, "device");
 
-    // STATE_CONNECTED
-    jint state_connected = CALEGetConstantsValue(env, CLASSPATH_BT_PROFILE, "STATE_CONNECTED");
-
-    // STATE_DISCONNECTED
-    jint state_disconnected = CALEGetConstantsValue(env, CLASSPATH_BT_PROFILE, "STATE_DISCONNECTED");
-
-    if (newState == state_connected)
+    if (newState == g_state_connected)
     {
 
         OIC_LOG(DEBUG, TAG, "LE CONNECTED");
@@ -2239,7 +2254,7 @@ Java_org_iotivity_ca_CaLeServerInterface_caLeGattServerConnectionStateChangeCall
         }
         (*env)->ReleaseStringUTFChars(env, jni_remoteAddress, remoteAddress);
     }
-    else if (newState == state_disconnected)
+    else if (newState == g_state_disconnected)
     {
         OIC_LOG(DEBUG, TAG, "LE DISCONNECTED");
 
@@ -2422,10 +2437,17 @@ Java_org_iotivity_ca_CaLeServerInterface_caLeAdvertiseStartFailureCallback(JNIEn
 
     jint data_too_large = CALEGetConstantsValue(env, CLASSPATH_BT_ADVERTISE_CB,
                                                 "ADVERTISE_FAILED_DATA_TOO_LARGE");
+    jint already_started = CALEGetConstantsValue(env, CLASSPATH_BT_ADVERTISE_CB,
+                                                 "ADVERTISE_FAILED_ALREADY_STARTED");
+
     if (data_too_large == errorCode)
     {
         OIC_LOG_V(ERROR, TAG, "advertise data too large. please check length of device name");
     }
+    else if (already_started == errorCode)
+    {
+        OIC_LOG_V(INFO, TAG, "advertising is already started");
+    }
 }
 
 /**
index 2905742..b6ad36f 100644 (file)
 
 #define TAG PCF("OIC_CA_LE_UTILS")
 
-jmethodID CALEGetJNIMethodID(JNIEnv *env, const char* className,
-                             const char* methodName,
-                             const char* methodFormat)
-{
-    VERIFY_NON_NULL_RET(env, TAG, "env", NULL);
-    VERIFY_NON_NULL_RET(className, TAG, "className", NULL);
-    VERIFY_NON_NULL_RET(methodName, TAG, "methodName", NULL);
-    VERIFY_NON_NULL_RET(methodFormat, TAG, "methodFormat", NULL);
-
-    jclass jni_cid = (*env)->FindClass(env, className);
-    if (!jni_cid)
-    {
-        OIC_LOG_V(ERROR, TAG, "jni_cid [%s] is null", className);
-        return NULL;
-    }
-
-    jmethodID jni_midID = (*env)->GetMethodID(env, jni_cid, methodName, methodFormat);
-    if (!jni_midID)
-    {
-        OIC_LOG_V(ERROR, TAG, "jni_midID [%s] is null", methodName);
-        return NULL;
-    }
-
-    return jni_midID;
-}
-
 jobject CALEGetUuidFromString(JNIEnv *env, const char* uuid)
 {
     VERIFY_NON_NULL_RET(uuid, TAG, "uuid is null", NULL);
@@ -130,9 +104,9 @@ bool CALEIsBondedDevice(JNIEnv *env, jobject bluetoothDevice)
     VERIFY_NON_NULL_RET(env, TAG, "env is null", false);
     VERIFY_NON_NULL_RET(bluetoothDevice, TAG, "bluetoothDevice is null", false);
 
-    jmethodID jni_mid_getBondState = CALEGetJNIMethodID(env, "android/bluetooth/BluetoothDevice",
-                                                        "getBondState",
-                                                        "()I");
+    jmethodID jni_mid_getBondState = CAGetJNIMethodID(env, "android/bluetooth/BluetoothDevice",
+                                                      "getBondState",
+                                                      "()I");
     if (!jni_mid_getBondState)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_getBondState is null");
@@ -198,8 +172,8 @@ jobjectArray CALEGetBondedDevices(JNIEnv *env)
         return NULL;
     }
 
-    jmethodID jni_mid_toArray = CALEGetJNIMethodID(env, "java/util/Set", "toArray",
-                                                   "()[Ljava/lang/Object;");
+    jmethodID jni_mid_toArray = CAGetJNIMethodID(env, "java/util/Set", "toArray",
+                                                 "()[Ljava/lang/Object;");
     if (!jni_mid_toArray)
     {
         OIC_LOG(ERROR, TAG, "getBondedDevices: jni_mid_toArray is null");
@@ -351,9 +325,9 @@ jstring CALEGetAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice)
     VERIFY_NON_NULL_RET(env, TAG, "env is null", NULL);
     VERIFY_NON_NULL_RET(bluetoothDevice, TAG, "bluetoothDevice is null", NULL);
 
-    jmethodID jni_mid_getAddress = CALEGetJNIMethodID(env, "android/bluetooth/BluetoothDevice",
-                                                      "getAddress",
-                                                      "()Ljava/lang/String;");
+    jmethodID jni_mid_getAddress = CAGetJNIMethodID(env, "android/bluetooth/BluetoothDevice",
+                                                    "getAddress",
+                                                    "()Ljava/lang/String;");
     if (!jni_mid_getAddress)
     {
         OIC_LOG(ERROR, TAG, "jni_mid_getAddress is null");
@@ -373,8 +347,6 @@ jstring CALEGetAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice)
 
 jint CALEGetConstantsValue(JNIEnv *env, const char* classType, const char* name)
 {
-    OIC_LOG(DEBUG, TAG, "CALEGetConstantsValue");
-
     VERIFY_NON_NULL_RET(env, TAG, "env", -1);
     VERIFY_NON_NULL_RET(classType, TAG, "classType", -1);
     VERIFY_NON_NULL_RET(name, TAG, "name", -1);
@@ -451,3 +423,36 @@ jobject CALEGetRemoteDevice(JNIEnv *env, jstring address)
     OIC_LOG(DEBUG, TAG, "OUT - CALEGetRemoteDevice");
     return jni_obj_device;
 }
+
+jstring CALEGetAddressFromGatt(JNIEnv *env, jobject gatt)
+{
+    OIC_LOG(DEBUG, TAG, "IN - CALEGetAddressFromGatt");
+
+    VERIFY_NON_NULL_RET(env, TAG, "env is null", NULL);
+    VERIFY_NON_NULL_RET(gatt, TAG, "gatt is null", NULL);
+
+    jmethodID jni_mid_getDevice = CAGetJNIMethodID(env, CLASSPATH_BT_GATT, "getDevice",
+                                                   METHODID_BT_DEVICE);
+    if (!jni_mid_getDevice)
+    {
+        OIC_LOG(ERROR, TAG, "jni_mid_getDevice is null");
+        return NULL;
+    }
+
+    jobject jni_obj_device = (*env)->CallObjectMethod(env, gatt, jni_mid_getDevice);
+    if (!jni_obj_device)
+    {
+        OIC_LOG(ERROR, TAG, "jni_obj_device is null");
+        return NULL;
+    }
+
+    jstring jni_address = CALEGetAddressFromBTDevice(env, jni_obj_device);
+    if (!jni_address)
+    {
+        OIC_LOG(ERROR, TAG, "jni_address is null");
+        return NULL;
+    }
+
+    OIC_LOG(DEBUG, TAG, "OUT - CALEGetAddressFromGatt");
+    return jni_address;
+}
index dcb1b04..dd01468 100644 (file)
@@ -36,6 +36,11 @@ extern "C"
 {
 #endif
 
+#define CA_LE_AUTO_CONNECT_FLAG    1
+#define CA_LE_CONNECTION_STATE     2
+#define CA_LE_SEND_STATE           3
+#define CA_LE_DESCRIPTOR_FOUND     4
+
 /* Service UUID */
 static const char OIC_GATT_SERVICE_UUID[] = CA_GATT_SERVICE_UUID;
 static const char OIC_GATT_CHARACTERISTIC_REQUEST_UUID[] = CA_GATT_REQUEST_CHRC_UUID;
@@ -60,20 +65,9 @@ static const jint BOND_BONDED = 12;
 static const jint BOND_BONDING = 11;
 static const jint BOND_NONE = 10;
 
-static const jint STATE_CONNECTED = 2;
-static const jint STATE_DISCONNECTED = 0;
-
-/**
- * get method ID for method Name and class
- * @param[in]   env              JNI interface pointer.
- * @param[in]   className        android class.
- * @param[in]   methodName       android method name.
- * @param[in]   methodFormat     method type of methodName.
- * @return  jmethodID of the method.
- */
-jmethodID CALEGetJNIMethodID(JNIEnv *env, const char* className,
-                             const char* methodName,
-                             const char* methodFormat);
+static const uint16_t STATE_CONNECTED = 3;
+static const uint16_t STATE_SERVICE_CONNECTED = 2;
+static const uint16_t STATE_DISCONNECTED = 1;
 
 /**
  * get uuid(jni object) from uuid(character).
@@ -167,6 +161,14 @@ jint CALEGetConstantsValue(JNIEnv *env, const char* classType, const char* name)
  */
 jobject CALEGetRemoteDevice(JNIEnv *env, jstring address);
 
+/**
+ * get address from gatt profile object.
+ * @param[in]   env                   JNI interface pointer.
+ * @param[in]   gatt                  gatt profile object.
+ * @return  LE address.
+ */
+jstring CALEGetAddressFromGatt(JNIEnv *env, jobject gatt);
+
 #ifdef __cplusplus
 } /* extern "C" */
 #endif
index fd351f2..d776c4f 100644 (file)
@@ -49,7 +49,7 @@ Java_org_iotivity_ca_caLeClientInterface_caLeRegisterGattCallback
 /*
  * Class:     org_iotivity_ca_caLeClientInterface
  * Method:    caLeScanCallback
- * Signature: (Landroid/bluetooth/BluetoothDevice;I[B)V
+ * Signature: (Landroid/bluetooth/BluetoothDevice;)V
  */
 JNIEXPORT void JNICALL
 Java_org_iotivity_ca_caLeClientInterface_caLeScanCallback
@@ -84,8 +84,16 @@ Java_org_iotivity_ca_caLeClientInterface_caLeGattServicesDiscoveredCallback
 
 /*
  * Class:     org_iotivity_ca_caLeClientInterface
+ * Method:    caLeGattNWServicesDiscoveredCallback
+ * Signature: (Landroid/bluetooth/BluetoothGatt;I)V
+ */
+JNIEXPORT void JNICALL
+Java_org_iotivity_ca_CaLeClientInterface_caLeGattNWServicesDiscoveredCallback
+(JNIEnv *, jobject, jobject, jint);
+/*
+ * Class:     org_iotivity_ca_caLeClientInterface
  * Method:    caLeGattCharacteristicWritjclasseCallback
- * Signature: (Landroid/bluetooth/BluetoothGatt;Landroid/bluetooth/BluetoothGattCharacteristic;I)V
+ * Signature: (Landroid/bluetooth/BluetoothGatt;[BI)V
  */
 JNIEXPORT void JNICALL
 Java_org_iotivity_ca_caLeClientInterface_caLeGattCharacteristicWriteCallback
@@ -103,7 +111,7 @@ Java_org_iotivity_ca_caLeClientInterface_caLeGattCharacteristicChangedCallback
 /*
  * Class:     org_iotivity_ca_caLeClientInterface
  * Method:    caLeGattDescriptorWriteCallback
- * Signature: (Landroid/bluetooth/BluetoothGatt;Landroid/bluetooth/BluetoothGattDescriptor;I)V
+ * Signature: (Landroid/bluetooth/BluetoothGatt;I)V
  */
 JNIEXPORT void JNICALL
 Java_org_iotivity_ca_caLeClientInterface_caLeGattDescriptorWriteCallback
@@ -166,7 +174,7 @@ Java_org_iotivity_ca_CaLeClientInterface_caManagerLeServicesDiscoveredCallback
 /*
  * Class:     org_iotivity_ca_jar_caleinterface
  * Method:    caManagerLeRemoteRssiCallback
- * Signature: (Landroid/bluetooth/BluetoothGatt;I)V
+ * Signature: (Landroid/bluetooth/BluetoothGatt;II)V
  */
 JNIEXPORT void JNICALL
 Java_org_iotivity_ca_CaLeClientInterface_caManagerLeRemoteRssiCallback
index fd4f813..e00b788 100644 (file)
@@ -34,7 +34,6 @@ extern "C"
  * Signature: (Landroid/bluetooth/BluetoothGattServerCallback;)V
  */
 JNIEXPORT void JNICALL
-
 Java_org_iotivity_ca_caLeServerInterface_caLeRegisterGattServerCallback
 (JNIEnv *, jobject, jobject);
 
@@ -77,8 +76,7 @@ Java_org_iotivity_ca_caLeServerInterface_caLeGattServerServiceAddedCallback
 /*
  * Class:     org_iotivity_ca_caLeServerInterface
  * Method:    caLeGattServerCharacteristicReadRequestCallback
- * Signature: (Landroid/bluetooth/BluetoothDevice;IILandroid/
- * bluetooth/BluetoothGattCharacteristic;)V
+ * Signature: (Landroid/bluetooth/BluetoothDevice;[B)V
  */
 JNIEXPORT void JNICALL
 Java_org_iotivity_ca_caLeServerInterface_caLeGattServerCharacteristicReadRequestCallback
@@ -87,8 +85,7 @@ Java_org_iotivity_ca_caLeServerInterface_caLeGattServerCharacteristicReadRequest
 /*
  * Class:     org_iotivity_ca_caLeServerInterface
  * Method:    caLeGattServerCharacteristicWriteRequestCallback
- * Signature: (Landroid/bluetooth/BluetoothDevice;ILandroid/bluetooth/
- * BluetoothGattCharacteristic;ZZI[B)V
+ * Signature: (Landroid/bluetooth/BluetoothDevice;[B)V
  */
 JNIEXPORT void JNICALL
 Java_org_iotivity_ca_caLeServerInterface_caLeGattServerCharacteristicWriteRequestCallback
index 63705b8..f07482c 100644 (file)
@@ -73,7 +73,12 @@ typedef enum
 /**
  * Callback to provide the status of the network change to CA layer.
  */
-static CANetworkChangeCallback g_networkCallback = NULL;
+static CAAdapterChangeCallback g_networkCallback = NULL;
+
+/**
+ * Callback to provide the status of the connection change to CA layer.
+ */
+static CAConnectionChangeCallback g_connectionCallback = NULL;
 
 /**
  * bleAddress of the local adapter. Value will be initialized to zero,
@@ -149,8 +154,10 @@ static CAErrorHandleCallback g_errorHandler = NULL;
 /**
  * Register network change notification callback.
  *
- * @param[in]  netCallback CANetworkChangeCallback callback which will
- *                         be set for the change in network.
+ * @param[in]  netCallback  CAAdapterChangeCallback callback which will
+ *                          be set for the change in adapter.
+ * @param[in]  connCallback CAConnectionChangeCallback callback which will
+ *                          be set for the change in connection.
  *
  * @return  0 on success otherwise a positive error value.
  * @retval  ::CA_STATUS_OK  Successful.
@@ -158,7 +165,8 @@ static CAErrorHandleCallback g_errorHandler = NULL;
  * @retval  ::CA_STATUS_FAILED Operation failed.
  *
  */
-static CAResult_t CALERegisterNetworkNotifications(CANetworkChangeCallback netCallback);
+static CAResult_t CALERegisterNetworkNotifications(CAAdapterChangeCallback netCallback,
+                                                   CAConnectionChangeCallback connCallback);
 
 /**
  * Set the thread pool handle which is required for spawning new
@@ -1721,7 +1729,8 @@ static CAResult_t CALEAdapterGattClientStop()
 
 CAResult_t CAInitializeLE(CARegisterConnectivityCallback registerCallback,
                           CANetworkPacketReceivedCallback reqRespCallback,
-                          CANetworkChangeCallback netCallback,
+                          CAAdapterChangeCallback netCallback,
+                          CAConnectionChangeCallback connCallback,
                           CAErrorHandleCallback errorCallback,
                           ca_thread_pool_t handle)
 {
@@ -1731,6 +1740,7 @@ CAResult_t CAInitializeLE(CARegisterConnectivityCallback registerCallback,
     VERIFY_NON_NULL(registerCallback, CALEADAPTER_TAG, "RegisterConnectivity callback is null");
     VERIFY_NON_NULL(reqRespCallback, CALEADAPTER_TAG, "PacketReceived Callback is null");
     VERIFY_NON_NULL(netCallback, CALEADAPTER_TAG, "NetworkChange Callback is null");
+    VERIFY_NON_NULL(connCallback, CALEADAPTER_TAG, "ConnectionChange Callback is null");
 
     CAResult_t result = CA_STATUS_OK;
     result = CAInitLEAdapterMutex();
@@ -1772,7 +1782,7 @@ CAResult_t CAInitializeLE(CARegisterConnectivityCallback registerCallback,
 
     CASetBLEClientErrorHandleCallback(CALEErrorHandler);
     CASetBLEServerErrorHandleCallback(CALEErrorHandler);
-    CALERegisterNetworkNotifications(netCallback);
+    CALERegisterNetworkNotifications(netCallback, connCallback);
 
     g_errorHandler = errorCallback;
 
@@ -1841,7 +1851,7 @@ static void CATerminateLE()
 
     CASetLEReqRespServerCallback(NULL);
     CASetLEReqRespClientCallback(NULL);
-    CALERegisterNetworkNotifications(NULL);
+    CALERegisterNetworkNotifications(NULL, NULL);
     CASetLEReqRespAdapterCallback(NULL);
     CATerminateLENetworkMonitor();
 
@@ -2157,12 +2167,14 @@ static CAResult_t CAGetLEInterfaceInformation(CAEndpoint_t **info, uint32_t *siz
     return CA_STATUS_OK;
 }
 
-static CAResult_t CALERegisterNetworkNotifications(CANetworkChangeCallback netCallback)
+static CAResult_t CALERegisterNetworkNotifications(CAAdapterChangeCallback netCallback,
+                                                   CAConnectionChangeCallback connCallback)
 {
     OIC_LOG(DEBUG, CALEADAPTER_TAG, "IN");
 
     ca_mutex_lock(g_bleNetworkCbMutex);
     g_networkCallback = netCallback;
+    g_connectionCallback = connCallback;
     ca_mutex_unlock(g_bleNetworkCbMutex);
     CAResult_t res = CA_STATUS_OK;
     if (netCallback)
@@ -2172,12 +2184,6 @@ static CAResult_t CALERegisterNetworkNotifications(CANetworkChangeCallback netCa
         {
             OIC_LOG(ERROR, CALEADAPTER_TAG, "CASetLEAdapterStateChangedCb failed!");
         }
-
-        res = CASetLENWConnectionStateChangedCb(CALEConnectionStateChangedCb);
-        if (CA_STATUS_OK != res)
-        {
-            OIC_LOG(ERROR, CALEADAPTER_TAG, "CALEConnectionStateChangedCb failed!");
-        }
     }
     else
     {
@@ -2188,6 +2194,15 @@ static CAResult_t CALERegisterNetworkNotifications(CANetworkChangeCallback netCa
         }
     }
 
+    if (g_connectionCallback)
+    {
+        res = CASetLENWConnectionStateChangedCb(CALEConnectionStateChangedCb);
+        if (CA_STATUS_OK != res)
+        {
+            OIC_LOG(ERROR, CALEADAPTER_TAG, "CASetLENWConnectionStateChangedCb failed!");
+        }
+    }
+
     OIC_LOG(DEBUG, CALEADAPTER_TAG, "OUT");
     return res;
 }
@@ -2250,6 +2265,16 @@ static void CALEConnectionStateChangedCb(CATransportAdapter_t adapter, const cha
 #endif
     }
 
+    CAEndpoint_t localEndpoint = { .adapter = CA_ADAPTER_GATT_BTLE };
+    OICStrcpy(localEndpoint.addr, sizeof(localEndpoint.addr), address);
+
+    ca_mutex_lock(g_bleNetworkCbMutex);
+    if (g_connectionCallback)
+    {
+        g_connectionCallback(&localEndpoint, isConnected);
+    }
+    ca_mutex_unlock(g_bleNetworkCbMutex);
+
     OIC_LOG(DEBUG, CALEADAPTER_TAG, "OUT");
 }
 
@@ -2257,15 +2282,6 @@ static void CALEDeviceStateChangedCb(CAAdapterState_t adapter_state)
 {
     OIC_LOG(DEBUG, CALEADAPTER_TAG, "IN - CALEDeviceStateChangedCb");
 
-    VERIFY_NON_NULL_VOID(g_localBLEAddress, CALEADAPTER_TAG, "g_localBLEAddress is null");
-    CAEndpoint_t localEndpoint = { .adapter = CA_ADAPTER_GATT_BTLE };
-
-    ca_mutex_lock(g_bleLocalAddressMutex);
-    OICStrcpy(localEndpoint.addr,
-              sizeof(localEndpoint.addr),
-              g_localBLEAddress);
-    ca_mutex_unlock(g_bleLocalAddressMutex);
-
     if (CA_ADAPTER_ENABLED == adapter_state)
     {
         ca_mutex_lock(g_bleIsServerMutex);
@@ -2310,7 +2326,7 @@ static void CALEDeviceStateChangedCb(CAAdapterState_t adapter_state)
     ca_mutex_lock(g_bleNetworkCbMutex);
     if (NULL != g_networkCallback)
     {
-        g_networkCallback(&localEndpoint, adapter_state);
+        g_networkCallback(CA_ADAPTER_GATT_BTLE, adapter_state);
     }
     else
     {
@@ -2637,7 +2653,7 @@ static void CALERemoveSendQueueData(CAQueueingThread_t *queueHandle, ca_mutex mu
 
 static void CALERemoveReceiveQueueData(u_arraylist_t *dataInfoList, const char* address)
 {
-    OIC_LOG(DEBUG, CALEADAPTER_TAG, "CALERemoveSendQueueData");
+    OIC_LOG(DEBUG, CALEADAPTER_TAG, "CALERemoveReceiveQueueData");
 
     VERIFY_NON_NULL_VOID(dataInfoList, CALEADAPTER_TAG, "dataInfoList");
     VERIFY_NON_NULL_VOID(address, CALEADAPTER_TAG, "address");
index eeccd50..82ceb71 100644 (file)
@@ -82,8 +82,8 @@ static gboolean CAGattDescriptorReadValue(
  * @param[in]  descriptor_path @c GattDescriptor1 object path for the
  *                             user description descriptor.
  * @param[in]  value           User description descriptor value,
- *                             e.g. @c "OIC Node Request" or
- *                             @c "OIC Node Response".
+ *                             e.g. @c "OCF Node Request" or
+ *                             @c "OCF Node Response".
  *
  * @note This function does not allocate the @a descriptor object
  *       itself.  The caller is responsible for allocating that
index 47b1b5f..dd4e3f3 100644 (file)
  */
 #define TAG "OIC_CA_LE_MONITOR"
 
+#define MICROSECS_PER_SEC 1000000
+
+static uint64_t const INITIALIZE_TIMEOUT = 1 * MICROSECS_PER_SEC;
+
 static GMainLoop *g_mainloop = NULL;
 static ca_thread_pool_t g_threadPoolHandle = NULL;
 
@@ -70,11 +74,26 @@ static ca_mutex g_bleDeviceStateChangedCbMutex = NULL;
 static ca_mutex g_bleConnectionStateChangedCbMutex = NULL;
 
 /**
+ * Mutex to synchronize access to
+ */
+static ca_mutex g_btinitializeMutex = NULL;
+
+/**
+ * Condition for gmainloop to run.
+ */
+static ca_cond g_initializeCond = NULL;
+
+/**
+ * Flag to check if BT stack is initialised.
+ */
+static bool g_isBTStackInitialised = false;
+
+/**
 * This is the callback which will be called when the adapter state gets changed.
 *
 * @param result         [IN] Result of the query done to the platform.
 * @param adapter_state  [IN] State of the LE adapter.
-* @param user_data      [IN] Any user_data passed by the caller when querying for the state changed cb.
+* @param user_data      [IN] User data passed by the caller when querying for the state changed cb.
 *
 * @return  None.
 */
@@ -87,7 +106,7 @@ void CALEAdapterStateChangedCb(int result, bt_adapter_state_e adapter_state,
 * @param result         [IN] Result of the query done to the platform.
 * @param connected      [IN] State of connection.
 * @param remoteAddress  [IN] LE address of the device to be notified.
-* @param user_data      [IN] Any user_data passed by the caller when querying for the state changed cb.
+* @param user_data      [IN] User data passed by the caller when querying for the state changed cb.
 *
 * @return  None.
 */
@@ -96,7 +115,46 @@ void CALENWConnectionStateChangedCb(int result, bool connected,
 
 void CALEMainLoopThread(void *param)
 {
+    OIC_LOG(DEBUG, TAG, "IN");
+
+    int ret = bt_initialize();
+    if (BT_ERROR_NONE != ret)
+    {
+        OIC_LOG(ERROR, TAG, "bt_initialize failed");
+        return;
+    }
+    ret = bt_adapter_set_visibility(BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE, 0);
+    if (BT_ERROR_NONE != ret)
+    {
+        OIC_LOG(ERROR, TAG, "bt_adapter_set_visibility failed");
+        return;
+    }
+
+    ret = bt_adapter_set_state_changed_cb(CALEAdapterStateChangedCb, NULL);
+    if (BT_ERROR_NONE != ret)
+    {
+        OIC_LOG(DEBUG, TAG, "bt_adapter_set_state_changed_cb failed");
+        return;
+    }
+
+    ret = bt_gatt_set_connection_state_changed_cb(CALENWConnectionStateChangedCb, NULL);
+    if (BT_ERROR_NONE != ret)
+    {
+        OIC_LOG_V(ERROR, TAG,
+                  "bt_gatt_set_connection_state_changed_cb has failed");
+        return;
+    }
+
+    g_mainloop = g_main_loop_new(g_main_context_default(), FALSE);
+
+    ca_mutex_lock(g_btinitializeMutex);
+    g_isBTStackInitialised = true;
+    ca_mutex_unlock(g_btinitializeMutex);
+    ca_cond_signal(g_initializeCond);
+
+    // Run gmainloop to handle the events from bt stack
     g_main_loop_run(g_mainloop);
+    OIC_LOG(DEBUG, TAG, "OUT");
 }
 
 CAResult_t CAInitializeLENetworkMonitor()
@@ -123,6 +181,31 @@ CAResult_t CAInitializeLENetworkMonitor()
             return CA_STATUS_FAILED;
         }
     }
+
+    if (NULL == g_btinitializeMutex)
+    {
+        g_btinitializeMutex = ca_mutex_new();
+        if (NULL == g_btinitializeMutex)
+        {
+            OIC_LOG(ERROR, TAG, "ca_mutex_new failed");
+            ca_mutex_free(g_bleDeviceStateChangedCbMutex);
+            ca_mutex_free(g_bleConnectionStateChangedCbMutex);
+            return CA_STATUS_FAILED;
+        }
+    }
+
+    if (NULL == g_initializeCond)
+    {
+        g_initializeCond = ca_cond_new();
+        if (NULL == g_initializeCond)
+        {
+            OIC_LOG(ERROR, TAG, "ca_cond_new failed");
+            ca_mutex_free(g_bleDeviceStateChangedCbMutex);
+            ca_mutex_free(g_bleConnectionStateChangedCbMutex);
+            ca_mutex_free(g_btinitializeMutex);
+            return CA_STATUS_FAILED;
+        }
+    }
     OIC_LOG(DEBUG, TAG, "OUT");
 
     return CA_STATUS_OK;
@@ -137,6 +220,12 @@ void CATerminateLENetworkMonitor()
 
     ca_mutex_free(g_bleConnectionStateChangedCbMutex);
     g_bleConnectionStateChangedCbMutex = NULL;
+
+    ca_mutex_free(g_btinitializeMutex);
+    g_btinitializeMutex = NULL;
+
+    ca_cond_free(g_initializeCond);
+    g_initializeCond = NULL;
     OIC_LOG(DEBUG, TAG, "OUT");
 }
 
@@ -151,12 +240,6 @@ CAResult_t CAInitializeLEAdapter(const ca_thread_pool_t threadPool)
 CAResult_t CAStartLEAdapter()
 {
     OIC_LOG(DEBUG, TAG, "IN");
-    g_mainloop = g_main_loop_new(NULL, 0);
-    if(!g_mainloop)
-    {
-        OIC_LOG(ERROR, TAG, "g_main_loop_new failed\n");
-        return CA_STATUS_FAILED;
-    }
 
     if (CA_STATUS_OK != ca_thread_pool_add_task(g_threadPoolHandle, CALEMainLoopThread, (void *) NULL))
     {
@@ -164,35 +247,6 @@ CAResult_t CAStartLEAdapter()
         return CA_STATUS_FAILED;
     }
 
-    int ret = bt_initialize();
-    if (0 != ret)
-    {
-        OIC_LOG(ERROR, TAG, "bt_initialize failed");
-        return CA_STATUS_FAILED;
-    }
-
-    ret = bt_adapter_set_visibility(BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE, 0);
-    if (0 != ret)
-    {
-        OIC_LOG(ERROR, TAG, "bt_adapter_set_visibility failed");
-        return CA_STATUS_FAILED;
-    }
-
-    ret = bt_adapter_set_state_changed_cb(CALEAdapterStateChangedCb, NULL);
-    if (BT_ERROR_NONE != ret)
-    {
-        OIC_LOG(DEBUG, TAG, "bt_adapter_set_state_changed_cb failed");
-        return CA_STATUS_FAILED;
-    }
-
-    ret = bt_gatt_set_connection_state_changed_cb(CALENWConnectionStateChangedCb, NULL);
-    if (BT_ERROR_NONE != ret)
-    {
-        OIC_LOG_V(ERROR, TAG,
-                  "bt_gatt_set_connection_state_changed_cb has failed");
-        return CA_STATUS_FAILED;
-    }
-
     OIC_LOG(DEBUG, TAG, "OUT");
     return CA_STATUS_OK;
 }
@@ -208,7 +262,7 @@ CAResult_t CAStopLEAdapter()
     }
 
     ret = bt_deinitialize();
-    if (0 != ret)
+    if (BT_ERROR_NONE != ret)
     {
         OIC_LOG(ERROR, TAG, "bt_deinitialize failed");
         return CA_STATUS_FAILED;
@@ -225,6 +279,21 @@ CAResult_t CAGetLEAdapterState()
 {
     OIC_LOG(DEBUG, TAG, "IN");
 
+    ca_mutex_lock(g_btinitializeMutex);
+    if (!g_isBTStackInitialised)
+    {
+        OIC_LOG(INFO, TAG, "Wait for BT initialization");
+        CAWaitResult_t ret = ca_cond_wait_for(g_initializeCond, g_btinitializeMutex,
+                                              INITIALIZE_TIMEOUT);
+        if (CA_WAIT_TIMEDOUT == ret)
+        {
+            OIC_LOG(ERROR, TAG, "Timeout before BT initialize");
+            ca_mutex_unlock(g_btinitializeMutex);
+            return CA_STATUS_FAILED;
+        }
+    }
+    ca_mutex_unlock(g_btinitializeMutex);
+
     bt_adapter_state_e adapterState = BT_ADAPTER_DISABLED;
 
     //Get Bluetooth adapter state
index 125de56..0b234d7 100644 (file)
@@ -114,13 +114,6 @@ static ca_thread_pool_t g_leServerThreadPool = NULL;
  */
 static GMainLoop *g_eventLoop = NULL;
 
-static CALEConnectionStateChangedCallback g_connStateCb = NULL;
-
-void CASetLEConnectionStateChangedCallback(CALEConnectionStateChangedCallback connStateCb)
-{
-    g_connStateCb = connStateCb;
-}
-
 void CALEGattServerConnectionStateChanged(bool connected, const char *remoteAddress)
 {
     VERIFY_NON_NULL_VOID(remoteAddress, TAG, "remote address");
@@ -128,18 +121,10 @@ void CALEGattServerConnectionStateChanged(bool connected, const char *remoteAddr
     if (connected)
     {
         OIC_LOG_V(DEBUG, TAG, "Connected to [%s]", remoteAddress);
-        if (g_connStateCb)
-        {
-            g_connStateCb(CA_ADAPTER_GATT_BTLE, remoteAddress, true);
-        }
     }
     else
     {
         OIC_LOG_V(DEBUG, TAG, "Disconnected from [%s]", remoteAddress);
-        if (g_connStateCb)
-        {
-            g_connStateCb(CA_ADAPTER_GATT_BTLE, remoteAddress, false);
-        }
     }
 }
 
@@ -207,10 +192,19 @@ CAResult_t CALEStartAdvertise(const char *serviceUUID)
         return CA_STATUS_FAILED;
     }
 
-    res = bt_adapter_le_start_advertising(g_hAdvertiser, NULL, NULL, NULL);
+    res = bt_adapter_le_set_advertising_device_name(g_hAdvertiser,
+                                                    BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, true);
+    if (BT_ERROR_NONE != res)
+    {
+        OIC_LOG_V(ERROR, TAG, "bt_adapter_le_set_advertising_device_name failed with ret[%s]",
+                  CALEGetErrorMsg(res));
+        return CA_STATUS_FAILED;
+    }
+
+    res = bt_adapter_le_start_advertising_new(g_hAdvertiser, NULL, NULL);
     if (BT_ERROR_NONE != res)
     {
-        OIC_LOG_V(ERROR, TAG, "bt_adapter_le_start_advertising failed with ret[%s]",
+        OIC_LOG_V(ERROR, TAG, "bt_adapter_le_start_advertising_new failed with ret[%s]",
                   CALEGetErrorMsg(res));
         return CA_STATUS_FAILED;
     }
@@ -692,7 +686,7 @@ CAResult_t CAAddNewCharacteristicsToGattServer(const bt_gatt_h svcPath, const ch
     OIC_LOG(DEBUG, TAG, "IN");
 
     int permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE;
-    int properties = BT_GATT_PROPERTY_WRITE | BT_GATT_PROPERTY_NOTIFY;
+    int properties;
     if(read)
     {
         properties = BT_GATT_PROPERTY_NOTIFY | BT_GATT_PROPERTY_READ;
@@ -745,8 +739,9 @@ CAResult_t CAAddNewCharacteristicsToGattServer(const bt_gatt_h svcPath, const ch
         char desc_value[2] = {1, 0};  // Notification enabled.
         bt_gatt_h descriptor = NULL;
         permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE;
-        ret = bt_gatt_descriptor_create(CA_GATT_CONFIGURATION_DESC_UUID,
-                                        permissions, desc_value, sizeof(desc_value), &descriptor);
+        ret = bt_gatt_descriptor_create(CA_GATT_CONFIGURATION_DESC_UUID, permissions,
+                                        desc_value, sizeof(desc_value),
+                                        &descriptor);
         if (0 != ret)
         {
             OIC_LOG_V(ERROR, TAG,
index 8dc46dd..07600f0 100644 (file)
@@ -268,6 +268,15 @@ const char *CALEGetErrorMsg(bt_error_e err)
         case BT_ERROR_NOT_SUPPORTED:
             errStr = "BT_ERROR_NOT_SUPPORTED";
             break;
+        case BT_ERROR_QUOTA_EXCEEDED:
+            errStr = "BT_ERROR_QUOTA_EXCEEDED";
+            break;
+        case BT_ERROR_NO_DATA:
+            errStr = "BT_ERROR_NO_DATA";
+            break;
+        case BT_ERROR_AGAIN:
+            errStr = "BT_ERROR_AGAIN";
+            break;
         default:
             errStr = "NOT Defined";
             break;
index f214067..a78aa06 100644 (file)
@@ -40,6 +40,7 @@
 #include "caremotehandler.h"
 #include "cablockwisetransfer.h"
 #include "oic_malloc.h"
+#include "oic_string.h"
 #include "camutex.h"
 #include "logger.h"
 
@@ -112,6 +113,7 @@ CAResult_t CATerminateBlockWiseTransfer()
 
     if (g_context.dataList)
     {
+        CARemoveAllBlockDataFromList();
         u_arraylist_free(&g_context.dataList);
     }
 
@@ -1231,7 +1233,7 @@ CAResult_t CASetMoreBitFromBlock(size_t payloadLen, coap_block_t *block)
 }
 
 CAResult_t CANegotiateBlockSize(CABlockData_t *currData, coap_block_t *block,
-                                coap_pdu_t *pdu, uint16_t blockType)
+                                const coap_pdu_t *pdu, uint16_t blockType)
 {
     OIC_LOG(DEBUG, TAG, "IN-NegotiateBlockSize");
 
@@ -2030,11 +2032,20 @@ CAData_t* CACreateNewDataSet(const coap_pdu_t *pdu, const CAEndpoint_t *endpoint
 
         // get resource uri information from received response message
         // to send next request message to remote device
-        CAResponseInfo_t resInfo = { 0 };
-        CAGetResponseInfoFromPDU(pdu, &resInfo, endpoint);
+        CAResponseInfo_t* resInfo = (CAResponseInfo_t*)OICCalloc(1, sizeof(*resInfo));
+        if (!resInfo)
+        {
+            OIC_LOG(ERROR, TAG, "memory allocation failed");
+            OICFree(requestData.token);
+            return NULL;
+        }
 
+        CAGetResponseInfoFromPDU(pdu, resInfo, endpoint);
         requestInfo->method = CA_GET;
-        requestInfo->info.resourceUri = resInfo.info.resourceUri;
+        requestInfo->info.resourceUri = OICStrdup(resInfo->info.resourceUri);
+
+        // after copying the resource uri, destroy response info.
+        CADestroyResponseInfoInternal(resInfo);
     }
 
     CAData_t *data = (CAData_t *) OICCalloc(1, sizeof(CAData_t));
@@ -2602,6 +2613,33 @@ CAResult_t CARemoveBlockDataFromList(const CABlockDataID_t *blockID)
     return CA_STATUS_OK;
 }
 
+CAResult_t CARemoveAllBlockDataFromList()
+{
+    OIC_LOG(DEBUG, TAG, "CARemoveAllBlockDataFromList");
+
+    ca_mutex_lock(g_context.blockDataListMutex);
+
+    size_t len = u_arraylist_length(g_context.dataList);
+    for (size_t i = len; i > 0; i--)
+    {
+        CABlockData_t *removedData = u_arraylist_remove(g_context.dataList, i - 1);
+        if (removedData)
+        {
+            // destroy memory
+            if (removedData->sentData)
+            {
+                CADestroyDataSet(removedData->sentData);
+            }
+            CADestroyBlockID(removedData->blockDataId);
+            OICFree(removedData->payload);
+            OICFree(removedData);
+        }
+    }
+    ca_mutex_unlock(g_context.blockDataListMutex);
+
+    return CA_STATUS_OK;
+}
+
 void CADestroyDataSet(CAData_t* data)
 {
     VERIFY_NON_NULL_VOID(data, TAG, "data");
@@ -2683,3 +2721,30 @@ void CALogBlockInfo(coap_block_t *block)
 
     OIC_LOG_V(DEBUG, TAG, "block option-szx : %d", block->szx);
 }
+
+CAResult_t CARemoveBlockDataFromListWithSeed(const CAToken_t token, uint8_t tokenLength,
+                                             uint16_t portNumber)
+{
+    CABlockDataID_t* blockDataID = CACreateBlockDatablockId(token, tokenLength, portNumber);
+    if (NULL == blockDataID || blockDataID->idLength < 1)
+    {
+        OIC_LOG(ERROR, TAG, "blockId is null");
+        CADestroyBlockID(blockDataID);
+        return CA_STATUS_FAILED;
+    }
+
+    CAResult_t res = CA_STATUS_OK;
+
+    if (NULL != CAGetBlockDataFromBlockDataList(blockDataID))
+    {
+        res = CARemoveBlockDataFromList(blockDataID);
+        if (CA_STATUS_OK != res)
+        {
+            OIC_LOG(ERROR, TAG, "CARemoveBlockDataFromList failed");
+        }
+    }
+
+    CADestroyBlockID(blockDataID);
+
+    return res;
+}
index 691e2bc..82919b7 100644 (file)
@@ -553,9 +553,8 @@ CAResult_t CACloseDtlsSession(const CAEndpoint_t *endpoint)
 #endif /* __WITH_DTLS__ */
 
 #ifdef TCP_ADAPTER
-void CARegisterKeepAliveHandler(CAKeepAliveConnectedCallback ConnHandler,
-                                CAKeepAliveDisconnectedCallback DisconnHandler)
+void CARegisterKeepAliveHandler(CAKeepAliveConnectionCallback ConnHandler)
 {
-    CATCPSetKeepAliveCallbacks(ConnHandler, DisconnHandler);
+    CATCPSetKeepAliveCallbacks(ConnHandler);
 }
 #endif
index a21f5b5..7ae093c 100644 (file)
 #define CA_MEMORY_ALLOC_CHECK(arg) {if (arg == NULL) \
     {OIC_LOG(ERROR, TAG, "memory error");goto memory_error_exit;} }
 
-
-
 static CAConnectivityHandler_t *g_adapterHandler = NULL;
 
 static uint32_t g_numberOfAdapters = 0;
 
 static CANetworkPacketReceivedCallback g_networkPacketReceivedCallback = NULL;
 
-static CANetworkChangeCallback g_networkChangeCallback = NULL;
+static CAAdapterChangeCallback g_adapterChangeCallback = NULL;
+
+static CAConnectionChangeCallback g_connChangeCallback = NULL;
 
 static CAErrorHandleCallback g_errorHandleCallback = NULL;
 
@@ -124,13 +124,24 @@ static void CAReceivedPacketCallback(const CASecureEndpoint_t *sep,
     }
 }
 
-static void CANetworkChangedCallback(const CAEndpoint_t *info, CANetworkStatus_t status)
+static void CAAdapterChangedCallback(CATransportAdapter_t adapter, CANetworkStatus_t status)
+{
+    // Call the callback.
+    if (g_adapterChangeCallback != NULL)
+    {
+        g_adapterChangeCallback(adapter, status);
+    }
+    OIC_LOG_V(DEBUG, TAG, "[%d]adapter status is changed to [%d]", adapter, status);
+}
+
+static void CAConnectionChangedCallback(const CAEndpoint_t *info, bool isConnected)
 {
     // Call the callback.
-    if (g_networkChangeCallback != NULL)
+    if (g_connChangeCallback != NULL)
     {
-        g_networkChangeCallback(info, status);
+        g_connChangeCallback(info, isConnected);
     }
+    OIC_LOG_V(DEBUG, TAG, "[%s] connection status is changed to [%d]", info->addr, isConnected);
 }
 
 static void CAAdapterErrorHandleCallback(const CAEndpoint_t *endpoint,
@@ -152,32 +163,32 @@ void CAInitializeAdapters(ca_thread_pool_t handle)
 
     // Initialize adapters and register callback.
 #ifdef IP_ADAPTER
-    CAInitializeIP(CARegisterCallback, CAReceivedPacketCallback, CANetworkChangedCallback,
+    CAInitializeIP(CARegisterCallback, CAReceivedPacketCallback, CAAdapterChangedCallback,
                    CAAdapterErrorHandleCallback, handle);
 #endif /* IP_ADAPTER */
 
 #ifdef EDR_ADAPTER
-    CAInitializeEDR(CARegisterCallback, CAReceivedPacketCallback, CANetworkChangedCallback,
-                    CAAdapterErrorHandleCallback, handle);
+    CAInitializeEDR(CARegisterCallback, CAReceivedPacketCallback, CAAdapterChangedCallback,
+                    CAConnectionChangedCallback, CAAdapterErrorHandleCallback, handle);
 #endif /* EDR_ADAPTER */
 
 #ifdef LE_ADAPTER
-    CAInitializeLE(CARegisterCallback, CAReceivedPacketCallback, CANetworkChangedCallback,
-                   CAAdapterErrorHandleCallback, handle);
+    CAInitializeLE(CARegisterCallback, CAReceivedPacketCallback, CAAdapterChangedCallback,
+                   CAConnectionChangedCallback, CAAdapterErrorHandleCallback, handle);
 #endif /* LE_ADAPTER */
 
 #ifdef RA_ADAPTER
-    CAInitializeRA(CARegisterCallback, CAReceivedPacketCallback, CANetworkChangedCallback,
+    CAInitializeRA(CARegisterCallback, CAReceivedPacketCallback, CAAdapterChangedCallback,
                    handle);
 #endif /* RA_ADAPTER */
 
 #ifdef TCP_ADAPTER
-    CAInitializeTCP(CARegisterCallback, CAReceivedPacketCallback, CANetworkChangedCallback,
-                    CAAdapterErrorHandleCallback, handle);
+    CAInitializeTCP(CARegisterCallback, CAReceivedPacketCallback, CAAdapterChangedCallback,
+                    CAConnectionChangedCallback, CAAdapterErrorHandleCallback, handle);
 #endif /* TCP_ADAPTER */
 
 #ifdef NFC_ADAPTER
-    CAInitializeNFC(CARegisterCallback, CAReceivedPacketCallback, CANetworkChangedCallback,
+    CAInitializeNFC(CARegisterCallback, CAReceivedPacketCallback, CAAdapterChangedCallback,
                     CAAdapterErrorHandleCallback, handle);
 #endif /* NFC_ADAPTER */
 }
@@ -189,11 +200,13 @@ void CASetPacketReceivedCallback(CANetworkPacketReceivedCallback callback)
     g_networkPacketReceivedCallback = callback;
 }
 
-void CASetNetworkChangeCallback(CANetworkChangeCallback callback)
+void CASetNetworkMonitorCallbacks(CAAdapterChangeCallback adapterCB,
+                                  CAConnectionChangeCallback connCB)
 {
-    OIC_LOG(DEBUG, TAG, "Set network handle callback");
+    OIC_LOG(DEBUG, TAG, "Set network monitoring callback");
 
-    g_networkChangeCallback = callback;
+    g_adapterChangeCallback = adapterCB;
+    g_connChangeCallback = connCB;
 }
 
 void CASetErrorHandleCallback(CAErrorHandleCallback errorCallback)
index e2eb295..5d5ed73 100644 (file)
@@ -297,6 +297,18 @@ static void CATimeoutCallback(const CAEndpoint_t *endpoint, const void *pdu, uin
     cadata->requestInfo = NULL;
     cadata->responseInfo = resInfo;
 
+#ifdef WITH_BWT
+    if (CAIsSupportedBlockwiseTransfer(endpoint->adapter))
+    {
+        res = CARemoveBlockDataFromListWithSeed(resInfo->info.token, resInfo->info.tokenLength,
+                                                endpoint->port);
+        if (CA_STATUS_OK != res)
+        {
+            OIC_LOG(ERROR, TAG, "CARemoveBlockDataFromListWithSeed failed");
+        }
+    }
+#endif // WITH_BWT
+
 #ifdef SINGLE_THREAD
     CAProcessReceivedData(cadata);
 #else
@@ -830,17 +842,6 @@ static void CAReceivedPacketCallback(const CASecureEndpoint_t *sep,
     coap_delete_pdu(pdu);
 }
 
-static void CANetworkChangedCallback(const CAEndpoint_t *info, CANetworkStatus_t status)
-{
-    (void)info;
-    (void)status;
-
-    if (g_nwMonitorHandler)
-    {
-        g_nwMonitorHandler(info, status);
-    }
-}
-
 void CAHandleRequestResponseCallbacks()
 {
 #ifdef SINGLE_THREAD
@@ -1033,8 +1034,6 @@ void CASetNetworkMonitorCallback(CANetworkMonitorCallback nwMonitorHandler)
 CAResult_t CAInitializeMessageHandler()
 {
     CASetPacketReceivedCallback(CAReceivedPacketCallback);
-
-    CASetNetworkChangeCallback(CANetworkChangedCallback);
     CASetErrorHandleCallback(CAErrorHandler);
 
 #ifndef SINGLE_THREAD
index 5ef5a87..7d84c1c 100644 (file)
@@ -47,7 +47,7 @@
 
 #define CA_BUFSIZE (128)
 #define CA_PDU_MIN_SIZE (4)
-#define CA_PORT_BUFFER_SIZE (4)
+#define CA_ENCODE_BUFFER_SIZE (4)
 
 static const char COAP_URI_HEADER[] = "coap://[::]/";
 
@@ -202,8 +202,7 @@ coap_pdu_t *CAParsePDU(const char *data, uint32_t length, uint32_t *outCode,
     if (0 >= ret)
     {
         OIC_LOG(ERROR, TAG, "pdu parse failed");
-        coap_delete_pdu(outpdu);
-        return NULL;
+        goto exit;
     }
 
 #ifdef WITH_TCP
@@ -218,15 +217,13 @@ coap_pdu_t *CAParsePDU(const char *data, uint32_t length, uint32_t *outCode,
         {
             OIC_LOG_V(ERROR, TAG, "coap version is not available : %d",
                       outpdu->hdr->coap_hdr_udp_t.version);
-            coap_delete_pdu(outpdu);
-            return NULL;
+            goto exit;
         }
         if (outpdu->hdr->coap_hdr_udp_t.token_length > CA_MAX_TOKEN_LEN)
         {
             OIC_LOG_V(ERROR, TAG, "token length has been exceed : %d",
                       outpdu->hdr->coap_hdr_udp_t.token_length);
-            coap_delete_pdu(outpdu);
-            return NULL;
+            goto exit;
         }
     }
 
@@ -236,6 +233,10 @@ coap_pdu_t *CAParsePDU(const char *data, uint32_t length, uint32_t *outCode,
     }
 
     return outpdu;
+
+exit:
+    coap_delete_pdu(outpdu);
+    return NULL;
 }
 
 coap_pdu_t *CAGeneratePDUImpl(code_t code, const CAInfo_t *info,
@@ -396,7 +397,7 @@ CAResult_t CAParseURI(const char *uriInfo, coap_list_t **optlist)
 
     if (uri.port != COAP_DEFAULT_PORT)
     {
-        unsigned char portbuf[CA_PORT_BUFFER_SIZE] = { 0 };
+        unsigned char portbuf[CA_ENCODE_BUFFER_SIZE] = { 0 };
         int ret = coap_insert(optlist,
                               CACreateNewOptionNode(COAP_OPTION_URI_PORT,
                                                     coap_encode_var_bytes(portbuf, uri.port),
@@ -535,13 +536,13 @@ CAResult_t CAParseHeadOption(uint32_t code, const CAInfo_t *info, coap_list_t **
     if (CA_FORMAT_UNDEFINED != info->payloadFormat)
     {
         coap_list_t* node = NULL;
-        uint8_t buf[3] = {0};
+        uint8_t buf[CA_ENCODE_BUFFER_SIZE] = {0};
         switch (info->payloadFormat)
         {
             case CA_FORMAT_APPLICATION_CBOR:
                 node = CACreateNewOptionNode(
                         COAP_OPTION_CONTENT_FORMAT,
-                        coap_encode_var_bytes(buf, (uint16_t)COAP_MEDIATYPE_APPLICATION_CBOR),
+                        coap_encode_var_bytes(buf, (unsigned short)COAP_MEDIATYPE_APPLICATION_CBOR),
                         (char *)buf);
                 break;
             default:
@@ -563,13 +564,13 @@ CAResult_t CAParseHeadOption(uint32_t code, const CAInfo_t *info, coap_list_t **
     if (CA_FORMAT_UNDEFINED != info->acceptFormat)
     {
         coap_list_t* node = NULL;
-        uint8_t buf[3] = {0};
+        uint8_t buf[CA_ENCODE_BUFFER_SIZE] = {0};
         switch (info->acceptFormat)
         {
             case CA_FORMAT_APPLICATION_CBOR:
                 node = CACreateNewOptionNode(
                         COAP_OPTION_ACCEPT,
-                        coap_encode_var_bytes(buf, (uint16_t)COAP_MEDIATYPE_APPLICATION_CBOR),
+                        coap_encode_var_bytes(buf, (unsigned short)COAP_MEDIATYPE_APPLICATION_CBOR),
                         (char *)buf);
                 break;
             default:
@@ -669,7 +670,10 @@ uint32_t CAGetOptionCount(coap_opt_iterator_t opt_iter)
             && COAP_OPTION_BLOCK1 != opt_iter.type && COAP_OPTION_BLOCK2 != opt_iter.type
             && COAP_OPTION_SIZE1 != opt_iter.type && COAP_OPTION_SIZE2 != opt_iter.type
             && COAP_OPTION_CONTENT_FORMAT != opt_iter.type
-            && COAP_OPTION_ACCEPT != opt_iter.type)
+            && COAP_OPTION_ACCEPT != opt_iter.type
+            && COAP_OPTION_URI_HOST != opt_iter.type && COAP_OPTION_URI_PORT != opt_iter.type
+            && COAP_OPTION_ETAG != opt_iter.type && COAP_OPTION_MAXAGE != opt_iter.type
+            && COAP_OPTION_PROXY_URI != opt_iter.type && COAP_OPTION_PROXY_SCHEME != opt_iter.type)
         {
             count++;
         }
@@ -849,7 +853,7 @@ CAResult_t CAGetInfoFromPDU(const coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
                 {
                     outInfo->payloadFormat = CA_FORMAT_UNSUPPORTED;
                     OIC_LOG_V(DEBUG, TAG, "option[%d] has an unsupported format [%d]",
-                            opt_iter.type, (uint8_t)buf[0]);
+                              opt_iter.type, (uint8_t)buf[0]);
                 }
             }
             else if (COAP_OPTION_ACCEPT == opt_iter.type)
@@ -863,7 +867,17 @@ CAResult_t CAGetInfoFromPDU(const coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
                     outInfo->acceptFormat = CA_FORMAT_UNSUPPORTED;
                 }
                 OIC_LOG_V(DEBUG, TAG, "option[%d] has an unsupported format [%d]",
-                        opt_iter.type, (uint8_t)buf[0]);
+                          opt_iter.type, (uint8_t)buf[0]);
+            }
+            else if (COAP_OPTION_URI_PORT == opt_iter.type ||
+                    COAP_OPTION_URI_HOST == opt_iter.type ||
+                    COAP_OPTION_ETAG == opt_iter.type ||
+                    COAP_OPTION_MAXAGE == opt_iter.type ||
+                    COAP_OPTION_PROXY_URI == opt_iter.type ||
+                    COAP_OPTION_PROXY_SCHEME== opt_iter.type)
+            {
+                OIC_LOG_V(INFO, TAG, "option[%d] has an unsupported format [%d]",
+                          opt_iter.type, (uint8_t)buf[0]);
             }
             else
             {
index 754b1c2..9a6c56a 100644 (file)
@@ -92,28 +92,6 @@ static void CAQueueingThreadBaseRoutine(void *threadValue)
         OICFree(message);
     }
 
-    // remove all remained list data.
-    while (u_queue_get_size(thread->dataQueue) > 0)
-    {
-        // get data
-        u_queue_message_t *message = u_queue_get_element(thread->dataQueue);
-
-        // free
-        if(NULL != message)
-        {
-            if (NULL != thread->destroy)
-            {
-                thread->destroy(message->msg, message->size);
-            }
-            else
-            {
-                OICFree(message->msg);
-            }
-
-            OICFree(message);
-        }
-    }
-
     ca_mutex_lock(thread->threadMutex);
     ca_cond_signal(thread->threadCond);
     ca_mutex_unlock(thread->threadMutex);
@@ -261,6 +239,29 @@ CAResult_t CAQueueingThreadDestroy(CAQueueingThread_t *thread)
     ca_mutex_free(thread->threadMutex);
     thread->threadMutex = NULL;
     ca_cond_free(thread->threadCond);
+
+    // remove all remained list data.
+    while (u_queue_get_size(thread->dataQueue) > 0)
+    {
+        // get data
+        u_queue_message_t *message = u_queue_get_element(thread->dataQueue);
+
+        // free
+        if(NULL != message)
+        {
+            if (NULL != thread->destroy)
+            {
+                thread->destroy(message->msg, message->size);
+            }
+            else
+            {
+                OICFree(message->msg);
+            }
+
+            OICFree(message);
+        }
+    }
+
     u_queue_delete(thread->dataQueue);
 
     return CA_STATUS_OK;
index 3598110..ff70009 100644 (file)
@@ -38,6 +38,8 @@
 
 #define TAG "OIC_CA_IP_MONITOR"
 
+static CAIPConnectionStateChangeCallback g_networkChangeCallback;
+
 static CAInterface_t *CANewInterfaceItem(int index, const char *name, int family,
                                          uint32_t addr, int flags);
 
@@ -69,6 +71,11 @@ int CAGetPollingInterval(int interval)
     return interval;
 }
 
+void CAIPSetNetworkMonitorCallback(CAIPConnectionStateChangeCallback callback)
+{
+    g_networkChangeCallback = callback;
+}
+
 CAInterface_t *CAFindInterfaceChange()
 {
     char buf[MAX_INTERFACE_INFO_LENGTH] = { 0 };
@@ -321,16 +328,10 @@ CAResult_t CAIPJniInit()
         return CA_STATUS_FAILED;
     }
 
-    jclass cls_Context = (*env)->FindClass(env, "android/content/Context");
-    if (!cls_Context)
-    {
-        OIC_LOG(ERROR, TAG, "Could not get context object class");
-        return CA_STATUS_FAILED;
-    }
+    jmethodID mid_getApplicationContext = CAGetJNIMethodID(env, "android/content/Context",
+                                                           "getApplicationContext",
+                                                           "()Landroid/content/Context;");
 
-    jmethodID mid_getApplicationContext = (*env)->GetMethodID(env, cls_Context,
-                                                                "getApplicationContext",
-                                                                "()Landroid/content/Context;");
     if (!mid_getApplicationContext)
     {
         OIC_LOG(ERROR, TAG, "Could not get getApplicationContext method");
@@ -444,9 +445,9 @@ Java_org_iotivity_ca_CaIpInterface_caIpStateEnabled(JNIEnv *env, jclass class)
 {
     (void)env;
     (void)class;
-    OIC_LOG(DEBUG, TAG, "caIpStateEnabled");
 
-    CAWakeUpForChange();
+    OIC_LOG(DEBUG, TAG, "Wifi is in Activated State");
+    g_networkChangeCallback(CA_ADAPTER_IP, CA_INTERFACE_UP);
 }
 
 JNIEXPORT void JNICALL
@@ -454,13 +455,7 @@ Java_org_iotivity_ca_CaIpInterface_caIpStateDisabled(JNIEnv *env, jclass class)
 {
     (void)env;
     (void)class;
-    OIC_LOG(DEBUG, TAG, "caIpStateDisabled");
 
-    u_arraylist_t *iflist = CAIPGetInterfaceInformation(0);
-    if (!iflist)
-    {
-        OIC_LOG_V(ERROR, TAG, "get interface info failed");
-        return;
-    }
-    u_arraylist_destroy(iflist);
+    OIC_LOG(DEBUG, TAG, "Wifi is in Deactivated State");
+    g_networkChangeCallback(CA_ADAPTER_IP, CA_INTERFACE_DOWN);
 }
index 308ec6d..4c4c9fb 100644 (file)
@@ -68,7 +68,7 @@ static CANetworkPacketReceivedCallback g_networkPacketCallback = NULL;
 /**
  * Network Changed Callback to CA.
  */
-static CANetworkChangeCallback g_networkChangeCallback = NULL;
+static CAAdapterChangeCallback g_networkChangeCallback = NULL;
 
 /**
  * error Callback to CA adapter.
@@ -137,10 +137,16 @@ void CAIPDeinitializeQueueHandles()
 
 #endif // SINGLE_THREAD
 
-void CAIPConnectionStateCB(const char *ipAddress, CANetworkStatus_t status)
+void CAIPConnectionStateCB(CATransportAdapter_t adapter, CANetworkStatus_t status)
 {
-    (void)ipAddress;
-    (void)status;
+    if (g_networkChangeCallback)
+    {
+        g_networkChangeCallback(adapter, status);
+    }
+    else
+    {
+        OIC_LOG(ERROR, TAG, "g_networkChangeCallback is NULL");
+    }
 }
 
 #ifdef __WITH_DTLS__
@@ -215,7 +221,7 @@ static void CAInitializeIPGlobals()
 
 CAResult_t CAInitializeIP(CARegisterConnectivityCallback registerCallback,
                           CANetworkPacketReceivedCallback networkPacketCallback,
-                          CANetworkChangeCallback netCallback,
+                          CAAdapterChangeCallback netCallback,
                           CAErrorHandleCallback errorCallback, ca_thread_pool_t handle)
 {
     OIC_LOG(DEBUG, TAG, "IN");
@@ -234,6 +240,9 @@ CAResult_t CAInitializeIP(CARegisterConnectivityCallback registerCallback,
     caglobals.ip.threadpool = handle;
 
     CAIPSetPacketReceiveCallback(CAIPPacketReceivedCB);
+#ifndef SINGLE_THREAD
+    CAIPSetConnectionStateChangeCallback(CAIPConnectionStateCB);
+#endif
 #ifdef __WITH_DTLS__
     CAAdapterNetDtlsInit();
 
index c49b064..c64fcb5 100644 (file)
@@ -168,6 +168,12 @@ void CADeInitializeIPGlobals()
         close(caglobals.ip.m4s.fd);
         caglobals.ip.m4s.fd = -1;
     }
+
+    if (caglobals.ip.netlinkFd != -1)
+    {
+        close(caglobals.ip.netlinkFd);
+        caglobals.ip.netlinkFd = -1;
+    }
 }
 
 static void CAReceiveHandler(void *data)
@@ -244,7 +250,12 @@ static void CASelectReturned(fd_set *readFds, int ret)
         else ISSET(m4s, readFds, CA_MULTICAST | CA_IPV4 | CA_SECURE)
         else if (FD_ISSET(caglobals.ip.netlinkFd, readFds))
         {
-            CAHandleNetlink();
+            CAInterface_t *ifchanged = CAFindInterfaceChange();
+            if (ifchanged)
+            {
+                CAProcessNewInterface(ifchanged);
+                OICFree(ifchanged);
+            }
             break;
         }
         else if (FD_ISSET(caglobals.ip.shutdownFds[0], readFds))
@@ -255,13 +266,6 @@ static void CASelectReturned(fd_set *readFds, int ret)
             {
                 continue;
             }
-
-            CAInterface_t *ifchanged = CAFindInterfaceChange();
-            if (ifchanged)
-            {
-                CAProcessNewInterface(ifchanged);
-                OICFree(ifchanged);
-            }
             break;
         }
         else
@@ -830,64 +834,15 @@ static void CAProcessNewInterface(CAInterface_t *ifitem)
         OIC_LOG(DEBUG, TAG, "ifitem is null");
         return;
     }
-
-    applyMulticastToInterface6(ifitem->index);
-    struct in_addr inaddr = { .s_addr = ifitem->ipv4addr };
-    applyMulticastToInterface4(inaddr);
-}
-static void CAHandleNetlink()
-{
-#ifdef __linux__
-    char buf[4096];
-    struct nlmsghdr *nh;
-    struct sockaddr_nl sa;
-    struct iovec iov = { buf, sizeof (buf) };
-    struct msghdr msg = { (void *)&sa, sizeof (sa), &iov, 1, NULL, 0, 0 };
-
-    size_t len = recvmsg(caglobals.ip.netlinkFd, &msg, 0);
-
-    for (nh = (struct nlmsghdr *)buf; NLMSG_OK(nh, len); nh = NLMSG_NEXT(nh, len))
+    if (ifitem->family == AF_INET6)
     {
-        if (nh != NULL && nh->nlmsg_type != RTM_NEWLINK)
-        {
-            continue;
-        }
-
-        struct ifinfomsg *ifi = (struct ifinfomsg *)NLMSG_DATA(nh);
-        if (!ifi || (ifi->ifi_flags & IFF_LOOPBACK) || !(ifi->ifi_flags & IFF_RUNNING))
-        {
-            continue;
-        }
-
-        int newIndex = ifi->ifi_index;
-
-        u_arraylist_t *iflist = CAIPGetInterfaceInformation(newIndex);
-        if (!iflist)
-        {
-            OIC_LOG_V(ERROR, TAG, "get interface info failed: %s", strerror(errno));
-            return;
-        }
-
-        uint32_t listLength = u_arraylist_length(iflist);
-        for (uint32_t i = 0; i < listLength; i++)
-        {
-            CAInterface_t *ifitem = (CAInterface_t *)u_arraylist_get(iflist, i);
-            if (!ifitem)
-            {
-                continue;
-            }
-
-            if ((int)ifitem->index != newIndex)
-            {
-                continue;
-            }
-
-            CAProcessNewInterface(ifitem);
-            break; // we found the one we were looking for
-        }
-        u_arraylist_destroy(iflist);
+        applyMulticastToInterface6(ifitem->index);
+    }
+    if (ifitem->family == AF_INET)
+    {
+        struct in_addr inaddr = { .s_addr = ifitem->ipv4addr };
+        applyMulticastToInterface4(inaddr);
     }
-#endif // __linux__
 }
 
 void CAIPSetPacketReceiveCallback(CAIPPacketReceivedCallback callback)
@@ -900,6 +855,11 @@ void CAIPSetExceptionCallback(CAIPExceptionCallback callback)
     g_exceptionCallback = callback;
 }
 
+void CAIPSetConnectionStateChangeCallback(CAIPConnectionStateChangeCallback callback)
+{
+    CAIPSetNetworkMonitorCallback(callback);
+}
+
 static void sendData(int fd, const CAEndpoint_t *endpoint,
                      const void *data, uint32_t dlen,
                      const char *cast, const char *fam)
index f1d5211..a2f2e4f 100644 (file)
 
 #include "caipinterface.h"
 
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
 #include <sys/types.h>
+#include <sys/select.h>
 #include <ifaddrs.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
 #include <net/if.h>
-#include <sys/socket.h>
 #include <netdb.h>
-#include <string.h>
 #include <errno.h>
-#include <unistd.h>
 
+#ifdef __linux__
+#include <linux/netlink.h>
+#include <linux/rtnetlink.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#endif
+
+#include "camutex.h"
 #include "caadapterutils.h"
 #include "logger.h"
 #include "oic_malloc.h"
 
 #define TAG "OIC_CA_IP_MONITOR"
 
-CAResult_t CAIPStartNetworkMonitor()
+/**
+ * Mutex for synchronizing access to cached interface and IP address information.
+ */
+static ca_mutex g_networkMonitorContextMutex = NULL;
+
+/**
+ * Used to storing network interface.
+ */
+static u_arraylist_t *g_netInterfaceList = NULL;
+
+static CAIPConnectionStateChangeCallback g_networkChangeCallback = NULL;
+
+static CAResult_t CAIPInitializeNetworkMonitorList();
+static void CAIPDestroyNetworkMonitorList();
+static CAInterface_t *CANewInterfaceItem(int index, const char *name, int family,
+                                         uint32_t addr, int flags);
+
+static CAResult_t CAIPInitializeNetworkMonitorList()
+{
+    if (!g_networkMonitorContextMutex)
+    {
+        g_networkMonitorContextMutex = ca_mutex_new();
+        if (!g_networkMonitorContextMutex)
+        {
+            OIC_LOG(ERROR, TAG, "ca_mutex_new has failed");
+            return CA_STATUS_FAILED;
+        }
+    }
+
+    if (!g_netInterfaceList)
+    {
+        g_netInterfaceList = u_arraylist_create();
+        if (!g_netInterfaceList)
+        {
+            OIC_LOG(ERROR, TAG, "u_arraylist_create has failed");
+            CAIPDestroyNetworkMonitorList();
+            return CA_STATUS_FAILED;
+        }
+    }
+}
+
+static void CAIPDestroyNetworkMonitorList()
+{
+    if (g_netInterfaceList)
+    {
+        u_arraylist_destroy(g_netInterfaceList);
+        g_netInterfaceList = NULL;
+    }
+
+    if (g_networkMonitorContextMutex)
+    {
+        ca_mutex_free(g_networkMonitorContextMutex);
+        g_networkMonitorContextMutex = NULL;
+    }
+}
+
+static bool CACmpNetworkList(uint32_t ifiindex)
+{
+    if (!g_netInterfaceList)
+    {
+        OIC_LOG(ERROR, TAG, "g_netInterfaceList is NULL");
+        return false;
+    }
+
+    ca_mutex_lock(g_networkMonitorContextMutex);
+
+    uint32_t list_length = u_arraylist_length(g_netInterfaceList);
+    for (uint32_t list_index = 0; list_index < list_length; list_index++)
+    {
+        CAInterface_t *currItem = (CAInterface_t *) u_arraylist_get(g_netInterfaceList, list_index);
+        if (currItem->index == ifiindex)
+        {
+            ca_mutex_unlock(g_networkMonitorContextMutex);
+            return true;
+        }
+    }
+    ca_mutex_unlock(g_networkMonitorContextMutex);
+    return false;
+}
+
+static CAResult_t CAAddNetworkMonitorList(CAInterface_t *ifitem)
 {
+    VERIFY_NON_NULL(g_netInterfaceList, TAG, "g_netInterfaceList is NULL");
+    VERIFY_NON_NULL(ifitem, TAG, "ifitem is NULL");
+
+    ca_mutex_lock(g_networkMonitorContextMutex);
+    bool result = u_arraylist_add(g_netInterfaceList, (void *) ifitem);
+    if (!result)
+    {
+        OIC_LOG(ERROR, TAG, "u_arraylist_add failed.");
+        ca_mutex_unlock(g_networkMonitorContextMutex);
+        return CA_STATUS_FAILED;
+    }
+    ca_mutex_unlock(g_networkMonitorContextMutex);
     return CA_STATUS_OK;
 }
 
+static void CARemoveNetworkMonitorList(int ifiindex)
+{
+    VERIFY_NON_NULL_VOID(g_netInterfaceList, TAG, "g_netInterfaceList is NULL");
+
+    ca_mutex_lock(g_networkMonitorContextMutex);
+
+    uint32_t list_length = u_arraylist_length(g_netInterfaceList);
+    for (uint32_t list_index = 0; list_index < list_length; list_index++)
+    {
+        CAInterface_t *removedifitem = (CAInterface_t *) u_arraylist_get(
+                g_netInterfaceList, list_index);
+        if (removedifitem && removedifitem->index == ifiindex)
+        {
+            if (u_arraylist_remove(g_netInterfaceList, list_index))
+            {
+                OICFree(removedifitem);
+                ca_mutex_unlock(g_networkMonitorContextMutex);
+                return;
+            }
+            continue;
+        }
+    }
+    ca_mutex_unlock(g_networkMonitorContextMutex);
+    return;
+}
+
+CAResult_t CAIPStartNetworkMonitor()
+{
+    return CAIPInitializeNetworkMonitorList();
+}
+
 CAResult_t CAIPStopNetworkMonitor()
 {
+    CAIPDestroyNetworkMonitorList();
     return CA_STATUS_OK;
 }
 
@@ -51,9 +189,96 @@ int CAGetPollingInterval(int interval)
     return interval;
 }
 
+void CAIPSetNetworkMonitorCallback(CAIPConnectionStateChangeCallback callback)
+{
+    g_networkChangeCallback = callback;
+}
+
+static CAInterface_t *CANewInterfaceItem(int index, const char *name, int family,
+                                         uint32_t addr, int flags)
+{
+    CAInterface_t *ifitem = (CAInterface_t *)OICCalloc(1, sizeof (CAInterface_t));
+    if (!ifitem)
+    {
+        OIC_LOG(ERROR, TAG, "Malloc failed");
+        return NULL;
+    }
+
+    OICStrcpy(ifitem->name, sizeof (ifitem->name), name);
+    ifitem->index = index;
+    ifitem->family = family;
+    ifitem->ipv4addr = addr;
+    ifitem->flags = flags;
+
+    return ifitem;
+}
+
 CAInterface_t *CAFindInterfaceChange()
 {
-    return NULL;
+    CAInterface_t *foundNewInterface = NULL;
+#ifdef __linux__
+    char buf[4096];
+    struct nlmsghdr *nh;
+    struct sockaddr_nl sa;
+    struct iovec iov = { buf, sizeof (buf) };
+    struct msghdr msg = { (void *)&sa, sizeof (sa), &iov, 1, NULL, 0, 0 };
+
+    size_t len = recvmsg(caglobals.ip.netlinkFd, &msg, 0);
+
+    for (nh = (struct nlmsghdr *)buf; NLMSG_OK(nh, len); nh = NLMSG_NEXT(nh, len))
+    {
+        if (nh != NULL && nh->nlmsg_type != RTM_NEWLINK)
+        {
+            continue;
+        }
+
+        struct ifinfomsg *ifi = (struct ifinfomsg *)NLMSG_DATA(nh);
+
+        int ifiIndex = ifi->ifi_index;
+        u_arraylist_t *iflist = CAIPGetInterfaceInformation(ifiIndex);
+
+        if ((!ifi || (ifi->ifi_flags & IFF_LOOPBACK) || !(ifi->ifi_flags & IFF_RUNNING)))
+        {
+            bool isFound = CACmpNetworkList(ifiIndex);
+            if (isFound)
+            {
+                CARemoveNetworkMonitorList(ifiIndex);
+                if (g_networkChangeCallback)
+                {
+                    g_networkChangeCallback(CA_ADAPTER_IP ,CA_INTERFACE_DOWN);
+                }
+            }
+            continue;
+        }
+
+        if (!iflist)
+        {
+            OIC_LOG_V(ERROR, TAG, "get interface info failed: %s", strerror(errno));
+            return NULL;
+        }
+
+        uint32_t listLength = u_arraylist_length(iflist);
+        for (uint32_t i = 0; i < listLength; i++)
+        {
+            CAInterface_t *ifitem = (CAInterface_t *)u_arraylist_get(iflist, i);
+            if (!ifitem)
+            {
+                continue;
+            }
+
+            if ((int)ifitem->index != ifiIndex)
+            {
+                continue;
+            }
+
+            foundNewInterface = CANewInterfaceItem(ifitem->index, ifitem->name, ifitem->family,
+                                                   ifitem->ipv4addr, ifitem->flags);
+            break;    // we found the one we were looking for
+        }
+        u_arraylist_destroy(iflist);
+    }
+#endif
+    return foundNewInterface;
 }
 
 u_arraylist_t *CAIPGetInterfaceInformation(int desiredIndex)
@@ -138,9 +363,24 @@ u_arraylist_t *CAIPGetInterfaceInformation(int desiredIndex)
             goto exit;
         }
 
-        OIC_LOG_V(DEBUG, TAG, "Added interface: %s (%d)", ifitem->name, family);
+        bool isFound = CACmpNetworkList(ifitem->index);
+        if (!isFound)
+        {
+            CAInterface_t *newifitem = CANewInterfaceItem(ifitem->index, ifitem->name, ifitem->family,
+                                                          ifitem->ipv4addr, ifitem->flags);
+            CAResult_t ret = CAAddNetworkMonitorList(newifitem);
+            if (CA_STATUS_OK != ret)
+            {
+                OICFree(newifitem);
+                goto exit;
+            }
+            if (g_networkChangeCallback)
+            {
+                g_networkChangeCallback(CA_ADAPTER_IP, CA_INTERFACE_UP);
+            }
+            OIC_LOG_V(DEBUG, TAG, "Added interface: %s (%d)", ifitem->name, ifitem->family);
+        }
     }
-
     freeifaddrs(ifp);
     return iflist;
 
index 437e535..aaa39d4 100644 (file)
@@ -39,6 +39,8 @@
 #define TAG "IP_MONITOR"
 #define MAX_INTERFACE_INFO_LENGTH (1024)
 
+static CAIPConnectionStateChangeCallback g_networkChangeCallback;
+
 static CAInterface_t *CANewInterfaceItem(int index, char *name, int family,
                                          uint32_t addr, int flags);
 
@@ -56,6 +58,11 @@ int CAGetPollingInterval(int interval)
     return interval;
 }
 
+void CAIPSetNetworkMonitorCallback(CAIPConnectionStateChangeCallback callback)
+{
+    g_networkChangeCallback = callback;
+}
+
 CAInterface_t *CAFindInterfaceChange()
 {
     char buf[MAX_INTERFACE_INFO_LENGTH] = { 0 };
@@ -357,17 +364,11 @@ void CAWIFIConnectionStateChangedCb(wifi_connection_state_e state, wifi_ap_h ap,
 
     if (WIFI_CONNECTION_STATE_CONNECTED == state)
     {
-        CAWakeUpForChange();
+        g_networkChangeCallback(CA_ADAPTER_IP, CA_INTERFACE_UP);
     }
     else
     {
-        u_arraylist_t *iflist = CAIPGetInterfaceInformation(0);
-        if (!iflist)
-        {
-            OIC_LOG_V(ERROR, TAG, "get interface info failed");
-            return;
-        }
-        u_arraylist_destroy(iflist);
+        g_networkChangeCallback(CA_ADAPTER_IP, CA_INTERFACE_DOWN);
     }
 
     OIC_LOG(DEBUG, TAG, "OUT");
index aa23348..9247bc3 100644 (file)
@@ -148,7 +148,25 @@ CAResult_t CANfcCreateJniInterfaceObject()
         isAttached = true;\r
     }\r
 \r
-    jclass jni_NfcInterface = (*env)->FindClass(env, "org/iotivity/ca/CaNfcInterface");\r
+    jmethodID mid_getApplicationContext = CAGetJNIMethodID(env, "android/content/Context",\r
+                                                           "getApplicationContext",\r
+                                                           "()Landroid/content/Context;");\r
+\r
+    if (!mid_getApplicationContext)\r
+    {\r
+        OIC_LOG(ERROR, TAG, "Could not get getApplicationContext method");\r
+        return CA_STATUS_FAILED;\r
+    }\r
+\r
+    jobject jApplicationContext = (*env)->CallObjectMethod(env, g_context,\r
+                                                           mid_getApplicationContext);\r
+    if (!jApplicationContext)\r
+    {\r
+        OIC_LOG(ERROR, TAG, "Could not get application context");\r
+        return CA_STATUS_FAILED;\r
+    }\r
+\r
+    jclass jni_NfcInterface = (*env)->FindClass(env, CLASS_NFCINTERFACE);\r
     if (!jni_NfcInterface)\r
     {\r
         OIC_LOG(ERROR, TAG, "Could not get CaNfcInterface class");\r
@@ -164,7 +182,7 @@ CAResult_t CANfcCreateJniInterfaceObject()
     }\r
 \r
     jobject jni_nfcInstance = (*env)->NewObject(env, jni_NfcInterface,\r
-                                                NfcInterfaceConstructorMethod, g_context,\r
+                                                NfcInterfaceConstructorMethod, jApplicationContext,\r
                                                 g_activity);\r
     if (!jni_nfcInstance)\r
     {\r
@@ -240,7 +258,7 @@ CAResult_t CANFCStartServer()
         isAttached = true;\r
     }\r
 \r
-    jclass jni_NfcInterface = (*env)->FindClass(env, "org/iotivity/ca/CaNfcInterface");\r
+    jclass jni_NfcInterface = (*env)->FindClass(env, CLASS_NFCINTERFACE);\r
     if (!jni_NfcInterface)\r
     {\r
         OIC_LOG(ERROR, TAG, "Could not get CaNFCClientInterface class");\r
@@ -323,15 +341,8 @@ Java_org_iotivity_ca_CaNfcInterface_caNativeNfcCreateNdefMessage(JNIEnv *env, jo
         return NULL;\r
     }\r
 \r
-    jclass cid_string = (*env)->FindClass(env, "java/lang/String");\r
-    if (!cid_string)\r
-    {\r
-        OIC_LOG(ERROR, TAG, "Could not get NfcAdapter class for cid_string");\r
-        return NULL;\r
-    }\r
-\r
-    jmethodID mid_getBytes = (*env)->GetMethodID(env, cid_string, "getBytes",\r
-                                                 "(Ljava/lang/String;)[B");\r
+    jmethodID mid_getBytes = CAGetJNIMethodID(env, "java/lang/String", "getBytes",\r
+                                              "(Ljava/lang/String;)[B");\r
     if (!mid_getBytes)\r
     {\r
         OIC_LOG(ERROR, TAG, "Could not get methodId for mid_getBytes");\r
index cc34caa..eddee4d 100644 (file)
@@ -58,9 +58,9 @@ static CAQueueingThread_t *g_sendQueueHandle = NULL;
 static CANetworkPacketReceivedCallback g_packetReceivedCallback = NULL;
 
 /**
- *  Network Changed Callback to CA
+ *  Adapter Changed Callback to CA
  */
-static CANetworkChangeCallback g_connectionStateCallback = NULL;
+static CAAdapterChangeCallback g_adapterStateCallback = NULL;
 
 /**
  * error Callback to CA adapter
@@ -177,16 +177,16 @@ void CANFCErrorHandler(const CAEndpoint_t *endpoint, const void *data, uint32_t
 
 CAResult_t CAInitializeNFC(CARegisterConnectivityCallback registerCallback,
                            CANetworkPacketReceivedCallback packetReceivedCallback,
-                           CANetworkChangeCallback connectionStateCallback,
+                           CAAdapterChangeCallback netCallback,
                            CAErrorHandleCallback errorCallback, ca_thread_pool_t handle)
 {
     OIC_LOG(DEBUG, TAG, "IN");
     VERIFY_NON_NULL(registerCallback, TAG, "registerCallback");
     VERIFY_NON_NULL(packetReceivedCallback, TAG, "packetReceivedCallback");
-    VERIFY_NON_NULL(connectionStateCallback, TAG, "connectionStateCallback");
+    VERIFY_NON_NULL(netCallback, TAG, "netCallback");
     VERIFY_NON_NULL(handle, TAG, "thread pool handle");
 
-    g_connectionStateCallback = connectionStateCallback;
+    g_adapterStateCallback = netCallback;
     g_packetReceivedCallback = packetReceivedCallback;
     g_errorCallback = errorCallback;
 
index b34cb83..fba4ca8 100644 (file)
@@ -59,7 +59,7 @@ static CANetworkPacketReceivedCallback g_networkPacketCallback = NULL;
 /**
  * Network Changed Callback to CA.
  */
-static CANetworkChangeCallback g_networkChangeCallback = NULL;
+static CAAdapterChangeCallback g_networkChangeCallback = NULL;
 
 /**
  * Holds XMPP data information.
@@ -91,26 +91,16 @@ void CARANotifyNetworkChange(const char *address, CANetworkStatus_t status)
 
     g_xmppData.connectionStatus = status;
 
-    CAEndpoint_t *localEndpoint = CACreateEndpointObject(CA_DEFAULT_FLAGS,
-                                CA_ADAPTER_REMOTE_ACCESS,
-                                address, 0);
-    if (!localEndpoint)
-    {
-        OIC_LOG(ERROR, RA_ADAPTER_TAG, "localEndpoint creation failed!");
-        return;
-    }
-    CANetworkChangeCallback networkChangeCallback = g_networkChangeCallback;
+    CAAdapterChangeCallback networkChangeCallback = g_networkChangeCallback;
     if (networkChangeCallback)
     {
-        networkChangeCallback(localEndpoint, status);
+        networkChangeCallback(CA_ADAPTER_REMOTE_ACCESS, status);
     }
     else
     {
         OIC_LOG(ERROR, RA_ADAPTER_TAG, "g_networkChangeCallback is NULL");
     }
 
-    CAFreeEndpoint(localEndpoint);
-
     OIC_LOG(DEBUG, RA_ADAPTER_TAG, "CARANotifyNetworkChange OUT");
 }
 
@@ -359,8 +349,8 @@ static int CARAConnHandler(xmpp_t *xmpp, xmppconn_info_t *conninfo, void *udata)
 }
 
 CAResult_t CAInitializeRA(CARegisterConnectivityCallback registerCallback,
-                                CANetworkPacketReceivedCallback networkPacketCallback,
-                                CANetworkChangeCallback netCallback, ca_thread_pool_t handle)
+                          CANetworkPacketReceivedCallback networkPacketCallback,
+                          CAAdapterChangeCallback netCallback, ca_thread_pool_t handle)
 {
     OIC_LOG(DEBUG, RA_ADAPTER_TAG, "CAInitializeRA IN");
     if (!registerCallback || !networkPacketCallback || !netCallback || !handle)
@@ -615,7 +605,7 @@ static CANetworkPacketReceivedCallback g_networkPacketCallback = NULL;
 /**
  * Network Changed Callback to CA.
  */
-static CANetworkChangeCallback g_networkChangeCallback = NULL;
+static CAAdapterChangeCallback g_networkChangeCallback = NULL;
 
 /**
  * Holds XMPP data information.
@@ -657,26 +647,16 @@ void CARANotifyNetworkChange(const char *address, CANetworkStatus_t status)
 {
     OIC_LOG(DEBUG, RA_ADAPTER_TAG, "CARANotifyNetworkChange IN");
 
-    CAEndpoint_t *localEndpoint = CACreateEndpointObject(CA_DEFAULT_FLAGS,
-                                CA_ADAPTER_REMOTE_ACCESS,
-                                address, 0);
-    if (!localEndpoint)
-    {
-        OIC_LOG(ERROR, RA_ADAPTER_TAG, "localEndpoint creation failed!");
-        return;
-    }
-    CANetworkChangeCallback networkChangeCallback = g_networkChangeCallback;
+    CAAdapterChangeCallback networkChangeCallback = g_networkChangeCallback;
     if (networkChangeCallback)
     {
-        networkChangeCallback(localEndpoint, status);
+        networkChangeCallback(CA_ADAPTER_REMOTE_ACCESS, status);
     }
     else
     {
         OIC_LOG(ERROR, RA_ADAPTER_TAG, "g_networkChangeCallback is NULL");
     }
 
-    CAFreeEndpoint(localEndpoint);
-
     OIC_LOG(DEBUG, RA_ADAPTER_TAG, "CARANotifyNetworkChange OUT");
 }
 
@@ -783,8 +763,8 @@ void CARAXmppMessageReceivedCB(void * const param, xmpp_error_code_t result,
 }
 
 CAResult_t CAInitializeRA(CARegisterConnectivityCallback registerCallback,
-                                CANetworkPacketReceivedCallback networkPacketCallback,
-                                CANetworkChangeCallback netCallback, ca_thread_pool_t handle)
+                          CANetworkPacketReceivedCallback networkPacketCallback,
+                          CAAdapterChangeCallback netCallback, ca_thread_pool_t handle)
 {
     OIC_LOG(DEBUG, RA_ADAPTER_TAG, "CAInitializeRA IN");
     if (!registerCallback || !networkPacketCallback || !netCallback || !handle)
index df48527..7972635 100644 (file)
@@ -19,6 +19,8 @@ if target_os in ['linux', 'tizen', 'android']:
     common_files = [
         os.path.join(src_dir, 'catcpadapter.c'),
         os.path.join(src_dir, 'catcpserver.c') ]
+else :
+    common_files = [os.path.join(src_dir, 'catcpadapter.c')]
 
 # Get list of target-specific source file base names, i.e. no parent
 # directories prepended to the path.
diff --git a/resource/csdk/connectivity/src/tcp_adapter/arduino/SConscript b/resource/csdk/connectivity/src/tcp_adapter/arduino/SConscript
new file mode 100644 (file)
index 0000000..b9125ae
--- /dev/null
@@ -0,0 +1,14 @@
+#######################################################
+#       Build TCP adapter for Ardunino
+#######################################################
+
+Import('env', 'src_dir')
+import os.path
+
+env.AppendUnique(CPPPATH = [ os.path.join(src_dir, 'arduino') ])
+
+if env.get('SHIELD') == 'ETH':
+    src_files = [ 'catcpserver_eth.cpp' ,
+                  'catcpadapterutils_eth.cpp']
+
+Return('src_files')
diff --git a/resource/csdk/connectivity/src/tcp_adapter/arduino/catcpadapterutils_eth.cpp b/resource/csdk/connectivity/src/tcp_adapter/arduino/catcpadapterutils_eth.cpp
new file mode 100644 (file)
index 0000000..7ecba20
--- /dev/null
@@ -0,0 +1,82 @@
+/******************************************************************
+*
+* Copyright 2015 Samsung Electronics All Rights Reserved.
+*
+*
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+******************************************************************/
+#include "catcpadapterutils_eth.h"
+
+#include <Arduino.h>
+#include <Ethernet.h>
+#include <socket.h>
+#include <w5100.h>
+#include <EthernetUdp.h>
+#include <IPAddress.h>
+
+#include "logger.h"
+#include "cacommon.h"
+#include "caadapterinterface.h"
+#include "caadapterutils.h"
+
+#define TAG "IPU"
+
+CAResult_t CAArduinoGetAvailableTCPSocket(int *sockID)
+{
+    VERIFY_NON_NULL(sockID, TAG, "sockID");
+    //Is any socket available to work with ?
+    *sockID = 0;
+    for (int i = 1; i < MAX_SOCK_NUM; i++)
+    {
+        uint8_t state = W5100.readSnSR(i);
+        if (state == SnSR::CLOSED || state == SnSR::FIN_WAIT)
+        {
+            *sockID = i;
+            break;
+        }
+    }
+
+    if (*sockID == 0)
+    {
+        OIC_LOG(ERROR, TAG, "sockID 0");
+        return CA_SOCKET_OPERATION_FAILED;
+    }
+
+    return CA_STATUS_OK;
+}
+
+CAResult_t CAArduinoInitTCPSocket(uint16_t *port, int *socketID)
+{
+    OIC_LOG(DEBUG, TAG, "IN");
+    VERIFY_NON_NULL(port, TAG, "port");
+    VERIFY_NON_NULL(socketID, TAG, "socketID");
+
+    CAResult_t ret = CAArduinoGetAvailableTCPSocket(socketID);
+    if (ret != CA_STATUS_OK)
+    {
+        OIC_LOG(ERROR, TAG, "get sock fail");
+        return ret;
+    }
+
+    //Create a tcp socket on which to recv/send.
+    if (!socket(*socketID, SnMR::TCP, *port, 0))
+    {
+        OIC_LOG(ERROR, TAG, "sock fail");
+        return CA_STATUS_FAILED;
+    }
+    OIC_LOG_V(DEBUG, TAG, "socketId:%d", *socketID);
+    OIC_LOG(DEBUG, TAG, "OUT");
+    return CA_STATUS_OK;
+}
diff --git a/resource/csdk/connectivity/src/tcp_adapter/arduino/catcpadapterutils_eth.h b/resource/csdk/connectivity/src/tcp_adapter/arduino/catcpadapterutils_eth.h
new file mode 100644 (file)
index 0000000..4ecbd84
--- /dev/null
@@ -0,0 +1,66 @@
+/* ****************************************************************
+ *
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************/
+
+/**
+ * @file
+ * This file provides APIs ethernet client/server/network monitor modules.
+ */
+
+#ifndef CA_ETHERNET_ADAPTER_UTILS_
+#define CA_ETHERNET_ADAPTER_UTILS_
+
+#include <Arduino.h>
+#include <Ethernet.h>
+#include <socket.h>
+#include <w5100.h>
+#include <IPAddress.h>
+
+#include "logger.h"
+#include "cacommon.h"
+#include "caadapterinterface.h"
+#include "caipadapter.h"
+#include "caadapterutils.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * Get available TCP socket.
+ * @param[out]   sockID         Available UDP socket ID.
+ * @return  ::CA_STATUS_OK or Appropriate error code.
+ */
+CAResult_t CAArduinoGetAvailableTCPSocket(int *sockID);
+
+/**
+ * Initialize Unicast TCP socket.
+ * @param[in/out]   port        Port to start the unicast server.
+ * @param[out]      socketID    Unicast socket ID.
+ * @return  ::CA_STATUS_OK or Appropriate error code.
+ */
+CAResult_t CAArduinoInitTCPSocket(uint16_t *port, int *socketID);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CA_ETHERNET_ADAPTER_UTILS_ */
+
diff --git a/resource/csdk/connectivity/src/tcp_adapter/arduino/catcpserver_eth.cpp b/resource/csdk/connectivity/src/tcp_adapter/arduino/catcpserver_eth.cpp
new file mode 100644 (file)
index 0000000..3cc0e7d
--- /dev/null
@@ -0,0 +1,322 @@
+/* ****************************************************************
+ *
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************/
+
+#include <stdio.h>
+#include <errno.h>
+
+#include <Arduino.h>
+#include <Ethernet.h>
+#include <SPI.h>
+#include <w5100.h>
+#include <IPAddress.h>
+
+#include "catcpadapterutils_eth.h"
+#include "catcpinterface.h"
+#include "pdu.h"
+#include "caadapterutils.h"
+#include "camutex.h"
+#include "oic_malloc.h"
+#include "oic_string.h"
+
+/**
+ * Logging tag for module name.
+ */
+#define TAG "TCP_SERVER"
+
+/**
+ * Maximum CoAP over TCP header length
+ * to know the total data length.
+ */
+#define TCP_MAX_HEADER_LEN  6
+
+#define TCP_UNICAST_PORT  55556
+
+uint16_t tcpClientPort = 0;
+uint8_t tcpClientIP[4] = {0};
+
+/**
+ * Maintains the callback to be notified when data received from remote device.
+ */
+static CATCPPacketReceivedCallback g_packetReceivedCallback = NULL;
+
+/**
+ * Error callback to update error in TCP.
+ */
+static CATCPErrorHandleCallback g_TCPErrorHandler = NULL;
+
+static uint16_t g_unicastPort = 0;
+
+static int g_unicastSocket = -1;
+
+static EthernetServer server(TCP_UNICAST_PORT);
+
+/**
+ * @var g_receivedDataLen
+ * @brief Actual length of data received.
+ */
+static uint32_t g_receivedDataLen = 0;
+
+static void CATCPReadDataInternal();
+
+uint16_t CAGetTcpServerPortNum(const char *ipAddress, bool isSecured)
+{
+    return g_unicastPort;
+}
+
+void CATCPPullData()
+{
+    CATCPReadDataInternal();
+}
+
+CAResult_t CATCPStartServer()
+{
+    OIC_LOG(DEBUG, TAG, "IN");
+
+    if (caglobals.tcp.started)
+    {
+        return CA_STATUS_OK;
+    }
+
+    if (!caglobals.tcp.ipv4tcpenabled)
+    {
+        caglobals.tcp.ipv4tcpenabled = true;    // only needed to run CA tests
+    }
+
+    uint8_t rawIPAddr[4] = {0};
+    char address[16] = {0};
+    W5100.getIPAddress(rawIPAddr);
+    int ret = snprintf(address, sizeof(address), "%d.%d.%d.%d", rawIPAddr[0], rawIPAddr[1], rawIPAddr[2],
+                       rawIPAddr[3]);
+    if(0 > ret)
+    {
+        OIC_LOG(ERROR, TAG, "Error getting IP");
+        return CA_STATUS_FAILED;
+    }
+
+    OIC_LOG_V(DEBUG, TAG, "address:%s", address);
+    int serverFD = 1;
+    g_unicastPort = TCP_UNICAST_PORT;
+
+    if (CAArduinoInitTCPSocket(&g_unicastPort, &serverFD) != CA_STATUS_OK)
+    {
+        OIC_LOG(DEBUG, TAG, "Init TCP Socket failed");
+        return CA_STATUS_FAILED;
+    }
+
+    listen(serverFD);
+    EthernetClass::_server_port[serverFD] = g_unicastPort;
+    g_unicastSocket = serverFD;
+    caglobals.ip.u4.port =  TCP_UNICAST_PORT;
+
+    caglobals.tcp.terminate = false;
+    caglobals.tcp.started = true;
+
+    OIC_LOG_V(DEBUG, TAG, "g_unicastPort: %u", g_unicastPort);
+    OIC_LOG_V(DEBUG, TAG, "g_unicastSocket: %d", g_unicastSocket);
+    OIC_LOG(DEBUG, TAG, "OUT");
+    return CA_STATUS_OK;
+}
+
+void CATCPStopServer()
+{
+    OIC_LOG(DEBUG, TAG, "IN");
+    caglobals.tcp.terminate = true;
+    caglobals.tcp.started = false;
+
+    if (-1 != g_unicastSocket)
+    {
+        close(g_unicastSocket);
+        g_unicastSocket = -1;
+    }
+
+    caglobals.ip.u4.port = 0;
+    OIC_LOG(DEBUG, TAG, "OUT");
+}
+
+void CATCPSetPacketReceiveCallback(CATCPPacketReceivedCallback callback)
+{
+    OIC_LOG(DEBUG, TAG, "IN");
+
+    g_packetReceivedCallback = callback;
+
+    OIC_LOG(DEBUG, TAG, "OUT");
+}
+
+void CATCPSetErrorHandler(CATCPErrorHandleCallback errorHandleCallback)
+{
+    return;
+}
+
+void CATCPReadDataInternal()
+{
+    OIC_LOG(DEBUG, TAG, "CATCPReadDataInternal IN");
+    if (false == caglobals.tcp.started)
+    {
+        OIC_LOG(ERROR, TAG, "Server is not running");
+        return;
+    }
+
+    EthernetClient client = server.available();
+
+    if (client && client.connected())
+    {
+        client.getTCPClientIP(tcpClientIP);
+        client.getTCPClientPort(&tcpClientPort);
+        OIC_LOG_V(DEBUG, TAG, "Client ip is %d.%d.%d.%d , Port is : %d", tcpClientIP[0],
+                tcpClientIP[1], tcpClientIP[2], tcpClientIP[3], tcpClientPort);
+
+        OIC_LOG(DEBUG, TAG, "DATA Available");
+        unsigned char *recvBuffer = NULL;
+        size_t bufSize = TCP_MAX_HEADER_LEN;
+
+        recvBuffer = (unsigned char *) OICCalloc(1, bufSize);
+        if (!recvBuffer)
+        {
+            OIC_LOG(ERROR, TAG, "out of memory");
+        }
+
+        bool isHeaderChecked = false;
+        size_t totalLen = 0;
+        size_t totalReceivedLen = 0;
+
+        do
+        {
+            size_t bufferLen = 0;
+            if (client.available())
+            {
+                bufferLen = client.read(recvBuffer, bufSize);
+                totalReceivedLen += bufferLen;
+            }
+
+            if (!isHeaderChecked && totalReceivedLen)
+            {
+                coap_transport_type transport;
+                size_t headerLen;
+                CAGetTCPHeaderDetails(recvBuffer, &transport, &headerLen);
+                if (totalReceivedLen >= headerLen)
+                {
+                    // get actual data length from coap over tcp header
+                    totalLen = CAGetTotalLengthFromPacketHeader((const unsigned char *) recvBuffer,
+                                                                 bufferLen);
+                    bufSize = totalLen;
+                    unsigned char *newBuf = (unsigned char *) OICRealloc(recvBuffer, bufSize);
+                    if (NULL == newBuf)
+                    {
+                        OIC_LOG(ERROR, TAG, "out of memory");
+                        OICFree(recvBuffer);
+                        return;
+                    }
+
+                    recvBuffer = newBuf;
+                    isHeaderChecked = true;
+                }
+            }
+
+            if (totalLen == totalReceivedLen)
+            {
+                CASecureEndpoint_t ep =
+                    {.endpoint = {.adapter = CA_ADAPTER_TCP, .port = tcpClientPort}};
+
+                IPAddress clientIP = tcpClientIP;
+                int ret = snprintf(ep.endpoint.addr, sizeof(ep.endpoint.addr), "%d.%d.%d.%d",
+                                   clientIP[0], clientIP[1], clientIP[2], clientIP[3]);
+                if(0 > ret)
+                {
+                    OIC_LOG(ERROR, TAG, "Error parsing client IP");
+                    OICFree(recvBuffer);
+                    return;
+                }
+
+                OIC_LOG_V(DEBUG, TAG, "Client ip is %d.%d.%d.%d", clientIP[0],
+                          clientIP[1], clientIP[2], clientIP[3]);
+                if (g_packetReceivedCallback)
+                {
+                    g_packetReceivedCallback(&ep, recvBuffer, totalLen);
+                }
+
+                OIC_LOG_V(DEBUG, TAG, "received data len:%d", totalLen);
+                break;
+            }
+        } while (!totalLen || totalLen > totalReceivedLen);
+
+        OICFree(recvBuffer);
+
+        OIC_LOG(DEBUG, TAG, "OUT");
+    }
+    else
+    {
+        OIC_LOG(DEBUG, TAG, "NoData");
+    }
+    return;
+}
+
+CAResult_t CAGetTCPInterfaceInformation(CAEndpoint_t **info, uint32_t *size)
+{
+    OIC_LOG(DEBUG, TAG, "IN");
+
+    VERIFY_NON_NULL(info, TAG, "info is NULL");
+    VERIFY_NON_NULL(size, TAG, "size is NULL");
+
+    return CA_NOT_SUPPORTED;
+}
+
+static void sendData(const CAEndpoint_t *endpoint,
+                     const void *data, size_t dlen)
+{
+    uint16_t port = endpoint->port;
+    uint8_t ipAddr[4] = { 0 };
+    uint16_t parsedPort = 0;
+    if (CAParseIPv4AddressInternal(endpoint->addr, ipAddr, sizeof(ipAddr),
+                                   &parsedPort) != CA_STATUS_OK)
+    {
+        OIC_LOG(ERROR, TAG, "parse fail");
+        return;
+    }
+
+    if (dlen > 65535) // Max value for uint16_t
+    {
+        // This will never happen as max buffer size we are dealing with is COAP_MAX_PDU_SIZE
+        OIC_LOG(ERROR, TAG, "Size exceeded");
+        return;
+    }
+
+    uint32_t ret = send(g_unicastSocket, (const uint8_t *)data, (uint16_t)dlen);
+    if (ret <= 0)
+    {
+        OIC_LOG_V(ERROR, TAG, "SendData failed: %d", ret);
+    }
+
+    OIC_LOG(DEBUG, TAG, "OUT");
+}
+
+void CATCPSendData(CAEndpoint_t *endpoint, const void *data, uint32_t datalen,
+                   bool isMulticast)
+{
+    VERIFY_NON_NULL_VOID(endpoint, TAG, "endpoint is NULL");
+    VERIFY_NON_NULL_VOID(data, TAG, "data is NULL");
+
+    if (!isMulticast)
+    {
+        if (caglobals.tcp.ipv4tcpenabled && (endpoint->adapter & CA_ADAPTER_TCP))
+        {
+            sendData(endpoint, data, datalen);
+        }
+    }
+}
\ No newline at end of file
index 1108877..d2fda2c 100644 (file)
@@ -71,9 +71,14 @@ static CAQueueingThread_t *g_sendQueueHandle = NULL;
 static CANetworkPacketReceivedCallback g_networkPacketCallback = NULL;
 
 /**
- * Network Changed Callback to CA.
+ * Adapter Changed Callback to CA.
  */
-static CANetworkChangeCallback g_networkChangeCallback = NULL;
+static CAAdapterChangeCallback g_networkChangeCallback = NULL;
+
+/**
+ * Connection Changed Callback to CA.
+ */
+static CAConnectionChangeCallback g_connectionChangeCallback = NULL;
 
 /**
  * error Callback to CA adapter.
@@ -84,14 +89,9 @@ static void CATCPPacketReceivedCB(const CASecureEndpoint_t *sep,
                                   const void *data, uint32_t dataLength);
 
 /**
- * KeepAlive Connected Callback to CA adapter.
+ * KeepAlive Connected or Disconnected Callback to CA adapter.
  */
-static CAKeepAliveConnectedCallback g_connCallback = NULL;
-
-/**
- * KeepAlive Disconnected Callback to CA adapter.
- */
-static CAKeepAliveDisconnectedCallback g_disconnCallback = NULL;
+static CAKeepAliveConnectionCallback g_connKeepAliveCallback = NULL;
 
 static CAResult_t CATCPInitializeQueueHandles();
 
@@ -175,33 +175,36 @@ void CATCPErrorHandler(const CAEndpoint_t *endpoint, const void *data,
     }
 }
 
-static void CATCPKeepAliveHandler(const char *addr, uint16_t port, bool isConnected)
+static void CATCPConnectionHandler(const char *addr, uint16_t port, bool isConnected)
 {
     CAEndpoint_t endpoint = { .adapter =  CA_ADAPTER_TCP,
                               .port = port };
     OICStrcpy(endpoint.addr, sizeof(endpoint.addr), addr);
 
-    if (isConnected)
+    // Pass the changed connection status to RI Layer for keepalive.
+    if (g_connKeepAliveCallback)
     {
-        g_connCallback(&endpoint);
+        g_connKeepAliveCallback(&endpoint, isConnected);
     }
-    else
+
+    // Pass the changed connection status to CAUtil.
+    if (g_connectionChangeCallback)
     {
-        g_disconnCallback(&endpoint);
+        g_connectionChangeCallback(&endpoint, isConnected);
     }
 }
 
-void CATCPSetKeepAliveCallbacks(CAKeepAliveConnectedCallback ConnHandler,
-                                CAKeepAliveDisconnectedCallback DisconnHandler)
+void CATCPSetKeepAliveCallbacks(CAKeepAliveConnectionCallback ConnHandler)
 {
-    g_connCallback = ConnHandler;
-    g_disconnCallback = DisconnHandler;
-
-    CATCPSetKeepAliveCallback(CATCPKeepAliveHandler);
+    g_connKeepAliveCallback = ConnHandler;
 }
 
 static void CAInitializeTCPGlobals()
 {
+    caglobals.tcp.ipv4.fd = -1;
+    caglobals.tcp.ipv4.port = 0;
+    caglobals.tcp.ipv6.fd = -1;
+    caglobals.tcp.ipv6.port = 0;
     caglobals.tcp.selectTimeout = CA_TCP_SELECT_TIMEOUT;
     caglobals.tcp.listenBacklog = CA_TCP_LISTEN_BACKLOG;
     caglobals.tcp.svrlist = NULL;
@@ -217,26 +220,34 @@ static void CAInitializeTCPGlobals()
     }
 
     caglobals.tcp.ipv4tcpenabled = flags & CA_IPV4;
+    caglobals.tcp.ipv6tcpenabled = flags & CA_IPV6;
 }
 
 CAResult_t CAInitializeTCP(CARegisterConnectivityCallback registerCallback,
                            CANetworkPacketReceivedCallback networkPacketCallback,
-                           CANetworkChangeCallback netCallback,
+                           CAAdapterChangeCallback netCallback,
+                           CAConnectionChangeCallback connCallback,
                            CAErrorHandleCallback errorCallback, ca_thread_pool_t handle)
 {
     OIC_LOG(DEBUG, TAG, "IN");
     VERIFY_NON_NULL(registerCallback, TAG, "registerCallback");
     VERIFY_NON_NULL(networkPacketCallback, TAG, "networkPacketCallback");
     VERIFY_NON_NULL(netCallback, TAG, "netCallback");
+#ifndef SINGLE_THREAD
     VERIFY_NON_NULL(handle, TAG, "thread pool handle");
+#endif
 
     g_networkChangeCallback = netCallback;
+    g_connectionChangeCallback = connCallback;
     g_networkPacketCallback = networkPacketCallback;
     g_errorCallback = errorCallback;
 
     CAInitializeTCPGlobals();
+#ifndef SINGLE_THREAD
     caglobals.tcp.threadpool = handle;
+#endif
 
+    CATCPSetConnectionChangedCallback(CATCPConnectionHandler);
     CATCPSetPacketReceiveCallback(CATCPPacketReceivedCB);
     CATCPSetErrorHandler(CATCPErrorHandler);
 
@@ -261,6 +272,9 @@ CAResult_t CAInitializeTCP(CARegisterConnectivityCallback registerCallback,
 
 CAResult_t CAStartTCP()
 {
+    OIC_LOG(DEBUG, TAG, "IN");
+
+#ifndef SINGLE_THREAD
     if (CA_STATUS_OK != CATCPInitializeQueueHandles())
     {
         OIC_LOG(ERROR, TAG, "Failed to Initialize Queue Handle");
@@ -275,11 +289,21 @@ CAResult_t CAStartTCP()
         return CA_STATUS_FAILED;
     }
 
+#else
+    CAResult_t ret = CATCPStartServer();
+    if (CA_STATUS_OK != ret)
+    {
+        OIC_LOG_V(DEBUG, TAG, "CATCPStartServer failed[%d]", ret);
+        return ret;
+    }
+#endif
+
     return CA_STATUS_OK;
 }
 
 CAResult_t CAStartTCPListeningServer()
 {
+#ifndef SINGLE_THREAD
     if (!caglobals.server)
     {
         caglobals.server = true;    // only needed to run CA tests
@@ -291,6 +315,7 @@ CAResult_t CAStartTCPListeningServer()
         OIC_LOG_V(ERROR, TAG, "Failed to start listening server![%d]", ret);
         return ret;
     }
+#endif
 
     return CA_STATUS_OK;
 }
@@ -347,7 +372,13 @@ static size_t CAQueueTCPData(bool isMulticast, const CAEndpoint_t *endpoint,
 int32_t CASendTCPUnicastData(const CAEndpoint_t *endpoint,
                              const void *data, uint32_t dataLength)
 {
+    OIC_LOG(DEBUG, TAG, "IN");
+#ifndef SINGLE_THREAD
     return CAQueueTCPData(false, endpoint, data, dataLength);
+#else
+    CATCPSendData(endpoint, data, dataLength, false);
+    return dataLength;
+#endif
 }
 
 int32_t CASendTCPMulticastData(const CAEndpoint_t *endpoint,
@@ -358,15 +389,21 @@ int32_t CASendTCPMulticastData(const CAEndpoint_t *endpoint,
 
 CAResult_t CAReadTCPData()
 {
+    OIC_LOG(DEBUG, TAG, "IN");
+#ifdef SINGLE_THREAD
+    CATCPPullData();
+#endif
     return CA_STATUS_OK;
 }
 
 CAResult_t CAStopTCP()
 {
+#ifndef SINGLE_THREAD
     if (g_sendQueueHandle && g_sendQueueHandle->threadMutex)
     {
         CAQueueingThreadStop(g_sendQueueHandle);
     }
+#endif
 
     CATCPStopServer();
 
@@ -380,7 +417,9 @@ void CATerminateTCP()
 {
     CATCPSetPacketReceiveCallback(NULL);
 
+#ifndef SINGLE_THREAD
     CATCPDeinitializeQueueHandles();
+#endif
 }
 
 void CATCPSendDataThread(void *threadData)
@@ -454,3 +493,55 @@ void CADataDestroyer(void *data, uint32_t size)
 
     CAFreeTCPData(TCPData);
 }
+
+#ifdef SINGLE_THREAD
+size_t CAGetTotalLengthFromPacketHeader(const unsigned char *recvBuffer, size_t size)
+{
+    OIC_LOG(DEBUG, TAG, "IN - CAGetTotalLengthFromHeader");
+
+    if (NULL == recvBuffer || !size)
+    {
+        OIC_LOG(ERROR, TAG, "recvBuffer is NULL");
+        return 0;
+    }
+
+    coap_transport_type transport = coap_get_tcp_header_type_from_initbyte(
+            ((unsigned char *)recvBuffer)[0] >> 4);
+    size_t optPaylaodLen = coap_get_length_from_header((unsigned char *)recvBuffer,
+                                                        transport);
+    size_t headerLen = coap_get_tcp_header_length((unsigned char *)recvBuffer);
+
+    OIC_LOG_V(DEBUG, TAG, "option/paylaod length [%d]", optPaylaodLen);
+    OIC_LOG_V(DEBUG, TAG, "header length [%d]", headerLen);
+    OIC_LOG_V(DEBUG, TAG, "total data length [%d]", headerLen + optPaylaodLen);
+
+    OIC_LOG(DEBUG, TAG, "OUT - CAGetTotalLengthFromHeader");
+    return headerLen + optPaylaodLen;
+}
+
+void CAGetTCPHeaderDetails(unsigned char* recvBuffer, coap_transport_type *transport,
+                           size_t *headerlen)
+{
+    if (NULL == recvBuffer)
+    {
+        OIC_LOG(ERROR, TAG, "recvBuffer is NULL");
+        return;
+    }
+
+    if (NULL == transport)
+    {
+        OIC_LOG(ERROR, TAG, "transport is NULL");
+        return;
+    }
+
+    if (NULL == headerlen)
+    {
+        OIC_LOG(ERROR, TAG, "headerlen is NULL");
+        return;
+    }
+
+    *transport = coap_get_tcp_header_type_from_initbyte(
+        ((unsigned char *)recvBuffer)[0] >> 4);
+    *headerlen = coap_get_tcp_header_length_for_transport(*transport);
+}
+#endif
index 5334502..257c6e0 100644 (file)
 
 #include <sys/types.h>
 #include <sys/socket.h>
+#include <sys/select.h>
 #include <sys/ioctl.h>
+#include <sys/poll.h>
 #include <stdio.h>
 #include <unistd.h>
-#include <sys/types.h>
 #include <fcntl.h>
-#include <sys/select.h>
 #include <arpa/inet.h>
 #include <netinet/in.h>
 #include <net/if.h>
 #include <errno.h>
-#include <sys/poll.h>
 
 #ifndef WITH_ARDUINO
 #include <sys/socket.h>
 #define TCP_MAX_HEADER_LEN  6
 
 /**
- * Accept server file descriptor.
- */
-static int g_acceptServerFD = -1;
-
-/**
  * Mutex to synchronize device object list.
  */
 static ca_mutex g_mutexObjectList = NULL;
@@ -89,14 +83,14 @@ static CATCPErrorHandleCallback g_TCPErrorHandler = NULL;
 /**
  * Connected Callback to pass the connection information to RI.
  */
-static CATCPKeepAliveHandleCallback g_keepaliveCallback = NULL;
+static CATCPConnectionHandleCallback g_connectionCallback = NULL;
 
 static CAResult_t CATCPCreateMutex();
 static void CATCPDestroyMutex();
 static CAResult_t CATCPCreateCond();
 static void CATCPDestroyCond();
-static CAResult_t CACreateAcceptSocket();
-static void CAAcceptConnection();
+static int CACreateAcceptSocket(int family, CASocket_t *sock);
+static void CAAcceptConnection(CATransportFlags_t flag, CASocket_t *sock);
 static void CAFindReadyMessage();
 static void CASelectReturned(fd_set *readFds, int ret);
 static void CAReceiveMessage(int fd);
@@ -178,9 +172,13 @@ static void CAFindReadyMessage()
 
     FD_ZERO(&readFds);
 
-    if (-1 != g_acceptServerFD)
+    if (-1 != caglobals.tcp.ipv4.fd)
     {
-        FD_SET(g_acceptServerFD, &readFds);
+        FD_SET(caglobals.tcp.ipv4.fd, &readFds);
+    }
+    if (-1 != caglobals.tcp.ipv6.fd)
+    {
+        FD_SET(caglobals.tcp.ipv6.fd, &readFds);
     }
     if (-1 != caglobals.tcp.shutdownFds[0])
     {
@@ -223,11 +221,31 @@ static void CAFindReadyMessage()
 
 static void CASelectReturned(fd_set *readFds, int ret)
 {
-    (void)ret;
+    VERIFY_NON_NULL_VOID(readFds, TAG, "readFds is NULL");
 
-    if (g_acceptServerFD != -1 && FD_ISSET(g_acceptServerFD, readFds))
+    if (caglobals.tcp.ipv4.fd != -1 && FD_ISSET(caglobals.tcp.ipv4.fd, readFds))
     {
-        CAAcceptConnection();
+        CAAcceptConnection(CA_IPV4, &caglobals.tcp.ipv4);
+        return;
+    }
+    else if (caglobals.tcp.ipv6.fd != -1 && FD_ISSET(caglobals.tcp.ipv6.fd, readFds))
+    {
+        CAAcceptConnection(CA_IPV6, &caglobals.tcp.ipv6);
+        return;
+    }
+    else if (-1 != caglobals.tcp.connectionFds[0] &&
+            FD_ISSET(caglobals.tcp.connectionFds[0], readFds))
+    {
+        // new connection was created from remote device.
+        // exit the function to update read file descriptor.
+        char buf[MAX_ADDR_STR_SIZE_CA] = {0};
+        ssize_t len = read(caglobals.tcp.connectionFds[0], buf, sizeof (buf));
+        if (-1 == len)
+        {
+            return;
+        }
+        OIC_LOG_V(DEBUG, TAG, "Received new connection event with [%s]", buf);
+        FD_CLR(caglobals.tcp.connectionFds[0], readFds);
         return;
     }
     else if (-1 != caglobals.tcp.connectionFds[0] &&
@@ -264,13 +282,14 @@ static void CASelectReturned(fd_set *readFds, int ret)
     }
 }
 
-static void CAAcceptConnection()
+static void CAAcceptConnection(CATransportFlags_t flag, CASocket_t *sock)
 {
+    VERIFY_NON_NULL_VOID(sock, TAG, "sock is NULL");
+
     struct sockaddr_storage clientaddr;
     socklen_t clientlen = sizeof (struct sockaddr_in);
 
-    int sockfd = accept(g_acceptServerFD, (struct sockaddr *)&clientaddr,
-                        &clientlen);
+    int sockfd = accept(sock->fd, (struct sockaddr *)&clientaddr, &clientlen);
     if (-1 != sockfd)
     {
         CATCPSessionInfo_t *svritem =
@@ -283,6 +302,7 @@ static void CAAcceptConnection()
         }
 
         svritem->fd = sockfd;
+        svritem->sep.endpoint.flags = flag;
         CAConvertAddrToName((struct sockaddr_storage *)&clientaddr, clientlen,
                             (char *) &svritem->sep.endpoint.addr, &svritem->sep.endpoint.port);
 
@@ -397,94 +417,171 @@ static void CAWakeUpForReadFdsUpdate(const char *host)
     }
 }
 
+static CAResult_t CATCPConvertNameToAddr(int family, const char *host, uint16_t port,
+                                         struct sockaddr_storage *sockaddr)
+{
+    struct addrinfo *addrs = NULL;
+    struct addrinfo hints = { .ai_family = family,
+                              .ai_protocol   = IPPROTO_TCP,
+                              .ai_socktype = SOCK_STREAM,
+                              .ai_flags = AI_NUMERICHOST };
+
+    int r = getaddrinfo(host, NULL, &hints, &addrs);
+    if (r)
+    {
+        if (EAI_SYSTEM == r)
+        {
+            OIC_LOG_V(ERROR, TAG, "getaddrinfo failed: errno %s", strerror(errno));
+        }
+        else
+        {
+            OIC_LOG_V(ERROR, TAG, "getaddrinfo failed: %s", gai_strerror(r));
+        }
+        freeaddrinfo(addrs);
+        return CA_STATUS_FAILED;
+    }
+    // assumption: in this case, getaddrinfo will only return one addrinfo
+    // or first is the one we want.
+    if (addrs[0].ai_family == AF_INET6)
+    {
+        memcpy(sockaddr, addrs[0].ai_addr, sizeof (struct sockaddr_in6));
+        ((struct sockaddr_in6 *)sockaddr)->sin6_port = htons(port);
+    }
+    else
+    {
+        memcpy(sockaddr, addrs[0].ai_addr, sizeof (struct sockaddr_in));
+        ((struct sockaddr_in *)sockaddr)->sin_port = htons(port);
+    }
+    freeaddrinfo(addrs);
+    return CA_STATUS_OK;
+}
+
 static int CATCPCreateSocket(int family, CATCPSessionInfo_t *svritem)
 {
-    // create tcp socket
+    // #1. create tcp socket.
     int fd = socket(family, SOCK_STREAM, IPPROTO_TCP);
     if (-1 == fd)
     {
         OIC_LOG_V(ERROR, TAG, "create socket failed: %s", strerror(errno));
-        goto exit;
+        return -1;
     }
 
+    // #2. convert address from string to binary.
     struct sockaddr_storage sa = { .ss_family = family };
-    CAConvertNameToAddr(svritem->sep.endpoint.addr, svritem->sep.endpoint.port, &sa);
-    socklen_t socklen = sizeof (struct sockaddr_in);
+    CAResult_t res = CATCPConvertNameToAddr(family, svritem->sep.endpoint.addr,
+                                            svritem->sep.endpoint.port, &sa);
+    if (CA_STATUS_OK != res)
+    {
+        close(fd);
+        return -1;
+    }
 
-    // connect to TCP server
-    int ret = connect(fd, (struct sockaddr *)&sa, socklen);
-    if (0 == ret)
+    // #3. set socket length.
+    socklen_t socklen;
+    if (sa.ss_family == AF_INET6)
     {
-        OIC_LOG(DEBUG, TAG, "connect socket success");
-        CAWakeUpForReadFdsUpdate(svritem->sep.endpoint.addr);
+        struct sockaddr_in6 *sock6 = (struct sockaddr_in6 *)&sa;
+        if (!sock6->sin6_scope_id)
+        {
+            sock6->sin6_scope_id = svritem->sep.endpoint.interface;
+        }
+        socklen = sizeof(struct sockaddr_in6);
     }
     else
     {
-        OIC_LOG(ERROR, TAG, "failed to connect socket");
-        goto exit;
+        socklen = sizeof(struct sockaddr_in);
     }
 
-    return fd;
-
-exit:
-    if (fd >= 0)
+    // #4. connect to remote server device.
+    if (connect(fd, (struct sockaddr *)&sa, socklen) < 0)
     {
+        OIC_LOG_V(ERROR, TAG, "failed to connect socket, %s", strerror(errno));
         close(fd);
+        return -1;
     }
-    return -1;
+
+    OIC_LOG(DEBUG, TAG, "connect socket success");
+    CAWakeUpForReadFdsUpdate(svritem->sep.endpoint.addr);
+    return fd;
 }
 
-static CAResult_t CACreateAcceptSocket()
+static int CACreateAcceptSocket(int family, CASocket_t *sock)
 {
-    if (g_acceptServerFD != -1)
+    VERIFY_NON_NULL_RET(sock, TAG, "sock", -1);
+
+    if (sock->fd != -1)
     {
         OIC_LOG(DEBUG, TAG, "accept socket created already");
-        return CA_STATUS_OK;
+        return sock->fd;
     }
 
-    int reuse = 1;
-    struct sockaddr_in server = { .sin_addr.s_addr = INADDR_ANY,
-                                  .sin_family = AF_INET,
-                                  .sin_port = htons(SERVER_PORT),
-                                  .sin_zero = { 0 } };
+    socklen_t socklen;
+    struct sockaddr_storage server = { .ss_family = family };
 
-    g_acceptServerFD = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
-    if (g_acceptServerFD < 0)
+    int fd = socket(family, SOCK_STREAM, IPPROTO_TCP);
+    if (fd < 0)
     {
         OIC_LOG(ERROR, TAG, "Failed to create socket");
         goto exit;
     }
 
-    if (-1 == setsockopt(g_acceptServerFD, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse)))
+    if (family == AF_INET6)
+    {
+        // the socket is re‐stricted to sending and receiving IPv6 packets only.
+        int on = 1;
+        if (-1 == setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof (on)))
+        {
+            OIC_LOG_V(ERROR, TAG, "IPV6_V6ONLY failed: %s", strerror(errno));
+            goto exit;
+        }
+        ((struct sockaddr_in6 *)&server)->sin6_port = htons(sock->port);
+        socklen = sizeof (struct sockaddr_in6);
+    }
+    else
+    {
+        ((struct sockaddr_in *)&server)->sin_port = htons(sock->port);
+        socklen = sizeof (struct sockaddr_in);
+    }
+
+    int reuse = 1;
+    if (-1 == setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse)))
     {
         OIC_LOG(ERROR, TAG, "setsockopt SO_REUSEADDR");
         goto exit;
     }
 
-    int serverlen = sizeof(server);
-    if (-1 == bind(g_acceptServerFD, (struct sockaddr *)&server, serverlen))
+    if (-1 == bind(fd, (struct sockaddr *)&server, socklen))
     {
-        OIC_LOG(ERROR, TAG, "bind() error");
+        OIC_LOG_V(ERROR, TAG, "bind socket failed: %s", strerror(errno));
         goto exit;
     }
 
-    if (listen(g_acceptServerFD, caglobals.tcp.listenBacklog) != 0)
+    if (listen(fd, caglobals.tcp.listenBacklog) != 0)
     {
         OIC_LOG(ERROR, TAG, "listen() error");
         goto exit;
     }
 
-    CHECKFD(g_acceptServerFD);
+    if (!sock->port)  // return the assigned port
+    {
+        if (-1 == getsockname(fd, (struct sockaddr *)&server, &socklen))
+        {
+            OIC_LOG_V(ERROR, TAG, "getsockname failed: %s", strerror(errno));
+            goto exit;
+        }
+        sock->port = ntohs(family == AF_INET6 ?
+                      ((struct sockaddr_in6 *)&server)->sin6_port :
+                      ((struct sockaddr_in *)&server)->sin_port);
+    }
 
-    return CA_STATUS_OK;
+    return fd;
 
 exit:
-    if (g_acceptServerFD >= 0)
+    if (fd >= 0)
     {
-        close(g_acceptServerFD);
-        g_acceptServerFD = -1;
+        close(fd);
     }
-    return CA_STATUS_FAILED;
+    return -1;
 }
 
 static void CAInitializePipe(int *fds)
@@ -529,6 +626,10 @@ CAResult_t CATCPStartServer(const ca_thread_pool_t threadPool)
     {
         caglobals.tcp.ipv4tcpenabled = true;    // only needed to run CA tests
     }
+    if (!caglobals.tcp.ipv6tcpenabled)
+    {
+        caglobals.tcp.ipv6tcpenabled = true;    // only needed to run CA tests
+    }
 
     CAResult_t res = CATCPCreateMutex();
     if (CA_STATUS_OK == res)
@@ -550,12 +651,15 @@ CAResult_t CATCPStartServer(const ca_thread_pool_t threadPool)
 
     if (caglobals.server)
     {
-        res = CACreateAcceptSocket();
-        if (CA_STATUS_OK != res)
-        {
-            OIC_LOG(ERROR, TAG, "failed to create accept socket");
-            return res;
-        }
+        caglobals.tcp.ipv4.fd = CACreateAcceptSocket(AF_INET, &caglobals.tcp.ipv4);
+        CHECKFD(caglobals.tcp.ipv4.fd);
+        caglobals.tcp.ipv6.fd = CACreateAcceptSocket(AF_INET6, &caglobals.tcp.ipv6);
+        CHECKFD(caglobals.tcp.ipv6.fd);
+
+        OIC_LOG_V(DEBUG, TAG, "IPv4 socket fd=%d, port=%d",
+                  caglobals.tcp.ipv4.fd, caglobals.tcp.ipv4.port);
+        OIC_LOG_V(DEBUG, TAG, "IPv6 socket fd=%d, port=%d",
+                  caglobals.tcp.ipv6.fd, caglobals.tcp.ipv6.port);
     }
 
     // create pipe for fast shutdown
@@ -609,10 +713,16 @@ void CATCPStopServer()
     // mutex unlock
     ca_mutex_unlock(g_mutexObjectList);
 
-    if (-1 != g_acceptServerFD)
+    if (-1 != caglobals.tcp.ipv4.fd)
+    {
+        close(caglobals.tcp.ipv4.fd);
+        caglobals.tcp.ipv4.fd = -1;
+    }
+
+    if (-1 != caglobals.tcp.ipv6.fd)
     {
-        close(g_acceptServerFD);
-        g_acceptServerFD = -1;
+        close(caglobals.tcp.ipv6.fd);
+        caglobals.tcp.ipv6.fd = -1;
     }
 
     CATCPDisconnectAll();
@@ -625,9 +735,9 @@ void CATCPSetPacketReceiveCallback(CATCPPacketReceivedCallback callback)
     g_packetReceivedCallback = callback;
 }
 
-void CATCPSetKeepAliveCallback(CATCPKeepAliveHandleCallback keepaliveHandler)
+void CATCPSetConnectionChangedCallback(CATCPConnectionHandleCallback connHandler)
 {
-    g_keepaliveCallback = keepaliveHandler;
+    g_connectionCallback = connHandler;
 }
 
 static size_t CACheckPayloadLength(const void *data, size_t dlen)
@@ -666,8 +776,8 @@ static size_t CACheckPayloadLength(const void *data, size_t dlen)
     return payloadLen;
 }
 
-static void sendData(const CAEndpoint_t *endpoint,
-                     const void *data, size_t dlen)
+static void sendData(const CAEndpoint_t *endpoint, const void *data,
+                     size_t dlen, const char *fam)
 {
     // #1. get TCP Server object from list
     size_t index = 0;
@@ -723,7 +833,7 @@ static void sendData(const CAEndpoint_t *endpoint,
         remainLen -= len;
     } while (remainLen > 0);
 
-    OIC_LOG_V(INFO, TAG, "unicast ipv4tcp sendTo is successful: %zu bytes", dlen);
+    OIC_LOG_V(INFO, TAG, "unicast %stcp sendTo is successful: %zu bytes", fam, dlen);
 }
 
 void CATCPSendData(CAEndpoint_t *endpoint, const void *data, uint32_t datalen,
@@ -734,9 +844,13 @@ void CATCPSendData(CAEndpoint_t *endpoint, const void *data, uint32_t datalen,
 
     if (!isMulticast)
     {
-        if (caglobals.tcp.ipv4tcpenabled && (endpoint->adapter & CA_ADAPTER_TCP))
+        if (caglobals.tcp.ipv6tcpenabled && (endpoint->flags & CA_IPV6))
+        {
+            sendData(endpoint, data, datalen, "ipv6");
+        }
+        if (caglobals.tcp.ipv4tcpenabled && (endpoint->flags & CA_IPV4))
         {
-            sendData(endpoint, data, datalen);
+            sendData(endpoint, data, datalen, "ipv4");
         }
     }
 }
@@ -762,41 +876,41 @@ CATCPSessionInfo_t *CAConnectTCPSession(const CAEndpoint_t *endpoint)
     }
     memcpy(svritem->sep.endpoint.addr, endpoint->addr, sizeof(svritem->sep.endpoint.addr));
     svritem->sep.endpoint.port = endpoint->port;
+    svritem->sep.endpoint.flags = endpoint->flags;
+    svritem->sep.endpoint.interface = endpoint->interface;
 
     // #2. create the socket and connect to TCP server
-    if (caglobals.tcp.ipv4tcpenabled)
+    int family = (svritem->sep.endpoint.flags & CA_IPV6) ? AF_INET6 : AF_INET;
+    int fd = CATCPCreateSocket(family, svritem);
+    if (-1 == fd)
     {
-        int fd = CATCPCreateSocket(AF_INET, svritem);
-        if (-1 == fd)
+        OICFree(svritem);
+        return NULL;
+    }
+
+    // #3. add TCP connection info to list
+    svritem->fd = fd;
+    ca_mutex_lock(g_mutexObjectList);
+    if (caglobals.tcp.svrlist)
+    {
+        bool res = u_arraylist_add(caglobals.tcp.svrlist, svritem);
+        if (!res)
         {
+            OIC_LOG(ERROR, TAG, "u_arraylist_add failed.");
+            close(svritem->fd);
             OICFree(svritem);
+            ca_mutex_unlock(g_mutexObjectList);
             return NULL;
         }
+    }
+    ca_mutex_unlock(g_mutexObjectList);
 
-        // #3. add TCP connection info to list
-        svritem->fd = fd;
-        ca_mutex_lock(g_mutexObjectList);
-        if (caglobals.tcp.svrlist)
-        {
-            bool res = u_arraylist_add(caglobals.tcp.svrlist, svritem);
-            if (!res)
-            {
-                OIC_LOG(ERROR, TAG, "u_arraylist_add failed.");
-                close(svritem->fd);
-                OICFree(svritem);
-                ca_mutex_unlock(g_mutexObjectList);
-                return NULL;
-            }
-        }
-        ca_mutex_unlock(g_mutexObjectList);
-
-        CHECKFD(fd);
+    CHECKFD(fd);
 
-        // pass the connection information to RI for keepalive.
-        if (g_keepaliveCallback)
-        {
-            g_keepaliveCallback(svritem->sep.endpoint.addr, svritem->sep.endpoint.port, true);
-        }
+    // pass the connection information to CA Common Layer.
+    if (g_connectionCallback)
+    {
+        g_connectionCallback(svritem->sep.endpoint.addr, svritem->sep.endpoint.port, true);
     }
 
     return svritem;
@@ -815,15 +929,16 @@ CAResult_t CADisconnectTCPSession(CATCPSessionInfo_t *svritem, size_t index)
     }
     u_arraylist_remove(caglobals.tcp.svrlist, index);
     OICFree(svritem->recvData);
-    OICFree(svritem);
-    ca_mutex_unlock(g_mutexObjectList);
 
-    // pass the connection information to RI for keepalive.
-    if (g_keepaliveCallback)
+    // pass the connection information to CA Common Layer.
+    if (g_connectionCallback)
     {
-        g_keepaliveCallback(svritem->sep.endpoint.addr, svritem->sep.endpoint.port, false);
+        g_connectionCallback(svritem->sep.endpoint.addr, svritem->sep.endpoint.port, false);
     }
 
+    OICFree(svritem);
+    ca_mutex_unlock(g_mutexObjectList);
+
     return CA_STATUS_OK;
 }
 
@@ -847,8 +962,7 @@ void CATCPDisconnectAll()
     ca_mutex_unlock(g_mutexObjectList);
 }
 
-CATCPSessionInfo_t *CAGetTCPSessionInfoFromEndpoint(const CAEndpoint_t *endpoint,
-                                                    size_t *index)
+CATCPSessionInfo_t *CAGetTCPSessionInfoFromEndpoint(const CAEndpoint_t *endpoint, size_t *index)
 {
     VERIFY_NON_NULL_RET(endpoint, TAG, "endpoint is NULL", NULL);
     VERIFY_NON_NULL_RET(index, TAG, "index is NULL", NULL);
@@ -866,7 +980,8 @@ CATCPSessionInfo_t *CAGetTCPSessionInfoFromEndpoint(const CAEndpoint_t *endpoint
 
         if (!strncmp(svritem->sep.endpoint.addr, endpoint->addr,
                      sizeof(svritem->sep.endpoint.addr))
-                && (svritem->sep.endpoint.port == endpoint->port))
+                && (svritem->sep.endpoint.port == endpoint->port)
+                && (svritem->sep.endpoint.flags & endpoint->flags))
         {
             *index = i;
             return svritem;
index 53b2d6e..688a04f 100644 (file)
@@ -67,18 +67,31 @@ if env.get('LOGGING'):
 ######################################################################
 # Source files and Targets
 ######################################################################
-catests = catest_env.Program('catests', ['catests.cpp',
-                                         'caprotocolmessagetest.cpp',
-                                               'ca_api_unittest.cpp',
-                                               'camutex_tests.cpp',
-                                               'uarraylist_test.cpp'
-                                               ])
+
+target_os = env.get('TARGET_OS')
+target_transport = env.get('TARGET_TRANSPORT')
+
+if (('IP' in target_transport) or ('ALL' in target_transport)):
+       if target_os != 'arduino':
+               catests = catest_env.Program('catests', ['catests.cpp',
+                                                        'caprotocolmessagetest.cpp',
+                                                        'cablocktransfertest.cpp',
+                                                        'ca_api_unittest.cpp',
+                                                        'camutex_tests.cpp',
+                                                        'uarraylist_test.cpp'
+                                                              ])
+else:
+       catests = catest_env.Program('catests', ['catests.cpp',
+                                                'caprotocolmessagetest.cpp',
+                                                'ca_api_unittest.cpp',
+                                                'camutex_tests.cpp',
+                                                'uarraylist_test.cpp'
+                                                      ])
 
 Alias("test", [catests])
 
 env.AppendTarget('test')
 if env.get('TEST') == '1':
-        target_os = env.get('TARGET_OS')
         if target_os == 'linux':
                 from tools.scons.RunTest import *
                 run_test(catest_env,
index a226291..d413bb1 100644 (file)
@@ -68,17 +68,15 @@ void error_handler(const CAEndpoint_t *object, const CAErrorInfo_t* errorInfo)
     return;
 }
 
-void adapter_handler(CATransportAdapter_t adapter,
-                     bool enabled)
+void adapter_handler(CATransportAdapter_t /*adapter*/,
+                     bool /*enabled*/)
 {
-
 }
 
-void connection_handler(CATransportAdapter_t adapter,
-                        const char *remote_address,
-                        bool connected)
+void connection_handler(CATransportAdapter_t /*adapter*/,
+                        const char * /*remote_address*/,
+                        bool /*connected*/)
 {
-
 }
 
 static char* addr = NULL;
@@ -461,13 +459,8 @@ TEST_F(CATests, RegisterDTLSCredentialsHandlerTest)
 // check return value
 TEST_F(CATests, RegisterNetworkMonitorHandler)
 {
-#ifdef LE_ADAPTER
     EXPECT_EQ(CA_STATUS_OK, CARegisterNetworkMonitorHandler(adapter_handler,
                                                             connection_handler));
-#else
-    EXPECT_EQ(CA_NOT_SUPPORTED, CARegisterNetworkMonitorHandler(adapter_handler,
-                                                                connection_handler));
-#endif
 }
 
 // CASetAutoConnectionDeviceInfo TC
diff --git a/resource/csdk/connectivity/test/cablocktransfertest.cpp b/resource/csdk/connectivity/test/cablocktransfertest.cpp
new file mode 100644 (file)
index 0000000..d43c6f5
--- /dev/null
@@ -0,0 +1,541 @@
+/* ****************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************/
+
+#include "gtest/gtest.h"
+#include "cainterface.h"
+#include "cautilinterface.h"
+#include "cacommon.h"
+#include "caprotocolmessage.h"
+#include "cablockwisetransfer.h"
+
+#define LARGE_PAYLOAD_LENGTH    1024
+
+class CABlockTransferTests : public testing::Test {
+    protected:
+    virtual void SetUp() {
+        CAInitialize();
+    }
+
+    virtual void TearDown()
+    {
+        CATerminate();
+    }
+};
+
+TEST_F(CABlockTransferTests, CACreateNewDataSetTest)
+{
+    CAEndpoint_t* tempRep = NULL;
+    CACreateEndpoint(CA_DEFAULT_FLAGS, CA_ADAPTER_IP, "127.0.0.1", 5683, &tempRep);
+
+    coap_pdu_t *pdu = NULL;
+    coap_list_t *options = NULL;
+    coap_transport_type transport = coap_udp;
+
+    CAToken_t tempToken = NULL;
+    CAGenerateToken(&tempToken, CA_MAX_TOKEN_LEN);
+
+    CAInfo_t requestData;
+    memset(&requestData, 0, sizeof(CAInfo_t));
+    requestData.token = tempToken;
+    requestData.tokenLength = CA_MAX_TOKEN_LEN;
+    requestData.type = CA_MSG_NONCONFIRM;
+
+    requestData.payload = (CAPayload_t) calloc(LARGE_PAYLOAD_LENGTH, sizeof(char));
+    if (!requestData.payload)
+    {
+        CADestroyToken(tempToken);
+        FAIL() << "requestData.payload allocation failed";
+    }
+    memset(requestData.payload, '1', sizeof(requestData.payload) - 1);
+    requestData.payloadSize = sizeof(requestData.payload);
+    requestData.type = CA_MSG_NONCONFIRM;
+
+    pdu = CAGeneratePDU(CA_GET, &requestData, tempRep, &options, &transport);
+
+    CAData_t *cadata = CACreateNewDataSet(pdu, tempRep);
+    EXPECT_TRUE(cadata != NULL);
+
+    CABlockData_t *currData = CACreateNewBlockData(cadata);
+    EXPECT_TRUE(currData != NULL);
+
+    if (currData)
+    {
+        CAData_t *getData = CAGetDataSetFromBlockDataList(currData->blockDataId);
+        EXPECT_TRUE(getData != NULL);
+
+        CARemoveBlockDataFromList(currData->blockDataId);
+    }
+
+    CADestroyDataSet(cadata);
+    coap_delete_list(options);
+    coap_delete_pdu(pdu);
+
+    CADestroyToken(tempToken);
+    CADestroyEndpoint(tempRep);
+    free(requestData.payload);
+}
+
+TEST_F(CABlockTransferTests, CAGetBlockDataFromBlockDataListTest)
+{
+    CAEndpoint_t* tempRep = NULL;
+    CACreateEndpoint(CA_DEFAULT_FLAGS, CA_ADAPTER_IP, "127.0.0.1", 5683, &tempRep);
+
+    coap_pdu_t *pdu = NULL;
+    coap_list_t *options = NULL;
+    coap_transport_type transport = coap_udp;
+
+    CAToken_t tempToken = NULL;
+    CAGenerateToken(&tempToken, CA_MAX_TOKEN_LEN);
+
+    CAInfo_t requestData;
+    memset(&requestData, 0, sizeof(CAInfo_t));
+    requestData.token = tempToken;
+    requestData.tokenLength = CA_MAX_TOKEN_LEN;
+    requestData.type = CA_MSG_NONCONFIRM;
+
+    pdu = CAGeneratePDU(CA_GET, &requestData, tempRep, &options, &transport);
+
+    CAData_t *cadata = CACreateNewDataSet(pdu, tempRep);
+    EXPECT_TRUE(cadata != NULL);
+
+    CABlockData_t *currData = CACreateNewBlockData(cadata);
+    EXPECT_TRUE(currData != NULL);
+
+    if (currData)
+    {
+        CABlockData_t *data = CAGetBlockDataFromBlockDataList(currData->blockDataId);
+        EXPECT_TRUE(data != NULL);
+
+        CARemoveBlockDataFromList(currData->blockDataId);
+    }
+
+    CADestroyDataSet(cadata);
+    coap_delete_list(options);
+    coap_delete_pdu(pdu);
+
+    CADestroyToken(tempToken);
+    CADestroyEndpoint(tempRep);
+    free(requestData.payload);
+}
+
+TEST_F(CABlockTransferTests, CAGetPayloadFromBlockDataListTest)
+{
+    CAEndpoint_t* tempRep = NULL;
+    CACreateEndpoint(CA_DEFAULT_FLAGS, CA_ADAPTER_IP, "127.0.0.1", 5683, &tempRep);
+
+    coap_pdu_t *pdu = NULL;
+    coap_list_t *options = NULL;
+    coap_transport_type transport = coap_udp;
+
+    CAToken_t tempToken = NULL;
+    CAGenerateToken(&tempToken, CA_MAX_TOKEN_LEN);
+
+    CAInfo_t requestData;
+    memset(&requestData, 0, sizeof(CAInfo_t));
+    requestData.token = tempToken;
+    requestData.tokenLength = CA_MAX_TOKEN_LEN;
+    requestData.type = CA_MSG_NONCONFIRM;
+
+    pdu = CAGeneratePDU(CA_GET, &requestData, tempRep, &options, &transport);
+
+    CAData_t *cadata = CACreateNewDataSet(pdu, tempRep);
+    EXPECT_TRUE(cadata != NULL);
+
+    CABlockData_t *currData = CACreateNewBlockData(cadata);
+    EXPECT_TRUE(currData != NULL);
+
+    size_t fullPayload = 0;
+    CAPayload_t payload = CAGetPayloadFromBlockDataList(currData->blockDataId,
+                                                        &fullPayload);
+
+    size_t payloadLen = (payload != NULL) ? strlen((const char*) payload) : 0;
+    EXPECT_TRUE(fullPayload == payloadLen);
+
+    CARemoveBlockDataFromList(currData->blockDataId);
+    CADestroyDataSet(cadata);
+    coap_delete_list(options);
+    coap_delete_pdu(pdu);
+
+    CADestroyToken(tempToken);
+    CADestroyEndpoint(tempRep);
+    free(requestData.payload);
+}
+
+// request and block option1
+TEST_F(CABlockTransferTests, CAAddBlockOptionTest)
+{
+    CAEndpoint_t* tempRep = NULL;
+    CACreateEndpoint(CA_DEFAULT_FLAGS, CA_ADAPTER_IP, "127.0.0.1", 5683, &tempRep);
+
+    coap_pdu_t *pdu = NULL;
+    coap_list_t *options = NULL;
+    coap_transport_type transport = coap_udp;
+
+    CAToken_t tempToken = NULL;
+    CAGenerateToken(&tempToken, CA_MAX_TOKEN_LEN);
+
+    CAInfo_t requestData;
+    memset(&requestData, 0, sizeof(CAInfo_t));
+    requestData.token = tempToken;
+    requestData.tokenLength = CA_MAX_TOKEN_LEN;
+
+    requestData.payload = (CAPayload_t) calloc(LARGE_PAYLOAD_LENGTH, sizeof(char));
+    if(!requestData.payload)
+    {
+        CADestroyToken(tempToken);
+        FAIL() << "requestData.payload allocation failed";
+    }
+    memset(requestData.payload, '1', sizeof(requestData.payload) - 1);
+    requestData.payloadSize = sizeof(requestData.payload);
+    requestData.type = CA_MSG_NONCONFIRM;
+
+    pdu = CAGeneratePDU(CA_GET, &requestData, tempRep, &options, &transport);
+
+    EXPECT_EQ(CA_STATUS_OK, CAAddBlockOption(&pdu, &requestData, tempRep, &options));
+
+    coap_delete_list(options);
+    coap_delete_pdu(pdu);
+
+    CADestroyToken(tempToken);
+    CADestroyEndpoint(tempRep);
+    free(requestData.payload);
+}
+
+// request and block option1
+TEST_F(CABlockTransferTests, CAAddBlockOption1InRequest)
+{
+    CAEndpoint_t* tempRep = NULL;
+    CACreateEndpoint(CA_DEFAULT_FLAGS, CA_ADAPTER_IP, "127.0.0.1", 5683, &tempRep);
+
+    coap_pdu_t *pdu = NULL;
+    coap_list_t *options = NULL;
+    coap_transport_type transport = coap_udp;
+
+    CAToken_t tempToken = NULL;
+    CAGenerateToken(&tempToken, CA_MAX_TOKEN_LEN);
+
+    CAInfo_t requestData;
+    memset(&requestData, 0, sizeof(CAInfo_t));
+    requestData.token = tempToken;
+    requestData.tokenLength = CA_MAX_TOKEN_LEN;
+
+    requestData.payload = (CAPayload_t) calloc(LARGE_PAYLOAD_LENGTH, sizeof(char));
+    if(!requestData.payload)
+    {
+        CADestroyToken(tempToken);
+        FAIL() << "requestData.payload allocation failed";
+    }
+    memset(requestData.payload, '1', sizeof(requestData.payload) - 1);
+    requestData.payloadSize = sizeof(requestData.payload);
+    requestData.type = CA_MSG_NONCONFIRM;
+
+    pdu = CAGeneratePDU(CA_GET, &requestData, tempRep, &options, &transport);
+
+    CAData_t *cadata = CACreateNewDataSet(pdu, tempRep);
+    EXPECT_TRUE(cadata != NULL);
+
+    CABlockData_t *currData = CACreateNewBlockData(cadata);
+    EXPECT_TRUE(currData != NULL);
+
+    EXPECT_EQ(CA_STATUS_OK, CAUpdateBlockOptionType(currData->blockDataId,
+                                                    COAP_OPTION_BLOCK1));
+
+    EXPECT_EQ(CA_STATUS_OK, CAAddBlockOption1(&pdu, &requestData,
+                                              requestData.payloadSize,
+                                              currData->blockDataId, &options));
+
+    CADestroyDataSet(cadata);
+    coap_delete_list(options);
+    coap_delete_pdu(pdu);
+
+    CADestroyToken(tempToken);
+    CADestroyEndpoint(tempRep);
+    free(requestData.payload);
+}
+
+// response and block option1
+TEST_F(CABlockTransferTests, CAAddBlockOption1InResponse)
+{
+    CAEndpoint_t* tempRep = NULL;
+    CACreateEndpoint(CA_DEFAULT_FLAGS, CA_ADAPTER_IP, "127.0.0.1", 5683, &tempRep);
+
+    coap_pdu_t *pdu = NULL;
+    coap_list_t *options = NULL;
+    coap_transport_type transport = coap_udp;
+
+    CAToken_t tempToken = NULL;
+    CAGenerateToken(&tempToken, CA_MAX_TOKEN_LEN);
+
+    CAInfo_t responseData;
+    memset(&responseData, 0, sizeof(CAInfo_t));
+    responseData.token = tempToken;
+    responseData.tokenLength = CA_MAX_TOKEN_LEN;
+    responseData.type = CA_MSG_NONCONFIRM;
+    responseData.messageId = 1;
+
+    responseData.payload = (CAPayload_t) calloc(LARGE_PAYLOAD_LENGTH, sizeof(char));
+    if(!responseData.payload)
+    {
+        CADestroyToken(tempToken);
+        FAIL() << "requestData.payload allocation failed";
+    }
+    memset(responseData.payload, '1', sizeof(responseData.payload) - 1);
+    responseData.payloadSize = sizeof(responseData.payload);
+
+    pdu = CAGeneratePDU(CA_CREATED, &responseData, tempRep, &options, &transport);
+
+    CAData_t *cadata = CACreateNewDataSet(pdu, tempRep);
+    EXPECT_TRUE(cadata != NULL);
+
+    CABlockData_t *currData = CACreateNewBlockData(cadata);
+    EXPECT_TRUE(currData != NULL);
+
+    EXPECT_EQ(CA_STATUS_OK, CAUpdateBlockOptionType(currData->blockDataId,
+                                                    COAP_OPTION_BLOCK1));
+
+    EXPECT_EQ(CA_STATUS_OK, CAAddBlockOption1(&pdu, &responseData,
+                                              responseData.payloadSize,
+                                              currData->blockDataId, &options));
+
+    CADestroyDataSet(cadata);
+    coap_delete_list(options);
+    coap_delete_pdu(pdu);
+
+    CADestroyToken(tempToken);
+    CADestroyEndpoint(tempRep);
+    free(responseData.payload);
+}
+
+// response and block option2
+TEST_F(CABlockTransferTests, CAAddBlockOption2InResponse)
+{
+    CAEndpoint_t* tempRep = NULL;
+    CACreateEndpoint(CA_DEFAULT_FLAGS, CA_ADAPTER_IP, "127.0.0.1", 5683, &tempRep);
+
+    coap_pdu_t *pdu = NULL;
+    coap_list_t *options = NULL;
+    coap_transport_type transport = coap_udp;
+
+    CAToken_t tempToken = NULL;
+    CAGenerateToken(&tempToken, CA_MAX_TOKEN_LEN);
+
+    CAInfo_t responseData;
+    memset(&responseData, 0, sizeof(CAInfo_t));
+    responseData.token = tempToken;
+    responseData.tokenLength = CA_MAX_TOKEN_LEN;
+    responseData.type = CA_MSG_NONCONFIRM;
+    responseData.messageId = 1;
+
+    responseData.payload = (CAPayload_t) calloc(LARGE_PAYLOAD_LENGTH, sizeof(char));
+    if(!responseData.payload)
+    {
+        CADestroyToken(tempToken);
+        FAIL() << "requestData.payload allocation failed";
+    }
+    memset(responseData.payload, '1', sizeof(responseData.payload) - 1);
+    responseData.payloadSize = sizeof(responseData.payload);
+
+    pdu = CAGeneratePDU(CA_CREATED, &responseData, tempRep, &options, &transport);
+
+    CAData_t *cadata = CACreateNewDataSet(pdu, tempRep);
+    EXPECT_TRUE(cadata != NULL);
+
+    CABlockData_t *currData = CACreateNewBlockData(cadata);
+    EXPECT_TRUE(currData != NULL);
+
+    EXPECT_EQ(CA_STATUS_OK, CAUpdateBlockOptionType(currData->blockDataId,
+                                                    COAP_OPTION_BLOCK2));
+
+    EXPECT_EQ(CA_STATUS_OK, CAAddBlockOption2(&pdu, &responseData,
+                                              responseData.payloadSize,
+                                              currData->blockDataId, &options));
+
+    CADestroyDataSet(cadata);
+    coap_delete_list(options);
+    coap_delete_pdu(pdu);
+
+    CADestroyToken(tempToken);
+    CADestroyEndpoint(tempRep);
+    free(responseData.payload);
+}
+
+// request and block option1
+TEST_F(CABlockTransferTests, CAAddBlockOption2InRequest)
+{
+    CAEndpoint_t* tempRep = NULL;
+    CACreateEndpoint(CA_DEFAULT_FLAGS, CA_ADAPTER_IP, "127.0.0.1", 5683, &tempRep);
+
+    coap_pdu_t *pdu = NULL;
+    coap_list_t *options = NULL;
+    coap_transport_type transport = coap_udp;
+
+    CAToken_t tempToken = NULL;
+    CAGenerateToken(&tempToken, CA_MAX_TOKEN_LEN);
+
+    CAInfo_t requestData;
+    memset(&requestData, 0, sizeof(CAInfo_t));
+    requestData.token = tempToken;
+    requestData.tokenLength = CA_MAX_TOKEN_LEN;
+
+    requestData.payload = (CAPayload_t) calloc(LARGE_PAYLOAD_LENGTH, sizeof(char));
+    if(!requestData.payload)
+    {
+        CADestroyToken(tempToken);
+        FAIL() << "requestData.payload allocation failed";
+    }
+    memset(requestData.payload, '1', sizeof(requestData.payload) - 1);
+    requestData.payloadSize = sizeof(requestData.payload);
+    requestData.type = CA_MSG_NONCONFIRM;
+
+    pdu = CAGeneratePDU(CA_GET, &requestData, tempRep, &options, &transport);
+
+    CAData_t *cadata = CACreateNewDataSet(pdu, tempRep);
+    EXPECT_TRUE(cadata != NULL);
+
+    CABlockData_t *currData = CACreateNewBlockData(cadata);
+    EXPECT_TRUE(currData != NULL);
+
+    EXPECT_EQ(CA_STATUS_OK, CAUpdateBlockOptionType(currData->blockDataId,
+                                                    COAP_OPTION_BLOCK2));
+
+    EXPECT_EQ(CA_STATUS_OK, CAAddBlockOption2(&pdu, &requestData,
+                                              requestData.payloadSize,
+                                              currData->blockDataId, &options));
+
+    CARemoveBlockDataFromList(currData->blockDataId);
+    CADestroyDataSet(cadata);
+    coap_delete_list(options);
+    coap_delete_pdu(pdu);
+
+    CADestroyToken(tempToken);
+    CADestroyEndpoint(tempRep);
+    free(requestData.payload);
+}
+
+TEST_F(CABlockTransferTests, CAGetBlockSizeOptionFromPduTest)
+{
+    CAEndpoint_t* tempRep = NULL;
+    CACreateEndpoint(CA_DEFAULT_FLAGS, CA_ADAPTER_IP, "127.0.0.1", 5683, &tempRep);
+
+    coap_pdu_t *pdu = NULL;
+    coap_list_t *options = NULL;
+    coap_transport_type transport = coap_udp;
+
+    CAToken_t tempToken = NULL;
+    CAGenerateToken(&tempToken, CA_MAX_TOKEN_LEN);
+
+    CAInfo_t requestData;
+    memset(&requestData, 0, sizeof(CAInfo_t));
+    requestData.token = tempToken;
+    requestData.tokenLength = CA_MAX_TOKEN_LEN;
+    requestData.type = CA_MSG_NONCONFIRM;
+
+    pdu = CAGeneratePDU(CA_GET, &requestData, tempRep, &options, &transport);
+
+    size_t totalPayloadLen = 0;
+    EXPECT_FALSE(CAIsPayloadLengthInPduWithBlockSizeOption(pdu, COAP_OPTION_SIZE1,
+                                                           &totalPayloadLen));
+
+    coap_delete_list(options);
+    coap_delete_pdu(pdu);
+
+    CADestroyToken(tempToken);
+    CADestroyEndpoint(tempRep);
+    free(requestData.payload);
+}
+
+TEST_F(CABlockTransferTests, CASetNextBlockOption1Test)
+{
+    CAEndpoint_t* tempRep = NULL;
+    CACreateEndpoint(CA_DEFAULT_FLAGS, CA_ADAPTER_IP, "127.0.0.1", 5683, &tempRep);
+
+    coap_pdu_t *pdu = NULL;
+    coap_list_t *options = NULL;
+    coap_transport_type transport = coap_udp;
+
+    CAToken_t tempToken = NULL;
+    CAGenerateToken(&tempToken, CA_MAX_TOKEN_LEN);
+
+    CAInfo_t responseData;
+    memset(&responseData, 0, sizeof(CAInfo_t));
+    responseData.token = tempToken;
+    responseData.tokenLength = CA_MAX_TOKEN_LEN;
+    responseData.type = CA_MSG_NONCONFIRM;
+    responseData.messageId = 1;
+
+    pdu = CAGeneratePDU(CA_CREATED, &responseData, tempRep, &options, &transport);
+
+    CAData_t *cadata = CACreateNewDataSet(pdu, tempRep);
+    EXPECT_TRUE(cadata != NULL);
+
+    CABlockData_t *currData = CACreateNewBlockData(cadata);
+    EXPECT_TRUE(currData != NULL);
+
+    coap_block_t block = {0, 0, 0};
+    EXPECT_EQ(CA_STATUS_OK, CASetNextBlockOption1(pdu, tempRep, cadata, block, pdu->length));
+
+    EXPECT_EQ(CA_STATUS_OK, CAHandleRequestResponse());
+
+    CADestroyDataSet(cadata);
+    coap_delete_list(options);
+    coap_delete_pdu(pdu);
+
+    CADestroyToken(tempToken);
+    CADestroyEndpoint(tempRep);
+    free(responseData.payload);
+}
+
+TEST_F(CABlockTransferTests, CASetNextBlockOption2Test)
+{
+    CAEndpoint_t* tempRep = NULL;
+    CACreateEndpoint(CA_DEFAULT_FLAGS, CA_ADAPTER_IP, "127.0.0.1", 5683, &tempRep);
+
+    coap_pdu_t *pdu = NULL;
+    coap_list_t *options = NULL;
+    coap_transport_type transport = coap_udp;
+
+    CAToken_t tempToken = NULL;
+    CAGenerateToken(&tempToken, CA_MAX_TOKEN_LEN);
+
+    CAInfo_t requestData;
+    memset(&requestData, 0, sizeof(CAInfo_t));
+    requestData.token = tempToken;
+    requestData.tokenLength = CA_MAX_TOKEN_LEN;
+    requestData.type = CA_MSG_NONCONFIRM;
+
+    pdu = CAGeneratePDU(CA_GET, &requestData, tempRep, &options, &transport);
+
+    CAData_t *cadata = CACreateNewDataSet(pdu, tempRep);
+    EXPECT_TRUE(cadata != NULL);
+
+    CABlockData_t *currData = CACreateNewBlockData(cadata);
+    EXPECT_TRUE(currData != NULL);
+
+    coap_block_t block = {0, 0, 0};
+    EXPECT_EQ(CA_STATUS_OK, CASetNextBlockOption2(pdu, tempRep, cadata, block, pdu->length));
+
+    CADestroyDataSet(cadata);
+    coap_delete_list(options);
+    coap_delete_pdu(pdu);
+
+    CADestroyToken(tempToken);
+    CADestroyEndpoint(tempRep);
+    free(requestData.payload);
+}
index 24fcf06..1c3f34e 100644 (file)
@@ -87,30 +87,6 @@ TEST(MutexTests, TC_01_CREATE)
     }
 }
 
-TEST(MutexTests, TC_02_TRY_LOCK)
-{
-    ca_mutex mymutex = ca_mutex_new();
-
-    EXPECT_TRUE(mymutex != NULL);
-    if (mymutex != NULL)
-    {
-        EXPECT_TRUE(ca_mutex_trylock(mymutex)); // acquire it
-
-        ca_mutex_unlock(mymutex); // release it
-
-        ca_mutex_lock(mymutex); // acquire it
-
-        EXPECT_FALSE(ca_mutex_trylock(mymutex)); // he should be lock
-
-        EXPECT_FALSE(ca_mutex_trylock(NULL));
-
-        ca_mutex_unlock(mymutex); // release it
-        ca_mutex_free(mymutex);
-
-        EXPECT_FALSE(ca_mutex_trylock(NULL));
-    }
-}
-
 typedef struct _tagFunc1
 {
     ca_mutex mutex;
index 33e15f6..c89cb4c 100644 (file)
@@ -9,39 +9,25 @@ print "Reading util folder script"
 
 ca_os = env.get('TARGET_OS')
 ca_transport = env.get('TARGET_TRANSPORT')
-src_dir = env.get('SRC_DIR')
-root_dir = './../'
-src_dir = './../util/src/'
-
-env.PrependUnique(CPPPATH = [ os.path.join(root_dir, 'api') ])
-env.AppendUnique(CPPPATH = [ os.path.join(root_dir, 'inc'),
-                             os.path.join(root_dir, 'lib/libcoap-4.1.1'),
-                             os.path.join(src_dir, '/resource/csdk/logger/include/'),
-                             os.path.join(root_dir, 'common/inc'),
-                             os.path.join(root_dir, 'util/inc') ])
-
-if ca_os == 'android':
-       env.AppendUnique(CPPPATH = [ os.path.join(root_dir, 'util/src/android') ])
+target_os = env.get('TARGET_OS')
+project_root = env.get('SRC_DIR')
+root_dir = os.path.join(project_root, 'resource', 'csdk', 'connectivity')
+src_dir = os.path.join(root_dir, 'util', 'src')
 
 ######################################################################
 # Source files to build common for platforms
 ######################################################################
 
-env.AppendUnique(CA_SRC = [os.path.join(src_dir,'cautilinterface.c')])
-
-if (('BLE' in ca_transport) or ('ALL' in ca_transport)):
-    if ca_os in ['linux', 'tizen', 'arduino']:
-               env.AppendUnique(CA_SRC = [
-               os.path.join(src_dir,'camanager/' + ca_os + '/caleconnectionmanager.c')])
+env.AppendUnique(CA_SRC = [os.path.join('./../util/src/cautilinterface.c')])
 
-    if ca_os == 'android':
-               env.AppendUnique(CA_SRC = [
-               os.path.join(src_dir,'camanager/android/caleconnectionmanager.c'),
-               os.path.join(src_dir,'camanager/android/caleautoconnector.c'),
-               os.path.join(src_dir,'camanager/android/camanagerleutil.c'),
-               os.path.join(src_dir,'camanager/android/camanagerdevice.c')])
+if target_os == 'android':
+       if (('BLE' in ca_transport) or ('ALL' in ca_transport)):
+                       env.AppendUnique(CA_SRC = [
+                       os.path.join(src_dir, 'camanager', 'android', 'caleconnectionmanager.c'),
+                       os.path.join(src_dir, 'camanager', 'android', 'caleautoconnector.c'),
+                       os.path.join(src_dir, 'camanager', 'android', 'camanagerleutil.c'),
+                       os.path.join(src_dir, 'camanager', 'android', 'camanagerdevice.c')])
 
-if (('BT' in ca_transport) or ('ALL' in ca_transport)):
-    if ca_os == 'android':
-               env.AppendUnique(CA_SRC = [
-               os.path.join(src_dir,'btpairing/android/cabtpairing.c')])
\ No newline at end of file
+       if (('BT' in ca_transport) or ('ALL' in ca_transport)):
+                       env.AppendUnique(CA_SRC = [
+                       os.path.join(src_dir, 'btpairing' ,'android', 'cabtpairing.c')])
\ No newline at end of file
index 9a175bf..fa3cb81 100644 (file)
@@ -48,18 +48,7 @@ CAResult_t CASetLEClientAutoConnectionDeviceInfo();
  */
 CAResult_t CAUnsetLEClientAutoConnectionDeviceInfo();
 
-/**
- * Start advertise to receive request for scanning or connecting.
- */
-void CAStartServerLEAdvertising();
-
-/**
- * Stop advertise to destroy advertiser.
- */
-void CAStopServerLEAdvertising();
-
-#ifdef __ANDROID__
-#ifdef LE_ADAPTER
+#if defined(__ANDROID__) && defined(LE_ADAPTER)
 /**
  * initialize client connection manager
  * @param[in]   env                   JNI interface pointer.
@@ -78,7 +67,6 @@ CAResult_t CAManagerLEClientInitialize(JNIEnv *env, JavaVM *jvm, jobject context
  */
 CAResult_t CAManagerLEClientTerminate(JNIEnv *env);
 #endif
-#endif
 
 #ifdef __cplusplus
 } /* extern "C" */
index 0a0e973..9852abe 100644 (file)
@@ -49,7 +49,7 @@ org_iotivity_ca_CaBtPairingInterface_oicEdrBondStateChangedCallback
 /*
  * Class:     org_iotivity_ca_OicBtUtilClientInterface
  * Method:    oicEdrFoundDeviceCallback
- * Signature: (BluetoothDevice)V
+ * Signature: (Landroid/bluetooth/BluetoothDevice;)V
  */
 JNIEXPORT void JNICALL
 org_iotivity_ca_CaBtPairingInterface_oicEdrFoundDeviceCallback
index 76f439c..6416674 100644 (file)
@@ -120,14 +120,22 @@ CAResult_t CAManagerStartAutoConnection(JNIEnv *env, jstring remote_le_address)
     VERIFY_NON_NULL(remote_le_address, TAG, "remote_le_address is null");
 
     OIC_LOG(DEBUG, TAG, "IN - CAManagerStartAutoConnection");
+    ca_mutex_lock(g_connectRetryMutex);
 
-    if (true == CAManagerGetAutoConnectionFlag(env, remote_le_address))
+    bool isAutoConnecting = false;
+    if (CA_STATUS_OK != CAManagerGetAutoConnectingFlag(env, remote_le_address, &isAutoConnecting))
     {
-        OIC_LOG(INFO, TAG, "auto connecting.");
+        OIC_LOG(DEBUG, TAG, "CAManagerIsAutoConnecting has failed");
+        ca_mutex_unlock(g_connectRetryMutex);
         return CA_STATUS_FAILED;
     }
 
-    ca_mutex_lock(g_connectRetryMutex);
+    if (isAutoConnecting)
+    {
+        OIC_LOG(INFO, TAG, "connection has been already in progress or completed");
+        ca_mutex_unlock(g_connectRetryMutex);
+        return CA_STATUS_FAILED;
+    }
 
     for (size_t retry_cnt = 0 ; retry_cnt < MAX_RETRY_COUNT ; retry_cnt++)
     {
@@ -139,8 +147,8 @@ CAResult_t CAManagerStartAutoConnection(JNIEnv *env, jstring remote_le_address)
                       MAX_RETRY_COUNT - retry_cnt - 1);
             if (ca_cond_wait_for(g_connectRetryCond, g_connectRetryMutex, TIMEOUT) == 0)
             {
-                OIC_LOG(INFO, TAG, "request to connect gatt was canceled");
                 ca_mutex_unlock(g_connectRetryMutex);
+                OIC_LOG(INFO, TAG, "request to connect gatt was canceled");
                 return CA_STATUS_OK;
             }
             // time out. retry connection
@@ -176,7 +184,7 @@ jobject CAManagerConnectGatt(JNIEnv *env, jstring remote_le_address)
     }
 
     // request to connection with AutoConnection Flag
-    OIC_LOG(INFO, TAG, "request to gatt connection for auto connection");
+    OIC_LOG(INFO, TAG, "request gatt connection by CM auto connector");
     jobject newGatt = (jobject)CALEClientConnect(env, jni_bluetooth, JNI_TRUE);
     if (NULL == newGatt)
     {
@@ -185,7 +193,7 @@ jobject CAManagerConnectGatt(JNIEnv *env, jstring remote_le_address)
     }
 
     // set flag auto connection is requested.
-    CAManagerSetAutoConnectionFlag(env, remote_le_address, true);
+    CAManagerSetAutoConnectingFlag(env, remote_le_address, true);
 
     OIC_LOG(DEBUG, TAG, "OUT - CAManagerConnectGatt");
     return newGatt;
index c4e43e3..fb5742b 100644 (file)
 
 #define TAG "OIC_CA_MANAGER_LE"
 
-static CAAdapterStateChangedCB g_adapterStateCB = NULL;
-static CAConnectionStateChangedCB g_connStateCB = NULL;
-
 static const jint SUPPORT_ADNROID_API_LEVEL = 18;
 static const jint AUTH_FAIL = 5;
 static const jint LINK_LOSS = 8;
 static const jint ACCEPT_TIMEOUT_EXCEPTION = 16;
 static const jint REMOTE_DISCONNECT = 19;
 static const jint LOCAL_DISCONNECT = 22;
-static const jint CONNECTION_FAILED_TO_BE_EASTABLISHED = 62;
 static const jint USER_REMOVED_BOND = 68;
 static JavaVM *g_jvm = NULL;
 static jobject g_context = NULL;
 static jobject g_connectedDeviceSet = NULL;
 
-void CASetLENetworkMonitorCallbacks(CAAdapterStateChangedCB adapterStateCB,
-                                    CAConnectionStateChangedCB connStateCB)
-{
-    OIC_LOG(DEBUG, TAG, "CASetLENetworkMonitorCallbacks");
-
-    g_adapterStateCB = adapterStateCB;
-    g_connStateCB = connStateCB;
-}
 
 CAResult_t CASetLEClientAutoConnectionDeviceInfo(const char* address)
 {
@@ -76,27 +64,25 @@ CAResult_t CASetLEClientAutoConnectionDeviceInfo(const char* address)
         }
         isAttached = true;
     }
-
     OIC_LOG_V(DEBUG, TAG, "set [%s] for Auto Connection", address);
+
     jstring jni_leAddress = (*env)->NewStringUTF(env, address);
+    if (!jni_leAddress)
+    {
+        OIC_LOG(ERROR, TAG, "jni_leAddress is null");
+        goto error_exit;
+    }
 
     if (!CAManagerCheckBTAddress(env, jni_leAddress))
     {
         OIC_LOG(ERROR, TAG, "this address is not BT address string format");
-        if (isAttached)
-        {
-            (*g_jvm)->DetachCurrentThread(g_jvm);
-        }
-        return CA_STATUS_FAILED;
+        goto error_exit;
     }
 
-    // if there is target address in SharedPreference. it will be reseted.
-    if (CAManagerIsConnectedDeviceAddress(env, g_context,
-                                          jni_leAddress,
-                                          g_connectedDeviceSet))
+    // if there is target address in SharedPreference, it will be reset.
+    if (CAManagerIsConnectedDeviceAddress(env, g_context, jni_leAddress, g_connectedDeviceSet))
     {
-        if (!CAManagerRemoveConnectedDeviceAddress(env, g_context,
-                                                   jni_leAddress,
+        if (!CAManagerRemoveConnectedDeviceAddress(env, g_context, jni_leAddress,
                                                    g_connectedDeviceSet))
         {
             OIC_LOG(ERROR, TAG, "Preference - remove has failed");
@@ -108,8 +94,7 @@ CAResult_t CASetLEClientAutoConnectionDeviceInfo(const char* address)
     }
 
     // it will be added new target address.
-    if (!CAManagerAddConnectedDeviceAddress(env, g_context,
-                                            jni_leAddress, g_connectedDeviceSet))
+    if (!CAManagerAddConnectedDeviceAddress(env, g_context, jni_leAddress, g_connectedDeviceSet))
     {
         OIC_LOG(ERROR, TAG, "Preference - putting has failed");
     }
@@ -124,6 +109,15 @@ CAResult_t CASetLEClientAutoConnectionDeviceInfo(const char* address)
     }
 
     return CA_STATUS_OK;
+
+error_exit:
+
+    if (isAttached)
+    {
+        (*g_jvm)->DetachCurrentThread(g_jvm);
+    }
+
+    return CA_STATUS_FAILED;
 }
 
 CAResult_t CAUnsetLEClientAutoConnectionDeviceInfo(const char* address)
@@ -146,27 +140,25 @@ CAResult_t CAUnsetLEClientAutoConnectionDeviceInfo(const char* address)
         }
         isAttached = true;
     }
-
     OIC_LOG_V(DEBUG, TAG, "unset [%s] for Auto Connection", address);
+
     jstring jni_leAddress = (*env)->NewStringUTF(env, address);
+    if (!jni_leAddress)
+    {
+        OIC_LOG(ERROR, TAG, "jni_leAddress is null");
+        goto error_exit;
+    }
 
     if (!CAManagerCheckBTAddress(env, jni_leAddress))
     {
         OIC_LOG(ERROR, TAG, "this address is not BT address string format");
-        if (isAttached)
-        {
-            (*g_jvm)->DetachCurrentThread(g_jvm);
-        }
-        return CA_STATUS_FAILED;
+        goto error_exit;
     }
 
-    // if there is target address in SharedPreference. it would be removed
-    if (CAManagerIsConnectedDeviceAddress(env, g_context,
-                                          jni_leAddress,
-                                          g_connectedDeviceSet))
+    // if there is target address in SharedPreference, it will be removed
+    if (CAManagerIsConnectedDeviceAddress(env, g_context, jni_leAddress, g_connectedDeviceSet))
     {
-        if (!CAManagerRemoveConnectedDeviceAddress(env, g_context,
-                                                   jni_leAddress,
+        if (!CAManagerRemoveConnectedDeviceAddress(env, g_context, jni_leAddress,
                                                    g_connectedDeviceSet))
         {
             OIC_LOG(ERROR, TAG, "Preference - remove has failed");
@@ -178,10 +170,10 @@ CAResult_t CAUnsetLEClientAutoConnectionDeviceInfo(const char* address)
     }
 
     // remove target device for auto connection
-    CAResult_t ret = CAManagerRemoveData(env, jni_leAddress);
+    CAResult_t ret = CAManagerRemoveACData(env, jni_leAddress);
     if (CA_STATUS_OK != ret)
     {
-        OIC_LOG(ERROR, TAG, "CAManagerRemoveData has failed");
+        OIC_LOG(ERROR, TAG, "CAManagerRemoveACData has failed");
     }
 
     if (isAttached)
@@ -189,7 +181,16 @@ CAResult_t CAUnsetLEClientAutoConnectionDeviceInfo(const char* address)
         (*g_jvm)->DetachCurrentThread(g_jvm);
     }
 
-    return CA_STATUS_OK;
+    return ret;
+
+error_exit:
+
+    if (isAttached)
+    {
+        (*g_jvm)->DetachCurrentThread(g_jvm);
+    }
+
+    return CA_STATUS_FAILED;
 }
 
 CAResult_t CAManagerLEClientInitialize(JNIEnv *env, JavaVM *jvm, jobject context)
@@ -208,10 +209,10 @@ CAResult_t CAManagerLEClientInitialize(JNIEnv *env, JavaVM *jvm, jobject context
 
     g_jvm = jvm;
     g_context = (*env)->NewGlobalRef(env, context);;
+
     CAManagerInitMutexVaraibles();
     CAManagerInitLEAutoConnection();
-
-    CAManagerCreateACDataList(env);
+    CAManagerCreateACDataList();
 
     // get last connected device list
     jobject set = NULL;
@@ -220,15 +221,12 @@ CAResult_t CAManagerLEClientInitialize(JNIEnv *env, JavaVM *jvm, jobject context
     {
         // create new set<String> object
         set = CAManagerCreateSetString(env);
-        if (set)
-        {
-            OIC_LOG(DEBUG, TAG, "created new SetString");
-        }
-        else
+        if (!set)
         {
             OIC_LOG(ERROR, TAG, "CAManagerCreateSetString has failed");
             return CA_STATUS_FAILED;
         }
+        OIC_LOG(DEBUG, TAG, "created new SetString");
     }
     else
     {
@@ -257,12 +255,13 @@ CAResult_t CAManagerLEClientTerminate(JNIEnv *env)
         OIC_LOG(ERROR, TAG, "CALEClientDisconnectAll has failed");
     }
 
-    res = CAManagerRemoveAllData(env);
+    res = CAManagerRemoveAllACData(env);
     if (CA_STATUS_OK != res)
     {
-        OIC_LOG(ERROR, TAG, "CAManagerRemoveAllData has failed");
+        OIC_LOG(ERROR, TAG, "CAManagerRemoveAllACData has failed");
     }
 
+    CAManagerDestroyACDataList();
     CAManagerTerminateLEAutoConnection();
     CAManagerTerminateMutexVariables();
 
@@ -285,7 +284,7 @@ JNIEXPORT void JNICALL
 Java_org_iotivity_ca_CaLeClientInterface_caManagerAdapterStateChangedCallback(
         JNIEnv *env, jobject obj, jint state)
 {
-    OIC_LOG(DEBUG, TAG, "caManagerAdapterStateChangedCallback");
+    OIC_LOG_V(INFO, TAG, "caManagerAdapterStateChangedCallback - state %d", state);
     VERIFY_NON_NULL_VOID(env, TAG, "env");
     VERIFY_NON_NULL_VOID(obj, TAG, "obj");
 
@@ -296,17 +295,13 @@ Java_org_iotivity_ca_CaLeClientInterface_caManagerAdapterStateChangedCallback(
     if (state_on == state)
     {
         OIC_LOG(DEBUG, TAG, "AdapterStateChangedCallback : state_on");
-        if (g_adapterStateCB)
-        {
-            g_adapterStateCB(CA_ADAPTER_GATT_BTLE, true);
-        }
 
         // when BT state is on. recovery flag has to be reset.
         CAManagerSetBTRecovery(false);
 
         // find target device for autoconnect
         size_t length = CAManagerGetACDataLength();
-        OIC_LOG_V(DEBUG, TAG, "target device : %d", length);
+        OIC_LOG_V(DEBUG, TAG, "length of ACDataList : %d", length);
         for (size_t idx = 0; idx < length; idx++)
         {
             jstring leAddress = CAManagerGetLEAddressFromACData(env, idx);
@@ -324,19 +319,16 @@ Java_org_iotivity_ca_CaLeClientInterface_caManagerAdapterStateChangedCallback(
     else if (state_off == state)
     {
         OIC_LOG(DEBUG, TAG, "AdapterStateChangedCallback : state_off");
-        if (g_adapterStateCB)
-        {
-            g_adapterStateCB(CA_ADAPTER_GATT_BTLE, false);
-        }
 
-        // reset autoconnect flag for all target devices
+        // reset isAutoConnecting flag for all target devices
         size_t length = CAManagerGetACDataLength();
+        OIC_LOG_V(DEBUG, TAG, "length of ACDataList : %d", length);
         for (size_t idx = 0; idx < length; idx++)
         {
             jstring address = CAManagerGetLEAddressFromACData(env, idx);
             if (address)
             {
-                CAManagerSetAutoConnectionFlag(env, address, false);
+                CAManagerSetAutoConnectingFlag(env, address, false);
             }
         }
 
@@ -349,12 +341,10 @@ Java_org_iotivity_ca_CaLeClientInterface_caManagerAdapterStateChangedCallback(
     else if (state_turning_off == state)
     {
         OIC_LOG(DEBUG, TAG, "AdapterStateChangedCallback : state_turning_off");
-        return;
     }
     else
     {
         OIC_LOG(INFO, TAG, "AdapterStateChangedCallback state is not available");
-        return;
     }
 }
 
@@ -362,7 +352,10 @@ JNIEXPORT void JNICALL
 Java_org_iotivity_ca_CaLeClientInterface_caManagerBondStateChangedCallback(
         JNIEnv *env, jobject obj, jobject device)
 {
-    OIC_LOG(DEBUG, TAG, "caManagerBondStateChangedCallback");
+    OIC_LOG(INFO, TAG, "caManagerBondStateChangedCallback");
+    // this callback is called by CaLeClientInterface
+    // only when bond state is changed from BOND_BONDED to BOND_NONE
+    OIC_LOG(DEBUG, TAG, "bond state is changed from BOND_BONDED to BOND_NONE");
     VERIFY_NON_NULL_VOID(env, TAG, "env");
     VERIFY_NON_NULL_VOID(obj, TAG, "obj");
     VERIFY_NON_NULL_VOID(device, TAG, "device");
@@ -385,29 +378,26 @@ Java_org_iotivity_ca_CaLeClientInterface_caManagerBondStateChangedCallback(
     // if there is no data, CAData will be created.
     OIC_LOG_V(DEBUG, TAG, "bond none device : %s", leAddress);
 
-    CAResult_t res = CAManagerRemoveData(env, jni_leAddress);
+    CAResult_t res = CAManagerRemoveACData(env, jni_leAddress);
     if (CA_STATUS_OK != res)
     {
-        OIC_LOG(ERROR, TAG, "CAManagerRemoveData has failed");
+        OIC_LOG(ERROR, TAG, "CAManagerRemoveACData has failed");
     }
 
     (*env)->ReleaseStringUTFChars(env, jni_leAddress, leAddress);
 
-    if (!CAManagerRemoveConnectedDeviceAddress(env, g_context,
-                                               jni_leAddress,
+    if (!CAManagerRemoveConnectedDeviceAddress(env, g_context, jni_leAddress,
                                                g_connectedDeviceSet))
     {
         OIC_LOG(ERROR, TAG, "CAManagerRemoveConnectedDeviceAddress has failed");
     }
-
-    OIC_LOG(INFO, TAG, "bonded state changed bone_none");
 }
 
 JNIEXPORT void JNICALL
 Java_org_iotivity_ca_CaLeClientInterface_caManagerLeGattConnectionStateChangeCB(
         JNIEnv *env, jobject obj, jobject gatt, jint status, jint newState)
 {
-    OIC_LOG_V(DEBUG, TAG, "caManagerLeGattConnectionStateChangeCB-status(%d), newState(%d)",
+    OIC_LOG_V(INFO, TAG, "caManagerLeGattConnectionStateChangeCB - status %d, newState %d",
               status, newState);
 
     VERIFY_NON_NULL_VOID(env, TAG, "env");
@@ -416,12 +406,11 @@ Java_org_iotivity_ca_CaLeClientInterface_caManagerLeGattConnectionStateChangeCB(
 
     jint state_connected = CALEGetConstantsValue(env, CLASSPATH_BT_PROFILE, "STATE_CONNECTED");
     jint state_disconnected = CALEGetConstantsValue(env, CLASSPATH_BT_PROFILE, "STATE_DISCONNECTED");
-    jint gatt_success = CALEGetConstantsValue(env, CLASSPATH_BT_GATT, "GATT_SUCCESS");
 
-    jstring jni_address = CAManagerGetAddressFromGatt(env, gatt);
+    jstring jni_address = CALEGetAddressFromGatt(env, gatt);
     if (!jni_address)
     {
-        OIC_LOG(ERROR, TAG, "CAManagerGetAddressFromGatt is null");
+        OIC_LOG(ERROR, TAG, "CALEGetAddressFromGatt is null");
         return;
     }
 
@@ -429,52 +418,43 @@ Java_org_iotivity_ca_CaLeClientInterface_caManagerLeGattConnectionStateChangeCB(
     if (!address)
     {
         OIC_LOG(ERROR, TAG, "address is null");
+        (*env)->DeleteLocalRef(env, jni_address);
         return;
     }
 
-    OIC_LOG_V(INFO, TAG, "connection state : status(%d), addr:(%s), newState(%d)",
-              status, address, newState);
+    OIC_LOG_V(DEBUG, TAG, "caManagerLeGattConnectionStateChangeCB - address [%s]", address);
 
-    if (gatt_success == status && state_connected == newState) // le connected
+    if (GATT_SUCCESS == status && state_connected == newState) // le connected
     {
         OIC_LOG(DEBUG, TAG, "LE is connected");
+
         CAResult_t res = CAManagerReadRemoteRssi(env, gatt);
         if (CA_STATUS_OK != res)
         {
             OIC_LOG(ERROR, TAG, "CAManagerReadRemoteRssi has failed");
-            (*env)->ReleaseStringUTFChars(env, jni_address, address);
-            return;
+            goto exit;
         }
     }
     else if (state_disconnected == newState)// le disconnected
     {
+        OIC_LOG(DEBUG, TAG, "LE is disconnected");
+
         if (LINK_LOSS == status || REMOTE_DISCONNECT == status)
         {
-            OIC_LOG(DEBUG, TAG, "LE is disconnected");
-
-            if (g_connStateCB)
-            {
-                OIC_LOG_V(DEBUG, TAG, "LE Disconnected state is %d, %s", newState, address);
-                g_connStateCB(CA_ADAPTER_GATT_BTLE, address, false);
-                OIC_LOG(DEBUG, TAG, "LE Disconnected state callback is called");
-            }
-
-            if (!CAManagerIsMatchedACData(env, jni_address))
+            if (!CAManagerIsInACDataList(env, jni_address))
             {
                 OIC_LOG_V(DEBUG, TAG, "this[%s] is not target address for Auto Connection",
                           address);
-                (*env)->ReleaseStringUTFChars(env, jni_address, address);
-                return;
+                goto exit;
             }
 
-            CAManagerSetAutoConnectionFlag(env, jni_address, false);
+            CAManagerSetAutoConnectingFlag(env, jni_address, false);
 
             CAResult_t res = CAManagerStartAutoConnection(env, jni_address);
             if (CA_STATUS_OK != res)
             {
-                (*env)->ReleaseStringUTFChars(env, jni_address, address);
                 OIC_LOG(ERROR, TAG, "CAManagerStartAutoConnection has failed");
-                return;
+                goto exit;
             }
         }
         else if (ACCEPT_TIMEOUT_EXCEPTION == status)
@@ -482,6 +462,8 @@ Java_org_iotivity_ca_CaLeClientInterface_caManagerLeGattConnectionStateChangeCB(
             CAManagerProcessRecovery(env, START_RECOVERY);
         }
     }
+
+exit:
     (*env)->ReleaseStringUTFChars(env, jni_address, address);
     (*env)->DeleteLocalRef(env, jni_address);
 }
@@ -497,7 +479,7 @@ Java_org_iotivity_ca_CaLeClientInterface_caManagerLeServicesDiscoveredCallback(J
                                                                                jobject gatt,
                                                                                jint status)
 {
-    OIC_LOG_V(DEBUG, TAG, "caManagerLeServicesDiscoveredCallback - status %d: ", status);
+    OIC_LOG_V(INFO, TAG, "caManagerLeServicesDiscoveredCallback - status %d", status);
     VERIFY_NON_NULL_VOID(env, TAG, "env");
     VERIFY_NON_NULL_VOID(obj, TAG, "obj");
     VERIFY_NON_NULL_VOID(gatt, TAG, "gatt");
@@ -510,10 +492,10 @@ Java_org_iotivity_ca_CaLeClientInterface_caManagerLeServicesDiscoveredCallback(J
             return;
         }
 
-        jstring jni_address = CAManagerGetAddressFromGatt(env, gatt);
+        jstring jni_address = CALEGetAddressFromGatt(env, gatt);
         if (!jni_address)
         {
-            OIC_LOG(ERROR, TAG, "CAManagerGetAddressFromGatt is null");
+            OIC_LOG(ERROR, TAG, "CALEGetAddressFromGatt is null");
             return;
         }
 
@@ -524,139 +506,27 @@ Java_org_iotivity_ca_CaLeClientInterface_caManagerLeServicesDiscoveredCallback(J
             (*env)->DeleteLocalRef(env, jni_address);
             return;
         }
-        OIC_LOG_V(DEBUG, TAG, "ServicesDiscovered device : %s", address);
 
-        // target address for auto connection will be set in device list.
-        // check set connected address information by user
-        jclass jni_cls_set = (*env)->FindClass(env, "java/util/HashSet");
-        if (!jni_cls_set)
-        {
-            OIC_LOG(ERROR, TAG, "jni_cls_set is null");
-            (*env)->ReleaseStringUTFChars(env, jni_address, address);
-            (*env)->DeleteLocalRef(env, jni_address);
-            return;
-        }
-
-        jmethodID jni_mid_iterator = (*env)->GetMethodID(env, jni_cls_set, "iterator",
-                                                            "()Ljava/util/Iterator;");
-        if (!jni_mid_iterator)
-        {
-            OIC_LOG(ERROR, TAG, "jni_mid_iterator is null");
-            (*env)->DeleteLocalRef(env, jni_cls_set);
-            (*env)->ReleaseStringUTFChars(env, jni_address, address);
-            (*env)->DeleteLocalRef(env, jni_address);
-            return;
-        }
-
-        jobject jni_obj_iter = (*env)->CallObjectMethod(env, g_connectedDeviceSet, jni_mid_iterator);
-        if (!jni_obj_iter)
-        {
-            OIC_LOG(ERROR, TAG, "jni_obj_iter is null");
-            (*env)->DeleteLocalRef(env, jni_cls_set);
-            (*env)->ReleaseStringUTFChars(env, jni_address, address);
-            (*env)->DeleteLocalRef(env, jni_address);
-            return;
-        }
-
-        // Get the Iterator method IDs
-        jclass jni_cls_iterator = (*env)->FindClass(env, "java/util/Iterator");
-        if (!jni_cls_iterator)
-        {
-            OIC_LOG(ERROR, TAG, "jni_cls_iterator is null");
-            (*env)->DeleteLocalRef(env, jni_obj_iter);
-            (*env)->DeleteLocalRef(env, jni_cls_set);
-            (*env)->ReleaseStringUTFChars(env, jni_address, address);
-            (*env)->DeleteLocalRef(env, jni_address);
-            return;
-        }
-
-        jmethodID jni_mid_hasNext = (*env)->GetMethodID(env, jni_cls_iterator, "hasNext", "()Z");
-        if (!jni_mid_hasNext)
-        {
-            OIC_LOG(ERROR, TAG, "jni_mid_hasNext is null");
-            (*env)->DeleteLocalRef(env, jni_cls_iterator);
-            (*env)->DeleteLocalRef(env, jni_obj_iter);
-            (*env)->DeleteLocalRef(env, jni_cls_set);
-            (*env)->ReleaseStringUTFChars(env, jni_address, address);
-            (*env)->DeleteLocalRef(env, jni_address);
-            return;
-        }
-
-        jmethodID jni_mid_next = (*env)->GetMethodID(env, jni_cls_iterator, "next",
-                                                        "()Ljava/lang/Object;");
-        if (!jni_mid_next)
-        {
-            OIC_LOG(ERROR, TAG, "jni_mid_next is null");
-            (*env)->DeleteLocalRef(env, jni_cls_iterator);
-            (*env)->DeleteLocalRef(env, jni_obj_iter);
-            (*env)->DeleteLocalRef(env, jni_cls_set);
-            (*env)->ReleaseStringUTFChars(env, jni_address, address);
-            (*env)->DeleteLocalRef(env, jni_address);
-            return;
-        }
+        OIC_LOG_V(DEBUG, TAG, "ServicesDiscovered device : %s", address);
 
-        // Iterate over the entry Set
-        while ((*env)->CallBooleanMethod(env, jni_obj_iter, jni_mid_hasNext))
+        if (CAManagerIsConnectedDeviceAddress(env, g_context, jni_address, g_connectedDeviceSet))
         {
-            jstring jni_str_entry = (jstring)(*env)->CallObjectMethod(env, jni_obj_iter,
-                                                                        jni_mid_next);
-            if (!jni_str_entry)
-            {
-                OIC_LOG(ERROR, TAG, "jni_str_entry is null");
-                (*env)->DeleteLocalRef(env, jni_cls_iterator);
-                (*env)->DeleteLocalRef(env, jni_obj_iter);
-                (*env)->DeleteLocalRef(env, jni_cls_set);
-                (*env)->ReleaseStringUTFChars(env, jni_address, address);
-                (*env)->DeleteLocalRef(env, jni_address);
-                return;
-            }
-            const char* foundAddress = (*env)->GetStringUTFChars(env, jni_str_entry, NULL);
-            if (!foundAddress)
-            {
-                OIC_LOG(ERROR, TAG, "addr is null");
-                (*env)->DeleteLocalRef(env, jni_str_entry);
-                (*env)->DeleteLocalRef(env, jni_cls_iterator);
-                (*env)->DeleteLocalRef(env, jni_obj_iter);
-                (*env)->DeleteLocalRef(env, jni_cls_set);
-                (*env)->ReleaseStringUTFChars(env, jni_address, address);
-                (*env)->DeleteLocalRef(env, jni_address);
-                return;
-            }
-            OIC_LOG_V(INFO, TAG, "found last connected address [%s] from SharedPreferences",
-                      foundAddress);
-
-            if (!strcmp(foundAddress, address))
-            {
-                // if BLE address is matched each other
-                // this address will be added into auto connection list.
-                OIC_LOG(INFO, TAG, "AC list - address will be added into ACData list");
-                CAManagerAddACData(env, jni_address);
-                CAManagerSetAutoConnectionFlag(env, jni_address, false);
-
-                // next connection will be requested as JNI_TRUE flag
-                // after first connection
-                CALEClientSetAutoConnectFlag(env, jni_str_entry, JNI_TRUE);
-            }
-            else
-            {
-                OIC_LOG(INFO, TAG, "AC list - device is not matched");
-            }
+            OIC_LOG(INFO, TAG, "AC list - the address will be added to ACData list");
+            CAManagerAddACData(env, jni_address);
+            CAManagerSetAutoConnectingFlag(env, jni_address, false);
 
-            (*env)->ReleaseStringUTFChars(env, jni_str_entry, foundAddress);
-            (*env)->DeleteLocalRef(env, jni_str_entry);
+            // next connection will be requested with JNI_TRUE on autoConnect flag
+            // after first connection
+            CALEClientSetFlagToState(env, jni_address, CA_LE_AUTO_CONNECT_FLAG, JNI_TRUE);
         }
-
-        if (g_connStateCB)
+        else
         {
-            g_connStateCB(CA_ADAPTER_GATT_BTLE, address, true);
-            OIC_LOG(DEBUG, TAG, "LE Connected callback is called");
+            OIC_LOG(DEBUG, TAG, "AC list - the address is not set to AutoConnect");
         }
 
-        (*env)->DeleteLocalRef(env, jni_cls_iterator);
-        (*env)->DeleteLocalRef(env, jni_obj_iter);
-        (*env)->DeleteLocalRef(env, jni_cls_set);
         (*env)->ReleaseStringUTFChars(env, jni_address, address);
         (*env)->DeleteLocalRef(env, jni_address);
+
         OIC_LOG(INFO, TAG, "ServicesDiscovery is successful");
     }
     else
index 6950361..7a431e8 100644 (file)
@@ -36,8 +36,7 @@ static bool g_isBTRecovery = false;
 
 jstring CAManagerGetLEAddressFromACData(JNIEnv *env, size_t idx)
 {
-    OIC_LOG(DEBUG, TAG, "CAManagerGetLEAddressFromACData");
-    OIC_LOG_V(DEBUG, TAG, "idx : %d", idx);
+    OIC_LOG_V(DEBUG, TAG, "CAManagerGetLEAddressFromACData (idx : %d)", idx);
     if (idx <= u_arraylist_length(g_deviceACDataList))
     {
         CAManagerACData_t *curData = (CAManagerACData_t *) u_arraylist_get(
@@ -54,30 +53,39 @@ jstring CAManagerGetLEAddressFromACData(JNIEnv *env, size_t idx)
             OIC_LOG(ERROR, TAG, "address is null");
             return NULL;
         }
-        OIC_LOG_V(INFO, TAG, "found out target address : %s", address);
+        OIC_LOG_V(INFO, TAG, "found target address : %s", address);
         (*env)->ReleaseStringUTFChars(env, curData->address, address);
 
         return curData->address;
     }
+    OIC_LOG(DEBUG, TAG, "idx is greater than the length of ACDataList");
     return NULL;
 }
 
-void CAManagerCreateACDataList(JNIEnv *env)
+void CAManagerCreateACDataList()
 {
     OIC_LOG(DEBUG, TAG, "CAManagerCreateACDataList");
-    VERIFY_NON_NULL_VOID(env, TAG, "env");
 
     ca_mutex_lock(g_deviceACDataListMutex);
-    // create new object array
-    if (g_deviceACDataList == NULL)
+    if (NULL == g_deviceACDataList)
     {
         OIC_LOG(DEBUG, TAG, "Create AC Data list");
-
         g_deviceACDataList = u_arraylist_create();
     }
     ca_mutex_unlock(g_deviceACDataListMutex);
 }
 
+void CAManagerDestroyACDataList()
+{
+    OIC_LOG(DEBUG, TAG, "CAManagerDestroyACDataList");
+    if (g_deviceACDataList)
+    {
+        OIC_LOG(DEBUG, TAG, "Destroy AC Data list");
+        u_arraylist_free(&g_deviceACDataList);
+        g_deviceACDataList = NULL;
+    }
+}
+
 CAResult_t CAManagerInitMutexVaraibles()
 {
     if (NULL == g_deviceACDataListMutex)
@@ -103,10 +111,10 @@ void CAManagerTerminateMutexVariables()
 
 static CAManagerACData_t *CAManagerCreateACData(jstring jaddress)
 {
-    OIC_LOG(DEBUG, TAG, "IN-CAManagerCreateACData");
+    OIC_LOG(DEBUG, TAG, "IN - CAManagerCreateACData");
     VERIFY_NON_NULL_RET(jaddress, TAG, "jaddress", NULL);
 
-    // create block data
+    // create AC data
     CAManagerACData_t *data = (CAManagerACData_t *) OICCalloc(1, sizeof(*data));
     if (!data)
     {
@@ -115,21 +123,24 @@ static CAManagerACData_t *CAManagerCreateACData(jstring jaddress)
     }
 
     data->address = jaddress;
-    data->isAutoConnect = false;
+    data->isAutoConnecting = false;
 
-    OIC_LOG(DEBUG, TAG, "OUT-CAManagerCreateACData");
+    OIC_LOG(DEBUG, TAG, "OUT - CAManagerCreateACData");
     return data;
 }
 
-bool CAManagerIsMatchedACData(JNIEnv *env, jstring jaddress)
+bool CAManagerIsInACDataList(JNIEnv *env, jstring jaddress)
 {
     VERIFY_NON_NULL_RET(env, TAG, "env", NULL);
     VERIFY_NON_NULL_RET(jaddress, TAG, "jaddress", false);
 
+    ca_mutex_lock(g_deviceACDataListMutex);
+
     const char* address = (*env)->GetStringUTFChars(env, jaddress, NULL);
     if (!address)
     {
         OIC_LOG(ERROR, TAG, "address is null");
+        ca_mutex_unlock(g_deviceACDataListMutex);
         return false;
     }
 
@@ -142,6 +153,7 @@ bool CAManagerIsMatchedACData(JNIEnv *env, jstring jaddress)
         {
             OIC_LOG(ERROR, TAG, "curData is null");
             (*env)->ReleaseStringUTFChars(env, jaddress, address);
+            ca_mutex_unlock(g_deviceACDataListMutex);
             return false;
         }
 
@@ -150,6 +162,7 @@ bool CAManagerIsMatchedACData(JNIEnv *env, jstring jaddress)
         {
             OIC_LOG(ERROR, TAG, "address is null");
             (*env)->ReleaseStringUTFChars(env, jaddress, address);
+            ca_mutex_unlock(g_deviceACDataListMutex);
             return false;
         }
 
@@ -157,41 +170,49 @@ bool CAManagerIsMatchedACData(JNIEnv *env, jstring jaddress)
         {
             (*env)->ReleaseStringUTFChars(env, curData->address, setAddress);
             (*env)->ReleaseStringUTFChars(env, jaddress, address);
+            ca_mutex_unlock(g_deviceACDataListMutex);
             return true;
         }
         (*env)->ReleaseStringUTFChars(env, curData->address, setAddress);
     }
+
+    OIC_LOG_V(DEBUG, TAG, "[%s] doesn't exist in list", address);
     (*env)->ReleaseStringUTFChars(env, jaddress, address);
+    ca_mutex_unlock(g_deviceACDataListMutex);
 
     return false;
 }
 
 void CAManagerAddACData(JNIEnv *env, jstring jaddress)
 {
-    OIC_LOG(DEBUG, TAG, "IN-CAManagerAddACData");
+    OIC_LOG(DEBUG, TAG, "IN - CAManagerAddACData");
 
     VERIFY_NON_NULL_VOID(env, TAG, "env");
     VERIFY_NON_NULL_VOID(jaddress, TAG, "jaddress");
 
-    ca_mutex_lock(g_deviceACDataListMutex);
-
-    if(!CAManagerIsMatchedACData(env, jaddress))
+    if(!CAManagerIsInACDataList(env, jaddress))
     {
-        OIC_LOG(DEBUG, TAG, "ACdata will be added");
+        OIC_LOG(DEBUG, TAG, "new ACdata will be added in List");
         // add CAManagerACData
         jobject gaddress = (*env)->NewGlobalRef(env, jaddress);
 
         CAManagerACData_t *data = CAManagerCreateACData(gaddress);
+
+        ca_mutex_lock(g_deviceACDataListMutex);
         u_arraylist_add(g_deviceACDataList, data);
+        ca_mutex_unlock(g_deviceACDataListMutex);
+    }
+    else
+    {
+        OIC_LOG(DEBUG, TAG, "the address is already in ACData list");
     }
-    ca_mutex_unlock(g_deviceACDataListMutex);
 
-    OIC_LOG(DEBUG, TAG, "OUT-CAManagerAddACData");
+    OIC_LOG(DEBUG, TAG, "OUT - CAManagerAddACData");
 }
 
-CAResult_t CAManagerRemoveData(JNIEnv *env, jstring jaddress)
+CAResult_t CAManagerRemoveACData(JNIEnv *env, jstring jaddress)
 {
-    OIC_LOG(DEBUG, TAG, "IN-CAManagerRemoveData");
+    OIC_LOG(DEBUG, TAG, "CAManagerRemoveACData");
     VERIFY_NON_NULL(env, TAG, "env");
     VERIFY_NON_NULL(jaddress, TAG, "jaddress");
 
@@ -205,7 +226,7 @@ CAResult_t CAManagerRemoveData(JNIEnv *env, jstring jaddress)
         return CA_STATUS_FAILED;
     }
 
-    OIC_LOG_V(DEBUG, TAG, "(%s) will be removed", address);
+    OIC_LOG_V(DEBUG, TAG, "[%s] will be removed", address);
 
     size_t length = u_arraylist_length(g_deviceACDataList);
     for (size_t idx = 0; idx < length; idx++)
@@ -256,15 +277,16 @@ CAResult_t CAManagerRemoveData(JNIEnv *env, jstring jaddress)
         (*env)->ReleaseStringUTFChars(env, curData->address, setAddress);
     }
 
+    OIC_LOG_V(DEBUG, TAG, "[%s] doesn't exist in list", address);
     (*env)->ReleaseStringUTFChars(env, jaddress, address);
     ca_mutex_unlock(g_deviceACDataListMutex);
-    OIC_LOG(DEBUG, TAG, "OUT-CAManagerRemoveData");
+
     return CA_STATUS_OK;
 }
 
-CAResult_t CAManagerRemoveAllData(JNIEnv *env)
+CAResult_t CAManagerRemoveAllACData(JNIEnv *env)
 {
-    OIC_LOG(DEBUG, TAG, "IN-CAManagerRemoveAllData");
+    OIC_LOG(DEBUG, TAG, "IN - CAManagerRemoveAllACData");
     VERIFY_NON_NULL(env, TAG, "env");
 
     ca_mutex_lock(g_deviceACDataListMutex);
@@ -296,15 +318,15 @@ CAResult_t CAManagerRemoveAllData(JNIEnv *env)
         OICFree(curData);
     }
     ca_mutex_unlock(g_deviceACDataListMutex);
-    OIC_LOG(DEBUG, TAG, "OUT-CAManagerRemoveAllData");
+    OIC_LOG(DEBUG, TAG, "OUT - CAManagerRemoveAllACData");
     return CA_STATUS_OK;
 }
 
-bool CAManagerGetAutoConnectionFlag(JNIEnv *env, jstring jaddress)
+CAResult_t CAManagerGetAutoConnectingFlag(JNIEnv *env, jstring jaddress, bool *flag)
 {
-    OIC_LOG(DEBUG, TAG, "IN-CAManagerGetAutoConnectionFlag");
-    VERIFY_NON_NULL_RET(env, TAG, "env", NULL);
-    VERIFY_NON_NULL_RET(jaddress, TAG, "jaddress", NULL);
+    OIC_LOG(DEBUG, TAG, "CAManagerGetAutoConnectingFlag");
+    VERIFY_NON_NULL(env, TAG, "env");
+    VERIFY_NON_NULL(jaddress, TAG, "jaddress");
 
     ca_mutex_lock(g_deviceACDataListMutex);
 
@@ -340,26 +362,29 @@ bool CAManagerGetAutoConnectionFlag(JNIEnv *env, jstring jaddress)
 
         if (!strcmp(setAddress, address))
         {
+            OIC_LOG_V(DEBUG, TAG, "address : [%s], isAutoConnecting : %d", address,
+                      curData->isAutoConnecting);
+            *flag = curData->isAutoConnecting;
             (*env)->ReleaseStringUTFChars(env, curData->address, setAddress);
             (*env)->ReleaseStringUTFChars(env, jaddress, address);
             ca_mutex_unlock(g_deviceACDataListMutex);
-            OIC_LOG_V(DEBUG, TAG, "flag is %d", curData->isAutoConnect);
-            return curData->isAutoConnect;
+            return CA_STATUS_OK;
         }
         (*env)->ReleaseStringUTFChars(env, curData->address, setAddress);
     }
+
+    OIC_LOG_V(DEBUG, TAG, "[%s] doesn't exist in list", address);
     (*env)->ReleaseStringUTFChars(env, jaddress, address);
     ca_mutex_unlock(g_deviceACDataListMutex);
 
-    OIC_LOG(DEBUG, TAG, "OUT-CAManagerGetAutoConnectionFlag");
-    return false;
+    return CA_STATUS_FAILED;
 }
 
-void CAManagerSetAutoConnectionFlag(JNIEnv *env, jstring jaddress, bool flag)
+bool CAManagerSetAutoConnectingFlag(JNIEnv *env, jstring jaddress, bool flag)
 {
-    OIC_LOG(DEBUG, TAG, "IN-CAManagerSetAutoConnectionFlag");
-    VERIFY_NON_NULL_VOID(env, TAG, "env");
-    VERIFY_NON_NULL_VOID(jaddress, TAG, "jaddress");
+    OIC_LOG(DEBUG, TAG, "CAManagerSetAutoConnectingFlag");
+    VERIFY_NON_NULL_RET(env, TAG, "env", false);
+    VERIFY_NON_NULL_RET(jaddress, TAG, "jaddress", false);
 
     ca_mutex_lock(g_deviceACDataListMutex);
 
@@ -368,7 +393,7 @@ void CAManagerSetAutoConnectionFlag(JNIEnv *env, jstring jaddress, bool flag)
     {
         OIC_LOG(ERROR, TAG, "address is null");
         ca_mutex_unlock(g_deviceACDataListMutex);
-        return;
+        return false;
     }
 
     size_t length = u_arraylist_length(g_deviceACDataList);
@@ -381,7 +406,7 @@ void CAManagerSetAutoConnectionFlag(JNIEnv *env, jstring jaddress, bool flag)
             OIC_LOG(ERROR, TAG, "curData is null");
             (*env)->ReleaseStringUTFChars(env, jaddress, address);
             ca_mutex_unlock(g_deviceACDataListMutex);
-            return;
+            return false;
         }
 
         const char* setAddress = (*env)->GetStringUTFChars(env, curData->address, NULL);
@@ -390,24 +415,27 @@ void CAManagerSetAutoConnectionFlag(JNIEnv *env, jstring jaddress, bool flag)
             OIC_LOG(ERROR, TAG, "address is null");
             (*env)->ReleaseStringUTFChars(env, jaddress, address);
             ca_mutex_unlock(g_deviceACDataListMutex);
-            return;
+            return false;
         }
 
         if (!strcmp(setAddress, address))
         {
-            OIC_LOG_V(DEBUG, TAG, "flag is set to %d", flag);
-            curData->isAutoConnect = flag;
+            OIC_LOG_V(DEBUG, TAG, "isAutoConnecting flag of [%s] is set to %d", address,
+                      curData->isAutoConnecting);
+            curData->isAutoConnecting = flag;
             (*env)->ReleaseStringUTFChars(env, curData->address, setAddress);
             (*env)->ReleaseStringUTFChars(env, jaddress, address);
             ca_mutex_unlock(g_deviceACDataListMutex);
-            return;
+            return true;
         }
         (*env)->ReleaseStringUTFChars(env, curData->address, setAddress);
     }
+
+    OIC_LOG_V(DEBUG, TAG, "[%s] doesn't exist in list", address);
     (*env)->ReleaseStringUTFChars(env, jaddress, address);
     ca_mutex_unlock(g_deviceACDataListMutex);
 
-    OIC_LOG(DEBUG, TAG, "OUT-CAManagerSetAutoConnectionFlag");
+    return false;
 }
 
 size_t CAManagerGetACDataLength()
@@ -418,7 +446,7 @@ size_t CAManagerGetACDataLength()
 void CAManagerSetBTRecovery(bool flag)
 {
     g_isBTRecovery = flag;
-    OIC_LOG_V(DEBUG, TAG, "BT recovery flag : %d", g_isBTRecovery);
+    OIC_LOG_V(DEBUG, TAG, "BT recovery flag is set to %d", g_isBTRecovery);
 }
 
 bool CAManagerIsRecoveryFlagSet()
index f3ec358..f9598e8 100644 (file)
@@ -35,8 +35,8 @@ extern "C"
  */
 typedef struct
 {
-    jstring address;      /**< remote address */
-    bool isAutoConnect;   /**< auto connection flag */
+    jstring address;         /**< remote address */
+    bool isAutoConnecting;   /**< whether GATT connection has been in progress */
 } CAManagerACData_t;
 
 /**
@@ -49,9 +49,13 @@ jstring CAManagerGetLEAddressFromACData(JNIEnv *env, size_t idx);
 
 /**
  * create auto connection list.
- * @param[in]   env                   JNI interface pointer.
  */
-void CAManagerCreateACDataList(JNIEnv *env);
+void CAManagerCreateACDataList();
+
+/**
+ * Destroy auto connection list.
+ */
+void CAManagerDestroyACDataList();
 
 /**
  * initialize mutex.
@@ -65,11 +69,11 @@ CAResult_t CAManagerInitMutexVaraibles();
 void CAManagerTerminateMutexVariables();
 
 /**
- * check whether target address is already contained in list or not.
+ * check whether target address is already contained in ACData list or not.
  * @param[in]   env                   JNI interface pointer.
  * @param[in]   jaddress              ble address.
  */
-bool CAManagerIsMatchedACData(JNIEnv *env, jstring jaddress);
+bool CAManagerIsInACDataList(JNIEnv *env, jstring jaddress);
 
 /**
  * add auto connection data into list.
@@ -79,35 +83,37 @@ bool CAManagerIsMatchedACData(JNIEnv *env, jstring jaddress);
 void CAManagerAddACData(JNIEnv *env, jstring jaddress);
 
 /**
- * remove auto connection data for selected ble address.
+ * remove auto connection data from ACData list for selected ble address.
  * @param[in]   env                   JNI interface pointer.
  * @param[in]   jaddress              ble address.
  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
  */
-CAResult_t CAManagerRemoveData(JNIEnv *env, jstring jaddress);
+CAResult_t CAManagerRemoveACData(JNIEnv *env, jstring jaddress);
 
 /**
- * remove auto connection data for all devices.
+ * remove auto connection data from ACData list for all devices.
  * @param[in]   env                   JNI interface pointer.
  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
  */
-CAResult_t CAManagerRemoveAllData(JNIEnv *env);
+CAResult_t CAManagerRemoveAllACData(JNIEnv *env);
 
 /**
- * get current auto connection flag.
+ * get isAutoConnecting flag for the address.
  * @param[in]   env                   JNI interface pointer.
  * @param[in]   jaddress              ble address.
- * @return  true or false
+ * @param[out]  flag                  isAutoConnecting flag
+ * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
  */
-bool CAManagerGetAutoConnectionFlag(JNIEnv *env, jstring jaddress);
+CAResult_t CAManagerGetAutoConnectingFlag(JNIEnv *env, jstring jaddress, bool *flag);
 
 /**
- * set auto connection flag.
+ * set isAutoConnecting flag for the address.
  * @param[in]   env                   JNI interface pointer.
  * @param[in]   jaddress              ble address.
- * @param[in]   flag                  auto connection flag.
+ * @param[in]   flag                  isAutoConnecting flag.
+ * @return  true or false
  */
-void CAManagerSetAutoConnectionFlag(JNIEnv *env, jstring jaddress, bool flag);
+bool CAManagerSetAutoConnectingFlag(JNIEnv *env, jstring jaddress, bool flag);
 
 /**
  * get length of auto connection list.
index 67ed86e..04121eb 100644 (file)
@@ -123,46 +123,6 @@ jobject CAManagerGetRemoteDevice(JNIEnv *env, jstring address)
     return jni_obj_device;
 }
 
-jstring CAManagerGetAddressFromGatt(JNIEnv *env, jobject gatt)
-{
-    OIC_LOG(DEBUG, TAG, "IN - CAManagerGetAddressFromGatt");
-
-    VERIFY_NON_NULL_RET(env, TAG, "env is null", NULL);
-    VERIFY_NON_NULL_RET(gatt, TAG, "gatt is null", NULL);
-
-    jclass jni_cid_gattdevice_list = (*env)->FindClass(env, CLASSPATH_BT_GATT);
-    if (!jni_cid_gattdevice_list)
-    {
-        OIC_LOG(ERROR, TAG, "jni_cid_gattdevice_list is null");
-        return NULL;
-    }
-
-    jmethodID jni_mid_getDevice = (*env)->GetMethodID(env, jni_cid_gattdevice_list, "getDevice",
-                                                      METHODID_BT_DEVICE);
-    if (!jni_mid_getDevice)
-    {
-        OIC_LOG(ERROR, TAG, "jni_mid_getDevice is null");
-        return NULL;
-    }
-
-    jobject jni_obj_device = (*env)->CallObjectMethod(env, gatt, jni_mid_getDevice);
-    if (!jni_obj_device)
-    {
-        OIC_LOG(ERROR, TAG, "jni_obj_device is null");
-        return NULL;
-    }
-
-    jstring jni_address = CALEGetAddressFromBTDevice(env, jni_obj_device);
-    if (!jni_address)
-    {
-        OIC_LOG(ERROR, TAG, "jni_address is null");
-        return NULL;
-    }
-
-    OIC_LOG(DEBUG, TAG, "OUT - CAManagerGetAddressFromGatt");
-    return jni_address;
-}
-
 bool CAManagerIsDeviceBonded(JNIEnv *env, jobject btDevice)
 {
     OIC_LOG(DEBUG, TAG, "IN - CAManagerIsDeviceBonded");
@@ -676,7 +636,7 @@ jobject CAManagerGetConnectedDeviceAddress(JNIEnv *env, jobject context)
 bool CAManagerRemoveConnectedDeviceAddress(JNIEnv *env, jobject context,
                                            jstring address, jobject set)
 {
-    OIC_LOG(DEBUG, TAG, "IN-CAManagerRemoveConnectedDeviceAddress");
+    OIC_LOG(DEBUG, TAG, "CAManagerRemoveConnectedDeviceAddress");
 
     VERIFY_NON_NULL_RET(env, TAG, "env", false);
     VERIFY_NON_NULL_RET(context, TAG, "context", false);
index 95b648b..9234dc9 100644 (file)
@@ -42,14 +42,6 @@ typedef enum {
 jobject CAManagerGetRemoteDevice(JNIEnv *env, jstring address);
 
 /**
- * get address from gatt profile object.
- * @param[in]   env                   JNI interface pointer.
- * @param[in]   gatt                  gatt profile object.
- * @return  LE address.
- */
-jstring CAManagerGetAddressFromGatt(JNIEnv *env, jobject gatt);
-
-/**
  * check whether the devie is bonded or not.
  * @param[in]   env                   JNI interface pointer.
  * @param[in]   btDevice              bluetooth device object.
diff --git a/resource/csdk/connectivity/util/src/camanager/arduino/caleconnectionmanager.c b/resource/csdk/connectivity/util/src/camanager/arduino/caleconnectionmanager.c
deleted file mode 100644 (file)
index 33f7648..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/* ****************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-#include "camanagerleinterface.h"
-#include "cacommon.h"
-#include "logger.h"
-
-#define TAG "OIC_CA_MANAGER_AR_LE"
-
-static CAAdapterStateChangedCB g_adapterStateCB = NULL;
-static CAConnectionStateChangedCB g_connStateCB = NULL;
-
-void CASetLENetworkMonitorCallbacks(CAAdapterStateChangedCB adapterStateCB,
-                                    CAConnectionStateChangedCB connStateCB)
-{
-    OIC_LOG(DEBUG, TAG, "CASetLENetworkMonitorCallbacks");
-
-    g_adapterStateCB = adapterStateCB;
-    g_connStateCB = connStateCB;
-}
-
-CAResult_t CASetLEClientAutoConnectionDeviceInfo(const char * address)
-{
-    OIC_LOG(DEBUG, TAG, "CASetClientAutoConnectionDeviceInfo");
-    (void)address;
-    return CA_NOT_SUPPORTED;
-}
-
-CAResult_t CAUnsetLEClientAutoConnectionDeviceInfo(const char * address)
-{
-    OIC_LOG(DEBUG, TAG, "CAUnsetClientAutoConnectionDeviceInfo");
-    (void)address;
-    return CA_NOT_SUPPORTED;
-}
-
-void CAStartServerLEAdvertising()
-{
-    OIC_LOG(DEBUG, TAG, "CAStartServerLEAdvertising");
-}
-
-void CAStopServerLEAdvertising()
-{
-    OIC_LOG(DEBUG, TAG, "CAStopServerLEAdvertising");
-}
diff --git a/resource/csdk/connectivity/util/src/camanager/linux/caleconnectionmanager.c b/resource/csdk/connectivity/util/src/camanager/linux/caleconnectionmanager.c
deleted file mode 100644 (file)
index 98f336e..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/* ****************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-#include "camanagerleinterface.h"
-#include "cacommon.h"
-#include "logger.h"
-
-#define TAG "OIC_CA_MANAGER_LI_LE"
-
-static CAAdapterStateChangedCB g_adapterStateCB = NULL;
-static CAConnectionStateChangedCB g_connStateCB = NULL;
-
-void CASetLENetworkMonitorCallbacks(CAAdapterStateChangedCB adapterStateCB,
-                                    CAConnectionStateChangedCB connStateCB)
-{
-    OIC_LOG(DEBUG, TAG, "CASetLENetworkMonitorCallbacks");
-
-    g_adapterStateCB = adapterStateCB;
-    g_connStateCB = connStateCB;
-}
-
-CAResult_t CASetLEClientAutoConnectionDeviceInfo(const char * address)
-{
-    OIC_LOG(DEBUG, TAG, "CASetLEClientAutoConnectionDeviceInfo");
-    (void)address;
-    return CA_NOT_SUPPORTED;
-}
-
-CAResult_t CAUnsetLEClientAutoConnectionDeviceInfo(const char * address)
-{
-    OIC_LOG(DEBUG, TAG, "CAUnsetLEClientAutoConnectionDeviceInfo");
-    (void)address;
-    return CA_NOT_SUPPORTED;
-}
-
-void CAStartServerLEAdvertising()
-{
-    OIC_LOG(DEBUG, TAG, "CAStartServerLEAdvertising");
-}
-
-void CAStopServerLEAdvertising()
-{
-    OIC_LOG(DEBUG, TAG, "CAStopServerLEAdvertising");
-}
index 83513f7..046ace4 100644 (file)
 #include "camanagerleinterface.h"
 #include "cabtpairinginterface.h"
 #include "cautilinterface.h"
-
+#include "cainterfacecontroller.h"
 #include "cacommon.h"
 #include "logger.h"
 
 #define TAG "OIC_CA_COMMON_UTILS"
 
+static CAAdapterStateChangedCB g_adapterStateCB = NULL;
+static CAConnectionStateChangedCB g_connStateCB = NULL;
+
+static void CAManagerAdapterMonitorHandler(CATransportAdapter_t adapter,
+                                           CANetworkStatus_t status)
+{
+    if (CA_INTERFACE_DOWN == status)
+    {
+        if (g_adapterStateCB)
+        {
+            g_adapterStateCB(adapter, false);
+            OIC_LOG(DEBUG, TAG, "Pass the disabled adapter state to upper layer");
+        }
+    }
+    else if (CA_INTERFACE_UP == status)
+    {
+        if (g_adapterStateCB)
+        {
+            g_adapterStateCB(adapter, true);
+            OIC_LOG(DEBUG, TAG, "Pass the enabled adapter state to upper layer");
+        }
+    }
+}
+
+static void CAManagerConnectionMonitorHandler(const CAEndpoint_t *info, bool isConnected)
+{
+    if (!info || !info->addr)
+    {
+        OIC_LOG(ERROR, TAG, "remoteAddress is NULL");
+        return;
+    }
+
+    if (isConnected)
+    {
+        if (g_connStateCB)
+        {
+            g_connStateCB(info->adapter, info->addr, isConnected);
+            OIC_LOG(DEBUG, TAG, "Pass the connected device info to upper layer");
+        }
+    }
+    else
+    {
+        if (g_connStateCB)
+        {
+            g_connStateCB(info->adapter, info->addr, isConnected);
+            OIC_LOG(DEBUG, TAG, "Pass the disconnected device info to upper layer");
+        }
+    }
+}
+
 CAResult_t CARegisterNetworkMonitorHandler(CAAdapterStateChangedCB adapterStateCB,
                                            CAConnectionStateChangedCB connStateCB)
 {
     OIC_LOG(DEBUG, TAG, "CARegisterNetworkMonitorHandler");
 
-#ifdef LE_ADAPTER
-    CASetLENetworkMonitorCallbacks(adapterStateCB, connStateCB);
-    return CA_STATUS_OK;
-#else
-    (void)adapterStateCB;
-    (void)connStateCB;
-    return CA_NOT_SUPPORTED;
-#endif
+    g_adapterStateCB = adapterStateCB;
+    g_connStateCB = connStateCB;
 
+    CASetNetworkMonitorCallbacks(CAManagerAdapterMonitorHandler,
+                                 CAManagerConnectionMonitorHandler);
+    return CA_STATUS_OK;
 }
 
 CAResult_t CASetAutoConnectionDeviceInfo(const char *address)
 {
     OIC_LOG(DEBUG, TAG, "CASetAutoConnectionDeviceInfo");
 
-#ifdef LE_ADAPTER
+#if defined(__ANDROID__) && defined(LE_ADAPTER)
     return CASetLEClientAutoConnectionDeviceInfo(address);
 #else
     (void)address;
@@ -59,7 +106,7 @@ CAResult_t CAUnsetAutoConnectionDeviceInfo(const char *address)
 {
     OIC_LOG(DEBUG, TAG, "CAUnsetAutoConnectionDeviceInfo");
 
-#ifdef LE_ADAPTER
+#if defined(__ANDROID__) && defined(LE_ADAPTER)
     return CAUnsetLEClientAutoConnectionDeviceInfo(address);
 #else
     (void)address;
index fcab193..932221d 100644 (file)
@@ -77,8 +77,18 @@ typedef enum {
 #endif
 
 #ifdef __TIZEN__
-#define OCLog(level,tag,mes)
-#define OCLogv(level,tag,fmt,args...)
+/**
+ * Output the contents of the specified buffer (in hex) with the specified priority level.
+ *
+ * @param[in]    level      DEBUG, INFO, WARNING, ERROR, FATAL
+ * @param[in]    tag        Module name
+ * @param[in]    buffer     pointer to buffer of bytes
+ * @param[in]    bufferSize max number of byte in buffer
+ */
+void OCLogBuffer(LogLevel level, const char * tag, const uint8_t * buffer, uint16_t bufferSize);
+
+#define OCLog(level,tag,mes) LOG_(LOG_ID_MAIN, (level), (tag), mes)
+#define OCLogv(level,tag,fmt,args...) LOG_(LOG_ID_MAIN, (level),tag,fmt,##args)
 #elif defined(ANDROID) || defined(__linux__) || defined(__APPLE__)
     /**
      * Configure logger to use a context that defines a custom logger function
@@ -183,7 +193,8 @@ typedef enum {
 
 #define OIC_LOG(level,tag,mes) LOG_(LOG_ID_MAIN, (level), (tag), mes)
 #define OIC_LOG_V(level,tag,fmt,args...) LOG_(LOG_ID_MAIN, level, tag, fmt, ##args)
-#define OIC_LOG_BUFFER(level, tag, buffer, bufferSize)
+#define OIC_LOG_BUFFER(level, tag, buffer, bufferSize)\
+    OCLogBuffer((level), (tag), (buffer), (bufferSize))
 
 #else // These macros are defined for Linux, Android, and Arduino
 
index 295ac5f..cc30d58 100644 (file)
@@ -100,8 +100,48 @@ static const uint16_t LINE_BUFFER_SIZE = (16 * 2) + 16 + 1;
 #endif
 #endif // __ANDROID__
 
-
 #ifndef ARDUINO
+
+/**
+ * Output the contents of the specified buffer (in hex) with the specified priority level.
+ *
+ * @param level      - DEBUG, INFO, WARNING, ERROR, FATAL
+ * @param tag        - Module name
+ * @param buffer     - pointer to buffer of bytes
+ * @param bufferSize - max number of byte in buffer
+ */
+void OCLogBuffer(LogLevel level, const char * tag, const uint8_t * buffer, uint16_t bufferSize)
+{
+    if (!buffer || !tag || (bufferSize == 0))
+    {
+        return;
+    }
+
+    // No idea why the static initialization won't work here, it seems the compiler is convinced
+    // that this is a variable-sized object.
+    char lineBuffer[LINE_BUFFER_SIZE];
+    memset(lineBuffer, 0, sizeof lineBuffer);
+    int lineIndex = 0;
+    int i;
+    for (i = 0; i < bufferSize; i++)
+    {
+        // Format the buffer data into a line
+        snprintf(&lineBuffer[lineIndex*3], sizeof(lineBuffer)-lineIndex*3, "%02X ", buffer[i]);
+        lineIndex++;
+        // Output 16 values per line
+        if (((i+1)%16) == 0)
+        {
+            OCLogv(level, tag, "%s", lineBuffer);
+            memset(lineBuffer, 0, sizeof lineBuffer);
+            lineIndex = 0;
+        }
+    }
+    // Output last values in the line, if any
+    if (bufferSize % 16)
+    {
+        OCLogv(level, tag, "%s", lineBuffer);
+    }
+}
 #ifndef __TIZEN__
 void OCLogConfig(oc_log_ctx_t *ctx)
 {
@@ -203,47 +243,6 @@ void OCLog(LogLevel level, const char * tag, const char * logStr)
        }
    #endif
    }
-
-/**
- * Output the contents of the specified buffer (in hex) with the specified priority level.
- *
- * @param level      - DEBUG, INFO, WARNING, ERROR, FATAL
- * @param tag        - Module name
- * @param buffer     - pointer to buffer of bytes
- * @param bufferSize - max number of byte in buffer
- */
-void OCLogBuffer(LogLevel level, const char * tag, const uint8_t * buffer, uint16_t bufferSize)
-{
-    if (!buffer || !tag || (bufferSize == 0))
-    {
-        return;
-    }
-
-    // No idea why the static initialization won't work here, it seems the compiler is convinced
-    // that this is a variable-sized object.
-    char lineBuffer[LINE_BUFFER_SIZE];
-    memset(lineBuffer, 0, sizeof lineBuffer);
-    int lineIndex = 0;
-    int i;
-    for (i = 0; i < bufferSize; i++)
-    {
-        // Format the buffer data into a line
-        snprintf(&lineBuffer[lineIndex*3], sizeof(lineBuffer)-lineIndex*3, "%02X ", buffer[i]);
-        lineIndex++;
-        // Output 16 values per line
-        if (((i+1)%16) == 0)
-        {
-            OCLog(level, tag, lineBuffer);
-            memset(lineBuffer, 0, sizeof lineBuffer);
-            lineIndex = 0;
-        }
-    }
-    // Output last values in the line, if any
-    if (bufferSize % 16)
-    {
-        OCLog(level, tag, lineBuffer);
-    }
-}
 #endif //__TIZEN__
 #endif //ARDUINO
 #ifdef ARDUINO
index 9def457..efb6851 100644 (file)
@@ -4,7 +4,7 @@ To build the IoTivity stack with the security features enabled:
 
 1) Build IoTivity with security enabled:
        $ cd <iotivity-base>
-       $ scons resource SECURED=1
+       $ scons SECURED=1
 
 2) Verify functionality using secure sample apps:
        $ cd <iotivity-base>/out/<...>/release/resource/csdk/stack/samples/linux/secure
index e07b442..de5a9cc 100644 (file)
@@ -101,13 +101,6 @@ OCStackResult SendAclReq(PEContext_t *context,
                          uint16_t securedPort);
 
 /*
- * Cleanup CARequestInfo_t object.
- *
- * @param requestInfo is the pointer to @ref CARequestInfo_t.
- */
-void FreeCARequestInfo(CARequestInfo_t *requestInfo);
-
-/*
  * This method is used by Policy engine to checks Amacl resource.
  * If Amacl is found then it fills up context->amsMgrContext->amsDeviceId
  * with amsID of the Amacl else leaves it empty.
index ca99cfb..0e4f0aa 100644 (file)
@@ -30,7 +30,7 @@ Quick guide : How to make provisioning tool and servers.
   1-3. Performing ownership transfer
      We provided OCDoOwnershipTransfer API to perform ownership transfer.
      In order to perform ownership transfer, unowned device list is required generated by OCDiscoverUnownedDevices API.
-     OCDoOwnershipTransfer will require the result callback as 3rd paramter.
+     OCDoOwnershipTransfer will require the result callback as 3rd parameter.
      This callback function will be invoked when ownership transfer is finished.
      You can check result of ownership transfer for each devices as array of OCProvisionResult_t.
 
index 5338d76..eb45a34 100644 (file)
@@ -20,10 +20,10 @@ $ ./Door_server
 # 7. Num. of Rowner : 1
 # 8. [1]Rowner : lightDeviceUUID0
 #
-# After successfull sending acl provisioning_client will ask you for CRL data:
+# After successful sending acl provisioning_client will ask you for CRL data:
 # 1. Enter number of revoced certificates(1..9): 1
 # 2. Revoced certificate 0: Serial number (E. g.: 100): 3
-# And then you should see message about successfull sending CRL
+# And then you should see message about successful sending CRL
 #
 # Note: provisioning_client send ACL and CRL only to Light sever
 
index cc1f689..c6769e8 100644 (file)
@@ -68,6 +68,18 @@ OCStackResult SRPProvisionDirectPairing(void *ctx, const OCProvisionDev_t *selec
                                         OicSecPconf_t *pconf, OCProvisionResultCB resultCallback);
 
 /**
+ * API to send Direct-Pairing Configuration to a device.
+ *
+ * @param[in] selectedDeviceInfo Selected target device.
+ * @param[in] pconf PCONF pointer.
+ * @param[in] resultCallback callback provided by API user, callback will be called when
+ *            provisioning request recieves a response from resource server.
+ * @return OC_STACK_OK in case of success and other value otherwise.
+ */
+OCStackResult SRPProvisionDirectPairing(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
+                                        OicSecPconf_t *pconf, OCProvisionResultCB resultCallback);
+
+/**
  * API to provision credential to devices.
  *
  * @param[in] type Type of credentials to be provisioned to the device.
index 9486f90..4ead7a3 100644 (file)
@@ -327,6 +327,11 @@ OCStackResult UpdateAmsMgrContext(PEContext_t *context, const CAEndpoint_t *endp
 {
     OCStackResult ret = OC_STACK_ERROR;
 
+    if (!context->amsMgrContext)
+    {
+        goto exit;
+    }
+
     //The AmsMgr context endpoint and requestInfo will be free from ,
     //AmsMgrAclReqCallback function
     if (context->amsMgrContext->endpoint)
@@ -354,7 +359,7 @@ void FreeCARequestInfo(CARequestInfo_t *requestInfo)
 {
     if (NULL == requestInfo)
     {
-        OIC_LOG_V(ERROR, TAG, "%s: Can't free memory. Received NULL requestInfo", __func__);
+        OIC_LOG_V(DEBUG, TAG, "%s: Can't free memory. Received NULL requestInfo", __func__);
         return;
     }
     OICFree(requestInfo->info.token);
old mode 100644 (file)
new mode 100755 (executable)
index 04f0fc3..4a4694d 100644 (file)
@@ -102,9 +102,15 @@ void SetPolicyEngineState(PEContext_t *context, const PEState_t state)
     context->amsProcessing = false;
     context->retVal = ACCESS_DENIED_POLICY_ENGINE_ERROR;
 
-    FreeCARequestInfo(context->amsMgrContext->requestInfo);
-    OICFree(context->amsMgrContext->endpoint);
-    memset(context->amsMgrContext, 0, sizeof(AmsMgrContext_t));
+    if (context->amsMgrContext)
+    {
+        if (context->amsMgrContext->requestInfo)
+        {
+            FreeCARequestInfo(context->amsMgrContext->requestInfo);
+        }
+        OICFree(context->amsMgrContext->endpoint);
+        memset(context->amsMgrContext, 0, sizeof(AmsMgrContext_t));
+    }
 
     // Set state.
     context->state = state;
index c6a4d02..95f3cd0 100644 (file)
@@ -85,13 +85,7 @@ OCStackResult HandleKeepAliveRequest(const CAEndpoint_t* endPoint,
  * API to handle the connected device for KeepAlive.
  * @return  Current Time.
  */
-void HandleKeepAliveConnCB(const CAEndpoint_t *endpoint);
-
-/**
- * API to handle the disconnected device for KeepAlive.
- * @return  Current Time.
- */
-void HandleKeepAliveDisconnCB(const CAEndpoint_t *endpoint);
+void HandleKeepAliveConnCB(const CAEndpoint_t *endpoint, bool isConnected);
 
 #ifdef __cplusplus
 } // extern "C"
index c8a7cfc..4b62813 100644 (file)
@@ -223,7 +223,7 @@ OCSecurityPayload* OCSecurityPayloadCreate(const uint8_t* securityData, size_t s
 void OCSecurityPayloadDestroy(OCSecurityPayload* payload);
 
 void OCDiscoveryPayloadAddResource(OCDiscoveryPayload* payload, const OCResource* res,
-        uint16_t port);
+                                   uint16_t securePort, uint16_t tcpPort);
 void OCDiscoveryPayloadAddNewResource(OCDiscoveryPayload* payload, OCResourcePayload* res);
 bool OCResourcePayloadAddStringLL(OCStringLL **payload, const char* type);
 
index 1bab0fc..8680c7f 100644 (file)
@@ -33,7 +33,7 @@
  * Maximum length of the URI supported by client/server while processing
  * REST requests/responses.
  */
-#define MAX_URI_LENGTH (64)
+#define MAX_URI_LENGTH (256)
 
 /**
  * Maximum length of the query supported by client/server while processing
index c7bd0f9..3335d95 100644 (file)
@@ -197,6 +197,9 @@ extern "C" {
 /** Port. */
 #define OC_RSRVD_HOSTING_PORT           "port"
 
+/** TCP Port. */
+#define OC_RSRVD_TCP_PORT               "tcp"
+
 /** For Server instance ID.*/
 #define OC_RSRVD_SERVER_INSTANCE_ID     "sid"
 
@@ -333,6 +336,18 @@ extern "C" {
 #define OC_RSRVD_RESOURCE_TYPE_RDPUBLISH "oic.wk.rdpub"
 
 /**
+ * Mark a parameter as unused. Used to prevent unused variable compiler warnings.
+ * Used in three cases:
+ * 1. in callbacks when one of the parameters are unused
+ * 2. when due to code changes a functions parameter is no longer
+ *    used but must be left in place for backward compatibility
+ *    reasons.
+ * 3. a variable is only used in the debug build variant and would
+ *    give a build warning in release mode.
+ */
+#define OC_UNUSED(x) (void)(x)
+
+/**
  * These enums (OCTransportAdapter and OCTransportFlags) must
  * be kept synchronized with OCConnectivityType (below) as well as
  * CATransportAdapter and CATransportFlags (in CACommon.h).
@@ -374,10 +389,10 @@ typedef enum
     OC_FLAG_SECURE     = (1 << 4),
 
     /** IPv4 & IPv6 auto-selection is the default.*/
-    /** IP adapter only.*/
+    /** IP & TCP adapter only.*/
     OC_IP_USE_V6       = (1 << 5),
 
-    /** IP adapter only.*/
+    /** IP & TCP adapter only.*/
     OC_IP_USE_V4       = (1 << 6),
 
     /** internal use only.*/
@@ -575,11 +590,11 @@ typedef enum
     /** De-register observation, intended for internal use.*/
     OC_REST_CANCEL_OBSERVE = (1 << 6),
 
-    #ifdef WITH_PRESENCE
+#ifdef WITH_PRESENCE
     /** Subscribe for all presence notifications of a particular resource.*/
     OC_REST_PRESENCE       = (1 << 7),
 
-    #endif
+#endif
     /** Allows OCDoResource caller to do discovery.*/
     OC_REST_DISCOVER       = (1 << 8)
 } OCMethod;
@@ -741,11 +756,11 @@ typedef enum
     OC_STACK_AUTHENTICATION_FAILURE,
 
     /** Insert all new error codes here!.*/
-    #ifdef WITH_PRESENCE
+#ifdef WITH_PRESENCE
     OC_STACK_PRESENCE_STOPPED = 128,
     OC_STACK_PRESENCE_TIMEOUT,
     OC_STACK_PRESENCE_DO_NOT_HANDLE,
-    #endif
+#endif
     /** ERROR in stack.*/
     OC_STACK_ERROR = 255
     /** Error status code - END HERE.*/
@@ -1073,6 +1088,9 @@ typedef struct OCResourcePayload
     uint8_t bitmap;
     bool secure;
     uint16_t port;
+#ifdef TCP_ADAPTER
+    uint16_t tcpPort;
+#endif
     struct OCResourcePayload* next;
 } OCResourcePayload;
 
index 0979901..fd7d8ee 100644 (file)
@@ -49,8 +49,8 @@ static char DISCOVERY_QUERY[] = "%s/oic/res";
 //Secure Virtual Resource database for Iotivity Client application\r
 //It contains Client's Identity and the PSK credentials\r
 //of other devices which the client trusts\r
-static char CRED_FILE[] = "oic_svr_db_client_directpairing.dat";\r
-\r
+static char CRED_FILE[] = "oic_svr_db_client_directpairing.dat";
+
 static const OCDPDev_t *discoveredDevs = NULL;\r
 static const OCDPDev_t *pairedDevs = NULL;\r
 \r
@@ -514,8 +514,8 @@ void *CLInterface(void *data)
                     OIC_LOG(ERROR, TAG, "Invalid PIN");\r
                     continue;\r
                 }\r
-                sscanf(input, "%8s", pinNumber);\r
-                printf("\n");\r
+                sscanf(input, "%8s", pinNumber);
+                printf("\n");
 \r
                 ret = DoDirectPairing(peer, pmSel, pinNumber);\r
                 if (OC_STACK_OK != ret)\r
@@ -636,6 +636,3 @@ int main(void)
 \r
     return 0;\r
 }\r
-\r
-\r
-\r
index 551cdd4..896621f 100755 (executable)
@@ -287,7 +287,6 @@ HandleBatchInterface(OCEntityHandlerRequest *ehRequest)
     }
 
     OCResource * collResource = (OCResource *) ehRequest->resource;
-    OCChildResource *tempChildResource = NULL;
 
     OCRepPayload* payload = OCRepPayloadCreate();
     if (!payload)
@@ -310,8 +309,8 @@ HandleBatchInterface(OCEntityHandlerRequest *ehRequest)
 
     if (stackRet == OC_STACK_OK)
     {
-        tempChildResource = collResource->rsrcChildResourcesHead;
-
+        OCChildResource *tempChildResource = (collResource) ? collResource->rsrcChildResourcesHead
+                                                              : NULL;
         while(tempChildResource)
         {
             OCResource* tempRsrcResource = tempChildResource->rsrcResource;
@@ -323,8 +322,8 @@ HandleBatchInterface(OCEntityHandlerRequest *ehRequest)
                 // is ehRequest->resource
                 ehRequest->resource = (OCResourceHandle) tempRsrcResource;
 
-                OCEntityHandlerResult ehResult = tempRsrcResource->entityHandler(OC_REQUEST_FLAG, ehRequest,
-                                                        tempRsrcResource->entityHandlerCallbackParam);
+                OCEntityHandlerResult ehResult = tempRsrcResource->entityHandler(OC_REQUEST_FLAG,
+                                           ehRequest, tempRsrcResource->entityHandlerCallbackParam);
 
                 // The default collection handler is returning as OK
                 if (stackRet != OC_STACK_SLOW_RESOURCE)
index 3c302a3..2ad55b2 100644 (file)
@@ -1386,7 +1386,8 @@ OCResourcePayload* OCDiscoveryPayloadGetResource(OCDiscoveryPayload* payload, si
     return NULL;
 }
 
-static OCResourcePayload* OCCopyResource(const OCResource* res, uint16_t port)
+static OCResourcePayload* OCCopyResource(const OCResource* res, uint16_t securePort,
+                                         uint16_t tcpPort)
 {
     OCResourcePayload* pl = (OCResourcePayload*)OICCalloc(1, sizeof(OCResourcePayload));
     if (!pl)
@@ -1481,15 +1482,17 @@ static OCResourcePayload* OCCopyResource(const OCResource* res, uint16_t port)
 
     pl->bitmap = res->resourceProperties & (OC_OBSERVABLE | OC_DISCOVERABLE);
     pl->secure = (res->resourceProperties & OC_SECURE) != 0;
-    pl->port = port;
-
+    pl->port = securePort;
+#ifdef TCP_ADAPTER
+    pl->tcpPort = tcpPort;
+#endif
     return pl;
 }
 
 void OCDiscoveryPayloadAddResource(OCDiscoveryPayload* payload, const OCResource* res,
-        uint16_t port)
+                                   uint16_t securePort, uint16_t tcpPort)
 {
-    OCDiscoveryPayloadAddNewResource(payload, OCCopyResource(res, port));
+    OCDiscoveryPayloadAddNewResource(payload, OCCopyResource(res, securePort, tcpPort));
 }
 
 bool OCResourcePayloadAddStringLL(OCStringLL **stringLL, const char *value)
@@ -1672,6 +1675,13 @@ OCPlatformPayload* OCPlatformPayloadCreateAsOwner(OCPlatformInfo* platformInfo)
 
     payload->base.type = PAYLOAD_TYPE_PLATFORM;
 
+    payload->interfaces = (OCStringLL*)OICCalloc(1, sizeof(OCStringLL));
+    if (!payload->interfaces)
+    {
+        return NULL;
+    }
+    payload->interfaces->value = OICStrdup(OC_RSRVD_INTERFACE_READ);
+    payload->rt = OICStrdup(OC_RSRVD_RESOURCE_TYPE_PLATFORM);
     payload->info = *platformInfo;
 
     return payload;
@@ -1687,11 +1697,11 @@ OCPlatformPayload* OCPlatformPayloadCreate(const OCPlatformInfo* platformInfo)
     }
 
     payload->base.type = PAYLOAD_TYPE_PLATFORM;
+    payload->rt = OICStrdup(OC_RSRVD_RESOURCE_TYPE_PLATFORM);
 
     OCResourcePayloadAddStringLL(&payload->interfaces, OC_RSRVD_INTERFACE_DEFAULT);
     OCResourcePayloadAddStringLL(&payload->interfaces, OC_RSRVD_INTERFACE_READ);
 
-    payload->rt = OICStrdup(OC_RSRVD_RESOURCE_TYPE_PLATFORM);
     OCCopyPlatformInfo(platformInfo, payload);
 
     return payload;
index 9f1bde6..7eee7b9 100644 (file)
@@ -358,6 +358,14 @@ static int64_t OCConvertDiscoveryPayload(OCDiscoveryPayload *payload, uint8_t *o
                 VERIFY_CBOR_SUCCESS(TAG, err, "Failed adding secure port value");
             }
 
+#ifdef TCP_ADAPTER
+            err |= cbor_encode_text_string(&policyMap, OC_RSRVD_TCP_PORT,
+                                           sizeof(OC_RSRVD_TCP_PORT) - 1);
+            VERIFY_CBOR_SUCCESS(TAG, err, "Failed adding tcp port tag");
+            err |= cbor_encode_uint(&policyMap, resource->tcpPort);
+            VERIFY_CBOR_SUCCESS(TAG, err, "Failed adding tcp port value");
+#endif
+
             err |= cbor_encoder_close_container(&linkMap, &policyMap);
             VERIFY_CBOR_SUCCESS(TAG, err, "Failed closing policy map");
 
old mode 100644 (file)
new mode 100755 (executable)
index 4763299..6373767
@@ -340,6 +340,16 @@ static OCStackResult OCParseDiscoveryPayload(OCPayload **outPayload, CborValue *
                 VERIFY_CBOR_SUCCESS(TAG, err, "to find port value");
             }
 
+#ifdef TCP_ADAPTER
+            // TCP Port
+            err = cbor_value_map_find_value(&policyMap, OC_RSRVD_TCP_PORT, &curVal);
+            if (cbor_value_is_valid(&curVal))
+            {
+                err = cbor_value_get_int(&curVal, (int *)&resource->tcpPort);
+                VERIFY_CBOR_SUCCESS(TAG, err, "to find tcp port value");
+            }
+#endif
+
             err = cbor_value_advance(&resourceMap);
             VERIFY_CBOR_SUCCESS(TAG, err, "to advance resource map");
 
@@ -356,6 +366,8 @@ static OCStackResult OCParseDiscoveryPayload(OCPayload **outPayload, CborValue *
     }
 
     *outPayload = (OCPayload *)out;
+    OIC_LOG_PAYLOAD(DEBUG, *outPayload);
+
     return OC_STACK_OK;
 
 exit:
@@ -385,6 +397,7 @@ static OCStackResult OCParseDevicePayload(OCPayload **outPayload, CborValue *roo
         // Resource Type
         err = cbor_value_map_find_value(rootValue, OC_RSRVD_RESOURCE_TYPE, &curVal);
         VERIFY_CBOR_SUCCESS(TAG, err, "to find resource type tag");
+
         if (cbor_value_is_valid(&curVal))
         {
             err =  OCParseStringLL(rootValue, OC_RSRVD_RESOURCE_TYPE, &out->types);
@@ -560,6 +573,7 @@ static OCStackResult OCParsePlatformPayload(OCPayload **outPayload, CborValue *r
         // Resource type
         err = cbor_value_map_find_value(rootValue, OC_RSRVD_RESOURCE_TYPE, &repVal);
         VERIFY_CBOR_SUCCESS(TAG, err, "to find resource type tag");
+
         if(cbor_value_is_valid(&repVal))
         {
             err = cbor_value_dup_text_string(&repVal, &rt, &len, NULL);
@@ -569,6 +583,7 @@ static OCStackResult OCParsePlatformPayload(OCPayload **outPayload, CborValue *r
         // Interface Types
         err = cbor_value_map_find_value(rootValue, OC_RSRVD_INTERFACE, &repVal);
         VERIFY_CBOR_SUCCESS(TAG, err, "to find interface tag");
+
         if(cbor_value_is_valid(&repVal))
         {
             err =  OCParseStringLL(rootValue, OC_RSRVD_INTERFACE, &interfaces);
@@ -841,8 +856,10 @@ exit:
 static CborError OCParseArray(OCRepPayload *out, const char *name, CborValue *container)
 {
     void *arr = NULL;
-    OCRepPayloadPropType type;
-    size_t dimensions[MAX_REP_ARRAY_DEPTH];
+
+    OCRepPayloadPropType type = OCREP_PROP_NULL;
+    size_t dimensions[MAX_REP_ARRAY_DEPTH] = { 0 };
+
     size_t dimTotal = 0;
     size_t allocSize = 0;
     bool res = true;
index d109ba3..29dff7f 100755 (executable)
@@ -111,6 +111,29 @@ static OCStackResult GetSecurePortInfo(OCDevAddr *endpoint, uint16_t *port)
     return OC_STACK_OK;
 }
 
+#ifdef TCP_ADAPTER
+/* This method will retrieve the tcp port */
+static OCStackResult GetTCPPortInfo(OCDevAddr *endpoint, uint16_t *port)
+{
+    uint16_t p = 0;
+
+    if (endpoint->adapter == OC_ADAPTER_IP)
+    {
+        if (endpoint->flags & OC_IP_USE_V4)
+        {
+            p = caglobals.tcp.ipv4.port;
+        }
+        else if (endpoint->flags & OC_IP_USE_V6)
+        {
+            p = caglobals.tcp.ipv6.port;
+        }
+    }
+
+    *port = p;
+    return OC_STACK_OK;
+}
+#endif
+
 /*
  * Function will extract 0, 1 or 2 filters from query.
  * More than 2 filters or unsupported filters will result in error.
@@ -291,21 +314,29 @@ OCStackResult BuildVirtualResourceResponse(const OCResource *resourcePtr,
     {
         return OC_STACK_INVALID_PARAM;
     }
-    uint16_t port = 0;
+    uint16_t securePort = 0;
     if (resourcePtr->resourceProperties & OC_SECURE)
     {
-       if (GetSecurePortInfo(devAddr, &port) != OC_STACK_OK)
+       if (GetSecurePortInfo(devAddr, &securePort) != OC_STACK_OK)
        {
-           port = 0;
+           securePort = 0;
        }
     }
 
     if (rdResponse)
     {
-        port = devAddr->port;
+        securePort = devAddr->port;
     }
 
-    OCDiscoveryPayloadAddResource(payload, resourcePtr, port);
+    uint16_t tcpPort = 0;
+#ifdef TCP_ADAPTER
+    if (GetTCPPortInfo(devAddr, &tcpPort) != OC_STACK_OK)
+    {
+        tcpPort = 0;
+    }
+#endif
+
+    OCDiscoveryPayloadAddResource(payload, resourcePtr, securePort, tcpPort);
     return OC_STACK_OK;
 }
 
@@ -707,8 +738,9 @@ static OCStackResult HandleVirtualResource (OCServerRequest *request, OCResource
                 OCDiscoveryPayload *discPayload = (OCDiscoveryPayload *)payload;
                 discPayload->sid = (char *)OICCalloc(1, UUID_STRING_SIZE);
                 VERIFY_NON_NULL(discPayload->sid, ERROR, OC_STACK_NO_MEMORY);
+
                 const char* uid = OCGetServerInstanceIDString();
-                if(uid)
+                if (uid)
                 {
                     memcpy(discPayload->sid, uid, UUID_STRING_SIZE);
                 }
index 5ca4deb..6b18641 100644 (file)
@@ -1353,7 +1353,7 @@ void OCHandleResponse(const CAEndpoint_t* endPoint, const CAResponseInfo_t* resp
             {
                 OIC_LOG(INFO, TAG, "Received a message without callbacks. Sending RESET");
                 SendDirectStackResponse(endPoint, responseInfo->info.messageId, CA_EMPTY,
-                        CA_MSG_RESET, 0, NULL, NULL, 0, NULL);
+                                        CA_MSG_RESET, 0, NULL, NULL, 0, NULL);
             }
         }
 
@@ -1676,6 +1676,11 @@ void OCHandleRequests(const CAEndpoint_t* endPoint, const CARequestInfo_t* reque
     {
         serverRequest.reqTotalSize = requestInfo->info.payloadSize;
         serverRequest.payload = (uint8_t *) OICMalloc(requestInfo->info.payloadSize);
+        if (!serverRequest.payload)
+        {
+            OIC_LOG(ERROR, TAG, "Allocation for payload failed.");
+            return;
+        }
         memcpy (serverRequest.payload, requestInfo->info.payload,
                 requestInfo->info.payloadSize);
     }
@@ -2039,7 +2044,7 @@ OCStackResult OCInit1(OCMode mode, OCTransportFlags serverFlags, OCTransportFlag
     VERIFY_SUCCESS(result, OC_STACK_OK);
 
 #ifdef TCP_ADAPTER
-    CARegisterKeepAliveHandler(HandleKeepAliveConnCB, HandleKeepAliveDisconnCB);
+    CARegisterKeepAliveHandler(HandleKeepAliveConnCB);
 #endif
 
 #ifdef WITH_PRESENCE
@@ -2072,7 +2077,7 @@ OCStackResult OCInit1(OCMode mode, OCTransportFlags serverFlags, OCTransportFlag
 #endif
 
 #ifdef TCP_ADAPTER
-    if(result == OC_STACK_OK)
+    if (result == OC_STACK_OK)
     {
         result = InitializeKeepAlive(myStackMode);
     }
@@ -2294,7 +2299,15 @@ static OCStackResult ParseRequestUri(const char *fullUri,
             {
                 colon = close + 1;
             }
-            adapter = (OCTransportAdapter)(adapter | OC_ADAPTER_IP);
+
+            if (istcp)
+            {
+                adapter = (OCTransportAdapter)(adapter | OC_ADAPTER_TCP);
+            }
+            else
+            {
+                adapter = (OCTransportAdapter)(adapter | OC_ADAPTER_IP);
+            }
             flags = (OCTransportFlags)(flags | OC_IP_USE_V6);
         }
         else
@@ -2306,14 +2319,15 @@ static OCStackResult ParseRequestUri(const char *fullUri,
                 end = (colon && colon < slash) ? colon : slash;
 
                 if (istcp)
-                {   // coap over tcp
+                {
+                    // coap over tcp
                     adapter = (OCTransportAdapter)(adapter | OC_ADAPTER_TCP);
                 }
                 else
                 {
                     adapter = (OCTransportAdapter)(adapter | OC_ADAPTER_IP);
-                    flags = (OCTransportFlags)(flags | OC_IP_USE_V4);
                 }
+                flags = (OCTransportFlags)(flags | OC_IP_USE_V4);
             }
             else
             {   // MAC address
@@ -2724,9 +2738,11 @@ OCStackResult OCCancel(OCDoHandle handle, OCQualityOfService qos, OCHeaderOption
         case OC_REST_OBSERVE:
         case OC_REST_OBSERVE_ALL:
 
-            OIC_LOG_V(INFO, TAG, "Canceling observation for resource %s",
-                                        clientCB->requestUri);
-            if (qos != OC_HIGH_QOS)
+            OIC_LOG_V(INFO, TAG, "Canceling observation for resource %s", clientCB->requestUri);
+
+            CopyDevAddrToEndpoint(clientCB->devAddr, &endpoint);
+
+            if ((endpoint.adapter & CA_ADAPTER_IP) && qos != OC_HIGH_QOS)
             {
                 FindAndDeleteClientCB(clientCB);
                 break;
@@ -2746,7 +2762,6 @@ OCStackResult OCCancel(OCDoHandle handle, OCQualityOfService qos, OCHeaderOption
             requestInfo.info.numOptions = numOptions + 1;
             requestInfo.info.resourceUri = OICStrdup (clientCB->requestUri);
 
-            CopyDevAddrToEndpoint(clientCB->devAddr, &endpoint);
 
             ret = OCSendRequest(&endpoint, &requestInfo);
 
@@ -3929,7 +3944,7 @@ OCStackResult OCDoDirectPairing(OCDPDev_t* peer, OCPrm_t pmSel, char *pinNumber,
         OIC_LOG(ERROR, TAG, "Invalid parameters");
         return OC_STACK_INVALID_PARAM;
     }
-    if(NULL == resultCallback)
+    if (NULL == resultCallback)
     {
         OIC_LOG(ERROR, TAG, "Invalid callback");
         return OC_STACK_INVALID_CALLBACK;
@@ -4243,7 +4258,11 @@ void insertResourceType(OCResource *resource, OCResourceType *resourceType)
             previous = pointer;
             pointer = pointer->next;
         }
-        previous->next = resourceType;
+
+        if (previous)
+        {
+            previous->next = resourceType;
+        }
     }
     resourceType->next = NULL;
 
index 8063f2b..c94bb85 100644 (file)
@@ -716,31 +716,31 @@ OCStackResult RemoveKeepAliveEntry(const CAEndpoint_t *endpoint)
     return OC_STACK_OK;
 }
 
-void HandleKeepAliveConnCB(const CAEndpoint_t *endpoint)
+void HandleKeepAliveConnCB(const CAEndpoint_t *endpoint, bool isConnected)
 {
     VERIFY_NON_NULL_NR(endpoint, FATAL);
 
-    OIC_LOG(DEBUG, TAG, "Received the connected device information from CA");
-
-    // Send discover message to find ping resource
-    OCCallbackData pingData = { .cb = PingRequestCallback };
-    OCDevAddr devAddr = { .adapter = OC_ADAPTER_TCP };
-    CopyEndpointToDevAddr(endpoint, &devAddr);
-
-    OCDoResource(NULL, OC_REST_DISCOVER, KEEPALIVE_RESOURCE_URI, &devAddr, NULL,
-                 OC_ADAPTER_TCP, OC_HIGH_QOS, &pingData, NULL, 0);
-}
-
-void HandleKeepAliveDisconnCB(const CAEndpoint_t *endpoint)
-{
-    VERIFY_NON_NULL_NR(endpoint, FATAL);
+    if (isConnected)
+    {
+        OIC_LOG(DEBUG, TAG, "Received the connected device information from CA");
 
-    OIC_LOG(DEBUG, TAG, "Received the disconnected device information from CA");
+        // Send discover message to find ping resource
+        OCCallbackData pingData = { .cb = PingRequestCallback };
+        OCDevAddr devAddr = { .adapter = OC_ADAPTER_TCP };
+        CopyEndpointToDevAddr(endpoint, &devAddr);
 
-    OCStackResult result = RemoveKeepAliveEntry(endpoint);
-    if(result != OC_STACK_OK)
+        OCDoResource(NULL, OC_REST_DISCOVER, KEEPALIVE_RESOURCE_URI, &devAddr, NULL,
+                     OC_ADAPTER_TCP, OC_HIGH_QOS, &pingData, NULL, 0);
+    }
+    else
     {
-        OIC_LOG(ERROR, TAG, "Failed to remove entry");
-        return;
+        OIC_LOG(DEBUG, TAG, "Received the disconnected device information from CA");
+
+        OCStackResult result = RemoveKeepAliveEntry(endpoint);
+        if(result != OC_STACK_OK)
+        {
+            OIC_LOG(ERROR, TAG, "Failed to remove entry");
+            return;
+        }
     }
 }
index 037edcd..a5b9fe4 100644 (file)
@@ -453,7 +453,7 @@ TEST(StackResource, CreateResourceBadUri)
     OIC_LOG(INFO, TAG, "Starting CreateResourceBadUri test");
     InitStack(OC_SERVER);
 
-    const char *uri65 = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL";
+    const char *uri257 = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVW";
 
     OCResourceHandle handle;
 
@@ -476,7 +476,7 @@ TEST(StackResource, CreateResourceBadUri)
     EXPECT_EQ(OC_STACK_INVALID_URI, OCCreateResource(&handle,
                                             "core.led",
                                             "core.rw",
-                                            uri65, //"/a/led",
+                                            uri257, //"/a/led",
                                             0,
                                             0,
                                             OC_DISCOVERABLE|OC_OBSERVABLE));
index 112c4b3..f5e55e8 100644 (file)
@@ -680,7 +680,6 @@ INPUT                  = . \
                          ../../../service/easy-setup/inc \
                          ../../../service/scene-manager/include \
 
-
 # This tag can be used to specify the character encoding of the source files
 # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
 # also the default input encoding. Doxygen uses libiconv (or the iconv built
@@ -1705,7 +1704,7 @@ UML_LOOK               = NO
 # the class node. If there are many fields or methods and many nodes the
 # graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS
 # threshold limits the number of items for each type to make the size more
-# managable. Set this to 0 for no limit. Note that the threshold may be
+# manageable. Set this to 0 for no limit. Note that the threshold may be
 # exceeded by 50% before the limit is enforced.
 
 UML_LIMIT_NUM_FIELDS   = 10
index 9fad828..5d84295 100644 (file)
@@ -50,7 +50,12 @@ if target_os not in ['windows', 'winrt']:
 
 examples_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
 examples_env.AppendUnique(RPATH = [env.get('BUILD_DIR')])
-examples_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'connectivity_abstraction', 'coap'])
+examples_env.PrependUnique(LIBS = ['coap'])
+examples_env.AppendUnique(LIBS = ['connectivity_abstraction'])
+examples_env.AppendUnique(LIBS = ['oc_logger'])
+examples_env.AppendUnique(LIBS = ['octbstack'])
+examples_env.AppendUnique(LIBS = ['oc'])
+
 if env.get('SECURED') == '1':
     examples_env.AppendUnique(LIBS = ['tinydtls'])
 
index db1b3a1..cde8eb2 100644 (file)
@@ -254,7 +254,6 @@ int main(int /*argc*/, char** /*argv[]*/)
                     cout << "Invalid option" << endl;
                     break;
             }
-            fflush(stdin);
         }
     }
     catch (OCException& e)
index 65ec176..519da78 100644 (file)
@@ -40,11 +40,17 @@ namespace OC
         *            After creating instances of OCHeaderOptions, use setHeaderOptions API
         *            (in OCResource.h) to set header Options.
         *            NOTE: HeaderOptionID  is an unsigned integer value which MUST be within
-        *            range of 2048 to 3000 inclusive of lower and upper bound.
+        *            range of 2048 to 3000 inclusive of lower and upper bound
+        *            except for If-Match with empty(num : 1), If-None-Match(num : 5),
+        *            Location-Path(num : 8), Location-Query(num : 20) option.
         *            HeaderOptions instance creation fails if above condition is not satisfied.
         */
         const uint16_t MIN_HEADER_OPTIONID = 2048;
         const uint16_t MAX_HEADER_OPTIONID = 3000;
+        const uint16_t IF_MATCH_OPTION_ID = 1;
+        const uint16_t IF_NONE_MATCH_OPTION_ID = 5;
+        const uint16_t LOCATION_PATH_OPTION_ID = 8;
+        const uint16_t LOCATION_QUERY_OPTION_ID = 20;
 
         class OCHeaderOption
         {
@@ -60,7 +66,11 @@ namespace OC
                 m_optionID(optionID),
                 m_optionData(optionData)
             {
-                if(!(optionID >= MIN_HEADER_OPTIONID && optionID <= MAX_HEADER_OPTIONID))
+                if (!(optionID >= MIN_HEADER_OPTIONID && optionID <= MAX_HEADER_OPTIONID)
+                        && optionID != IF_MATCH_OPTION_ID
+                        && optionID != IF_NONE_MATCH_OPTION_ID
+                        && optionID != LOCATION_PATH_OPTION_ID
+                        && optionID != LOCATION_QUERY_OPTION_ID)
                 {
                     throw OCException(OC::Exception::OPTION_ID_RANGE_INVALID);
                 }
index c9526f1..aa154bc 100644 (file)
@@ -83,6 +83,23 @@ namespace OC
                                         StringLLToVector(res->types),
                                         StringLLToVector(res->interfaces)
                                         )));
+
+#ifdef TCP_ADAPTER
+                            if (res->tcpPort != 0)
+                            {
+                                OCDevAddr tcpDevAddr = m_devAddr;
+                                tcpDevAddr.port = res->tcpPort;
+                                tcpDevAddr.adapter = OC_ADAPTER_TCP;
+                                m_resources.push_back(std::shared_ptr<OC::OCResource>(
+                                            new OC::OCResource(m_clientWrapper, tcpDevAddr,
+                                                std::string(res->uri),
+                                                std::string(payload->sid),
+                                                (res->bitmap & OC_OBSERVABLE) == OC_OBSERVABLE,
+                                                StringLLToVector(res->types),
+                                                StringLLToVector(res->interfaces)
+                                                )));
+                            }
+#endif
                         }
                         res = res->next;
                     }
index 526a0b9..4b97938 100644 (file)
@@ -60,7 +60,9 @@ namespace OC
         static const char GENERAL_JSON_PARSE_FAILED[]  = "JSON Parser Error";
         static const char RESOURCE_UNREG_FAILED[]      = "Unregistering resource failed";
         static const char OPTION_ID_RANGE_INVALID[]    =
-                            "Error: OptionID valid only from 2048 to 3000 inclusive.";
+                            "Error: OptionID valid only If-Match(1), If-None-Match(5),"
+                            "Location-Path(8), Location-Query(20),"
+                            "and from 2048 to 3000 inclusive.";
         static const char NO_ERROR[]                   = "No Error";
         static const char RESOURCE_CREATED[]           = "Resource Created";
         static const char RESOURCE_DELETED[]           = "Resource Deleted";
index 35ae31c..16612dd 100644 (file)
@@ -37,6 +37,7 @@ target_os = env.get('TARGET_OS')
 if target_os == 'android':
        liboc_logger_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
        liboc_logger_env.AppendUnique(LIBS = ['gnustl_shared', 'log'])
+       liboc_logger_env.AppendUnique(LINKFLAGS = ['-Wl,-soname,liboc_logger.so'])
 
 if target_os not in ['arduino', 'windows', 'winrt']:
        liboc_logger_env.AppendUnique(CFLAGS = ['-Wall', '-std=c99', '-fPIC'])
index de1e678..f1106a1 100644 (file)
@@ -57,8 +57,9 @@ if target_os not in ['darwin', 'ios', 'windows', 'winrt']:
        oclib_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
 
 if target_os == 'android':
-       oclib_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
-       oclib_env.AppendUnique(LIBS = ['boost_thread', 'gnustl_shared', 'log'])
+    oclib_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
+    oclib_env.AppendUnique(LIBS = ['boost_thread', 'gnustl_shared', 'log'])
+    oclib_env.AppendUnique(LINKFLAGS = ['-Wl,-soname,liboc.so'])
 
 if target_os == 'tizen':
        oclib_env.AppendUnique(CPPDEFINES = ['__TIZEN__'])
index df1a5e3..fbe63b1 100644 (file)
@@ -48,9 +48,15 @@ namespace OC
             {
                 for(uint16_t i = 0; i < HeaderOption::MIN_HEADER_OPTIONID; ++i)
                 {
-                    ASSERT_THROW(
-                            HeaderOption::OCHeaderOption(i,""),
-                            OCException);
+                    if (HeaderOption::IF_MATCH_OPTION_ID != i
+                            && HeaderOption::IF_NONE_MATCH_OPTION_ID != i
+                            && HeaderOption::LOCATION_PATH_OPTION_ID != i
+                            && HeaderOption::LOCATION_QUERY_OPTION_ID != i)
+                    {
+                        ASSERT_THROW(
+                                HeaderOption::OCHeaderOption(i,""),
+                                OCException);
+                    }
                 }
             }
 
old mode 100644 (file)
new mode 100755 (executable)
index 6168606..0d32276
@@ -166,6 +166,24 @@ OCEntityHandlerResult ProcessPostRequest(OCEntityHandlerRequest *ehRequest, OCRe
         return ehResult;
     }
 
+    char* tnn;
+    if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_TNN, &tnn))
+    {
+        OICStrcpy(gProvResource.tnn, sizeof(gProvResource.tnn), tnn);
+        OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.tnn %s", gProvResource.tnn);
+
+        gProvResource.ps = ES_PS_PROVISIONING_COMPLETED;
+    }
+
+    char* cd;
+    if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_CD, &cd))
+    {
+        OICStrcpy(gProvResource.cd, sizeof(gProvResource.cd), cd);
+        OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.cd %s", gProvResource.cd);
+    }
+
+    OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.ps %lld", gProvResource.ps);
+
     int64_t tr;
     if (OCRepPayloadGetPropInt(input, OC_RSRVD_ES_TR, &tr))
     {
@@ -187,6 +205,7 @@ OCEntityHandlerResult ProcessPostRequest(OCEntityHandlerRequest *ehRequest, OCRe
         }
         else
         {
+            gProvResource.tr = ES_PS_TRIGGER_INIT_VALUE;
             OIC_LOG(ERROR, ES_RH_TAG, "gNetworkInfoProvEventCb is NULL."
                     "Network handler not registered. Failed to connect to the network");
             ehResult = OC_EH_ERROR;
@@ -204,29 +223,6 @@ OCEntityHandlerResult ProcessPostRequest(OCEntityHandlerRequest *ehRequest, OCRe
         OIC_LOG(DEBUG, ES_RH_TAG, "Provisioning the network information to the Enrollee.");
     }
 
-    OICStrcpy(gProvResource.tnn, sizeof(gProvResource.tnn), "");
-    OICStrcpy(gProvResource.cd, sizeof(gProvResource.cd), "");
-
-    char* tnn;
-    if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_TNN, &tnn))
-    {
-        OICStrcpy(gProvResource.tnn, sizeof(gProvResource.tnn), tnn);
-        OIC_LOG(INFO, ES_RH_TAG, "got ssid");
-    }
-
-    OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.tnn %s", gProvResource.tnn);
-
-    char* cd;
-    if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_CD, &cd))
-    {
-        OICStrcpy(gProvResource.cd, sizeof(gProvResource.cd), cd);
-        OIC_LOG(INFO, ES_RH_TAG, "got password");
-    }OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.cd %s", gProvResource.cd);
-
-    gProvResource.ps = ES_PS_PROVISIONING_COMPLETED;
-
-    OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.ps %lld", gProvResource.ps);
-
     OCRepPayload *getResp = constructResponse(ehRequest);
     if (!getResp)
     {
index f21c1e1..dc8303b 100644 (file)
@@ -21,7 +21,7 @@
 /**
  * @file
  *
- * This file contains private internal callback function 
+ * This file contains private internal callback function
  * prototypes for Easy setup [Enrollee]
  */
 
old mode 100644 (file)
new mode 100755 (executable)
index 833e31e..249d586
@@ -166,6 +166,24 @@ OCEntityHandlerResult ProcessPostRequest(OCEntityHandlerRequest *ehRequest, OCRe
         return ehResult;
     }
 
+    char* tnn;
+    if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_TNN, &tnn))
+    {
+        OICStrcpy(gProvResource.tnn, sizeof(gProvResource.tnn), tnn);
+        OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.tnn %s", gProvResource.tnn);
+
+        gProvResource.ps = ES_PS_PROVISIONING_COMPLETED;
+    }
+
+    char* cd;
+    if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_CD, &cd))
+    {
+        OICStrcpy(gProvResource.cd, sizeof(gProvResource.cd), cd);
+        OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.cd %s", gProvResource.cd);
+    }
+
+    OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.ps %lld", gProvResource.ps);
+
     int64_t tr;
     if (OCRepPayloadGetPropInt(input, OC_RSRVD_ES_TR, &tr))
     {
@@ -187,6 +205,7 @@ OCEntityHandlerResult ProcessPostRequest(OCEntityHandlerRequest *ehRequest, OCRe
         }
         else
         {
+            gProvResource.tr = ES_PS_TRIGGER_INIT_VALUE;
             OIC_LOG(ERROR, ES_RH_TAG, "gNetworkInfoProvEventCb is NULL."
                     "Network handler not registered. Failed to connect to the network");
             ehResult = OC_EH_ERROR;
@@ -204,29 +223,6 @@ OCEntityHandlerResult ProcessPostRequest(OCEntityHandlerRequest *ehRequest, OCRe
         OIC_LOG(DEBUG, ES_RH_TAG, "Provisioning the network information to the Enrollee.");
     }
 
-    OICStrcpy(gProvResource.tnn, sizeof(gProvResource.tnn), "");
-    OICStrcpy(gProvResource.cd, sizeof(gProvResource.cd), "");
-
-    char* tnn;
-    if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_TNN, &tnn))
-    {
-        OICStrcpy(gProvResource.tnn, sizeof(gProvResource.tnn), tnn);
-        OIC_LOG(INFO, ES_RH_TAG, "got ssid");
-    }
-
-    OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.tnn %s", gProvResource.tnn);
-
-    char* cd;
-    if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_CD, &cd))
-    {
-        OICStrcpy(gProvResource.cd, sizeof(gProvResource.cd), cd);
-        OIC_LOG(INFO, ES_RH_TAG, "got password");
-    }OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.cd %s", gProvResource.cd);
-
-    gProvResource.ps = ES_PS_PROVISIONING_COMPLETED;
-
-    OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.ps %lld", gProvResource.ps);
-
     OCRepPayload *getResp = constructResponse(ehRequest);
     if (!getResp)
     {
index 4199e9a..00df2a9 100644 (file)
@@ -25,7 +25,7 @@ ESEnrolleeNetworkEventCallback gCallback;
 /**
  * It will return Device which is creating Soft AP.
  * i.e.Enrollee or Mediator.
- * This decesion is based on, what is the value set for ES_SOFTAP_MODE in build command as well as 
+ * This decision is based on, what is the value set for ES_SOFTAP_MODE in build command as well as
  * in iotivity.spec file.
  */
 DeviceRole ESSoftapHost()
index 9c0c57a..e0aded4 100644 (file)
@@ -53,7 +53,7 @@ class MediatorCSDKTest: public TestWithMock
 };
 
 //callbacks
-void OCProvisioningStatusCallback(EasySetupInfo  *easySetupInfo) 
+void OCProvisioningStatusCallback(EasySetupInfo  *easySetupInfo)
 {
     (void) easySetupInfo;
 }
index f631761..1624ff1 100644 (file)
@@ -63,7 +63,7 @@ if target_os not in ['windows', 'winrt']:
     easy_setup_env.AppendUnique(CXXFLAGS = ['-Wall', '-std=c++0x'])
 
 if target_os in ['linux']:
-   easy_setup_env.AppendUnique(LIBS = ['pthread', 'dl'])
+   easy_setup_env.AppendUnique(LIBS = ['pthread', 'dl', 'coap'])
 
 if target_os in ['android']:
        easy_setup_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
@@ -81,7 +81,7 @@ if target_os in ['linux']:
        easy_setup_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
        easy_setup_env.AppendUnique(RPATH = [env.get('BUILD_DIR')])
        easy_setup_env.AppendUnique(CXXFLAGS = ['-pthread'])
-       easy_setup_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'pthread', 'connectivity_abstraction'])
+       easy_setup_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger'])
        if env.get('SECURED') == '1':
                easy_setup_env.AppendUnique(LIBS = ['ocpmapi', 'ocprovision'])
 
index 480df19..099eddb 100644 (file)
@@ -77,16 +77,13 @@ if target_os not in ['windows', 'winrt']:
 
 
 if env.get('SECURED') == '1':
-            mediator_rich_test_env.PrependUnique(LIBS = ['tinydtls','ocprovision', 'ocpmapi'])
+            mediator_rich_test_env.PrependUnique(LIBS = ['tinydtls','ocprovision', 'ocpmapi', 'timer'])
 
 mediator_rich_test_env.PrependUnique(LIBS = [
+    'ESMediatorRich',
     'oc',
     'octbstack',
     'oc_logger',
-    'oc_logger_core',
-    'connectivity_abstraction',
-    'coap',
-    'ESMediatorRich',
     gtest,
     gtest_main])
 
@@ -105,4 +102,4 @@ if env.get('TEST') == '1':
     target_os = env.get('TARGET_OS')
     if target_os == 'linux':
         from tools.scons.RunTest import *
-        run_test(mediator_rich_test_env, '', 'service/easy-setup/mediator/richsdk/unittests/mediator_richsdk_test')
\ No newline at end of file
+        run_test(mediator_rich_test_env, '', 'service/easy-setup/mediator/richsdk/unittests/mediator_richsdk_test')
index ef24ed2..cc66800 100644 (file)
@@ -42,11 +42,11 @@ env.AppendUnique(CPPDEFINES = ['CPP_MEDIATOR'])
 
 if target_os not in ['windows', 'winrt']:
     mediator_env.AppendUnique(CXXFLAGS = ['-Wall', '-std=c++0x'])
-       
+
 mediator_env.PrependUnique(CPPPATH = [
             env.get('SRC_DIR') + '/resource/include',
             env.get('SRC_DIR') + '/resource/oc_logger/include',
-                       env.get('SRC_DIR') + '/resource/csdk/ocmalloc/include',         
+                       env.get('SRC_DIR') + '/resource/csdk/ocmalloc/include',
                        env.get('SRC_DIR') + '/resource/csdk/stack/include',
                        env.get('SRC_DIR') + '/resource/csdk/security/provisioning/include',
                        env.get('SRC_DIR') + '/resource/csdk/security/provisioning/include/internal',
@@ -58,7 +58,11 @@ mediator_env.PrependUnique(CPPPATH = [
                        env.get('SRC_DIR') + '/service/easy-setup/mediator/richsdk/src',
                        env.get('SRC_DIR') + '/service/easy-setup/inc'])
 
-mediator_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'pthread', 'connectivity_abstraction', 'coap', 'ESMediatorRich'])
+if env.get('SECURED') == '1':
+       mediator_env.PrependUnique(LIBS = ['tinydtls', 'timer'])
+
+mediator_env.PrependUnique(LIBS = ['ESMediatorRich', 'oc', 'octbstack', 'oc_logger'])
+
 if env.get('SECURED') == '1':
        mediator_env.PrependUnique(LIBS = ['ocpmapi', 'ocprovision'])
 
index 9a27b96..62be9f2 100644 (file)
@@ -100,9 +100,18 @@ try:
 except KeyError:
     print ''
 
-
-resource_container_env.PrependUnique(LIBS = ['rcs_client', 'rcs_server', 'rcs_common', 'oc','octbstack', 'oc_logger', 'connectivity_abstraction'])
-resource_container_env.AppendUnique(LIBS = ['dl', 'boost_system', 'boost_date_time', 'boost_thread'])
+resource_container_env.PrependUnique(LIBS = ['coap'])
+resource_container_env.AppendUnique(LIBS = ['connectivity_abstraction'])
+resource_container_env.AppendUnique(LIBS = ['oc_logger'])
+resource_container_env.AppendUnique(LIBS = ['octbstack'])
+resource_container_env.AppendUnique(LIBS = ['oc'])
+resource_container_env.AppendUnique(LIBS = ['rcs_client'])
+resource_container_env.AppendUnique(LIBS = ['rcs_server'])
+resource_container_env.AppendUnique(LIBS = ['rcs_common'])
+resource_container_env.AppendUnique(LIBS = ['dl'])
+resource_container_env.AppendUnique(LIBS = ['boost_system'])
+resource_container_env.AppendUnique(LIBS = ['boost_date_time'])
+resource_container_env.AppendUnique(LIBS = ['boost_thread'])
 
 if int(containerJavaSupport):
     try:
@@ -244,4 +253,4 @@ env.AppendTarget('containersampleclient')
 # Build Container Java SDK
 ######################################################################
 if target_os == 'android':
-    SConscript('android/SConscript')
\ No newline at end of file
+    SConscript('android/SConscript')
index a7c0cda..e853485 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  */
 
 include ':resource-container'
index 22bd821..20516e4 100644 (file)
@@ -16,11 +16,11 @@ linux_sample_env.AppendUnique(CPPPATH = ['include'])
 linux_sample_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
 linux_sample_env.AppendUnique(CPPDEFINES = ['LINUX'])
 linux_sample_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-linux_sample_env.AppendUnique(LIBS = ['oc'])
-linux_sample_env.AppendUnique(LIBS = ['octbstack'])
-linux_sample_env.AppendUnique(LIBS = ['libconnectivity_abstraction'])
 linux_sample_env.AppendUnique(LIBS = ['libcoap'])
+linux_sample_env.AppendUnique(LIBS = ['libconnectivity_abstraction'])
 linux_sample_env.AppendUnique(LIBS = ['liboc_logger'])
+linux_sample_env.AppendUnique(LIBS = ['octbstack'])
+linux_sample_env.AppendUnique(LIBS = ['oc'])
 linux_sample_env.AppendUnique(LIBS = ['pthread'])
 
 if env.get('SECURED') == '1':
@@ -36,4 +36,4 @@ if 'rt' in linux_sample_env.get('LIBS'):
 ######################################################################
 heightsensorapp = linux_sample_env.Program('HeightSensorApp', 'src/HeightSensorApp.cpp')
 Alias("heightsensorapp_sample", heightsensorapp)
-env.AppendTarget('heightsensorapp')
\ No newline at end of file
+env.AppendTarget('heightsensorapp')
index 31df5ca..6b7ab83 100644 (file)
@@ -16,11 +16,11 @@ linux_sample_env.AppendUnique(CPPPATH = ['include'])
 linux_sample_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
 linux_sample_env.AppendUnique(CPPDEFINES = ['LINUX'])
 linux_sample_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-linux_sample_env.AppendUnique(LIBS = ['oc'])
+linux_sample_env.AppendUnique(LIBS = ['coap'])
+linux_sample_env.AppendUnique(LIBS = ['connectivity_abstraction'])
+linux_sample_env.AppendUnique(LIBS = ['oc_logger'])
 linux_sample_env.AppendUnique(LIBS = ['octbstack'])
-linux_sample_env.AppendUnique(LIBS = ['libconnectivity_abstraction'])
-linux_sample_env.AppendUnique(LIBS = ['libcoap'])
-linux_sample_env.AppendUnique(LIBS = ['liboc_logger'])
+linux_sample_env.AppendUnique(LIBS = ['oc'])
 linux_sample_env.AppendUnique(LIBS = ['pthread'])
 
 if env.get('SECURED') == '1':
@@ -36,4 +36,4 @@ if 'rt' in linux_sample_env.get('LIBS'):
 ######################################################################
 weightsensorapp = linux_sample_env.Program('WeightSensorApp', 'src/WeightSensorApp.cpp')
 Alias("weightsensorapp_sample", weightsensorapp)
-env.AppendTarget('weightsensorapp')
\ No newline at end of file
+env.AppendTarget('weightsensorapp')
index 9b065ed..ee61a9a 100644 (file)
@@ -16,11 +16,11 @@ linux_sample_env.AppendUnique(CPPPATH = ['include'])
 linux_sample_env.AppendUnique(CXXFLAGS = ['-Wall', '-pthread','-std=c++0x'])
 linux_sample_env.AppendUnique(CPPDEFINES = ['LINUX'])
 linux_sample_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-linux_sample_env.AppendUnique(LIBS = ['oc'])
+linux_sample_env.AppendUnique(LIBS = ['coap'])
+linux_sample_env.AppendUnique(LIBS = ['connectivity_abstraction'])
+linux_sample_env.AppendUnique(LIBS = ['oc_logger'])
 linux_sample_env.AppendUnique(LIBS = ['octbstack'])
-linux_sample_env.AppendUnique(LIBS = ['libconnectivity_abstraction'])
-linux_sample_env.AppendUnique(LIBS = ['libcoap'])
-linux_sample_env.AppendUnique(LIBS = ['liboc_logger'])
+linux_sample_env.AppendUnique(LIBS = ['oc'])
 linux_sample_env.AppendUnique(LIBS = ['pthread'])
 
 if env.get('SECURED') == '1':
index 3109793..7fa770c 100644 (file)
@@ -16,11 +16,11 @@ linux_sample_env.AppendUnique(CPPPATH = ['include'])
 linux_sample_env.AppendUnique(CXXFLAGS = ['-Wall', '-pthread','-std=c++0x'])
 linux_sample_env.AppendUnique(CPPDEFINES = ['LINUX'])
 linux_sample_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-linux_sample_env.AppendUnique(LIBS = ['oc'])
+linux_sample_env.AppendUnique(LIBS = ['coap'])
+linux_sample_env.AppendUnique(LIBS = ['connectivity_abstraction'])
+linux_sample_env.AppendUnique(LIBS = ['oc_logger'])
 linux_sample_env.AppendUnique(LIBS = ['octbstack'])
-linux_sample_env.AppendUnique(LIBS = ['libconnectivity_abstraction'])
-linux_sample_env.AppendUnique(LIBS = ['libcoap'])
-linux_sample_env.AppendUnique(LIBS = ['liboc_logger'])
+linux_sample_env.AppendUnique(LIBS = ['oc'])
 linux_sample_env.AppendUnique(LIBS = ['pthread'])
 
 if env.get('SECURED') == '1':
index ff04522..5042f0c 100644 (file)
@@ -421,7 +421,7 @@ namespace OIC
 
                 }
             }
-            OIC_LOG_V(INFO, CONTAINER_TAG, "Container get request for %s finished, %d attributes",strResourceUri.c_str(), attr.size());
+            OIC_LOG_V(INFO, CONTAINER_TAG, "Container get request for %s finished, %zu attributes",strResourceUri.c_str(), attr.size());
 
             return RCSGetResponse::create(std::move(attr), 200);
         }
@@ -433,7 +433,7 @@ namespace OIC
             std::list<std::string> lstAttributes;
             std::string strResourceUri = request.getResourceUri();
 
-            OIC_LOG_V(INFO, CONTAINER_TAG, "Container set request for %s, %d attributes",strResourceUri.c_str(), attributes.size());
+            OIC_LOG_V(INFO, CONTAINER_TAG, "Container set request for %s, %zu attributes",strResourceUri.c_str(), attributes.size());
 
             if (m_mapServers.find(strResourceUri) != m_mapServers.end()
                 && m_mapResources.find(strResourceUri) != m_mapResources.end())
old mode 100644 (file)
new mode 100755 (executable)
index 9882002..1b78bd7
@@ -25,11 +25,12 @@ public abstract class TestBase extends InstrumentationTestCase {
     private OnResourceDiscoveredListener mOnResourceDiscoveredListener = new OnResourceDiscoveredListener() {
         @Override
         public void onResourceDiscovered(
-                RcsRemoteResourceObject RcsRemoteResourceObject) {
-            if (mClient != null)
+                RcsRemoteResourceObject remoteObject) {
+            if (mClient != null) {
                 return;
+            }
 
-            mClient = RcsRemoteResourceObject;
+            mClient = remoteObject;
             synchronized (mCond) {
                 mCond.notify();
             }
@@ -53,8 +54,7 @@ public abstract class TestBase extends InstrumentationTestCase {
         while (mClient == null) {
             try {
                 RcsDiscoveryManager.DiscoveryTask discoveryTask = RcsDiscoveryManager
-                        .getInstance().discoverResourceByType(
-                                RcsAddress.multicast(), "/oic/res",
+                        .getInstance().discoverResourceByType(RcsAddress.multicast(),
                                 RESOURCETYPE, mOnResourceDiscoveredListener);
 
                 synchronized (mCond) {
@@ -71,9 +71,13 @@ public abstract class TestBase extends InstrumentationTestCase {
     protected void setServerAttrbutes(RcsResourceAttributes attrs)
             throws RcsException {
         RcsResourceObject.AttributesLock lock = mServer.getAttributesLock();
-        lock.lock().putAll(attrs);
-        lock.apply();
-        lock.unlock();
+
+        try {
+            lock.lock().putAll(attrs);
+            lock.apply();
+        } finally {
+            lock.unlock();
+        }
     }
 
     @Override
index 5b8f4d4..4b8bb4e 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  */
 
 include ':service'
index b8a6828..2dc07d5 100644 (file)
@@ -31,12 +31,12 @@ sample_env = lib_env.Clone()
 
 sample_env.AppendUnique(CXXFLAGS = ['-Wall', '-std=c++0x'])
 sample_env.AppendUnique(LIBS = [
-    'rcs_common',
-    'oc',
-    'octbstack',
-    'oc_logger',
-    'connectivity_abstraction',
     'coap',
+    'connectivity_abstraction',
+    'oc_logger',
+    'octbstack',
+    'oc',
+    'rcs_common',
     'pthread'
     ])
 sample_env.AppendUnique(CPPPATH = ['../../include'])
index 3ad2106..1263096 100644 (file)
@@ -31,12 +31,12 @@ sample_env = lib_env.Clone()
 
 sample_env.AppendUnique(CXXFLAGS = ['-Wall', '-std=c++0x'])
 sample_env.AppendUnique(LIBS = [
-    'rcs_common',
-    'oc',
-    'octbstack',
-    'oc_logger',
-    'connectivity_abstraction',
     'coap',
+    'connectivity_abstraction',
+    'oc_logger',
+    'octbstack',
+    'oc',
+    'rcs_common',
     'pthread',
     'tinydtls'
     ])
index 8d7391d..7ebdf3f 100644 (file)
@@ -125,6 +125,9 @@ namespace OIC
         void DevicePresence::subscribeCB(OCStackResult ret,
                 const unsigned int seq, const std::string & hostAddress)
         {
+            OC_UNUSED(seq);
+            OC_UNUSED(hostAddress);
+
             OIC_LOG_V(DEBUG, BROKER_TAG, "subscribeCB()");
             OIC_LOG_V(DEBUG, BROKER_TAG, "Received presence CB from: %s",hostAddress.c_str());
             OIC_LOG_V(DEBUG, BROKER_TAG, "In subscribeCB: %d",ret);
index 34748b4..00012e6 100644 (file)
@@ -61,7 +61,16 @@ broker_test_env.AppendUnique(CPPPATH = ['../../common/utils/include'])
 broker_test_env.PrependUnique(CPPPATH = [env.get('SRC_DIR')+'/extlibs/hippomocks-master',
                              gtest_dir + '/include'])
 broker_test_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-broker_test_env.PrependUnique(LIBS = ['rcs_client','rcs_common', 'oc', 'octbstack', 'oc_logger', 'connectivity_abstraction', 'coap', gtest, gtest_main])
+
+broker_test_env.PrependUnique(LIBS = ['coap'])
+broker_test_env.AppendUnique(LIBS = ['connectivity_abstraction'])
+broker_test_env.AppendUnique(LIBS = ['oc_logger'])
+broker_test_env.AppendUnique(LIBS = ['octbstack'])
+broker_test_env.AppendUnique(LIBS = ['oc'])
+broker_test_env.AppendUnique(LIBS = ['rcs_client'])
+broker_test_env.AppendUnique(LIBS = ['rcs_common'])
+broker_test_env.AppendUnique(LIBS = [gtest])
+broker_test_env.AppendUnique(LIBS = [gtest_main])
 
 if target_os not in ['windows', 'winrt']:
     broker_test_env.AppendUnique(CXXFLAGS = ['-O2', '-g', '-Wall', '-fmessage-length=0', '-std=c++0x'])
index d942636..3126912 100644 (file)
@@ -698,7 +698,7 @@ TEST_F(ResourceObjectInterfaceHandlerTest, ThrowIfDefaultInterfaceIsInvalid)
 
 TEST_F(ResourceObjectInterfaceHandlerTest, SettingDefaultInterfaceEqualsGetDefaultInterface)
 {
-    initServer({SENSOR_INTERFACE}, BASELINE_INTERFACE);
+    initServer({ SENSOR_INTERFACE }, BASELINE_INTERFACE);
 
     EXPECT_EQ(BASELINE_INTERFACE, server->getDefaultInterface());
 }
index 67855cf..7af50f7 100644 (file)
@@ -76,14 +76,14 @@ if target_os not in ['windows', 'winrt']:
                 rcs_test_env.AppendUnique(LIBS = ['pthread'])
 
 rcs_test_env.PrependUnique(LIBS = [
+    'connectivity_abstraction',
+    'oc_logger',
+    'oc_logger_core',
+    'octbstack',
+    'oc',
     'rcs_client',
     'rcs_server',
     'rcs_common',
-    'oc',
-    'octbstack',
-    'oc_logger',
-    'oc_logger_core',
-    'connectivity_abstraction',
     gtest,
     gtest_main])
 
@@ -102,4 +102,4 @@ if env.get('TEST') == '1':
     target_os = env.get('TARGET_OS')
     if target_os == 'linux':
         from tools.scons.RunTest import *
-        run_test(rcs_test_env, '', 'service/resource-encapsulation/unittests/rcs_client_test')
\ No newline at end of file
+        run_test(rcs_test_env, '', 'service/resource-encapsulation/unittests/rcs_client_test')
index e3a09eb..69778e9 100644 (file)
@@ -1,23 +1,23 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * 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 com.example.sample.provider;
index 1062275..6b8f132 100644 (file)
@@ -17,23 +17,23 @@ resourcehosting_env.AppendUnique(CPPPATH = ['../../../../resource/csdk/connectiv
 resourcehosting_env.AppendUnique(CXXFLAGS = ['-O2', '-g', '-Wall', '-fmessage-length=0', '-std=c++0x'])
 resourcehosting_sample_env = resourcehosting_env.Clone()
 resourcehosting_env.AppendUnique(LIBS = [
+    'coap',
+    'connectivity_abstraction',
+    'oc_logger',
+    'octbstack',
+    'oc',
     'resource_hosting',
     'rcs_client',
     'rcs_server',
     'rcs_common',
-    'oc',
-    'octbstack',
-    'oc_logger',
-    'connectivity_abstraction',
-    'coap',
     'pthread'
     ])
 resourcehosting_sample_env.AppendUnique(LIBS = [
-    'oc',
-    'octbstack',
-    'oc_logger',
     'connectivity_abstraction',
     'coap',
+    'oc_logger',
+    'octbstack',
+    'oc',
     'pthread'
     ])
 
index b56a4cf..2f83458 100755 (executable)
@@ -134,7 +134,7 @@ TEST_F(HostingObjectTest, createMirroredServer)
 
     waitForCondition(waitForResponse);
     mocks.OnCallFunc(onDiscoveryResource).Do(
-            [this, &uri, &discoveryTask, &testObject, &discoveredResource]
+            [this, &uri, &discoveryTask]
              (RCSRemoteResourceObject::Ptr ptr)
             {
                 if(ptr->getUri() == testObject.getHostedServerUri())
@@ -203,7 +203,7 @@ TEST_F(HostingObjectTest, ExpectCallOnDestroyWhenStopHostingObject)
     int waitForResponse = 1000;
 
     mocks.ExpectCallFunc(onDestroy).Do(
-            [& responseCon]()
+            []()
             {
                 responseCon.notify_all();
             });
index 79b1d1d..e476b6d 100755 (executable)
@@ -106,7 +106,7 @@ TEST_F(ResourceHostingTest, HostingFoundBeforeMakeOriginServer)
     waitForCondition();
 
     mocks.OnCallFunc(onDiscoveryResource).Do(
-            [this, &uri, &testObject](RCSRemoteResourceObject::Ptr ptr)
+            [this, &uri](RCSRemoteResourceObject::Ptr ptr)
             {
                 if(ptr->getUri() == testObject.getHostedServerUri())
                 {
index 9348578..d351104 100755 (executable)
@@ -50,14 +50,14 @@ scenemanager_env.AppendUnique(CPPPATH = ['../resource-encapsulation/src/common/e
 
 
 scenemanager_env.PrependUnique(LIBS = [
+    'coap',
+    'connectivity_abstraction',
+    'oc_logger',
+    'octbstack',
+    'oc',
     'rcs_client',
     'rcs_server',
-    'rcs_common',
-    'oc',
-    'octbstack',
-    'oc_logger',
-    'connectivity_abstraction',
-    'libcoap'
+    'rcs_common'
     ])
 
 if target_os not in ['windows', 'winrt']:
index 6946510..8753303 100755 (executable)
@@ -18,15 +18,15 @@ scenemanager_sample_env.AppendUnique(CPPPATH = ['../../../../resource/csdk/conne
 scenemanager_sample_env.AppendUnique(CXXFLAGS = ['-O2', '-g', '-Wall', '-fmessage-length=0', '-std=c++0x'])
 
 scenemanager_sample_env.AppendUnique(LIBS = [
+    'oc_logger',
+    'coap',
+    'connectivity_abstraction',
     'scene_manager',
     'rcs_client',
     'rcs_server',
     'rcs_common',
-    'oc',
     'octbstack',
-    'oc_logger',
-    'connectivity_abstraction',
-    'coap',
+    'oc',
     'pthread'
     ])
 
@@ -45,4 +45,4 @@ if not env.get('RELEASE'):
 sceneserver = scenemanager_sample_env.Program('sceneserver', 'sceneserver.cpp')
 sceneclient = scenemanager_sample_env.Program('sceneclient', 'sceneclient.cpp')
 fanserver = scenemanager_sample_env.Program('fanserver', 'fanserver.cpp')
-lightserver = scenemanager_sample_env.Program('lightserver', 'lightserver.cpp')
\ No newline at end of file
+lightserver = scenemanager_sample_env.Program('lightserver', 'lightserver.cpp')
index 22bdc20..696003d 100755 (executable)
@@ -235,7 +235,6 @@ void executeScene()
 }
 
 // --- Scene Manager Remote API sample
-
 void configurePlatform()
 {
     PlatformConfig config
index 27eff03..5ef7aeb 100644 (file)
@@ -49,7 +49,7 @@ namespace OIC
         void SceneUtils::getHostUriString(
                 const std::string address, std::string *host, std::string *uri)
         {
-            unsigned int nextStartIndex = 0;
+            size_t nextStartIndex = 0;
             int indexOfStr = 3;
 
             if (address.find(COAP_TAG) == std::string::npos)
index 046db29..4020136 100644 (file)
@@ -54,7 +54,7 @@ the Edit Configuration window.
 
 From Run/Debug settings, Choose a launch configuration and press Edit -> select 'Environment' tab
 -> Click on 'Select' -> check LD_LIBRARY_PATH option -> OK. Edit the LD_LIBRARY_PATH and add the
-complete path upto the libs folder of the plug-in project
+complete path up to the libs folder of the plug-in project
 ( ~/iotivity/service/simulator/java/eclipse-plugin/ClientControllerPlugin/libs)
 -> Apply -> OK. Then Apply -> OK to close the properties window.
 
index 44fc3ee..c3e0604 100644 (file)
@@ -657,19 +657,26 @@ public class ResourceManager {
         Resource resource = new SingleResource();
         resource.setSimulatorResource(jSimulatorResource);
 
-        // Fetch and locally store the resource name and uri.
+        // Fetch and locally store the resource name, type and uri.
         String uri = jSimulatorResource.getURI();
         if (null == uri || uri.trim().isEmpty()) {
+            // URI is mandatory to be present in RAML. If it is not there, then
+            // resource can't be created.
             return null;
         }
         resource.setResourceURI(uri.trim());
 
-        String name = jSimulatorResource.getName();
-        if (null == name || name.trim().isEmpty()) {
-            return null;
+        String type = jSimulatorResource.getResourceType();
+        if (null != type) {
+            type = type.trim();
         }
+        resource.setResourceType(type);
 
-        resource.setResourceName(name.trim());
+        String name = jSimulatorResource.getName();
+        if (null != name) {
+            name = name.trim();
+        }
+        resource.setResourceName(name);
 
         return resource;
     }
@@ -682,7 +689,7 @@ public class ResourceManager {
      * notifies the UI listeners.
      */
     public boolean completeSingleResourceCreationByRAML(Resource resource,
-            String uri, String name, boolean multiInstance)
+            String uri, String name, String type, boolean multiInstance)
             throws SimulatorException {
         if (null == resource || !(resource instanceof SingleResource)) {
             return false;
@@ -697,21 +704,30 @@ public class ResourceManager {
             }
 
             // Update resource URI and Name if they are changed.
-            String newUri = uri.trim();
-            String newName = name.trim();
-
-            if (multiInstance) {
+            String newUri = "";
+            String newName = "";
+            String newType = "";
+
+            if (null != uri)
+                newUri = uri.trim();
+            if (null != name)
+                newName = name.trim();
+            if (null != type)
+                newType = type.trim();
+
+            if (!multiInstance && !singleRes.getResourceURI().equals(newUri)) {
+                jSimulatorSingleResource.setURI(newUri);
                 singleRes.setResourceURI(newUri);
+            }
+            String currentName = singleRes.getResourceName();
+            if (null == currentName || !currentName.equals(newName)) {
+                jSimulatorSingleResource.setName(newName);
                 singleRes.setResourceName(newName);
-            } else {
-                if (!singleRes.getResourceURI().equals(newUri)) {
-                    jSimulatorSingleResource.setURI(newUri);
-                    singleRes.setResourceURI(newUri);
-                }
-                if (!singleRes.getResourceName().equals(newName)) {
-                    jSimulatorSingleResource.setName(newName);
-                    singleRes.setResourceName(newName);
-                }
+            }
+            String currentType = singleRes.getResourceType();
+            if (null == currentType || !currentType.equals(newType)) {
+                jSimulatorSingleResource.setResourceType(newType);
+                singleRes.setResourceType(newType);
             }
 
             // Set the model change listener.
@@ -733,8 +749,6 @@ public class ResourceManager {
             singleRes.setResourceModel(jResModel);
 
             // Fetch the basic details of the resource.
-            singleRes.setResourceType(jSimulatorSingleResource
-                    .getResourceType());
             singleRes
                     .setResourceInterfaces(Utility
                             .convertVectorToSet(jSimulatorSingleResource
@@ -785,7 +799,6 @@ public class ResourceManager {
             }
             SimulatorSingleResource jResource;
             SingleResource resource;
-            boolean result;
             for (SimulatorResource jSimulatorResource : jSimulatorResources) {
                 // If the resource creation progress is canceled, then stop the
                 // creation and stop/delete
@@ -798,11 +811,27 @@ public class ResourceManager {
                 resource = new SingleResource();
                 resource.setSimulatorResource(jResource);
                 try {
-                    result = completeSingleResourceCreationByRAML(resource,
-                            jResource.getURI(), jResource.getName(), true);
-                    if (result) {
-                        resultSet.add(resource);
+                    String uri = jSimulatorResource.getURI();
+                    if (null == uri || uri.trim().isEmpty()) {
+                        // URI is mandatory to be present in RAML. If it is not
+                        // there, then resource will be ignored.
+                        continue;
+                    }
+                    resource.setResourceURI(uri.trim());
+
+                    String type = jSimulatorResource.getResourceType();
+                    if (null != type) {
+                        type = type.trim();
                     }
+                    resource.setResourceType(type);
+
+                    String name = jSimulatorResource.getName();
+                    if (null != name) {
+                        name = name.trim();
+                    }
+                    resource.setResourceName(name);
+
+                    resultSet.add(resource);
                 } catch (SimulatorException eInner) {
                     Activator
                             .getDefault()
index ecbec24..225a340 100644 (file)
@@ -429,7 +429,7 @@ public class ResourceManagerView extends ViewPart {
                                         .getDefault()
                                         .getLogManager()
                                         .log(Level.ERROR.ordinal(), new Date(),
-                                                "There is an error while creating the wizard.\n");
+                                                "There is an error while reading information from the UI wizard.\n");
                                 return;
                             }
 
index f45afec..88f50fd 100644 (file)
@@ -28,9 +28,6 @@ import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.swt.widgets.Display;
 
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.net.URL;
 import java.util.Date;
@@ -58,21 +55,21 @@ import oic.simulator.serviceprovider.view.dialogs.MainPage.Option;
  */
 public class CreateResourceWizard extends Wizard {
 
-    private MainPage                       mainPage;
-    private SimpleResourceBasicDetailsPage simpleResourceBasicDetailsPage;
-    private SimpleResourceAddAttributePage simpleResourceAddAttributePage;
-    private SimpleResourceOtherDetailsPage simpleResourceOtherDetailsPage;
-    private LoadRamlPage                   loadRamlPage;
-    private UpdatePropertiesPage           updatePropPage;
+    private MainPage                                  mainPage;
+    private SimpleResourceBasicDetailsPage            simpleResourceBasicDetailsPage;
+    private SimpleResourceAddAttributePage            simpleResourceAddAttributePage;
+    private SimpleResourceOtherDetailsPage            simpleResourceOtherDetailsPage;
+    private LoadRamlPage                              loadRamlPage;
+    private UpdatePropertiesPage                      updatePropPage;
+    private UpdateMultiInstanceCreationPropertiesPage updateMultiInstanceCreationPropPage;
 
-    private String                         status;
+    private String                                    status;
 
-    private WizardDialog                   wizDialog;
-    private boolean                        dlgForceClosed;
+    private WizardDialog                              wizDialog;
+    private boolean                                   dlgForceClosed;
 
-    private Resource                       createdResource;
-
-    private IProgressMonitor               progressMonitor;
+    private Resource                                  createdResource;
+    private Set<SingleResource>                       multiInstanceResourceSet;
 
     public CreateResourceWizard() {
         setWindowTitle("Create resources");
@@ -92,6 +89,7 @@ public class CreateResourceWizard extends Wizard {
         simpleResourceOtherDetailsPage = new SimpleResourceOtherDetailsPage();
         loadRamlPage = new LoadRamlPage();
         updatePropPage = new UpdatePropertiesPage();
+        updateMultiInstanceCreationPropPage = new UpdateMultiInstanceCreationPropertiesPage();
 
         addPage(mainPage);
         addPage(simpleResourceBasicDetailsPage);
@@ -99,6 +97,7 @@ public class CreateResourceWizard extends Wizard {
         addPage(simpleResourceOtherDetailsPage);
         addPage(loadRamlPage);
         addPage(updatePropPage);
+        addPage(updateMultiInstanceCreationPropPage);
     }
 
     public void setWizardDialog(WizardDialog dlg) {
@@ -135,14 +134,17 @@ public class CreateResourceWizard extends Wizard {
         return createdResource;
     }
 
+    public Set<SingleResource> getCreatedMultiInstanceResourceSet() {
+        return multiInstanceResourceSet;
+    }
+
     @Override
     public boolean canFinish() {
         IWizardPage curPage = this.getContainer().getCurrentPage();
-        if ((curPage == updatePropPage && ((mainPage.getOption() == Option.SIMPLE_FROM_RAML) || !Activator
-                .getDefault().getResourceManager().isAnyResourceExist()))
-                || curPage == simpleResourceAddAttributePage
-                || (curPage == loadRamlPage && loadRamlPage.isSelectionDone() && loadRamlPage
-                        .isMultiResourceCreation())) {
+        if ((curPage == updateMultiInstanceCreationPropPage || curPage == updatePropPage
+                && ((mainPage.getOption() == Option.SIMPLE_FROM_RAML) || !Activator
+                        .getDefault().getResourceManager().isAnyResourceExist()))
+                || curPage == simpleResourceAddAttributePage) {
             return true;
         }
         return false;
@@ -179,107 +181,58 @@ public class CreateResourceWizard extends Wizard {
                         .log(Level.ERROR.ordinal(), new Date(), e.getMessage());
                 e.printStackTrace();
             }
-        } else if (curPage == loadRamlPage) {
-            // Validate the file path.
-            FileInputStream fileStream = null;
-            try {
-                fileStream = new FileInputStream(
-                        loadRamlPage.getConfigFilePath());
-            } catch (FileNotFoundException e) {
-                MessageDialog
-                        .openError(getShell(), "Invalid File",
-                                "File doesn't exist. Either the file path or file name is invalid.");
-                return false;
-            } finally {
-                if (null != fileStream) {
-                    try {
-                        fileStream.close();
-                    } catch (IOException e) {
-                        Activator
-                                .getDefault()
-                                .getLogManager()
-                                .log(Level.ERROR.ordinal(), new Date(),
-                                        "There is an error while closing the file stream.\n");
-                    }
-                }
-            }
-
-            // Handling multiple instance creation of simple resource with RAML
-            if ((loadRamlPage.getResourceCount() + Activator.getDefault()
-                    .getResourceManager().getResourceCount()) > Constants.MAX_RESOURCE_COUNT) {
-                MessageDialog.openInformation(Display.getDefault()
-                        .getActiveShell(), "Resource limit exceeded",
-                        Constants.RESOURCE_LIMIT_EXCEEDED_MSG);
-                return false;
-            }
-
-            final int[] resCreatedCount = new int[1];
-            try {
-                getContainer().run(true, true, new IRunnableWithProgress() {
-
-                    @Override
-                    public void run(final IProgressMonitor monitor)
-                            throws InvocationTargetException,
-                            InterruptedException {
-                        progressMonitor = monitor;
-                        try {
-                            monitor.beginTask(
-                                    "Single Resource Creation(multi-instance) With RAML",
-                                    loadRamlPage.getResourceCount());
-                            resCreatedCount[0] = createMultiInstanceSingleResourceWithoutRAML();
-
-                        } finally {
-                            monitor.done();
-                        }
-                    }
-                });
-            } catch (InvocationTargetException e) {
-                Activator.getDefault().getLogManager()
-                        .log(Level.ERROR.ordinal(), new Date(), e.getMessage());
-                e.printStackTrace();
-            } catch (InterruptedException e) {
-                Activator.getDefault().getLogManager()
-                        .log(Level.ERROR.ordinal(), new Date(), e.getMessage());
-                e.printStackTrace();
-            }
-            boolean canceled = false;
-            if (null != progressMonitor && progressMonitor.isCanceled()
-                    && 0 == resCreatedCount[0]) {
-                canceled = true;
-            }
-            progressMonitor = null;
-            if (canceled) {
-                return false;
+        } else if (curPage == updatePropPage
+                || curPage == updateMultiInstanceCreationPropPage) {
+            multiInstanceResourceSet = loadRamlPage
+                    .getMultiInstanceResourceSet();
+            createdResource = loadRamlPage.getResource();
+
+            String resName;
+            String resURI;
+            String resType;
+            boolean multiInstanceCreation = loadRamlPage
+                    .isMultiResourceCreation();
+
+            if (curPage == updatePropPage) {
+                resName = updatePropPage.getResName();
+                resURI = updatePropPage.getResURI();
+                resType = updatePropPage.getResType();
             } else {
-                if (resCreatedCount[0] > 0) {
-                    UiListenerHandler.getInstance()
-                            .resourceCreatedUINotification(ResourceType.SINGLE);
-                }
+                resName = updateMultiInstanceCreationPropPage.getResName();
+                resURI = "";
+                resType = updateMultiInstanceCreationPropPage.getResType();
             }
-        } else if (curPage == updatePropPage) {
-            // Handling the single instance
-            String resName = updatePropPage.getResName();
-            String resURI = updatePropPage.getResURI();
+
             if (null == resName || resName.trim().length() < 1) {
                 MessageDialog.openError(Display.getDefault().getActiveShell(),
                         "Invalid Resource Name.", "Resource name is invalid");
                 return false;
             }
-            if (!Utility.isUriValid(resURI)) {
+
+            if (!multiInstanceCreation && !Utility.isUriValid(resURI)) {
                 MessageDialog.openError(Display.getDefault().getActiveShell(),
                         "Invalid Resource URI.", Constants.INVALID_URI_MESSAGE);
                 return false;
             }
+
             // Creation of simple resource with RAML
             // Checking whether the URI is used by any other resource.
-            if (Activator.getDefault().getResourceManager()
-                    .isResourceExist(updatePropPage.getResURI())) {
+            if (!multiInstanceCreation
+                    && Activator.getDefault().getResourceManager()
+                            .isResourceExist(resURI)) {
                 MessageDialog
                         .openError(getShell(), "Resource URI in use",
                                 "Entered resource URI is in use. Please try a different one.");
                 return false;
             }
 
+            if (!Utility.isResourceTypeValid(resType)) {
+                MessageDialog.openError(Display.getDefault().getActiveShell(),
+                        "Invalid Resource Type.",
+                        Constants.INVALID_RESOURCE_TYPE_MESSAGE);
+                return false;
+            }
+
             try {
                 getContainer().run(true, false, new IRunnableWithProgress() {
 
@@ -290,7 +243,11 @@ public class CreateResourceWizard extends Wizard {
                         try {
                             monitor.beginTask("Completing Resource Creation", 2);
                             monitor.worked(1);
-                            completeResourceCreationWithRAML();
+                            if (loadRamlPage.isMultiResourceCreation()) {
+                                completeMultiInstanceResourceCreationWithRAML();
+                            } else {
+                                completeSingleInstanceResourceCreationWithRAML();
+                            }
                             monitor.worked(1);
                         } finally {
                             monitor.done();
@@ -334,6 +291,15 @@ public class CreateResourceWizard extends Wizard {
         return updatePropPage;
     }
 
+    public UpdateMultiInstanceCreationPropertiesPage getUpdateMultiInstanceCreationPropPage() {
+        return updateMultiInstanceCreationPropPage;
+    }
+
+    public void setUpdateMultiInstanceCreationPropPage(
+            UpdateMultiInstanceCreationPropertiesPage updateMultiInstanceCreationPropPage) {
+        this.updateMultiInstanceCreationPropPage = updateMultiInstanceCreationPropPage;
+    }
+
     public void setStatus(String status) {
         this.status = status;
     }
@@ -395,22 +361,23 @@ public class CreateResourceWizard extends Wizard {
         }
     }
 
-    private void completeResourceCreationWithRAML() {
+    private void completeSingleInstanceResourceCreationWithRAML() {
+        String resName = updatePropPage.getResName();
+        String resURI = updatePropPage.getResURI();
+        String resType = updatePropPage.getResType();
+
         try {
             boolean result = false;
-            Resource res = loadRamlPage.getResource();
-            if (res instanceof SingleResource) {
+            if (createdResource instanceof SingleResource) {
                 result = Activator
                         .getDefault()
                         .getResourceManager()
-                        .completeSingleResourceCreationByRAML(res,
-                                updatePropPage.getResURI(),
-                                updatePropPage.getResName(), false);
+                        .completeSingleResourceCreationByRAML(createdResource,
+                                resURI, resName, resType, false);
             }
 
             if (result) {
                 status = "Resource created.";
-                createdResource = res;
             } else {
                 status = "Failed to create resource.";
                 createdResource = null;
@@ -422,47 +389,43 @@ public class CreateResourceWizard extends Wizard {
         }
     }
 
-    private int createMultiInstanceSingleResourceWithoutRAML() {
-        int toCreateCount = loadRamlPage.getResourceCount();
-        int resCreatedCount = 0;
-        Set<SingleResource> resources;
-        try {
-            resources = Activator
-                    .getDefault()
-                    .getResourceManager()
-                    .createSingleResourceMultiInstances(
-                            loadRamlPage.getConfigFilePath(), toCreateCount,
-                            progressMonitor);
-            if (null != progressMonitor && progressMonitor.isCanceled()) {
-                try {
-                    Activator.getDefault().getResourceManager()
-                            .removeSingleResources(resources);
-                } catch (SimulatorException e) {
-                    Activator
-                            .getDefault()
-                            .getLogManager()
-                            .log(Level.ERROR.ordinal(),
-                                    new Date(),
-                                    "There is an error while updating the resource model.\n"
-                                            + Utility.getSimulatorErrorString(
-                                                    e, null));
+    private void completeMultiInstanceResourceCreationWithRAML() {
+        String resName = updateMultiInstanceCreationPropPage.getResName();
+        String resType = updateMultiInstanceCreationPropPage.getResType();
+
+        if (null == multiInstanceResourceSet)
+            return;
+
+        boolean result = false;
+        int count = loadRamlPage.getResourceCount();
+        int successCount = 0;
+        SingleResource resource;
+        Iterator<SingleResource> itr = multiInstanceResourceSet.iterator();
+        while (itr.hasNext()) {
+            resource = itr.next();
+            try {
+                result = Activator
+                        .getDefault()
+                        .getResourceManager()
+                        .completeSingleResourceCreationByRAML(resource, null,
+                                resName, resType, true);
+                if (result) {
+                    successCount++;
                 }
-                return 0;
-            }
-            if (null != resources)
-                resCreatedCount = resources.size();
-            if (resCreatedCount > 0) {
-                status = "[" + resCreatedCount + " out of " + toCreateCount
-                        + "]";
-                status += ((resCreatedCount == 1) ? "resource" : "resources")
-                        + " created successfully.";
-            } else {
-                status = "Failed to create resources.";
+
+            } catch (SimulatorException e) {
+                // Do Nothing.
             }
-        } catch (SimulatorException e) {
-            status = "Failed to create resource.\n"
-                    + Utility.getSimulatorErrorString(e, null);
         }
-        return resCreatedCount;
+        if (successCount > 0) {
+            UiListenerHandler.getInstance().resourceCreatedUINotification(
+                    ResourceType.SINGLE);
+
+            status = "[" + successCount + " out of " + count + "]";
+            status += ((successCount == 1) ? "resource" : "resources")
+                    + " created successfully.";
+        } else {
+            status = "Failed to create resources.";
+        }
     }
 }
\ No newline at end of file
index 0a253eb..8c0c778 100644 (file)
@@ -46,6 +46,7 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.util.Date;
+import java.util.Set;
 
 import org.oic.simulator.ILogger.Level;
 import org.oic.simulator.SimulatorException;
@@ -74,9 +75,12 @@ public class LoadRamlPage extends WizardPage {
     private int                    resourceCount;
 
     private Resource               resource;
+    private Set<SingleResource>    multiInstanceResourceSet;
 
     private SimulatorResource.Type typeOfResource;
 
+    private IProgressMonitor       progressMonitor;
+
     protected LoadRamlPage() {
         super("Create Resource");
         resourceCount = -1;
@@ -217,7 +221,7 @@ public class LoadRamlPage extends WizardPage {
             resourceCount = -1;
         }
         if (null != configFilePath && configFilePath.trim().length() > 0) {
-            if (resourceCount == 1) {
+            if (resourceCount >= 1) {
                 done = true;
             }
         }
@@ -282,57 +286,165 @@ public class LoadRamlPage extends WizardPage {
             return null;
         }
 
+        IWizardPage nextPage;
+        String resName;
+        String resURI;
+        String resType;
         final CreateResourceWizard wizard = ((CreateResourceWizard) getWizard());
+        if (isMultiResourceCreation()) {
+            final int[] resCreatedCount = new int[1];
+            try {
+                getContainer().run(true, true, new IRunnableWithProgress() {
+
+                    @Override
+                    public void run(final IProgressMonitor monitor)
+                            throws InvocationTargetException,
+                            InterruptedException {
+                        progressMonitor = monitor;
+                        try {
+                            monitor.beginTask(
+                                    "Single Resource Creation(multi-instance) With RAML",
+                                    wizard.getLoadRamlPage().getResourceCount());
+                            resCreatedCount[0] = createMultiInstanceSingleResourceWithRAML();
+
+                        } finally {
+                            monitor.done();
+                        }
+                    }
+                });
+            } catch (InvocationTargetException e) {
+                Activator.getDefault().getLogManager()
+                        .log(Level.ERROR.ordinal(), new Date(), e.getMessage());
+                e.printStackTrace();
+            } catch (InterruptedException e) {
+                Activator.getDefault().getLogManager()
+                        .log(Level.ERROR.ordinal(), new Date(), e.getMessage());
+                e.printStackTrace();
+            }
 
-        try {
-            getContainer().run(true, false, new IRunnableWithProgress() {
-                @Override
-                public void run(IProgressMonitor monitor)
-                        throws InvocationTargetException, InterruptedException {
-                    try {
-                        monitor.beginTask("Resource Creation With RAML", 2);
-                        monitor.worked(1);
-                        resource = Activator.getDefault().getResourceManager()
-                                .createResourceByRAML(configFilePath);
-                        monitor.worked(1);
-                    } catch (SimulatorException e) {
-                        wizard.setStatus("Failed to create resource.\n"
-                                + Utility.getSimulatorErrorString(e, null));
-                    } finally {
-                        monitor.done();
+            if (0 == resCreatedCount[0]) {
+                wizard.setStatus("Failed to create Resources.");
+                wizard.getWizardDialog().close();
+                return null;
+            }
+
+            boolean canceled = false;
+            if (null != progressMonitor && progressMonitor.isCanceled()) {
+                canceled = true;
+            }
+            progressMonitor = null;
+            if (canceled) {
+                return null;
+            }
+
+            // It is guaranteed that will be at least one resource at this
+            // point.
+            SingleResource resourceInstance = (SingleResource) multiInstanceResourceSet
+                    .toArray()[0];
+            resName = resourceInstance.getResourceName();
+            resType = resourceInstance.getResourceType();
+            resURI = resourceInstance.getResourceURI();
+            UpdateMultiInstanceCreationPropertiesPage updatePageRef = wizard
+                    .getUpdateMultiInstanceCreationPropPage();
+            updatePageRef.setResName(resName);
+            updatePageRef.setResType(resType);
+            nextPage = updatePageRef;
+        } else {
+            try {
+                getContainer().run(true, false, new IRunnableWithProgress() {
+                    @Override
+                    public void run(IProgressMonitor monitor)
+                            throws InvocationTargetException,
+                            InterruptedException {
+                        try {
+                            monitor.beginTask("Resource Creation With RAML", 2);
+                            monitor.worked(1);
+                            resource = Activator.getDefault()
+                                    .getResourceManager()
+                                    .createResourceByRAML(configFilePath);
+                            monitor.worked(1);
+                        } catch (SimulatorException e) {
+                            wizard.setStatus("Failed to create resource.\n"
+                                    + Utility.getSimulatorErrorString(e, null));
+                        } finally {
+                            monitor.done();
+                        }
                     }
+                });
+            } catch (InvocationTargetException e) {
+                Activator.getDefault().getLogManager()
+                        .log(Level.ERROR.ordinal(), new Date(), e.getMessage());
+                e.printStackTrace();
+            } catch (InterruptedException e) {
+                Activator.getDefault().getLogManager()
+                        .log(Level.ERROR.ordinal(), new Date(), e.getMessage());
+                e.printStackTrace();
+            }
+            if (null == resource) {
+                wizard.setStatus("Failed to create Resource.");
+                wizard.getWizardDialog().close();
+                return null;
+            } else {
+                // Checking whether the resource is of type single.
+                Option intendedResource = wizard.getMainPage().getOption();
+                if ((intendedResource == Option.SIMPLE_FROM_RAML && !(resource instanceof SingleResource))) {
+                    MessageDialog
+                            .openError(
+                                    getShell(),
+                                    "Invalid RAML",
+                                    "Uploaded RAML is not of simple type. "
+                                            + "Please upload the proper RAML of simple type.");
+                    return null;
                 }
-            });
-        } catch (InvocationTargetException e) {
-            Activator.getDefault().getLogManager()
-                    .log(Level.ERROR.ordinal(), new Date(), e.getMessage());
-            e.printStackTrace();
-        } catch (InterruptedException e) {
-            Activator.getDefault().getLogManager()
-                    .log(Level.ERROR.ordinal(), new Date(), e.getMessage());
-            e.printStackTrace();
+            }
+            resName = resource.getResourceName();
+            resURI = resource.getResourceURI();
+            resType = resource.getResourceType();
+            UpdatePropertiesPage updatePageRef = wizard.getUpdatePropPage();
+            updatePageRef.setResName(resName);
+            updatePageRef.setResURI(resURI);
+            updatePageRef.setResType(resType);
+            nextPage = updatePageRef;
         }
-        if (null == resource) {
-            wizard.setStatus("Failed to create Resource.");
-            wizard.getWizardDialog().close();
-            return null;
-        } else {
-            // Checking whether the resource is of type single.
-            Option intendedResource = wizard.getMainPage().getOption();
-            if ((intendedResource == Option.SIMPLE_FROM_RAML && !(resource instanceof SingleResource))) {
-                MessageDialog
-                        .openError(
-                                getShell(),
-                                "Invalid RAML",
-                                "Uploaded RAML is not of simple type. "
-                                        + "Please upload the proper RAML of simple type.");
-                return null;
+        return nextPage;
+    }
+
+    public int createMultiInstanceSingleResourceWithRAML() {
+        int resCreatedCount = 0;
+        try {
+            multiInstanceResourceSet = Activator
+                    .getDefault()
+                    .getResourceManager()
+                    .createSingleResourceMultiInstances(configFilePath,
+                            resourceCount, progressMonitor);
+            if (null != progressMonitor && progressMonitor.isCanceled()) {
+                try {
+                    Activator.getDefault().getResourceManager()
+                            .removeSingleResources(multiInstanceResourceSet);
+                } catch (SimulatorException e) {
+                    Activator
+                            .getDefault()
+                            .getLogManager()
+                            .log(Level.ERROR.ordinal(),
+                                    new Date(),
+                                    "There is an error while handling the cancellation request.\n"
+                                            + Utility.getSimulatorErrorString(
+                                                    e, null));
+                }
+                return 0;
             }
+            if (null != multiInstanceResourceSet)
+                resCreatedCount = multiInstanceResourceSet.size();
+        } catch (SimulatorException e) {
+            Activator
+                    .getDefault()
+                    .getLogManager()
+                    .log(Level.ERROR.ordinal(),
+                            new Date(),
+                            "Failed to create resource(s).\n"
+                                    + Utility.getSimulatorErrorString(e, null));
         }
-        UpdatePropertiesPage updatePageRef = wizard.getUpdatePropPage();
-        updatePageRef.setResName(resource.getResourceName());
-        updatePageRef.setResURI(resource.getResourceURI());
-        return updatePageRef;
+        return resCreatedCount;
     }
 
     public String getConfigFilePath() {
@@ -350,4 +462,12 @@ public class LoadRamlPage extends WizardPage {
     public void setResource(Resource resource) {
         this.resource = resource;
     }
+
+    public Set<SingleResource> getMultiInstanceResourceSet() {
+        return multiInstanceResourceSet;
+    }
+
+    public void setMultiInstanceResourceSet(Set<SingleResource> resource) {
+        multiInstanceResourceSet = resource;
+    }
 }
\ No newline at end of file
index df8b03d..cf5514c 100644 (file)
@@ -58,6 +58,8 @@ public class ResourceWizardDialog extends WizardDialog {
             LoadRamlPage loadRamlPage = createWizard.getLoadRamlPage();
             UpdatePropertiesPage updatePropPage = createWizard
                     .getUpdatePropPage();
+            UpdateMultiInstanceCreationPropertiesPage updateMultiInstanceCreationPropPage = createWizard
+                    .getUpdateMultiInstanceCreationPropPage();
 
             IWizardPage curPage = wizard.getContainer().getCurrentPage();
             IWizardPage prevPage = null;
@@ -65,8 +67,10 @@ public class ResourceWizardDialog extends WizardDialog {
             if (curPage == loadRamlPage
                     || curPage == simpleResourceBasicDetailsPage) {
                 prevPage = mainPage;
-            } else if (curPage == updatePropPage) {
+            } else if (curPage == updatePropPage
+                    || curPage == updateMultiInstanceCreationPropPage) {
                 loadRamlPage.setResource(null);
+                loadRamlPage.setMultiInstanceResourceSet(null);
                 prevPage = loadRamlPage;
             } else if (curPage == simpleResourceAddAttributesPage) {
                 prevPage = simpleResourceBasicDetailsPage;
diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/UpdateMultiInstanceCreationPropertiesPage.java b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/UpdateMultiInstanceCreationPropertiesPage.java
new file mode 100644 (file)
index 0000000..6365916
--- /dev/null
@@ -0,0 +1,181 @@
+/*
+ * Copyright 2016 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 oic.simulator.serviceprovider.view.dialogs;
+
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+import oic.simulator.serviceprovider.utils.Constants;
+
+public class UpdateMultiInstanceCreationPropertiesPage extends WizardPage {
+
+    private Text   resNameTxt;
+    private Text   resTypeTxt;
+
+    private String resName;
+    private String resType;
+
+    protected UpdateMultiInstanceCreationPropertiesPage() {
+        super("Update Properties");
+    }
+
+    @Override
+    public void createControl(Composite parent) {
+        setPageComplete(true);
+        setTitle(Constants.UPDATE_PROP_PAGE_TITLE);
+        setMessage(Constants.UPDATE_PROP_PAGE_MESSAGE);
+
+        Composite comp = new Composite(parent, SWT.NONE);
+        GridLayout gridLayout = new GridLayout();
+        comp.setLayout(gridLayout);
+        GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+        comp.setLayoutData(gd);
+
+        Group grp = new Group(comp, SWT.NONE);
+        gridLayout = new GridLayout(2, false);
+        grp.setLayout(gridLayout);
+        gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+        grp.setLayoutData(gd);
+
+        Label resNameLbl = new Label(grp, SWT.NULL);
+        resNameLbl.setText("Resource Name");
+        gd = new GridData();
+        gd.verticalIndent = 20;
+        resNameLbl.setLayoutData(gd);
+
+        resNameTxt = new Text(grp, SWT.BORDER);
+        resNameTxt.setFocus();
+        gd = new GridData();
+        gd.widthHint = 300;
+        gd.verticalIndent = 20;
+        resNameTxt.setLayoutData(gd);
+
+        Label resTypeLbl = new Label(grp, SWT.NULL);
+        resTypeLbl.setText("Resource Type");
+        gd = new GridData();
+        gd.verticalIndent = 10;
+        resTypeLbl.setLayoutData(gd);
+
+        resTypeTxt = new Text(grp, SWT.BORDER);
+        gd = new GridData();
+        gd.widthHint = 300;
+        gd.verticalIndent = 10;
+        resTypeTxt.setLayoutData(gd);
+
+        Label descLbl = new Label(comp, SWT.NONE);
+        descLbl.setText("Description:");
+        gd = new GridData();
+        descLbl.setLayoutData(gd);
+
+        final Text text = new Text(comp, SWT.MULTI | SWT.READ_ONLY | SWT.BORDER
+                | SWT.WRAP | SWT.V_SCROLL);
+        text.setText("All resource instances will be configured with the same resource name and type.\n"
+                + "These properties can be changed later from properties view.");
+        gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+        text.setLayoutData(gd);
+
+        addUIListeners();
+
+        // Initialize data
+        if (resNameTxt.getText().length() < 1 && null != resName) {
+            resNameTxt.setText(resName);
+        }
+        if (resTypeTxt.getText().length() < 1 && null != resType) {
+            resTypeTxt.setText(resType);
+        }
+
+        setControl(comp);
+    }
+
+    private void addUIListeners() {
+        resNameTxt.addModifyListener(new ModifyListener() {
+            @Override
+            public void modifyText(ModifyEvent e) {
+                resName = resNameTxt.getText();
+                setPageComplete(isSelectionDone());
+            }
+        });
+
+        resTypeTxt.addModifyListener(new ModifyListener() {
+            @Override
+            public void modifyText(ModifyEvent e) {
+                resType = resTypeTxt.getText();
+                if (null == resType) {
+                    return;
+                }
+
+                setPageComplete(isSelectionDone());
+            }
+        });
+    }
+
+    @Override
+    public boolean canFlipToNextPage() {
+        return false;
+    }
+
+    public boolean isSelectionDone() {
+        boolean done = false;
+        if (null != resName && resName.trim().length() > 0 && null != resType
+                && resType.trim().length() > 0) {
+            done = true;
+        }
+        return done;
+    }
+
+    @Override
+    public IWizardPage getNextPage() {
+        return null;
+    }
+
+    public void setResName(String resName) {
+        if (null == resName) {
+            resName = "";
+        }
+
+        this.resName = resName;
+        if (null != resName && !resNameTxt.isDisposed())
+            resNameTxt.setText(resName);
+    }
+
+    public void setResType(String resType) {
+        if (null == resType) {
+            resType = "";
+        }
+
+        this.resType = resType;
+        if (null != resType && !resTypeTxt.isDisposed())
+            resTypeTxt.setText(resType);
+    }
+
+    public String getResName() {
+        return resName;
+    }
+
+    public String getResType() {
+        return resType;
+    }
+}
index b7628a6..af6b582 100644 (file)
@@ -34,9 +34,11 @@ public class UpdatePropertiesPage extends WizardPage {
 
     private Text   resNameTxt;
     private Text   resUriTxt;
+    private Text   resTypeTxt;
 
     private String resName;
     private String resURI;
+    private String resType;
 
     protected UpdatePropertiesPage() {
         super("Update Properties");
@@ -85,6 +87,18 @@ public class UpdatePropertiesPage extends WizardPage {
         gd.verticalIndent = 10;
         resUriTxt.setLayoutData(gd);
 
+        Label resTypeLbl = new Label(grp, SWT.NULL);
+        resTypeLbl.setText("Resource Type");
+        gd = new GridData();
+        gd.verticalIndent = 10;
+        resTypeLbl.setLayoutData(gd);
+
+        resTypeTxt = new Text(grp, SWT.BORDER);
+        gd = new GridData();
+        gd.widthHint = 300;
+        gd.verticalIndent = 10;
+        resTypeTxt.setLayoutData(gd);
+
         Label descLbl = new Label(comp, SWT.NONE);
         descLbl.setText("Description:");
         gd = new GridData();
@@ -105,6 +119,9 @@ public class UpdatePropertiesPage extends WizardPage {
         if (resNameTxt.getText().length() < 1 && null != resName) {
             resNameTxt.setText(resName);
         }
+        if (resTypeTxt.getText().length() < 1 && null != resType) {
+            resTypeTxt.setText(resType);
+        }
 
         setControl(comp);
     }
@@ -129,6 +146,18 @@ public class UpdatePropertiesPage extends WizardPage {
                 setPageComplete(isSelectionDone());
             }
         });
+
+        resTypeTxt.addModifyListener(new ModifyListener() {
+            @Override
+            public void modifyText(ModifyEvent e) {
+                resType = resTypeTxt.getText();
+                if (null == resType) {
+                    return;
+                }
+
+                setPageComplete(isSelectionDone());
+            }
+        });
     }
 
     @Override
@@ -139,7 +168,8 @@ public class UpdatePropertiesPage extends WizardPage {
     public boolean isSelectionDone() {
         boolean done = false;
         if (null != resName && resName.trim().length() > 0 && null != resURI
-                && resURI.trim().length() > 0) {
+                && resURI.trim().length() > 0 && null != resType
+                && resType.trim().length() > 0) {
             done = true;
         }
         return done;
@@ -151,17 +181,35 @@ public class UpdatePropertiesPage extends WizardPage {
     }
 
     public void setResName(String resName) {
+        if (null == resName) {
+            resName = "";
+        }
+
         this.resName = resName;
-        if (!resNameTxt.isDisposed())
+        if (null != resName && !resNameTxt.isDisposed())
             resNameTxt.setText(resName);
     }
 
     public void setResURI(String resURI) {
+        if (null == resURI) {
+            resURI = "";
+        }
+
         this.resURI = resURI;
-        if (!resUriTxt.isDisposed())
+        if (null != resUriTxt && !resUriTxt.isDisposed())
             resUriTxt.setText(resURI);
     }
 
+    public void setResType(String resType) {
+        if (null == resType) {
+            resType = "";
+        }
+
+        this.resType = resType;
+        if (null != resType && !resTypeTxt.isDisposed())
+            resTypeTxt.setText(resType);
+    }
+
     public String getResName() {
         return resName;
     }
@@ -169,4 +217,8 @@ public class UpdatePropertiesPage extends WizardPage {
     public String getResURI() {
         return resURI;
     }
+
+    public String getResType() {
+        return resType;
+    }
 }
index 15bc6ff..061f872 100644 (file)
@@ -177,22 +177,6 @@ std::shared_ptr<SimulatorResource> SimulatorResourceFactory::buildResource(
         resourceModel.remove("resourceType");\r
     }\r
 \r
-    // Construct resource type from uri\r
-    if(resourceType.empty())\r
-    {\r
-        std::ostringstream rtString;\r
-        rtString << "oic.r.";\r
-\r
-        size_t pos = resourceURI.rfind("/");\r
-        if (pos == std::string::npos)\r
-            pos = -1;\r
-\r
-        std::string rtName = resourceURI.substr(pos+1);\r
-        std::transform(rtName.begin(), rtName.end(), rtName.begin(), ::tolower);\r
-        rtString << rtName;\r
-        resourceType = rtString.str();\r
-    }\r
-\r
     // Extracting interface type.\r
     std::vector<std::string> interfaceTypes;\r
     if (resourceModel.contains("if"))\r
@@ -236,7 +220,8 @@ std::shared_ptr<SimulatorResource> SimulatorResourceFactory::buildResource(
             new SimulatorCollectionResourceImpl());\r
 \r
         collectionRes->setName(resourceName);\r
-        collectionRes->setResourceType(resourceType);\r
+        if(!resourceType.empty())\r
+            collectionRes->setResourceType(resourceType);\r
         if (interfaceTypes.size() > 0)\r
             collectionRes->setInterface(interfaceTypes);\r
         collectionRes->setURI(ResourceURIFactory::getInstance()->makeUniqueURI(resourceURI));\r
@@ -254,7 +239,8 @@ std::shared_ptr<SimulatorResource> SimulatorResourceFactory::buildResource(
             new SimulatorSingleResourceImpl());\r
 \r
         singleRes->setName(resourceName);\r
-        singleRes->setResourceType(resourceType);\r
+        if(!resourceType.empty())\r
+            singleRes->setResourceType(resourceType);\r
         if (interfaceTypes.size() > 0)\r
             singleRes->setInterface(interfaceTypes);\r
         singleRes->setURI(ResourceURIFactory::getInstance()->makeUniqueURI(resourceURI));\r
index 7285e13..f9ccdf9 100644 (file)
@@ -39,9 +39,15 @@ linux_sample_env.AppendUnique(CPPPATH = ['../../../sdk/src'])
 linux_sample_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
 linux_sample_env.AppendUnique(CPPDEFINES = ['LINUX'])
 linux_sample_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-linux_sample_env.AppendUnique(LIBS = ['libTGMSDKLibrary', 'oc', 'octbstack',
-                                      'connectivity_abstraction',
-                                      'libcoap', 'liboc_logger', 'dl', 'pthread'])
+linux_sample_env.PrependUnique(LIBS = ['coap'])
+linux_sample_env.AppendUnique(LIBS = ['connectivity_abstraction'])
+linux_sample_env.AppendUnique(LIBS = ['oc_logger'])
+linux_sample_env.AppendUnique(LIBS = ['octbstack'])
+linux_sample_env.AppendUnique(LIBS = ['oc'])
+linux_sample_env.AppendUnique(LIBS = ['libTGMSDKLibrary'])
+linux_sample_env.AppendUnique(LIBS = ['dl'])
+linux_sample_env.AppendUnique(LIBS = ['pthread'])
+
 if env.get('SECURED') == '1':
     linux_sample_env.AppendUnique(LIBS = ['tinydtls'])
 
index e1bd784..461103a 100644 (file)
@@ -77,11 +77,12 @@ if target_os not in ['windows', 'winrt']:
 
 ThingsManager_gtest_env.PrependUnique(LIBS = [
     'libTGMSDKLibrary',
-    'oc',
-    'octbstack',
+    'coap',
+    'connectivity_abstraction',
     'oc_logger',
     'oc_logger_core',
-    'connectivity_abstraction',
+    'oc',
+    'octbstack',
     gtest,
     gtest_main])
 
@@ -101,4 +102,4 @@ if env.get('TEST') == '1':
     if target_os == 'linux':
         from tools.scons.RunTest import *
         run_test(ThingsManager_gtest_env, '',
-                'service/things-manager/unittests/ThingsManagerTest')
\ No newline at end of file
+                'service/things-manager/unittests/ThingsManagerTest')