From 6e44d2470f553bccdde26e95cc8cfc19efbcad27 Mon Sep 17 00:00:00 2001 From: "jihwan.seo" Date: Thu, 14 May 2015 19:17:59 +0900 Subject: [PATCH] replace 'org_iotivity' with 'org_iotivity_ca' and change java file name - replace 'org_iotivity' with 'org_iotivity_ca' - change java file name for android callback interface - android EDR interface code is added - android BLE code had been separated since Gatt Server can be only supported after Android v5.0 and interface of LE client can only be supported until v4.4 - COPY: resource/csdk/connectivity/samples/android /sample_service/src/org/iotivity/ca/< CaEdrInterface.java & CaIpInterface.java & CaLeClientInterface.java & CaLeServerInterface.java> PASTE to: /android/android_api/base/src/main/java /org/iotivity/ca/ Change-Id: I77b605313f73f3b2677d05e99a047f541cfcda14 Signed-off-by: jihwan.seo Reviewed-on: https://gerrit.iotivity.org/gerrit/990 Tested-by: jenkins-iotivity Reviewed-by: Jaehong Jo Reviewed-by: Erich Keane --- .../main/java/org/iotivity/ca/CaEdrInterface.java | 87 ++++++ .../main/java/org/iotivity/ca/CaIpInterface.java | 52 ++-- .../java/org/iotivity/ca/CaLeClientInterface.java | 294 ++++++++++++++++++ .../java/org/iotivity/ca/CaLeServerInterface.java | 195 ++++++++++++ .../android/sample_service/AndroidManifest.xml | 4 +- .../android/sample_service/jni/ResourceModel.c | 34 +- .../jni/org_iotivity_ca_service_RMInterface.h | 134 ++++++++ .../jni/org_iotivity_service_RMInterface.h | 134 -------- .../sample_service/res/layout/activity_main.xml | 2 +- .../android/sample_service/res/menu/main.xml | 2 +- .../src/org/iotivity/ca/CaEdrInterface.java | 87 ++++++ .../src/org/iotivity/ca/CaIpInterface.java | 50 ++- .../src/org/iotivity/ca/CaLeClientInterface.java | 294 ++++++++++++++++++ .../src/org/iotivity/ca/CaLeServerInterface.java | 180 +++++++++++ .../src/org/iotivity/{ => ca}/service/DLog.java | 2 +- .../iotivity/{ => ca}/service/MainActivity.java | 4 +- .../org/iotivity/{ => ca}/service/RMInterface.java | 6 +- .../src/org/iotivity/jar/CALeInterface.java | 343 --------------------- .../src/org/iotivity/jar/caipinterface.java | 55 ---- .../src/bt_edr_adapter/android/caedrclient.c | 8 +- .../src/bt_edr_adapter/android/caedrnwmonitor.c | 10 +- .../src/bt_edr_adapter/android/caedrserver.c | 2 +- .../android/org_iotivity_ca_CaEdrInterface.h | 51 +++ .../android/org_iotivity_jar_caedrinterface.h | 31 -- .../src/bt_le_adapter/android/caleclient.c | 60 ++-- .../src/bt_le_adapter/android/calenwmonitor.c | 10 +- .../src/bt_le_adapter/android/caleserver.c | 62 ++-- .../android/org_iotivity_ca_CaLeClientInterface.h | 161 ++++++++++ .../android/org_iotivity_ca_CaLeServerInterface.h | 149 +++++++++ .../android/org_iotivity_jar_caleclientinterface.h | 141 --------- .../android/org_iotivity_jar_caleserverinterface.h | 129 -------- .../src/ip_adapter/android/caipnwmonitor.c | 42 +-- .../android/org_iotivity_ca_CaIpInterface.h | 40 ++- 33 files changed, 1837 insertions(+), 1018 deletions(-) create mode 100644 android/android_api/base/src/main/java/org/iotivity/ca/CaEdrInterface.java create mode 100644 android/android_api/base/src/main/java/org/iotivity/ca/CaLeClientInterface.java create mode 100644 android/android_api/base/src/main/java/org/iotivity/ca/CaLeServerInterface.java create mode 100644 resource/csdk/connectivity/samples/android/sample_service/jni/org_iotivity_ca_service_RMInterface.h delete mode 100644 resource/csdk/connectivity/samples/android/sample_service/jni/org_iotivity_service_RMInterface.h create mode 100644 resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/ca/CaEdrInterface.java create mode 100644 resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/ca/CaLeClientInterface.java create mode 100644 resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/ca/CaLeServerInterface.java rename resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/{ => ca}/service/DLog.java (98%) rename resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/{ => ca}/service/MainActivity.java (99%) rename resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/{ => ca}/service/RMInterface.java (89%) delete mode 100644 resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/jar/CALeInterface.java delete mode 100644 resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/jar/caipinterface.java create mode 100644 resource/csdk/connectivity/src/bt_edr_adapter/android/org_iotivity_ca_CaEdrInterface.h delete mode 100644 resource/csdk/connectivity/src/bt_edr_adapter/android/org_iotivity_jar_caedrinterface.h create mode 100644 resource/csdk/connectivity/src/bt_le_adapter/android/org_iotivity_ca_CaLeClientInterface.h create mode 100644 resource/csdk/connectivity/src/bt_le_adapter/android/org_iotivity_ca_CaLeServerInterface.h delete mode 100644 resource/csdk/connectivity/src/bt_le_adapter/android/org_iotivity_jar_caleclientinterface.h delete mode 100644 resource/csdk/connectivity/src/bt_le_adapter/android/org_iotivity_jar_caleserverinterface.h diff --git a/android/android_api/base/src/main/java/org/iotivity/ca/CaEdrInterface.java b/android/android_api/base/src/main/java/org/iotivity/ca/CaEdrInterface.java new file mode 100644 index 0000000..1e4d47c --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/ca/CaEdrInterface.java @@ -0,0 +1,87 @@ +/****************************************************************** + * + * Copyright 2014 Samsung Electronics All Rights Reserved. + * + * + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************/ + +package org.iotivity.ca; + +import android.bluetooth.BluetoothAdapter; +import android.bluetooth.BluetoothDevice; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; + +public class CaEdrInterface { + + private CaEdrInterface(Context context) { + + registerIntentFilter(context); + } + + private static IntentFilter registerIntentFilter(Context context) { + IntentFilter filter = new IntentFilter(); + filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); + filter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED); + context.registerReceiver(mReceiver, filter); + return filter; + } + + // Network Monitor + private native static void caEdrStateChangedCallback(int state); + + private native static void caEdrBondStateChangedCallback(String addr); + + private static final BroadcastReceiver mReceiver = new BroadcastReceiver() { + + @Override + public void onReceive(Context context, Intent intent) { + + String action = intent.getAction(); + + if (action != null && action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) { + + int state = + intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR); + + // STATE_ON:12, STATE_OFF:10 + if (state == BluetoothAdapter.STATE_ON || state == BluetoothAdapter.STATE_OFF) + { + caEdrStateChangedCallback(state); + } + } + + if (action != null && action.equals(BluetoothDevice.ACTION_BOND_STATE_CHANGED)) { + + int bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, + BluetoothDevice.ERROR); + + if (bondState == BluetoothDevice.BOND_NONE) { + if ((intent.getIntExtra(BluetoothDevice.EXTRA_PREVIOUS_BOND_STATE, + BluetoothDevice.ERROR) + == BluetoothDevice.BOND_BONDED)) { + BluetoothDevice device + = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); + + caEdrBondStateChangedCallback(device.getAddress()); + } + } + } + } + }; +} diff --git a/android/android_api/base/src/main/java/org/iotivity/ca/CaIpInterface.java b/android/android_api/base/src/main/java/org/iotivity/ca/CaIpInterface.java index 43d0ace..1e807d1 100644 --- a/android/android_api/base/src/main/java/org/iotivity/ca/CaIpInterface.java +++ b/android/android_api/base/src/main/java/org/iotivity/ca/CaIpInterface.java @@ -1,24 +1,22 @@ -/* - * //****************************************************************** - * // - * // 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 2014 Samsung Electronics All Rights Reserved. + * + * + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************/ package org.iotivity.ca; @@ -50,21 +48,21 @@ public class CaIpInterface { @Override public void onReceive(Context context, Intent intent) { if (intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, - WifiManager.WIFI_STATE_UNKNOWN) == WifiManager.WIFI_STATE_DISABLED) { - stateDisabled(); + WifiManager.WIFI_STATE_UNKNOWN) == WifiManager.WIFI_STATE_DISABLED) { + caIpStateDisabled(); } else if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) { ConnectivityManager manager = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo nwInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if(nwInfo.isConnected()) { - stateEnabled(); + caIpStateEnabled(); } } } }; - private native static void stateEnabled(); + private native static void caIpStateEnabled(); - private native static void stateDisabled(); -} \ No newline at end of file + private native static void caIpStateDisabled(); +} diff --git a/android/android_api/base/src/main/java/org/iotivity/ca/CaLeClientInterface.java b/android/android_api/base/src/main/java/org/iotivity/ca/CaLeClientInterface.java new file mode 100644 index 0000000..42165f2 --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/ca/CaLeClientInterface.java @@ -0,0 +1,294 @@ +/****************************************************************** + * + * Copyright 2014 Samsung Electronics All Rights Reserved. + * + * + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************/ + +package org.iotivity.ca; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import android.bluetooth.BluetoothAdapter; +import android.bluetooth.BluetoothDevice; +import android.bluetooth.BluetoothGatt; +import android.bluetooth.BluetoothGattCallback; +import android.bluetooth.BluetoothGattCharacteristic; +import android.bluetooth.BluetoothGattDescriptor; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.util.Log; + +public class CaLeClientInterface { + + private static String SERVICE_UUID = "713d0000-503e-4c75-ba94-3148f18d941e"; + + private CaLeClientInterface(Context context) { + + caLeRegisterLeScanCallback(mLeScanCallback); + caLeRegisterGattCallback(mGattCallback); + + registerIntentFilter(context); + } + + public static void getLeScanCallback() { + caLeRegisterLeScanCallback(mLeScanCallback); + } + + public static void getLeGattCallback() { + caLeRegisterGattCallback(mGattCallback); + } + + private static IntentFilter registerIntentFilter(Context context) { + IntentFilter filter = new IntentFilter(); + filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); + filter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED); + context.registerReceiver(mReceiver, filter); + return filter; + } + + private native static void caLeRegisterLeScanCallback(BluetoothAdapter.LeScanCallback callback); + + private native static void caLeRegisterGattCallback(BluetoothGattCallback callback); + + // BluetoothAdapter.LeScanCallback + private native static void caLeScanCallback(BluetoothDevice device, + int rssi, byte[] scanRecord); + + // BluetoothGattCallback + private native static void caLeGattConnectionStateChangeCallback( + BluetoothGatt gatt, int status, int newState); + + private native static void caLeGattServicesDiscoveredCallback(BluetoothGatt gatt, int status); + + private native static void caLeGattCharacteristicReadCallback( + BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, + byte[] data, int status); + + private native static void caLeGattCharacteristicWriteCallback( + BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, + byte[] data, int status); + + private native static void caLeGattCharacteristicChangedCallback( + BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, byte[] data); + + private native static void caLeGattDescriptorReadCallback(BluetoothGatt gatt, + BluetoothGattDescriptor descriptor, + int status); + + private native static void caLeGattDescriptorWriteCallback(BluetoothGatt gatt, + BluetoothGattDescriptor descriptor, + int status); + + private native static void caLeGattReliableWriteCompletedCallback(BluetoothGatt gatt, + int status); + + private native static void caLeGattReadRemoteRssiCallback(BluetoothGatt gatt, int rssi, + int status); + + // Network Monitor + private native static void caLeStateChangedCallback(int state); + + // bond state + private native static void caLeBondStateChangedCallback(String address); + + // Callback + private static BluetoothAdapter.LeScanCallback mLeScanCallback = + new BluetoothAdapter.LeScanCallback() { + + @Override + public void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord) { + + try { + List uuids = getUuids(scanRecord); + for (UUID uuid : uuids) { + Log.d("CA", "UUID : " + uuid.toString()); + if(uuid.toString().contains(SERVICE_UUID)) { + Log.d("CA", "we found that has the Device"); + caLeScanCallback(device, rssi, scanRecord); + } + } + } catch(UnsatisfiedLinkError e) { + + } + } + }; + + private static List getUuids(final byte[] scanRecord) { + List uuids = new ArrayList(); + + int offset = 0; + while (offset < (scanRecord.length - 2)) { + int len = scanRecord[offset++]; + if (len == 0) + break; + + int type = scanRecord[offset++]; + + switch (type) { + case 0x02: + case 0x03: + while (len > 1) { + int uuid16 = scanRecord[offset++]; + uuid16 += (scanRecord[offset++] << 8); + len -= 2; + uuids.add(UUID.fromString(String.format( + "%08x-0000-1000-8000-00805f9b34fb", uuid16))); + } + break; + case 0x06: + case 0x07: + while (len >= 16) { + try { + ByteBuffer buffer = ByteBuffer.wrap(scanRecord, offset++, 16). + order(ByteOrder.LITTLE_ENDIAN); + long mostSigBits = buffer.getLong(); + long leastSigBits = buffer.getLong(); + uuids.add(new UUID(leastSigBits, mostSigBits)); + } catch (IndexOutOfBoundsException e) { + Log.e("CA", e.toString()); + continue; + } finally { + offset += 15; + len -= 16; + } + } + break; + default: + offset += (len - 1); + break; + } + } + return uuids; + } + + private static final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() { + + @Override + public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) { + super.onConnectionStateChange(gatt, status, newState); + + caLeGattConnectionStateChangeCallback(gatt, status, newState); + } + + @Override + public void onServicesDiscovered(BluetoothGatt gatt, int status) { + super.onServicesDiscovered(gatt, status); + + caLeGattServicesDiscoveredCallback(gatt, status); + } + + @Override + public void onCharacteristicRead(BluetoothGatt gatt, + BluetoothGattCharacteristic characteristic, int status) { + super.onCharacteristicRead(gatt, characteristic, status); + + caLeGattCharacteristicReadCallback(gatt, characteristic, + characteristic.getValue(), status); + } + + @Override + public void onCharacteristicWrite(BluetoothGatt gatt, + BluetoothGattCharacteristic characteristic, int status) { + super.onCharacteristicWrite(gatt, characteristic, status); + + caLeGattCharacteristicWriteCallback(gatt, characteristic, + characteristic.getValue(), status); + } + + @Override + public void onCharacteristicChanged(BluetoothGatt gatt, + BluetoothGattCharacteristic characteristic) { + super.onCharacteristicChanged(gatt, characteristic); + + caLeGattCharacteristicChangedCallback(gatt, characteristic, + characteristic.getValue()); + } + + @Override + public void onDescriptorRead(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, + int status) { + super.onDescriptorRead(gatt, descriptor, status); + + caLeGattDescriptorReadCallback(gatt, descriptor, status); + } + + @Override + public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, + int status) { + super.onDescriptorWrite(gatt, descriptor, status); + + caLeGattDescriptorWriteCallback(gatt, descriptor, status); + } + + @Override + public void onReliableWriteCompleted(BluetoothGatt gatt, int status) { + super.onReliableWriteCompleted(gatt, status); + + caLeGattReliableWriteCompletedCallback(gatt, status); + } + + @Override + public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status) { + super.onReadRemoteRssi(gatt, rssi, status); + + caLeGattReadRemoteRssiCallback(gatt, rssi, status); + } + }; + + private static final BroadcastReceiver mReceiver = new BroadcastReceiver() { + + @Override + public void onReceive(Context context, Intent intent) { + + String action = intent.getAction(); + + if (action != null && action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) { + + int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, + BluetoothAdapter.ERROR); + + if (state == BluetoothAdapter.STATE_ON || state == BluetoothAdapter.STATE_OFF) + { + caLeStateChangedCallback(state); + } + } + + if (action != null && action.equals(BluetoothDevice.ACTION_BOND_STATE_CHANGED)) { + + int bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, + BluetoothDevice.ERROR); + + if (bondState == BluetoothDevice.BOND_NONE) { + if ((intent.getIntExtra(BluetoothDevice.EXTRA_PREVIOUS_BOND_STATE, + BluetoothDevice.ERROR) == BluetoothDevice.BOND_BONDED)) { + BluetoothDevice device = intent + .getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); + + caLeBondStateChangedCallback(device.getAddress()); + } + } + } + } + }; +} + diff --git a/android/android_api/base/src/main/java/org/iotivity/ca/CaLeServerInterface.java b/android/android_api/base/src/main/java/org/iotivity/ca/CaLeServerInterface.java new file mode 100644 index 0000000..3cbf0f2 --- /dev/null +++ b/android/android_api/base/src/main/java/org/iotivity/ca/CaLeServerInterface.java @@ -0,0 +1,195 @@ +/****************************************************************** + * + * Copyright 2014 Samsung Electronics All Rights Reserved. + * + * + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************/ + +package org.iotivity.ca; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import android.bluetooth.BluetoothAdapter; +import android.bluetooth.BluetoothDevice; +import android.bluetooth.BluetoothGatt; +import android.bluetooth.BluetoothGattCallback; +import android.bluetooth.BluetoothGattCharacteristic; +import android.bluetooth.BluetoothGattDescriptor; +import android.bluetooth.BluetoothGattServerCallback; +import android.bluetooth.BluetoothGattService; +import android.bluetooth.le.AdvertiseCallback; +import android.bluetooth.le.AdvertiseSettings; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.util.Log; + +public class CaLeServerInterface { + + private CaLeServerInterface() { + + caLeRegisterGattServerCallback(mGattServerCallback); + caLeRegisterBluetoothLeAdvertiseCallback(mAdvertiseCallback); + } + + public static void getLeGattServerCallback() { + caLeRegisterGattServerCallback(mGattServerCallback); + } + + public static void getBluetoothLeAdvertiseCallback() { + caLeRegisterBluetoothLeAdvertiseCallback(mAdvertiseCallback); + } + + private native static void caLeRegisterGattServerCallback(BluetoothGattServerCallback callback); + + private native static void caLeRegisterBluetoothLeAdvertiseCallback(AdvertiseCallback callback); + + // BluetoothGattServerCallback + private native static void caLeGattServerConnectionStateChangeCallback( + BluetoothDevice device, int status, int newState); + + private native static void caLeGattServerServiceAddedCallback(int status, + BluetoothGattService service); + + private native static void caLeGattServerCharacteristicReadRequestCallback( + BluetoothDevice device, + int requestId, int offset, BluetoothGattCharacteristic characteristic, byte[] data); + + private native static void caLeGattServerCharacteristicWriteRequestCallback( + BluetoothDevice device, int requestId, + BluetoothGattCharacteristic characteristic, byte[] data, boolean preparedWrite, + boolean responseNeeded, int offset, byte[] value); + + private native static void caLeGattServerDescriptorReadRequestCallback( + BluetoothDevice device, int requestId, int offset, BluetoothGattDescriptor descriptor); + + public native static void caLeGattServerDescriptorWriteRequestCallback( + BluetoothDevice device, int requestId, BluetoothGattDescriptor descriptor, + boolean preparedWrite, boolean responseNeeded, int offset, byte[] value); + + private native static void caLeGattServerExecuteWriteCallback(BluetoothDevice device, + int requestId, boolean execute); + + private native static void caLeGattServerNotificationSentCallback(BluetoothDevice device, + int status); + + // AdvertiseCallback + private native static void caLeAdvertiseStartSuccessCallback( + AdvertiseSettings settingsInEffect); + + private native static void caLeAdvertiseStartFailureCallback(int errorCode); + + private static final BluetoothGattServerCallback mGattServerCallback = + new BluetoothGattServerCallback() { + + @Override + public void onConnectionStateChange(BluetoothDevice device, int status, + int newState) { + super.onConnectionStateChange(device, status, newState); + + caLeGattServerConnectionStateChangeCallback(device, status, newState); + } + + @Override + public void onServiceAdded(int status, BluetoothGattService service) { + super.onServiceAdded(status, service); + + caLeGattServerServiceAddedCallback(status, service); + } + + @Override + public void onCharacteristicReadRequest( + BluetoothDevice device, int requestId, int offset, + BluetoothGattCharacteristic characteristic) { + super.onCharacteristicReadRequest(device, requestId, offset, characteristic); + + caLeGattServerCharacteristicReadRequestCallback(device, requestId, offset, + characteristic, + characteristic.getValue()); + } + + @Override + public void onCharacteristicWriteRequest( + BluetoothDevice device, int requestId, BluetoothGattCharacteristic characteristic, + boolean preparedWrite, boolean responseNeeded, int offset, byte[] value) { + super.onCharacteristicWriteRequest(device, requestId, characteristic, + preparedWrite, responseNeeded, offset, value); + + caLeGattServerCharacteristicWriteRequestCallback(device, requestId, characteristic, + value, preparedWrite, responseNeeded, + offset, value); + } + + @Override + public void onDescriptorReadRequest( + BluetoothDevice device, + int requestId, int offset, BluetoothGattDescriptor descriptor) { + super.onDescriptorReadRequest(device, requestId, offset, descriptor); + + caLeGattServerDescriptorReadRequestCallback(device, requestId, offset, descriptor); + } + + @Override + public void onDescriptorWriteRequest( + BluetoothDevice device, int requestId, BluetoothGattDescriptor descriptor, + boolean preparedWrite, boolean responseNeeded, int offset, + byte[] value) { + super.onDescriptorWriteRequest(device, requestId, descriptor, preparedWrite, + responseNeeded, offset, value); + + caLeGattServerDescriptorWriteRequestCallback(device, requestId, descriptor, + preparedWrite, responseNeeded, offset, + value); + } + + @Override + public void onExecuteWrite(BluetoothDevice device, int requestId, boolean execute) { + super.onExecuteWrite(device, requestId, execute); + + caLeGattServerExecuteWriteCallback(device, requestId, execute); + } + + @Override + public void onNotificationSent(BluetoothDevice device, int status) { + super.onNotificationSent(device, status); + + caLeGattServerNotificationSentCallback(device, status); + } + }; + + private static final AdvertiseCallback mAdvertiseCallback = new AdvertiseCallback() { + + @Override + public void onStartSuccess(AdvertiseSettings settingsInEffect) { + super.onStartSuccess(settingsInEffect); + + caLeAdvertiseStartSuccessCallback(settingsInEffect); + } + + @Override + public void onStartFailure(int errorCode) { + super.onStartFailure(errorCode); + + caLeAdvertiseStartFailureCallback(errorCode); + } + }; +} + diff --git a/resource/csdk/connectivity/samples/android/sample_service/AndroidManifest.xml b/resource/csdk/connectivity/samples/android/sample_service/AndroidManifest.xml index 91fcef9..4ffc3e2 100644 --- a/resource/csdk/connectivity/samples/android/sample_service/AndroidManifest.xml +++ b/resource/csdk/connectivity/samples/android/sample_service/AndroidManifest.xml @@ -1,6 +1,6 @@ @@ -13,7 +13,7 @@ android:label="@string/app_name" android:theme="@style/AppTheme" > diff --git a/resource/csdk/connectivity/samples/android/sample_service/jni/ResourceModel.c b/resource/csdk/connectivity/samples/android/sample_service/jni/ResourceModel.c index acca05d..31e3abe 100644 --- a/resource/csdk/connectivity/samples/android/sample_service/jni/ResourceModel.c +++ b/resource/csdk/connectivity/samples/android/sample_service/jni/ResourceModel.c @@ -8,7 +8,7 @@ #include "cainterface.h" #include "cacommon.h" -#include "org_iotivity_service_RMInterface.h" +#include "org_iotivity_ca_service_RMInterface.h" #define LOG_TAG "JNI_INTERFACE_SAMPLE" #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__) @@ -66,7 +66,7 @@ static char *g_remoteAddress = NULL; // init JNIEXPORT void JNICALL -Java_org_iotivity_service_RMInterface_setNativeResponseListener(JNIEnv *env, jobject obj, +Java_org_iotivity_ca_service_RMInterface_setNativeResponseListener(JNIEnv *env, jobject obj, jobject listener) { LOGI("setNativeResponseListener"); @@ -180,7 +180,7 @@ void JNI_OnUnload(JavaVM *jvm, void *reserved) } JNIEXPORT void JNICALL -Java_org_iotivity_service_RMInterface_RMInitialize(JNIEnv *env, jobject obj, jobject context) +Java_org_iotivity_ca_service_RMInterface_RMInitialize(JNIEnv *env, jobject obj, jobject context) { LOGI("RMInitialize"); @@ -211,7 +211,7 @@ Java_org_iotivity_service_RMInterface_RMInitialize(JNIEnv *env, jobject obj, job } JNIEXPORT void JNICALL -Java_org_iotivity_service_RMInterface_RMTerminate(JNIEnv *env, jobject obj) +Java_org_iotivity_ca_service_RMInterface_RMTerminate(JNIEnv *env, jobject obj) { LOGI("RMTerminate"); CADestroyToken(g_lastRequestToken); @@ -219,7 +219,7 @@ Java_org_iotivity_service_RMInterface_RMTerminate(JNIEnv *env, jobject obj) } JNIEXPORT void JNICALL -Java_org_iotivity_service_RMInterface_RMStartListeningServer(JNIEnv *env, jobject obj) +Java_org_iotivity_ca_service_RMInterface_RMStartListeningServer(JNIEnv *env, jobject obj) { LOGI("RMStartListeningServer"); @@ -230,7 +230,7 @@ Java_org_iotivity_service_RMInterface_RMStartListeningServer(JNIEnv *env, jobjec } JNIEXPORT void JNICALL -Java_org_iotivity_service_RMInterface_RMStartDiscoveryServer(JNIEnv *env, jobject obj) +Java_org_iotivity_ca_service_RMInterface_RMStartDiscoveryServer(JNIEnv *env, jobject obj) { LOGI("RMStartDiscoveryServer"); @@ -241,7 +241,7 @@ Java_org_iotivity_service_RMInterface_RMStartDiscoveryServer(JNIEnv *env, jobjec } JNIEXPORT void JNICALL -Java_org_iotivity_service_RMInterface_RMRegisterHandler(JNIEnv *env, jobject obj) +Java_org_iotivity_ca_service_RMInterface_RMRegisterHandler(JNIEnv *env, jobject obj) { LOGI("RMRegisterHandler"); @@ -249,7 +249,7 @@ Java_org_iotivity_service_RMInterface_RMRegisterHandler(JNIEnv *env, jobject obj } JNIEXPORT void JNICALL -Java_org_iotivity_service_RMInterface_RMFindResource(JNIEnv *env, jobject obj, jstring uri) +Java_org_iotivity_ca_service_RMInterface_RMFindResource(JNIEnv *env, jobject obj, jstring uri) { // create token CAToken_t token = NULL; @@ -288,7 +288,7 @@ Java_org_iotivity_service_RMInterface_RMFindResource(JNIEnv *env, jobject obj, j } JNIEXPORT void JNICALL -Java_org_iotivity_service_RMInterface_RMSendRequest(JNIEnv *env, jobject obj, jstring uri, +Java_org_iotivity_ca_service_RMInterface_RMSendRequest(JNIEnv *env, jobject obj, jstring uri, jstring payload, jint selectedNetwork, jint isSecured, jint msgType) { @@ -391,7 +391,7 @@ Java_org_iotivity_service_RMInterface_RMSendRequest(JNIEnv *env, jobject obj, js } JNIEXPORT void JNICALL -Java_org_iotivity_service_RMInterface_RMSendReqestToAll(JNIEnv *env, jobject obj, jstring uri, +Java_org_iotivity_ca_service_RMInterface_RMSendReqestToAll(JNIEnv *env, jobject obj, jstring uri, jint selectedNetwork) { LOGI("selectedNetwork - %d", selectedNetwork); @@ -475,7 +475,7 @@ Java_org_iotivity_service_RMInterface_RMSendReqestToAll(JNIEnv *env, jobject obj } JNIEXPORT void JNICALL -Java_org_iotivity_service_RMInterface_RMSendResponse(JNIEnv *env, jobject obj, +Java_org_iotivity_ca_service_RMInterface_RMSendResponse(JNIEnv *env, jobject obj, jint selectedNetwork, jint isSecured, jint msgType, jint responseValue) @@ -551,7 +551,7 @@ Java_org_iotivity_service_RMInterface_RMSendResponse(JNIEnv *env, jobject obj, } JNIEXPORT void JNICALL -Java_org_iotivity_service_RMInterface_RMAdvertiseResource(JNIEnv *env, jobject obj, jstring uri) +Java_org_iotivity_ca_service_RMInterface_RMAdvertiseResource(JNIEnv *env, jobject obj, jstring uri) { LOGI("RMAdvertiseResource"); @@ -610,7 +610,7 @@ Java_org_iotivity_service_RMInterface_RMAdvertiseResource(JNIEnv *env, jobject o } JNIEXPORT void JNICALL -Java_org_iotivity_service_RMInterface_RMSendNotification(JNIEnv *env, jobject obj, jstring uri, +Java_org_iotivity_ca_service_RMInterface_RMSendNotification(JNIEnv *env, jobject obj, jstring uri, jstring payload, jint selectedNetwork, jint isSecured, jint msgType, jint responseValue) @@ -717,7 +717,7 @@ Java_org_iotivity_service_RMInterface_RMSendNotification(JNIEnv *env, jobject ob } JNIEXPORT void JNICALL -Java_org_iotivity_service_RMInterface_RMSelectNetwork(JNIEnv *env, jobject obj, jint networkType) +Java_org_iotivity_ca_service_RMInterface_RMSelectNetwork(JNIEnv *env, jobject obj, jint networkType) { LOGI("RMSelectNetwork Type : %d", networkType); @@ -728,7 +728,7 @@ Java_org_iotivity_service_RMInterface_RMSelectNetwork(JNIEnv *env, jobject obj, } JNIEXPORT void JNICALL -Java_org_iotivity_service_RMInterface_RMUnSelectNetwork(JNIEnv *env, jobject obj, jint networkType) +Java_org_iotivity_ca_service_RMInterface_RMUnSelectNetwork(JNIEnv *env, jobject obj, jint networkType) { LOGI("RMUnSelectNetwork Type : %d", networkType); @@ -739,7 +739,7 @@ Java_org_iotivity_service_RMInterface_RMUnSelectNetwork(JNIEnv *env, jobject obj } JNIEXPORT void JNICALL -Java_org_iotivity_service_RMInterface_RMGetNetworkInfomation(JNIEnv *env, jobject obj) +Java_org_iotivity_ca_service_RMInterface_RMGetNetworkInfomation(JNIEnv *env, jobject obj) { LOGI("RMGetNetworkInfomation"); @@ -797,7 +797,7 @@ Java_org_iotivity_service_RMInterface_RMGetNetworkInfomation(JNIEnv *env, jobjec } JNIEXPORT void JNICALL -Java_org_iotivity_service_RMInterface_RMHandleRequestResponse(JNIEnv *env, jobject obj) +Java_org_iotivity_ca_service_RMInterface_RMHandleRequestResponse(JNIEnv *env, jobject obj) { LOGI("RMHandleRequestResponse"); diff --git a/resource/csdk/connectivity/samples/android/sample_service/jni/org_iotivity_ca_service_RMInterface.h b/resource/csdk/connectivity/samples/android/sample_service/jni/org_iotivity_ca_service_RMInterface.h new file mode 100644 index 0000000..db14ccb --- /dev/null +++ b/resource/csdk/connectivity/samples/android/sample_service/jni/org_iotivity_ca_service_RMInterface.h @@ -0,0 +1,134 @@ +#include +/* Header for class org_iotivity_ca_service_RMInterface */ + +#ifndef _Included_org_iotivity_ca_service_RMInterface +#define _Included_org_iotivity_ca_service_RMInterface +#ifdef __cplusplus +extern "C" { +#endif +JNIEXPORT void JNICALL Java_org_iotivity_ca_service_RMInterface_setNativeResponseListener + (JNIEnv *, jobject, jobject); +/* + * Class: org_iotivity_ca_service_RMInterface + * Method: RMInitialize + * Signature: (Landroid/content/Context;)V + */ +JNIEXPORT void JNICALL Java_org_iotivity_ca_service_RMInterface_RMInitialize + (JNIEnv *, jobject, jobject); + +/* + * Class: org_iotivity_ca_service_RMInterface + * Method: RMTerminate + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_iotivity_ca_service_RMInterface_RMTerminate + (JNIEnv *, jobject); + +/* + * Class: org_iotivity_ca_service_RMInterface + * Method: RMStartListeningServer + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_iotivity_ca_service_RMInterface_RMStartListeningServer + (JNIEnv *, jobject); + +/* + * Class: org_iotivity_ca_service_RMInterface + * Method: RMStartDiscoveryServer + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_iotivity_ca_service_RMInterface_RMStartDiscoveryServer + (JNIEnv *, jobject); + +/* + * Class: org_iotivity_ca_service_RMInterface + * Method: RMRegisterHandler + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_iotivity_ca_service_RMInterface_RMRegisterHandler + (JNIEnv *, jobject); + +/* + * Class: org_iotivity_ca_service_RMInterface + * Method: RMFindResource + * Signature: (Ljava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_org_iotivity_ca_service_RMInterface_RMFindResource + (JNIEnv *, jobject, jstring); + +/* + * Class: org_iotivity_ca_service_RMInterface + * Method: RMSendRequest + * Signature: (Ljava/lang/String;Ljava/lang/String;III)V + */ +JNIEXPORT void JNICALL Java_org_iotivity_ca_service_RMInterface_RMSendRequest + (JNIEnv *, jobject, jstring, jstring, jint, jint, jint); + +/* + * Class: org_iotivity_ca_service_RMInterface + * Method: RMSendReqestToAll + * Signature: (Ljava/lang/String;I)V + */ +JNIEXPORT void JNICALL Java_org_iotivity_ca_service_RMInterface_RMSendReqestToAll + (JNIEnv *, jobject, jstring, jint); + +/* + * Class: org_iotivity_ca_service_RMInterface + * Method: RMSendResponse + * Signature: (IIII)V + */ +JNIEXPORT void JNICALL Java_org_iotivity_ca_service_RMInterface_RMSendResponse + (JNIEnv *, jobject, jint, jint, jint, jint); + +/* + * Class: org_iotivity_ca_service_RMInterface + * Method: RMAdvertiseResource + * Signature: (Ljava/lang/String)V + */ +JNIEXPORT void JNICALL Java_org_iotivity_ca_service_RMInterface_RMAdvertiseResource + (JNIEnv *, jobject, jstring); + +/* + * Class: org_iotivity_ca_service_RMInterface + * Method: RMSendNotification + * Signature: (Ljava/lang/String;Ljava/lang/String;IIII)V + */ +JNIEXPORT void JNICALL Java_org_iotivity_ca_service_RMInterface_RMSendNotification + (JNIEnv *, jobject, jstring, jstring, jint, jint, jint, jint); + +/* + * Class: org_iotivity_ca_service_RMInterface + * Method: RMSelectNetwork + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_org_iotivity_ca_service_RMInterface_RMSelectNetwork + (JNIEnv *, jobject, jint); + +/* + * Class: org_iotivity_ca_service_RMInterface + * Method: RMUnSelectNetwork + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_org_iotivity_ca_service_RMInterface_RMUnSelectNetwork + (JNIEnv *, jobject, jint); + +/* + * Class: org_iotivity_ca_service_RMInterface + * Method: RMGetNetworkInfomation + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_iotivity_ca_service_RMInterface_RMGetNetworkInfomation + (JNIEnv *, jobject); + +/* + * Class: org_iotivity_ca_service_RMInterface + * Method: RMHandleRequestResponse + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_iotivity_ca_service_RMInterface_RMHandleRequestResponse + (JNIEnv *, jobject); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/resource/csdk/connectivity/samples/android/sample_service/jni/org_iotivity_service_RMInterface.h b/resource/csdk/connectivity/samples/android/sample_service/jni/org_iotivity_service_RMInterface.h deleted file mode 100644 index 8c6b61f..0000000 --- a/resource/csdk/connectivity/samples/android/sample_service/jni/org_iotivity_service_RMInterface.h +++ /dev/null @@ -1,134 +0,0 @@ -#include -/* Header for class org_iotivity_service_RMInterface */ - -#ifndef _Included_org_iotivity_service_RMInterface -#define _Included_org_iotivity_service_RMInterface -#ifdef __cplusplus -extern "C" { -#endif -JNIEXPORT void JNICALL Java_org_iotivity_service_RMInterface_setNativeResponseListener - (JNIEnv *, jobject, jobject); -/* - * Class: org_iotivity_service_RMInterface - * Method: RMInitialize - * Signature: (Landroid/content/Context;)V - */ -JNIEXPORT void JNICALL Java_org_iotivity_service_RMInterface_RMInitialize - (JNIEnv *, jobject, jobject); - -/* - * Class: org_iotivity_service_RMInterface - * Method: RMTerminate - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_iotivity_service_RMInterface_RMTerminate - (JNIEnv *, jobject); - -/* - * Class: org_iotivity_service_RMInterface - * Method: RMStartListeningServer - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_iotivity_service_RMInterface_RMStartListeningServer - (JNIEnv *, jobject); - -/* - * Class: org_iotivity_service_RMInterface - * Method: RMStartDiscoveryServer - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_iotivity_service_RMInterface_RMStartDiscoveryServer - (JNIEnv *, jobject); - -/* - * Class: org_iotivity_service_RMInterface - * Method: RMRegisterHandler - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_iotivity_service_RMInterface_RMRegisterHandler - (JNIEnv *, jobject); - -/* - * Class: org_iotivity_service_RMInterface - * Method: RMFindResource - * Signature: (Ljava/lang/String;)V - */ -JNIEXPORT void JNICALL Java_org_iotivity_service_RMInterface_RMFindResource - (JNIEnv *, jobject, jstring); - -/* - * Class: org_iotivity_service_RMInterface - * Method: RMSendRequest - * Signature: (Ljava/lang/String;Ljava/lang/String;III)V - */ -JNIEXPORT void JNICALL Java_org_iotivity_service_RMInterface_RMSendRequest - (JNIEnv *, jobject, jstring, jstring, jint, jint, jint); - -/* - * Class: org_iotivity_service_RMInterface - * Method: RMSendReqestToAll - * Signature: (Ljava/lang/String;I)V - */ -JNIEXPORT void JNICALL Java_org_iotivity_service_RMInterface_RMSendReqestToAll - (JNIEnv *, jobject, jstring, jint); - -/* - * Class: org_iotivity_service_RMInterface - * Method: RMSendResponse - * Signature: (IIII)V - */ -JNIEXPORT void JNICALL Java_org_iotivity_service_RMInterface_RMSendResponse - (JNIEnv *, jobject, jint, jint, jint, jint); - -/* - * Class: org_iotivity_service_RMInterface - * Method: RMAdvertiseResource - * Signature: (Ljava/lang/String)V - */ -JNIEXPORT void JNICALL Java_org_iotivity_service_RMInterface_RMAdvertiseResource - (JNIEnv *, jobject, jstring); - -/* - * Class: org_iotivity_service_RMInterface - * Method: RMSendNotification - * Signature: (Ljava/lang/String;Ljava/lang/String;IIII)V - */ -JNIEXPORT void JNICALL Java_org_iotivity_service_RMInterface_RMSendNotification - (JNIEnv *, jobject, jstring, jstring, jint, jint, jint, jint); - -/* - * Class: org_iotivity_service_RMInterface - * Method: RMSelectNetwork - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_org_iotivity_service_RMInterface_RMSelectNetwork - (JNIEnv *, jobject, jint); - -/* - * Class: org_iotivity_service_RMInterface - * Method: RMUnSelectNetwork - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_org_iotivity_service_RMInterface_RMUnSelectNetwork - (JNIEnv *, jobject, jint); - -/* - * Class: org_iotivity_service_RMInterface - * Method: RMGetNetworkInfomation - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_iotivity_service_RMInterface_RMGetNetworkInfomation - (JNIEnv *, jobject); - -/* - * Class: org_iotivity_service_RMInterface - * Method: RMHandleRequestResponse - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_iotivity_service_RMInterface_RMHandleRequestResponse - (JNIEnv *, jobject); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/resource/csdk/connectivity/samples/android/sample_service/res/layout/activity_main.xml b/resource/csdk/connectivity/samples/android/sample_service/res/layout/activity_main.xml index 25ce793..8f36a8e 100644 --- a/resource/csdk/connectivity/samples/android/sample_service/res/layout/activity_main.xml +++ b/resource/csdk/connectivity/samples/android/sample_service/res/layout/activity_main.xml @@ -6,7 +6,7 @@ android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" - tools:context="org.iotivity.service.MainActivity" > + tools:context="org.iotivity.ca.service.MainActivity" > + tools:context="org.iotivity.ca.sample_service.MainActivity" > uuids = getUuids(scanRecord); + for (UUID uuid : uuids) { + Log.d("CA", "UUID : " + uuid.toString()); + if(uuid.toString().contains(SERVICE_UUID)) { + Log.d("CA", "we found that has the Device"); + caLeScanCallback(device, rssi, scanRecord); + } + } + } catch(UnsatisfiedLinkError e) { + + } + } + }; + + private static List getUuids(final byte[] scanRecord) { + List uuids = new ArrayList(); + + int offset = 0; + while (offset < (scanRecord.length - 2)) { + int len = scanRecord[offset++]; + if (len == 0) + break; + + int type = scanRecord[offset++]; + + switch (type) { + case 0x02: + case 0x03: + while (len > 1) { + int uuid16 = scanRecord[offset++]; + uuid16 += (scanRecord[offset++] << 8); + len -= 2; + uuids.add(UUID.fromString(String.format( + "%08x-0000-1000-8000-00805f9b34fb", uuid16))); + } + break; + case 0x06: + case 0x07: + while (len >= 16) { + try { + ByteBuffer buffer = ByteBuffer.wrap(scanRecord, offset++, 16). + order(ByteOrder.LITTLE_ENDIAN); + long mostSigBits = buffer.getLong(); + long leastSigBits = buffer.getLong(); + uuids.add(new UUID(leastSigBits, mostSigBits)); + } catch (IndexOutOfBoundsException e) { + Log.e("CA", e.toString()); + continue; + } finally { + offset += 15; + len -= 16; + } + } + break; + default: + offset += (len - 1); + break; + } + } + return uuids; + } + + private static final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() { + + @Override + public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) { + super.onConnectionStateChange(gatt, status, newState); + + caLeGattConnectionStateChangeCallback(gatt, status, newState); + } + + @Override + public void onServicesDiscovered(BluetoothGatt gatt, int status) { + super.onServicesDiscovered(gatt, status); + + caLeGattServicesDiscoveredCallback(gatt, status); + } + + @Override + public void onCharacteristicRead(BluetoothGatt gatt, + BluetoothGattCharacteristic characteristic, int status) { + super.onCharacteristicRead(gatt, characteristic, status); + + caLeGattCharacteristicReadCallback(gatt, characteristic, + characteristic.getValue(), status); + } + + @Override + public void onCharacteristicWrite(BluetoothGatt gatt, + BluetoothGattCharacteristic characteristic, int status) { + super.onCharacteristicWrite(gatt, characteristic, status); + + caLeGattCharacteristicWriteCallback(gatt, characteristic, + characteristic.getValue(), status); + } + + @Override + public void onCharacteristicChanged(BluetoothGatt gatt, + BluetoothGattCharacteristic characteristic) { + super.onCharacteristicChanged(gatt, characteristic); + + caLeGattCharacteristicChangedCallback(gatt, characteristic, + characteristic.getValue()); + } + + @Override + public void onDescriptorRead(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, + int status) { + super.onDescriptorRead(gatt, descriptor, status); + + caLeGattDescriptorReadCallback(gatt, descriptor, status); + } + + @Override + public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, + int status) { + super.onDescriptorWrite(gatt, descriptor, status); + + caLeGattDescriptorWriteCallback(gatt, descriptor, status); + } + + @Override + public void onReliableWriteCompleted(BluetoothGatt gatt, int status) { + super.onReliableWriteCompleted(gatt, status); + + caLeGattReliableWriteCompletedCallback(gatt, status); + } + + @Override + public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status) { + super.onReadRemoteRssi(gatt, rssi, status); + + caLeGattReadRemoteRssiCallback(gatt, rssi, status); + } + }; + + private static final BroadcastReceiver mReceiver = new BroadcastReceiver() { + + @Override + public void onReceive(Context context, Intent intent) { + + String action = intent.getAction(); + + if (action != null && action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) { + + int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, + BluetoothAdapter.ERROR); + + if (state == BluetoothAdapter.STATE_ON || state == BluetoothAdapter.STATE_OFF) + { + caLeStateChangedCallback(state); + } + } + + if (action != null && action.equals(BluetoothDevice.ACTION_BOND_STATE_CHANGED)) { + + int bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, + BluetoothDevice.ERROR); + + if (bondState == BluetoothDevice.BOND_NONE) { + if ((intent.getIntExtra(BluetoothDevice.EXTRA_PREVIOUS_BOND_STATE, + BluetoothDevice.ERROR) == BluetoothDevice.BOND_BONDED)) { + BluetoothDevice device = intent + .getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); + + caLeBondStateChangedCallback(device.getAddress()); + } + } + } + } + }; +} + diff --git a/resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/ca/CaLeServerInterface.java b/resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/ca/CaLeServerInterface.java new file mode 100644 index 0000000..75f447b --- /dev/null +++ b/resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/ca/CaLeServerInterface.java @@ -0,0 +1,180 @@ +/****************************************************************** + * + * Copyright 2014 Samsung Electronics All Rights Reserved. + * + * + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************/ + +package org.iotivity.ca; + +import android.bluetooth.BluetoothDevice; +import android.bluetooth.BluetoothGattCharacteristic; +import android.bluetooth.BluetoothGattDescriptor; +import android.bluetooth.BluetoothGattServerCallback; +import android.bluetooth.BluetoothGattService; +import android.bluetooth.le.AdvertiseCallback; +import android.bluetooth.le.AdvertiseSettings; + +public class CaLeServerInterface { + + private CaLeServerInterface() { + + caLeRegisterGattServerCallback(mGattServerCallback); + caLeRegisterBluetoothLeAdvertiseCallback(mAdvertiseCallback); + } + + public static void getLeGattServerCallback() { + caLeRegisterGattServerCallback(mGattServerCallback); + } + + public static void getBluetoothLeAdvertiseCallback() { + caLeRegisterBluetoothLeAdvertiseCallback(mAdvertiseCallback); + } + + private native static void caLeRegisterGattServerCallback(BluetoothGattServerCallback callback); + + private native static void caLeRegisterBluetoothLeAdvertiseCallback(AdvertiseCallback callback); + + // BluetoothGattServerCallback + private native static void caLeGattServerConnectionStateChangeCallback( + BluetoothDevice device, int status, int newState); + + private native static void caLeGattServerServiceAddedCallback(int status, + BluetoothGattService service); + + private native static void caLeGattServerCharacteristicReadRequestCallback( + BluetoothDevice device, + int requestId, int offset, BluetoothGattCharacteristic characteristic, byte[] data); + + private native static void caLeGattServerCharacteristicWriteRequestCallback( + BluetoothDevice device, int requestId, + BluetoothGattCharacteristic characteristic, byte[] data, boolean preparedWrite, + boolean responseNeeded, int offset, byte[] value); + + private native static void caLeGattServerDescriptorReadRequestCallback( + BluetoothDevice device, int requestId, int offset, BluetoothGattDescriptor descriptor); + + public native static void caLeGattServerDescriptorWriteRequestCallback( + BluetoothDevice device, int requestId, BluetoothGattDescriptor descriptor, + boolean preparedWrite, boolean responseNeeded, int offset, byte[] value); + + private native static void caLeGattServerExecuteWriteCallback(BluetoothDevice device, + int requestId, boolean execute); + + private native static void caLeGattServerNotificationSentCallback(BluetoothDevice device, + int status); + + // AdvertiseCallback + private native static void caLeAdvertiseStartSuccessCallback( + AdvertiseSettings settingsInEffect); + + private native static void caLeAdvertiseStartFailureCallback(int errorCode); + + private static final BluetoothGattServerCallback mGattServerCallback = + new BluetoothGattServerCallback() { + + @Override + public void onConnectionStateChange(BluetoothDevice device, int status, + int newState) { + super.onConnectionStateChange(device, status, newState); + + caLeGattServerConnectionStateChangeCallback(device, status, newState); + } + + @Override + public void onServiceAdded(int status, BluetoothGattService service) { + super.onServiceAdded(status, service); + + caLeGattServerServiceAddedCallback(status, service); + } + + @Override + public void onCharacteristicReadRequest( + BluetoothDevice device, int requestId, int offset, + BluetoothGattCharacteristic characteristic) { + super.onCharacteristicReadRequest(device, requestId, offset, characteristic); + + caLeGattServerCharacteristicReadRequestCallback(device, requestId, offset, + characteristic, + characteristic.getValue()); + } + + @Override + public void onCharacteristicWriteRequest( + BluetoothDevice device, int requestId, BluetoothGattCharacteristic characteristic, + boolean preparedWrite, boolean responseNeeded, int offset, byte[] value) { + super.onCharacteristicWriteRequest(device, requestId, characteristic, + preparedWrite, responseNeeded, offset, value); + + caLeGattServerCharacteristicWriteRequestCallback(device, requestId, characteristic, + value, preparedWrite, responseNeeded, + offset, value); + } + + @Override + public void onDescriptorReadRequest( + BluetoothDevice device, + int requestId, int offset, BluetoothGattDescriptor descriptor) { + super.onDescriptorReadRequest(device, requestId, offset, descriptor); + + caLeGattServerDescriptorReadRequestCallback(device, requestId, offset, descriptor); + } + + @Override + public void onDescriptorWriteRequest( + BluetoothDevice device, int requestId, BluetoothGattDescriptor descriptor, + boolean preparedWrite, boolean responseNeeded, int offset, + byte[] value) { + super.onDescriptorWriteRequest(device, requestId, descriptor, preparedWrite, + responseNeeded, offset, value); + + caLeGattServerDescriptorWriteRequestCallback(device, requestId, descriptor, + preparedWrite, responseNeeded, offset, + value); + } + + @Override + public void onExecuteWrite(BluetoothDevice device, int requestId, boolean execute) { + super.onExecuteWrite(device, requestId, execute); + + caLeGattServerExecuteWriteCallback(device, requestId, execute); + } + + @Override + public void onNotificationSent(BluetoothDevice device, int status) { + super.onNotificationSent(device, status); + + caLeGattServerNotificationSentCallback(device, status); + } + }; + + private static final AdvertiseCallback mAdvertiseCallback = new AdvertiseCallback() { + + @Override + public void onStartSuccess(AdvertiseSettings settingsInEffect) { + super.onStartSuccess(settingsInEffect); + + caLeAdvertiseStartSuccessCallback(settingsInEffect); + } + + @Override + public void onStartFailure(int errorCode) { + super.onStartFailure(errorCode); + + caLeAdvertiseStartFailureCallback(errorCode); + } + }; +} diff --git a/resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/service/DLog.java b/resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/ca/service/DLog.java similarity index 98% rename from resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/service/DLog.java rename to resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/ca/service/DLog.java index b8b3b34..66d7874 100644 --- a/resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/service/DLog.java +++ b/resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/ca/service/DLog.java @@ -1,5 +1,5 @@ -package org.iotivity.service; +package org.iotivity.ca.service; import android.os.Handler; import android.widget.TextView; diff --git a/resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/service/MainActivity.java b/resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/ca/service/MainActivity.java similarity index 99% rename from resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/service/MainActivity.java rename to resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/ca/service/MainActivity.java index fc321cb..9bbe94f 100644 --- a/resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/service/MainActivity.java +++ b/resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/ca/service/MainActivity.java @@ -1,4 +1,4 @@ -package org.iotivity.service; +package org.iotivity.ca.service; import android.app.Activity; import android.app.AlertDialog; @@ -14,7 +14,7 @@ import android.widget.EditText; import android.widget.RelativeLayout; import android.widget.TextView; -import org.iotivity.sample_service.R; +import org.iotivity.ca.sample_service.R; public class MainActivity extends Activity { diff --git a/resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/service/RMInterface.java b/resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/ca/service/RMInterface.java similarity index 89% rename from resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/service/RMInterface.java rename to resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/ca/service/RMInterface.java index b70c066..0c9db02 100644 --- a/resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/service/RMInterface.java +++ b/resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/ca/service/RMInterface.java @@ -1,4 +1,4 @@ -package org.iotivity.service; +package org.iotivity.ca.service; import android.content.Context; @@ -9,7 +9,7 @@ public class RMInterface { System.loadLibrary("RMInterface"); } - private org.iotivity.service.MainActivity mResponseListener = null; + private org.iotivity.ca.service.MainActivity mResponseListener = null; public native void setNativeResponseListener(Object listener); @@ -46,7 +46,7 @@ public class RMInterface { public native void RMHandleRequestResponse(); - public void setResponseListener(org.iotivity.service.MainActivity listener) { + public void setResponseListener(org.iotivity.ca.service.MainActivity listener) { mResponseListener = listener; setNativeResponseListener(this); } diff --git a/resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/jar/CALeInterface.java b/resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/jar/CALeInterface.java deleted file mode 100644 index ccc24cb..0000000 --- a/resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/jar/CALeInterface.java +++ /dev/null @@ -1,343 +0,0 @@ -package org.iotivity.jar; - -import android.bluetooth.BluetoothAdapter; -import android.bluetooth.BluetoothDevice; -import android.bluetooth.BluetoothGatt; -import android.bluetooth.BluetoothGattCallback; -import android.bluetooth.BluetoothGattCharacteristic; -import android.bluetooth.BluetoothGattDescriptor; -import android.bluetooth.BluetoothGattServerCallback; -import android.bluetooth.BluetoothGattService; -import android.bluetooth.le.AdvertiseCallback; -import android.bluetooth.le.AdvertiseSettings; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.util.Log; - -public class CALeInterface { - - public CALeInterface(Context context) { - - CARegisterLeScanCallback(mLeScanCallback); - CARegisterLeGattCallback(mGattCallback); - CARegisterLeGattServerCallback(mGattServerCallback); - CARegisterBluetoothLeAdvertiseCallback(mAdvertiseCallback); - - registerIntentFilter(context); - } - - public static void getLeScanCallback() { - CARegisterLeScanCallback(mLeScanCallback); - } - - public static void getLeGattCallback() { - CARegisterLeGattCallback(mGattCallback); - } - - public static void getLeGattServerCallback() { - CARegisterLeGattServerCallback(mGattServerCallback); - } - - public static void getBluetoothLeAdvertiseCallback() { - CARegisterBluetoothLeAdvertiseCallback(mAdvertiseCallback); - } - - public static IntentFilter registerIntentFilter(Context context) { - IntentFilter filter = new IntentFilter(); - filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); - context.registerReceiver(mReceiver, filter); - return filter; - } - - public native static void CARegisterLeScanCallback( - BluetoothAdapter.LeScanCallback callback); - - public native static void CARegisterLeGattCallback( - BluetoothGattCallback callback); - - public native static void CARegisterLeGattServerCallback( - BluetoothGattServerCallback callback); - - public native static void CARegisterBluetoothLeAdvertiseCallback( - AdvertiseCallback callback); - - // BluetoothAdapter.LeScanCallback - public native static void CALeScanCallback(BluetoothDevice device, - int rssi, byte[] scanRecord); - - // BluetoothGattCallback - public native static void CALeGattConnectionStateChangeCallback( - BluetoothGatt gatt, int status, int newState); - - public native static void CALeGattServicesDiscoveredCallback( - BluetoothGatt gatt, int status); - - public native static void CALeGattCharacteristicReadCallback( - BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, - byte[] data, int status); - - public native static void CALeGattCharacteristicWriteCallback( - BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, - byte[] data, int status); - - public native static void CALeGattCharacteristicChangedCallback( - BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, - byte[] data); - - public native static void CALeGattDescriptorReadCallback( - BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status); - - public native static void CALeGattDescriptorWriteCallback( - BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status); - - public native static void CALeGattReliableWriteCompletedCallback( - BluetoothGatt gatt, int status); - - public native static void CALeGattReadRemoteRssiCallback( - BluetoothGatt gatt, int rssi, int status); - - // BluetoothGattServerCallback - public native static void CALeGattServerConnectionStateChangeCallback( - BluetoothDevice device, int status, int newState); - - public native static void CALeGattServerServiceAddedCallback(int status, - BluetoothGattService service); - - public native static void CALeGattServerCharacteristicReadRequestCallback( - BluetoothDevice device, int requestId, int offset, - BluetoothGattCharacteristic characteristic, byte[] data); - - public native static void CALeGattServerCharacteristicWriteRequestCallback( - BluetoothDevice device, int requestId, - BluetoothGattCharacteristic characteristic, byte[] data, - boolean preparedWrite, boolean responseNeeded, int offset, - byte[] value); - - public native static void CALeGattServerDescriptorReadRequestCallback( - BluetoothDevice device, int requestId, int offset, - BluetoothGattDescriptor descriptor); - - public native static void CALeGattServerDescriptorWriteRequestCallback( - BluetoothDevice device, int requestId, - BluetoothGattDescriptor descriptor, boolean preparedWrite, - boolean responseNeeded, int offset, byte[] value); - - public native static void CALeGattServerExecuteWriteCallback( - BluetoothDevice device, int requestId, boolean execute); - - public native static void CALeGattServerNotificationSentCallback( - BluetoothDevice device, int status); - - // AdvertiseCallback - public native static void CALeAdvertiseStartSuccessCallback( - AdvertiseSettings settingsInEffect); - - public native static void CALeAdvertiseStartFailureCallback(int errorCode); - - // Network Monitor - public native static void CALeStateChangedCallback(int state); - - // Callback - private static BluetoothAdapter.LeScanCallback mLeScanCallback - = new BluetoothAdapter.LeScanCallback() { - - @Override - public void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord) { - - try { - CALeScanCallback(device, rssi, scanRecord); - } catch(UnsatisfiedLinkError e) { - - } - } - }; - - private static final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() { - - @Override - public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) { - super.onConnectionStateChange(gatt, status, newState); - - CALeGattConnectionStateChangeCallback(gatt, status, newState); - } - - @Override - public void onServicesDiscovered(BluetoothGatt gatt, int status) { - super.onServicesDiscovered(gatt, status); - - CALeGattServicesDiscoveredCallback(gatt, status); - } - - @Override - public void onCharacteristicRead(BluetoothGatt gatt, - BluetoothGattCharacteristic characteristic, int status) { - super.onCharacteristicRead(gatt, characteristic, status); - - CALeGattCharacteristicReadCallback(gatt, characteristic, - characteristic.getValue(), status); - } - - @Override - public void onCharacteristicWrite(BluetoothGatt gatt, - BluetoothGattCharacteristic characteristic, int status) { - super.onCharacteristicWrite(gatt, characteristic, status); - - CALeGattCharacteristicWriteCallback(gatt, characteristic, - characteristic.getValue(), status); - } - - @Override - public void onCharacteristicChanged(BluetoothGatt gatt, - BluetoothGattCharacteristic characteristic) { - super.onCharacteristicChanged(gatt, characteristic); - - CALeGattCharacteristicChangedCallback(gatt, characteristic, - characteristic.getValue()); - } - - @Override - public void onDescriptorRead(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, - int status) { - super.onDescriptorRead(gatt, descriptor, status); - - CALeGattDescriptorReadCallback(gatt, descriptor, status); - } - - @Override - public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, - int status) { - super.onDescriptorWrite(gatt, descriptor, status); - - CALeGattDescriptorWriteCallback(gatt, descriptor, status); - } - - @Override - public void onReliableWriteCompleted(BluetoothGatt gatt, int status) { - super.onReliableWriteCompleted(gatt, status); - - CALeGattReliableWriteCompletedCallback(gatt, status); - } - - @Override - public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status) { - super.onReadRemoteRssi(gatt, rssi, status); - - CALeGattReadRemoteRssiCallback(gatt, rssi, status); - } - }; - - private static final BluetoothGattServerCallback mGattServerCallback - = new BluetoothGattServerCallback() { - - @Override - public void onConnectionStateChange(BluetoothDevice device, int status, - int newState) { - super.onConnectionStateChange(device, status, newState); - - CALeGattServerConnectionStateChangeCallback(device, status, newState); - } - - @Override - public void onServiceAdded(int status, BluetoothGattService service) { - super.onServiceAdded(status, service); - - CALeGattServerServiceAddedCallback(status, service); - } - - @Override - public void onCharacteristicReadRequest(BluetoothDevice device, - int requestId, int offset, - BluetoothGattCharacteristic characteristic) { - super.onCharacteristicReadRequest(device, requestId, offset, characteristic); - - CALeGattServerCharacteristicReadRequestCallback(device, requestId, offset, - characteristic, characteristic.getValue()); - } - - @Override - public void onCharacteristicWriteRequest(BluetoothDevice device, - int requestId, BluetoothGattCharacteristic characteristic, - boolean preparedWrite, boolean responseNeeded, int offset, - byte[] value) { - super.onCharacteristicWriteRequest(device, requestId, characteristic, - preparedWrite, responseNeeded, offset, value); - - CALeGattServerCharacteristicWriteRequestCallback(device, requestId, characteristic, - value, preparedWrite, responseNeeded, offset, value); - } - - @Override - public void onDescriptorReadRequest(BluetoothDevice device, - int requestId, int offset, BluetoothGattDescriptor descriptor) { - super.onDescriptorReadRequest(device, requestId, offset, descriptor); - - CALeGattServerDescriptorReadRequestCallback(device, requestId, offset, descriptor); - } - - @Override - public void onDescriptorWriteRequest(BluetoothDevice device, - int requestId, BluetoothGattDescriptor descriptor, - boolean preparedWrite, boolean responseNeeded, int offset, - byte[] value) { - super.onDescriptorWriteRequest(device, requestId, descriptor, preparedWrite, - responseNeeded, offset, value); - - CALeGattServerDescriptorWriteRequestCallback(device, requestId, descriptor, - preparedWrite, responseNeeded, offset, value); - } - - @Override - public void onExecuteWrite(BluetoothDevice device, int requestId, - boolean execute) { - super.onExecuteWrite(device, requestId, execute); - - CALeGattServerExecuteWriteCallback(device, requestId, execute); - } - - @Override - public void onNotificationSent(BluetoothDevice device, int status) { - super.onNotificationSent(device, status); - - CALeGattServerNotificationSentCallback(device, status); - } - }; - - private static final AdvertiseCallback mAdvertiseCallback = new AdvertiseCallback() { - - @Override - public void onStartSuccess(AdvertiseSettings settingsInEffect) { - super.onStartSuccess(settingsInEffect); - - CALeAdvertiseStartSuccessCallback(settingsInEffect); - } - - @Override - public void onStartFailure(int errorCode) { - super.onStartFailure(errorCode); - - CALeAdvertiseStartFailureCallback(errorCode); - } - }; - - private static final BroadcastReceiver mReceiver = new BroadcastReceiver() { - - @Override - public void onReceive(Context context, Intent intent) { - - String action = intent.getAction(); - - if (action != null && action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) { - - int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, - BluetoothAdapter.ERROR); - // STATE_ON:12, STATE_OFF:10 - if (state == BluetoothAdapter.STATE_ON || state == BluetoothAdapter.STATE_OFF) { - CALeStateChangedCallback(state); - } - } - } - }; -} - diff --git a/resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/jar/caipinterface.java b/resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/jar/caipinterface.java deleted file mode 100644 index c6e5e78..0000000 --- a/resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/jar/caipinterface.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.iotivity.jar; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.net.ConnectivityManager; -import android.net.NetworkInfo; -import android.net.wifi.WifiManager; -import android.util.Log; - -public class caipinterface { - - private static String TAG = "caipinterface"; - private static Context mContext = null; - - public caipinterface(Context context) { - Log.d(TAG, "caipinterface"); - mContext = context; - registerIpStateReceiver(); - } - - private void registerIpStateReceiver() { - - IntentFilter intentFilter = new IntentFilter(); - intentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION); - intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); - - mContext.registerReceiver(mReceiver, intentFilter); - } - - private static BroadcastReceiver mReceiver = new BroadcastReceiver() { - - @Override - public void onReceive(Context context, Intent intent) { - if (intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, - WifiManager.WIFI_STATE_UNKNOWN) == WifiManager.WIFI_STATE_DISABLED) { - CAIPStateDisabled(); - } else if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) { - ConnectivityManager manager = (ConnectivityManager) - mContext.getSystemService(Context.CONNECTIVITY_SERVICE); - NetworkInfo nwInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); - - if(nwInfo.isConnected()) { - CAIPStateEnabled(); - } - } - } - }; - - public native static void CAIPStateEnabled(); - - public native static void CAIPStateDisabled(); -} - diff --git a/resource/csdk/connectivity/src/bt_edr_adapter/android/caedrclient.c b/resource/csdk/connectivity/src/bt_edr_adapter/android/caedrclient.c index 0065fbe..386b7a1 100644 --- a/resource/csdk/connectivity/src/bt_edr_adapter/android/caedrclient.c +++ b/resource/csdk/connectivity/src/bt_edr_adapter/android/caedrclient.c @@ -43,7 +43,7 @@ static const char METHODID_BT_DEVICEPARAM[] = "(Ljava/lang/String;)Landroid/bluetooth/BluetoothDevice;"; static const char CLASSPATH_BT_ADPATER[] = "android/bluetooth/BluetoothAdapter"; static const char CLASSPATH_BT_DEVICE[] = "android/bluetooth/BluetoothDevice"; -static const char CLASSPATH_BT_INTERFACE[] = "org/iotivity/jar/caedrinterface"; +static const char CLASSPATH_BT_INTERFACE[] = "org/iotivity/ca/CaEdrInterface"; static const char CLASSPATH_BT_SOCKET[] = "android/bluetooth/BluetoothSocket"; static const char CLASSPATH_BT_UUID[] = "java/util/UUID"; static const char CLASSPATH_CONTEXT[] = "android/content/Context"; @@ -309,7 +309,7 @@ CAResult_t CAEDRCreateJNIInterfaceObject(jobject context) jclass EDRJniInterface = (*env)->FindClass(env, CLASSPATH_BT_INTERFACE); if (!EDRJniInterface) { - OIC_LOG(ERROR, TAG, "[EDRCore] Could not get caedrinterface class"); + OIC_LOG(ERROR, TAG, "[EDRCore] Could not get CaEdrInterface class"); return CA_STATUS_FAILED; } @@ -317,7 +317,7 @@ CAResult_t CAEDRCreateJNIInterfaceObject(jobject context) "(Landroid/content/Context;)V"); if (!EDRInterfaceConstructorMethod) { - OIC_LOG(ERROR, TAG, "[EDRCore] Could not get caedrinterface constructor method"); + OIC_LOG(ERROR, TAG, "[EDRCore] Could not get CaEdrInterface constructor method"); return CA_STATUS_FAILED; } @@ -451,7 +451,7 @@ void CAEDRInitialize(ca_thread_pool_t handle) if (g_context) { - CAEDRCreateJNIInterfaceObject(g_context); /* create java caedrinterface instance*/ + CAEDRCreateJNIInterfaceObject(g_context); /* create java CaEdrInterface instance*/ } OIC_LOG(DEBUG, TAG, "OUT"); diff --git a/resource/csdk/connectivity/src/bt_edr_adapter/android/caedrnwmonitor.c b/resource/csdk/connectivity/src/bt_edr_adapter/android/caedrnwmonitor.c index e91e415..64053cc 100644 --- a/resource/csdk/connectivity/src/bt_edr_adapter/android/caedrnwmonitor.c +++ b/resource/csdk/connectivity/src/bt_edr_adapter/android/caedrnwmonitor.c @@ -33,7 +33,7 @@ #include "caedrserver.h" #include "caedrutils.h" -#include "org_iotivity_jar_caedrinterface.h" +#include "org_iotivity_ca_CaEdrInterface.h" //#define DEBUG_MODE #define TAG PCF("CA_EDR_MONITOR") @@ -106,11 +106,11 @@ CAResult_t CAEDRClientSetCallbacks(void) } JNIEXPORT void JNICALL -Java_org_iotivity_jar_caedrinterface_CAEDRStateChangedCallback(JNIEnv *env, jobject obj, +Java_org_iotivity_ca_CaEdrInterface_caEdrStateChangedCallback(JNIEnv *env, jobject obj, jint status) { // STATE_ON:12, STATE_OFF:10 - OIC_LOG(DEBUG, TAG, "caedrinterface - Network State Changed"); + OIC_LOG(DEBUG, TAG, "CaEdrInterface - Network State Changed"); if (NULL == g_networkChangeCb) { @@ -157,10 +157,10 @@ Java_org_iotivity_jar_caedrinterface_CAEDRStateChangedCallback(JNIEnv *env, jobj } JNIEXPORT void JNICALL -Java_org_iotivity_jar_caedrinterface_CAEDRBondStateChangedCallback(JNIEnv *env, jobject obj, +Java_org_iotivity_ca_CaEdrInterface_caEdrBondStateChangedCallback(JNIEnv *env, jobject obj, jstring addr) { - OIC_LOG(DEBUG, TAG, "caedrinterface - Bond State Changed"); + OIC_LOG(DEBUG, TAG, "CaEdrInterface - Bond State Changed"); if (addr) { diff --git a/resource/csdk/connectivity/src/bt_edr_adapter/android/caedrserver.c b/resource/csdk/connectivity/src/bt_edr_adapter/android/caedrserver.c index 8705898..3aa2487 100644 --- a/resource/csdk/connectivity/src/bt_edr_adapter/android/caedrserver.c +++ b/resource/csdk/connectivity/src/bt_edr_adapter/android/caedrserver.c @@ -32,7 +32,7 @@ #include "camutex.h" #include "uarraylist.h" #include "caadapterutils.h" -#include "org_iotivity_jar_caedrinterface.h" +#include "org_iotivity_ca_CaEdrInterface.h" //#define DEBUG_MODE #define TAG PCF("CA_EDR_SERVER") diff --git a/resource/csdk/connectivity/src/bt_edr_adapter/android/org_iotivity_ca_CaEdrInterface.h b/resource/csdk/connectivity/src/bt_edr_adapter/android/org_iotivity_ca_CaEdrInterface.h new file mode 100644 index 0000000..1050749 --- /dev/null +++ b/resource/csdk/connectivity/src/bt_edr_adapter/android/org_iotivity_ca_CaEdrInterface.h @@ -0,0 +1,51 @@ +/****************************************************************** + * + * 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 +/* Header for class org_iotivity_ca_CaEdrInterface */ + +#ifndef Included_org_iotivity_ca_CaEdrInterface +#define Included_org_iotivity_ca_CaEdrInterface +#ifdef __cplusplus +extern "C" +{ +#endif +/* + * Class: org_iotivity_ca_CaEdrInterface + * Method: caEdrStateChangedCallback + * Signature: (I)V + */ +JNIEXPORT void JNICALL +Java_org_iotivity_ca_CaEdrInterface_caEdrStateChangedCallback +(JNIEnv *, jobject, jint); + +/* + * Class: org_iotivity_ca_CaEdrInterface + * Method: caEdrBondStateChangedCallback + * Signature: (I)V + */ +JNIEXPORT void JNICALL +Java_org_iotivity_ca_CaEdrInterface_caEdrBondStateChangedCallback +(JNIEnv *, jobject, jstring); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/resource/csdk/connectivity/src/bt_edr_adapter/android/org_iotivity_jar_caedrinterface.h b/resource/csdk/connectivity/src/bt_edr_adapter/android/org_iotivity_jar_caedrinterface.h deleted file mode 100644 index fbe3511..0000000 --- a/resource/csdk/connectivity/src/bt_edr_adapter/android/org_iotivity_jar_caedrinterface.h +++ /dev/null @@ -1,31 +0,0 @@ -#include -/* Header for class org_iotivity_jar_caedrinterface */ - -#ifndef Included_org_iotivity_jar_caedrinterface -#define Included_org_iotivity_jar_caedrinterface -#ifdef __cplusplus -extern "C" -{ -#endif -/* - * Class: org_iotivity_jar_caedrinterface - * Method: CAEDRStateChangedCallback - * Signature: (I)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_jar_caedrinterface_CAEDRStateChangedCallback -(JNIEnv *, jobject, jint); - -/* - * Class: org_iotivity_jar_caedrinterface - * Method: CAEDRStateChangedCallback - * Signature: (I)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_jar_caedrinterface_CAEDRBondStateChangedCallback -(JNIEnv *, jobject, jstring); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/resource/csdk/connectivity/src/bt_le_adapter/android/caleclient.c b/resource/csdk/connectivity/src/bt_le_adapter/android/caleclient.c index 06c1c05..75fddd6 100644 --- a/resource/csdk/connectivity/src/bt_le_adapter/android/caleclient.c +++ b/resource/csdk/connectivity/src/bt_le_adapter/android/caleclient.c @@ -34,7 +34,7 @@ #include "cathreadpool.h" /* for thread pool */ #include "camutex.h" #include "uarraylist.h" -#include "org_iotivity_jar_caleclientinterface.h" +#include "org_iotivity_ca_CaLeClientInterface.h" #define TAG PCF("CA_LE_CLIENT") @@ -132,10 +132,10 @@ CAResult_t CALECreateJniInterfaceObject() isAttached = true; } - jclass jni_LEInterface = (*env)->FindClass(env, "org/iotivity/jar/caleclientinterface"); + jclass jni_LEInterface = (*env)->FindClass(env, "org/iotivity/ca/CaLeClientInterface"); if (!jni_LEInterface) { - OIC_LOG(ERROR, TAG, "Could not get caleclientinterface class"); + OIC_LOG(ERROR, TAG, "Could not get CaLeClientInterface class"); goto error_exit; } @@ -143,12 +143,12 @@ CAResult_t CALECreateJniInterfaceObject() "(Landroid/content/Context;)V"); if (!LeInterfaceConstructorMethod) { - OIC_LOG(ERROR, TAG, "Could not get caleclientinterface constructor method"); + OIC_LOG(ERROR, TAG, "Could not get CaLeClientInterface constructor method"); goto error_exit; } (*env)->NewObject(env, jni_LEInterface, LeInterfaceConstructorMethod, g_context); - OIC_LOG(DEBUG, TAG, "Create instance for caleclientinterface"); + OIC_LOG(DEBUG, TAG, "Create instance for CaLeClientInterface"); if (isAttached) { @@ -3282,10 +3282,10 @@ CAResult_t CAGetLEAddress(char **local_address) } JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleclientinterface_CARegisterLeScanCallback(JNIEnv *env, jobject obj, - jobject callback) +Java_org_iotivity_ca_CaLeClientInterface_caLeRegisterLeScanCallback(JNIEnv *env, jobject obj, + jobject callback) { - OIC_LOG(DEBUG, TAG, "CARegisterLeScanCallback"); + OIC_LOG(DEBUG, TAG, "CaLeRegisterLeScanCallback"); VERIFY_NON_NULL_VOID(env, TAG, "env is null"); VERIFY_NON_NULL_VOID(callback, TAG, "callback is null"); @@ -3293,10 +3293,10 @@ Java_org_iotivity_jar_caleclientinterface_CARegisterLeScanCallback(JNIEnv *env, } JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleclientinterface_CARegisterLeGattCallback(JNIEnv *env, jobject obj, - jobject callback) +Java_org_iotivity_ca_CaLeClientInterface_caLeRegisterGattCallback(JNIEnv *env, jobject obj, + jobject callback) { - OIC_LOG(DEBUG, TAG, "CARegisterLeGattCallback"); + OIC_LOG(DEBUG, TAG, "CaLeRegisterGattCallback"); VERIFY_NON_NULL_VOID(env, TAG, "env is null"); VERIFY_NON_NULL_VOID(callback, TAG, "callback is null"); @@ -3304,7 +3304,7 @@ Java_org_iotivity_jar_caleclientinterface_CARegisterLeGattCallback(JNIEnv *env, } JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleclientinterface_CALeScanCallback(JNIEnv *env, jobject obj, +Java_org_iotivity_ca_CaLeClientInterface_caLeScanCallback(JNIEnv *env, jobject obj, jobject device, jint rssi, jbyteArray scanRecord) { @@ -3319,12 +3319,12 @@ Java_org_iotivity_jar_caleclientinterface_CALeScanCallback(JNIEnv *env, jobject } /* - * Class: org_iotivity_jar_caleinterface + * Class: org_iotivity_ca_jar_caleinterface * Method: CALeGattConnectionStateChangeCallback * Signature: (Landroid/bluetooth/BluetoothGatt;II)V */ JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleclientinterface_CALeGattConnectionStateChangeCallback(JNIEnv *env, +Java_org_iotivity_ca_CaLeClientInterface_caLeGattConnectionStateChangeCallback(JNIEnv *env, jobject obj, jobject gatt, jint status, @@ -3444,12 +3444,12 @@ error_exit: } /* - * Class: org_iotivity_jar_caleinterface + * Class: org_iotivity_ca_jar_caleinterface * Method: CALeGattServicesDiscoveredCallback * Signature: (Landroid/bluetooth/BluetoothGatt;I)V */ JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleclientinterface_CALeGattServicesDiscoveredCallback(JNIEnv *env, +Java_org_iotivity_ca_CaLeClientInterface_caLeGattServicesDiscoveredCallback(JNIEnv *env, jobject obj, jobject gatt, jint status) @@ -3541,12 +3541,12 @@ error_exit: } /* - * Class: org_iotivity_jar_caleinterface + * Class: org_iotivity_ca_jar_caleinterface * Method: CALeGattCharacteristicReadCallback * Signature: (Landroid/bluetooth/BluetoothGatt;Landroid/bluetooth/BluetoothGattCharacteristic;I)V */ JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleclientinterface_CALeGattCharacteristicReadCallback(JNIEnv *env, +Java_org_iotivity_ca_CaLeClientInterface_caLeGattCharacteristicReadCallback(JNIEnv *env, jobject obj, jobject gatt, jobject characteristic, @@ -3557,12 +3557,12 @@ Java_org_iotivity_jar_caleclientinterface_CALeGattCharacteristicReadCallback(JNI } /* - * Class: org_iotivity_jar_caleinterface + * Class: org_iotivity_ca_jar_caleinterface * Method: CALeGattCharacteristicWritjclasseCallback * Signature: (Landroid/bluetooth/BluetoothGatt;Landroid/bluetooth/BluetoothGattCharacteristic;I)V */ JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleclientinterface_CALeGattCharacteristicWriteCallback( +Java_org_iotivity_ca_CaLeClientInterface_caLeGattCharacteristicWriteCallback( JNIEnv *env, jobject obj, jobject gatt, jobject characteristic, jbyteArray data, jint status) { @@ -3636,12 +3636,12 @@ error_exit: } /* - * Class: org_iotivity_jar_caleinterface + * Class: org_iotivity_ca_jar_caleinterface * Method: CALeGattCharacteristicChangedCallback * Signature: (Landroid/bluetooth/BluetoothGatt;Landroid/bluetooth/BluetoothGattCharacteristic;)V */ JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleclientinterface_CALeGattCharacteristicChangedCallback( +Java_org_iotivity_ca_CaLeClientInterface_caLeGattCharacteristicChangedCallback( JNIEnv *env, jobject obj, jobject gatt, jobject characteristic, jbyteArray data) { OIC_LOG(DEBUG, TAG, "CALeGattCharacteristicChangedCallback"); @@ -3698,12 +3698,12 @@ Java_org_iotivity_jar_caleclientinterface_CALeGattCharacteristicChangedCallback( } /* - * Class: org_iotivity_jar_caleinterface + * Class: org_iotivity_ca_jar_caleinterface * Method: CALeGattDescriptorReadCallback * Signature: (Landroid/bluetooth/BluetoothGatt;Landroid/bluetooth/BluetoothGattDescriptor;I)V */ JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleclientinterface_CALeGattDescriptorReadCallback(JNIEnv *env, jobject obj, +Java_org_iotivity_ca_CaLeClientInterface_caLeGattDescriptorReadCallback(JNIEnv *env, jobject obj, jobject gatt, jobject descriptor, jint status) @@ -3712,12 +3712,12 @@ Java_org_iotivity_jar_caleclientinterface_CALeGattDescriptorReadCallback(JNIEnv } /* - * Class: org_iotivity_jar_caleinterface + * Class: org_iotivity_ca_jar_caleinterface * Method: CALeGattDescriptorWriteCallback * Signature: (Landroid/bluetooth/BluetoothGatt;Landroid/bluetooth/BluetoothGattDescriptor;I)V */ JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleclientinterface_CALeGattDescriptorWriteCallback(JNIEnv *env, jobject obj, +Java_org_iotivity_ca_CaLeClientInterface_caLeGattDescriptorWriteCallback(JNIEnv *env, jobject obj, jobject gatt, jobject descriptor, jint status) @@ -3743,12 +3743,12 @@ error_exit: } /* - * Class: org_iotivity_jar_caleinterface + * Class: org_iotivity_ca_jar_caleinterface * Method: CALeGattReliableWriteCompletedCallback * Signature: (Landroid/bluetooth/BluetoothGatt;I)V */ JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleclientinterface_CALeGattReliableWriteCompletedCallback(JNIEnv *env, +Java_org_iotivity_ca_CaLeClientInterface_caLeGattReliableWriteCompletedCallback(JNIEnv *env, jobject obj, jobject gatt, jint status) @@ -3757,12 +3757,12 @@ Java_org_iotivity_jar_caleclientinterface_CALeGattReliableWriteCompletedCallback } /* - * Class: org_iotivity_jar_caleinterface + * Class: org_iotivity_ca_jar_caleinterface * Method: CALeGattReadRemoteRssiCallback * Signature: (Landroid/bluetooth/BluetoothGatt;II)V */ JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleclientinterface_CALeGattReadRemoteRssiCallback(JNIEnv *env, jobject obj, +Java_org_iotivity_ca_CaLeClientInterface_caLeGattReadRemoteRssiCallback(JNIEnv *env, jobject obj, jobject gatt, jint rssi, jint status) { diff --git a/resource/csdk/connectivity/src/bt_le_adapter/android/calenwmonitor.c b/resource/csdk/connectivity/src/bt_le_adapter/android/calenwmonitor.c index d6874fa..28da4db 100644 --- a/resource/csdk/connectivity/src/bt_le_adapter/android/calenwmonitor.c +++ b/resource/csdk/connectivity/src/bt_le_adapter/android/calenwmonitor.c @@ -31,7 +31,7 @@ #include "camutex.h" -#include "org_iotivity_jar_caleclientinterface.h" +#include "org_iotivity_ca_CaLeClientInterface.h" #define TAG PCF("CA_LE_MONITOR") @@ -203,13 +203,13 @@ CAResult_t CAUnSetLEAdapterStateChangedCb() } JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleclientinterface_CALeStateChangedCallback(JNIEnv *env, jobject obj, +Java_org_iotivity_ca_CaLeClientInterface_caLeStateChangedCallback(JNIEnv *env, jobject obj, jint status) { VERIFY_NON_NULL_VOID(env, TAG, "env is null"); - OIC_LOG(DEBUG, TAG, "caleclientinterface - Network State Changed"); + OIC_LOG(DEBUG, TAG, "CaLeClientInterface - Network State Changed"); if (!gCALEDeviceStateChangedCallback) { @@ -249,10 +249,10 @@ Java_org_iotivity_jar_caleclientinterface_CALeStateChangedCallback(JNIEnv *env, } JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleclientinterface_CALeBondStateChangedCallback(JNIEnv *env, jobject obj, +Java_org_iotivity_ca_CaLeClientInterface_caLeBondStateChangedCallback(JNIEnv *env, jobject obj, jstring addr) { - OIC_LOG(DEBUG, TAG, "caleclientinterface - Bond State Changed"); + OIC_LOG(DEBUG, TAG, "CaLeClientInterface - Bond State Changed"); VERIFY_NON_NULL_VOID(env, TAG, "env is null"); VERIFY_NON_NULL_VOID(addr, TAG, "addr is null"); diff --git a/resource/csdk/connectivity/src/bt_le_adapter/android/caleserver.c b/resource/csdk/connectivity/src/bt_le_adapter/android/caleserver.c index dec1409..adcdc11 100644 --- a/resource/csdk/connectivity/src/bt_le_adapter/android/caleserver.c +++ b/resource/csdk/connectivity/src/bt_le_adapter/android/caleserver.c @@ -33,7 +33,7 @@ #include "cathreadpool.h" #include "camutex.h" #include "uarraylist.h" -#include "org_iotivity_jar_caleserverinterface.h" +#include "org_iotivity_ca_CaLeServerInterface.h" #define TAG PCF("CA_LE_SERVER") @@ -99,10 +99,10 @@ CAResult_t CALEServerCreateJniInterfaceObject() isAttached = true; } - jclass jni_LEInterface = (*env)->FindClass(env, "org/iotivity/jar/caleserverinterface"); + jclass jni_LEInterface = (*env)->FindClass(env, "org/iotivity/ca/CaLeServerInterface"); if (!jni_LEInterface) { - OIC_LOG(ERROR, TAG, "Could not get caleserverinterface class"); + OIC_LOG(ERROR, TAG, "Could not get CaLeServerInterface class"); goto exit; } @@ -110,12 +110,12 @@ CAResult_t CALEServerCreateJniInterfaceObject() "()V"); if (!LeInterfaceConstructorMethod) { - OIC_LOG(ERROR, TAG, "Could not get caleserverinterface constructor method"); + OIC_LOG(ERROR, TAG, "Could not get CaLeServerInterface constructor method"); goto exit; } (*env)->NewObject(env, jni_LEInterface, LeInterfaceConstructorMethod, g_context); - OIC_LOG(DEBUG, TAG, "Create instance for caleserverinterface"); + OIC_LOG(DEBUG, TAG, "Create instance for CaLeServerInterface"); if (isAttached) { @@ -2041,10 +2041,10 @@ CAResult_t CALEServerReorderinglist(uint32_t index) } JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleserverinterface_CARegisterLeGattServerCallback(JNIEnv *env, jobject obj, +Java_org_iotivity_ca_CaLeServerInterface_caLeRegisterGattServerCallback(JNIEnv *env, jobject obj, jobject callback) { - OIC_LOG(DEBUG, TAG, "caleserverinterface - Register Le Gatt Server Callback"); + OIC_LOG(DEBUG, TAG, "CaLeServerInterface - Register Le Gatt Server Callback"); VERIFY_NON_NULL_VOID(env, TAG, "env is null"); VERIFY_NON_NULL_VOID(callback, TAG, "callback is null"); @@ -2052,11 +2052,11 @@ Java_org_iotivity_jar_caleserverinterface_CARegisterLeGattServerCallback(JNIEnv } JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleserverinterface_CARegisterBluetoothLeAdvertiseCallback(JNIEnv *env, - jobject obj, - jobject callback) +Java_org_iotivity_ca_CaLeServerInterface_caLeRegisterBluetoothLeAdvertiseCallback(JNIEnv *env, + jobject obj, + jobject callback) { - OIC_LOG(DEBUG, TAG, "caleserverinterface - Register Le Advertise Callback"); + OIC_LOG(DEBUG, TAG, "CaLeServerInterface - Register Le Advertise Callback"); VERIFY_NON_NULL_VOID(env, TAG, "env is null"); VERIFY_NON_NULL_VOID(callback, TAG, "callback is null"); @@ -2064,10 +2064,10 @@ Java_org_iotivity_jar_caleserverinterface_CARegisterBluetoothLeAdvertiseCallback } JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleserverinterface_CALeGattServerConnectionStateChangeCallback( +Java_org_iotivity_ca_CaLeServerInterface_caLeGattServerConnectionStateChangeCallback( JNIEnv *env, jobject obj, jobject device, jint status, jint newState) { - OIC_LOG(DEBUG, TAG, "caleserverinterface - Gatt Server ConnectionStateChange Callback"); + OIC_LOG(DEBUG, TAG, "CaLeServerInterface - Gatt Server ConnectionStateChange Callback"); OIC_LOG_V(DEBUG, TAG, "New connection State: %d", newState); VERIFY_NON_NULL_VOID(env, TAG, "env is null"); @@ -2142,20 +2142,20 @@ Java_org_iotivity_jar_caleserverinterface_CALeGattServerConnectionStateChangeCal } JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleserverinterface_CALeGattServerServiceAddedCallback(JNIEnv *env, +Java_org_iotivity_ca_CaLeServerInterface_caLeGattServerServiceAddedCallback(JNIEnv *env, jobject obj, jint status, jobject gattService) { - OIC_LOG_V(DEBUG, TAG, "caleserverinterface - Gatt Service Added Callback(%d)", status); + OIC_LOG_V(DEBUG, TAG, "CaLeServerInterface - Gatt Service Added Callback(%d)", status); } JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleserverinterface_CALeGattServerCharacteristicReadRequestCallback( +Java_org_iotivity_ca_CaLeServerInterface_caLeGattServerCharacteristicReadRequestCallback( JNIEnv *env, jobject obj, jobject device, jint requestId, jint offset, jobject characteristic, jbyteArray data) { - OIC_LOG(DEBUG, TAG, "caleserverinterface - Gatt Server Characteristic Read Request Callback"); + OIC_LOG(DEBUG, TAG, "CaLeServerInterface - Gatt Server Characteristic Read Request Callback"); VERIFY_NON_NULL_VOID(env, TAG, "env is null"); VERIFY_NON_NULL_VOID(device, TAG, "device is null"); @@ -2166,12 +2166,12 @@ Java_org_iotivity_jar_caleserverinterface_CALeGattServerCharacteristicReadReques } JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleserverinterface_CALeGattServerCharacteristicWriteRequestCallback( +Java_org_iotivity_ca_CaLeServerInterface_caLeGattServerCharacteristicWriteRequestCallback( JNIEnv *env, jobject obj, jobject device, jint requestId, jobject characteristic, jbyteArray data, jboolean preparedWrite, jboolean responseNeeded, jint offset, jbyteArray value) { - OIC_LOG(DEBUG, TAG, "caleserverinterface - Gatt Server Characteristic Write Request Callback"); + OIC_LOG(DEBUG, TAG, "CaLeServerInterface - Gatt Server Characteristic Write Request Callback"); VERIFY_NON_NULL_VOID(env, TAG, "env is null"); VERIFY_NON_NULL_VOID(device, TAG, "device is null"); VERIFY_NON_NULL_VOID(value, TAG, "value is null"); @@ -2227,28 +2227,28 @@ Java_org_iotivity_jar_caleserverinterface_CALeGattServerCharacteristicWriteReque } JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleserverinterface_CALeGattServerDescriptorReadRequestCallback( +Java_org_iotivity_ca_CaLeServerInterface_caLeGattServerDescriptorReadRequestCallback( JNIEnv *env, jobject obj, jobject device, jint requestId, jint offset, jobject descriptor) { - OIC_LOG(DEBUG, TAG, "caleserverinterface_CALeGattServerDescriptorReadRequestCallback"); + OIC_LOG(DEBUG, TAG, "CaLeServerInterface_CALeGattServerDescriptorReadRequestCallback"); } JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleserverinterface_CALeGattServerDescriptorWriteRequestCallback( +Java_org_iotivity_ca_CaLeServerInterface_caLeGattServerDescriptorWriteRequestCallback( JNIEnv *env, jobject obj, jobject device, jint requestId, jobject descriptor, jboolean preparedWrite, jboolean responseNeeded, jint offset, jbyteArray value) { - OIC_LOG(DEBUG, TAG, "caleserverinterface_CALeGattServerDescriptorWriteRequestCallback"); + OIC_LOG(DEBUG, TAG, "CaLeServerInterface_CALeGattServerDescriptorWriteRequestCallback"); } JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleserverinterface_CALeGattServerExecuteWriteCallback(JNIEnv *env, +Java_org_iotivity_ca_CaLeServerInterface_caLeGattServerExecuteWriteCallback(JNIEnv *env, jobject obj, jobject device, jint requestId, jboolean execute) { - OIC_LOG(DEBUG, TAG, "caleserverinterface_CALeGattServerExecuteWriteCallback"); + OIC_LOG(DEBUG, TAG, "CaLeServerInterface_CALeGattServerExecuteWriteCallback"); VERIFY_NON_NULL_VOID(env, TAG, "env is null"); VERIFY_NON_NULL_VOID(device, TAG, "device is null"); @@ -2256,27 +2256,27 @@ Java_org_iotivity_jar_caleserverinterface_CALeGattServerExecuteWriteCallback(JNI } JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleserverinterface_CALeGattServerNotificationSentCallback(JNIEnv *env, +Java_org_iotivity_ca_CaLeServerInterface_caLeGattServerNotificationSentCallback(JNIEnv *env, jobject obj, jobject device, jint status) { - OIC_LOG(DEBUG, TAG, "caleserverinterface - Gatt Server Notification Sent Callback"); + OIC_LOG(DEBUG, TAG, "CaLeServerInterface - Gatt Server Notification Sent Callback"); } JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleserverinterface_CALeAdvertiseStartSuccessCallback( +Java_org_iotivity_ca_CaLeServerInterface_caLeAdvertiseStartSuccessCallback( JNIEnv *env, jobject obj, jobject settingsInEffect) { - OIC_LOG(DEBUG, TAG, "caleserverinterface - LE Advertise Start Success Callback"); + OIC_LOG(DEBUG, TAG, "CaLeServerInterface - LE Advertise Start Success Callback"); } JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleserverinterface_CALeAdvertiseStartFailureCallback(JNIEnv *env, +Java_org_iotivity_ca_CaLeServerInterface_caLeAdvertiseStartFailureCallback(JNIEnv *env, jobject obj, jint errorCode) { - OIC_LOG_V(ERROR, TAG, "caleserverinterface - LE Advertise Start Failure Callback(%)", + OIC_LOG_V(ERROR, TAG, "CaLeServerInterface - LE Advertise Start Failure Callback(%)", errorCode); } diff --git a/resource/csdk/connectivity/src/bt_le_adapter/android/org_iotivity_ca_CaLeClientInterface.h b/resource/csdk/connectivity/src/bt_le_adapter/android/org_iotivity_ca_CaLeClientInterface.h new file mode 100644 index 0000000..91491bc --- /dev/null +++ b/resource/csdk/connectivity/src/bt_le_adapter/android/org_iotivity_ca_CaLeClientInterface.h @@ -0,0 +1,161 @@ +/****************************************************************** + * + * 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 +/* Header for class org_iotivity_ca_caLeClientInterface */ + +#ifndef CA_Included_org_iotivity_ca_caLeClientInterface_H_ +#define CA_Included_org_iotivity_ca_caLeClientInterface_H_ +#ifdef __cplusplus +extern "C" +{ +#endif + +/* + * Class: org_iotivity_ca_caLeClientInterface + * Method: caLeRegisterLeScanCallback + * Signature: (Landroid/bluetooth/BluetoothAdapter/LeScanCallback;)V + */ +JNIEXPORT void JNICALL +Java_org_iotivity_ca_caLeClientInterface_caLeRegisterLeScanCallback +(JNIEnv *, jobject, jobject); + +/* + * Class: org_iotivity_ca_caLeClientInterface + * Method: caLeRegisterGattCallback + * Signature: (Landroid/bluetooth/BluetoothGattCallback;)V + */ +JNIEXPORT void JNICALL +Java_org_iotivity_ca_caLeClientInterface_caLeRegisterGattCallback +(JNIEnv *, jobject, jobject); + +/* + * Class: org_iotivity_ca_caLeClientInterface + * Method: caLeScanCallback + * Signature: (Landroid/bluetooth/BluetoothDevice;I[B)V + */ +JNIEXPORT void JNICALL +Java_org_iotivity_ca_caLeClientInterface_caLeScanCallback +(JNIEnv *, jobject, jobject, jint, jbyteArray); + +/* + * Class: org_iotivity_ca_caLeClientInterface + * Method: caLeGattConnectionStateChangeCallback + * Signature: (Landroid/bluetooth/BluetoothGatt;II)V + */ +JNIEXPORT void JNICALL +Java_org_iotivity_ca_caLeClientInterface_caLeGattConnectionStateChangeCallback +(JNIEnv *, jobject, jobject, jint, jint); + +/* + * Class: org_iotivity_ca_caLeClientInterface + * Method: caLeGattServicesDiscoveredCallback + * Signature: (Landroid/bluetooth/BluetoothGatt;I)V + */ +JNIEXPORT void JNICALL +Java_org_iotivity_ca_caLeClientInterface_caLeGattServicesDiscoveredCallback +(JNIEnv *, jobject, jobject, jint); + +/* + * Class: org_iotivity_ca_caLeClientInterface + * Method: caLeGattCharacteristicReadCallback + * Signature: (Landroid/bluetooth/BluetoothGatt;Landroid/bluetooth/BluetoothGattCharacteristic;I)V + */ +JNIEXPORT void JNICALL +Java_org_iotivity_ca_caLeClientInterface_caLeGattCharacteristicReadCallback +(JNIEnv *, jobject, jobject, jobject, jbyteArray, jint); + +/* + * Class: org_iotivity_ca_caLeClientInterface + * Method: caLeGattCharacteristicWritjclasseCallback + * Signature: (Landroid/bluetooth/BluetoothGatt;Landroid/bluetooth/BluetoothGattCharacteristic;I)V + */ +JNIEXPORT void JNICALL +Java_org_iotivity_ca_caLeClientInterface_caLeGattCharacteristicWriteCallback +(JNIEnv *, jobject, jobject, jobject, jbyteArray, jint); + +/* + * Class: org_iotivity_ca_caLeClientInterface + * Method: caLeGattCharacteristicChangedCallback + * Signature: (Landroid/bluetooth/BluetoothGatt;Landroid/bluetooth/BluetoothGattCharacteristic;)V + */ +JNIEXPORT void JNICALL +Java_org_iotivity_ca_caLeClientInterface_caLeGattCharacteristicChangedCallback +(JNIEnv *, jobject, jobject, jobject, jbyteArray); + +/* + * Class: org_iotivity_ca_caLeClientInterface + * Method: caLeGattDescriptorReadCallback + * Signature: (Landroid/bluetooth/BluetoothGatt;Landroid/bluetooth/BluetoothGattDescriptor;I)V + */ +JNIEXPORT void JNICALL +Java_org_iotivity_ca_caLeClientInterface_caLeGattDescriptorReadCallback +(JNIEnv *, jobject, jobject, jobject, jint); + +/* + * Class: org_iotivity_ca_caLeClientInterface + * Method: caLeGattDescriptorWriteCallback + * Signature: (Landroid/bluetooth/BluetoothGatt;Landroid/bluetooth/BluetoothGattDescriptor;I)V + */ +JNIEXPORT void JNICALL +Java_org_iotivity_ca_caLeClientInterface_caLeGattDescriptorWriteCallback +(JNIEnv *, jobject, jobject, jobject, jint); + +/* + * Class: org_iotivity_ca_caLeClientInterface + * Method: caLeGattReliableWriteCompletedCallback + * Signature: (Landroid/bluetooth/BluetoothGatt;I)V + */ +JNIEXPORT void JNICALL +Java_org_iotivity_ca_caLeClientInterface_caLeGattReliableWriteCompletedCallback +(JNIEnv *, jobject, jobject, jint); + +/* + * Class: org_iotivity_ca_caLeClientInterface + * Method: caLeGattReadRemoteRssiCallback + * Signature: (Landroid/bluetooth/BluetoothGatt;II)V + */ +JNIEXPORT void JNICALL +Java_org_iotivity_ca_caLeClientInterface_caLeGattReadRemoteRssiCallback +(JNIEnv *, jobject, jobject, jint, jint); + +/* + * Class: org_iotivity_ca_caLeClientInterface + * Method: caLeStateChangedCallback + * Signature: (I)V + */ +JNIEXPORT void JNICALL +Java_org_iotivity_ca_caLeClientInterface_caLeStateChangedCallback +(JNIEnv *, jobject, jint); + +/* + * Class: org_iotivity_ca_caLeClientInterface + * Method: caLeBondStateChangedCallback + * Signature: (I)V + */ +JNIEXPORT void JNICALL +Java_org_iotivity_ca_caLeClientInterface_caLeBondStateChangedCallback +(JNIEnv *, jobject, jstring); + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/resource/csdk/connectivity/src/bt_le_adapter/android/org_iotivity_ca_CaLeServerInterface.h b/resource/csdk/connectivity/src/bt_le_adapter/android/org_iotivity_ca_CaLeServerInterface.h new file mode 100644 index 0000000..10c4abe --- /dev/null +++ b/resource/csdk/connectivity/src/bt_le_adapter/android/org_iotivity_ca_CaLeServerInterface.h @@ -0,0 +1,149 @@ +/****************************************************************** + * + * 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 +/* Header for class org_iotivity_ca_caLeServerInterface */ + +#ifndef CA_Included_org_iotivity_ca_caLeServerInterface_H_ +#define CA_Included_org_iotivity_ca_caLeServerInterface_H_ +#ifdef __cplusplus +extern "C" +{ +#endif + +/* + * Class: org_iotivity_ca_caLeServerInterface + * Method: caLeRegisterGattServerCallback + * Signature: (Landroid/bluetooth/BluetoothGattServerCallback;)V + */ +JNIEXPORT void JNICALL + +Java_org_iotivity_ca_caLeServerInterface_caLeRegisterGattServerCallback +(JNIEnv *, jobject, jobject); + +/* + * Class: org_iotivity_ca_caLeServerInterface + * Method: caLeRegisterBluetoothLeAdvertiseCallback + * Signature: (Landroid/bluetooth/le/AdvertiseCallback;)V + */ +JNIEXPORT void JNICALL +Java_org_iotivity_ca_caLeServerInterface_caLeRegisterBluetoothLeAdvertiseCallback +(JNIEnv *, jobject, jobject); + +/* + * Class: org_iotivity_ca_caLeServerInterface + * Method: caLeGattServerConnectionStateChangeCallback + * Signature: (Landroid/bluetooth/BluetoothDevice;II)V + */ +JNIEXPORT void JNICALL +Java_org_iotivity_ca_caLeServerInterface_caLeGattServerConnectionStateChangeCallback +(JNIEnv *, jobject, jobject, jint, jint); + +/* + * Class: org_iotivity_ca_caLeServerInterface + * Method: caLeGattServerServiceAddedCallback + * Signature: (ILandroid/bluetooth/BluetoothGattService;)V + */ +JNIEXPORT void JNICALL +Java_org_iotivity_ca_caLeServerInterface_caLeGattServerServiceAddedCallback +(JNIEnv *, jobject, jint, jobject); + +/* + * Class: org_iotivity_ca_caLeServerInterface + * Method: caLeGattServerCharacteristicReadRequestCallback + * Signature: (Landroid/bluetooth/BluetoothDevice;IILandroid/ + * bluetooth/BluetoothGattCharacteristic;)V + */ +JNIEXPORT void JNICALL +Java_org_iotivity_ca_caLeServerInterface_caLeGattServerCharacteristicReadRequestCallback +(JNIEnv *, jobject, jobject, jint, jint, jobject, jbyteArray); + +/* + * Class: org_iotivity_ca_caLeServerInterface + * Method: caLeGattServerCharacteristicWriteRequestCallback + * Signature: (Landroid/bluetooth/BluetoothDevice;ILandroid/bluetooth/ + * BluetoothGattCharacteristic;ZZI[B)V + */ +JNIEXPORT void JNICALL +Java_org_iotivity_ca_caLeServerInterface_caLeGattServerCharacteristicWriteRequestCallback +(JNIEnv *, jobject, jobject, jint, jobject, jbyteArray, jboolean, jboolean, jint, jbyteArray); + +/* + * Class: org_iotivity_ca_caLeServerInterface + * Method: caLeGattServerDescriptorReadRequestCallback + * Signature: (Landroid/bluetooth/BluetoothDevice;IILandroid/bluetooth/ + * BluetoothGattDescriptor;)V + */ +JNIEXPORT void JNICALL +Java_org_iotivity_ca_caLeServerInterface_caLeGattServerDescriptorReadRequestCallback +(JNIEnv *, jobject, jobject, jint, jint, jobject); + +/* + * Class: org_iotivity_ca_caLeServerInterface + * Method: caLeGattServerDescriptorWriteRequestCallback + * Signature: (Landroid/bluetooth/BluetoothDevice;ILandroid/bluetooth/ + * BluetoothGattDescriptor;ZZI[B)V + */ +JNIEXPORT void JNICALL +Java_org_iotivity_ca_caLeServerInterface_caLeGattServerDescriptorWriteRequestCallback +(JNIEnv *, jobject, jobject, jint, jobject, jboolean, jboolean, jint, jbyteArray); + +/* + * Class: org_iotivity_ca_caLeServerInterface + * Method: caLeGattServerExecuteWriteCallback + * Signature: (Landroid/bluetooth/BluetoothDevice;IZ)V + */ +JNIEXPORT void JNICALL +Java_org_iotivity_ca_caLeServerInterface_caLeGattServerExecuteWriteCallback +(JNIEnv *, jobject, jobject, jint, jboolean); + +/* + * Class: org_iotivity_ca_caLeServerInterface + * Method: caLeGattServerNotificationSentCallback + * Signature: (Landroid/bluetooth/BluetoothDevice;I)V + */ +JNIEXPORT void JNICALL +Java_org_iotivity_ca_caLeServerInterface_caLeGattServerNotificationSentCallback +(JNIEnv *, jobject, jobject, jint); + +/* + * Class: org_iotivity_ca_caLeServerInterface + * Method: caLeAdvertiseStartSuccessCallback + * Signature: (Landroid/bluetooth/le/AdvertiseSettings;)V + */ +JNIEXPORT void JNICALL +Java_org_iotivity_ca_caLeServerInterface_caLeAdvertiseStartSuccessCallback +(JNIEnv *, jobject, jobject); + +/* + * Class: org_iotivity_ca_caLeServerInterface + * Method: caLeAdvertiseStartFailureCallback + * Signature: (I)V + */ +JNIEXPORT void JNICALL +Java_org_iotivity_ca_caLeServerInterface_caLeAdvertiseStartFailureCallback +(JNIEnv *, jobject, jint); + + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/resource/csdk/connectivity/src/bt_le_adapter/android/org_iotivity_jar_caleclientinterface.h b/resource/csdk/connectivity/src/bt_le_adapter/android/org_iotivity_jar_caleclientinterface.h deleted file mode 100644 index e57b2d1..0000000 --- a/resource/csdk/connectivity/src/bt_le_adapter/android/org_iotivity_jar_caleclientinterface.h +++ /dev/null @@ -1,141 +0,0 @@ -#include -/* Header for class org_iotivity_jar_caleclientinterface */ - -#ifndef CA_Included_org_iotivity_jar_caleclientinterface_H_ -#define CA_Included_org_iotivity_jar_caleclientinterface_H_ -#ifdef __cplusplus -extern "C" -{ -#endif - -/* - * Class: org_iotivity_jar_caleclientinterface - * Method: CARegisterLeScanCallback - * Signature: (Landroid/bluetooth/BluetoothAdapter/LeScanCallback;)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleclientinterface_CARegisterLeScanCallback -(JNIEnv *, jobject, jobject); - -/* - * Class: org_iotivity_jar_caleclientinterface - * Method: CARegisterLeGattCallback - * Signature: (Landroid/bluetooth/BluetoothGattCallback;)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleclientinterface_CARegisterLeGattCallback -(JNIEnv *, jobject, jobject); - -/* - * Class: org_iotivity_jar_caleclientinterface - * Method: CALeScanCallback - * Signature: (Landroid/bluetooth/BluetoothDevice;I[B)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleclientinterface_CALeScanCallback -(JNIEnv *, jobject, jobject, jint, jbyteArray); - -/* - * Class: org_iotivity_jar_caleclientinterface - * Method: CALeGattConnectionStateChangeCallback - * Signature: (Landroid/bluetooth/BluetoothGatt;II)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleclientinterface_CALeGattConnectionStateChangeCallback -(JNIEnv *, jobject, jobject, jint, jint); - -/* - * Class: org_iotivity_jar_caleclientinterface - * Method: CALeGattServicesDiscoveredCallback - * Signature: (Landroid/bluetooth/BluetoothGatt;I)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleclientinterface_CALeGattServicesDiscoveredCallback -(JNIEnv *, jobject, jobject, jint); - -/* - * Class: org_iotivity_jar_caleclientinterface - * Method: CALeGattCharacteristicReadCallback - * Signature: (Landroid/bluetooth/BluetoothGatt;Landroid/bluetooth/BluetoothGattCharacteristic;I)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleclientinterface_CALeGattCharacteristicReadCallback -(JNIEnv *, jobject, jobject, jobject, jbyteArray, jint); - -/* - * Class: org_iotivity_jar_caleclientinterface - * Method: CALeGattCharacteristicWritjclasseCallback - * Signature: (Landroid/bluetooth/BluetoothGatt;Landroid/bluetooth/BluetoothGattCharacteristic;I)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleclientinterface_CALeGattCharacteristicWriteCallback -(JNIEnv *, jobject, jobject, jobject, jbyteArray, jint); - -/* - * Class: org_iotivity_jar_caleclientinterface - * Method: CALeGattCharacteristicChangedCallback - * Signature: (Landroid/bluetooth/BluetoothGatt;Landroid/bluetooth/BluetoothGattCharacteristic;)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleclientinterface_CALeGattCharacteristicChangedCallback -(JNIEnv *, jobject, jobject, jobject, jbyteArray); - -/* - * Class: org_iotivity_jar_caleclientinterface - * Method: CALeGattDescriptorReadCallback - * Signature: (Landroid/bluetooth/BluetoothGatt;Landroid/bluetooth/BluetoothGattDescriptor;I)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleclientinterface_CALeGattDescriptorReadCallback -(JNIEnv *, jobject, jobject, jobject, jint); - -/* - * Class: org_iotivity_jar_caleclientinterface - * Method: CALeGattDescriptorWriteCallback - * Signature: (Landroid/bluetooth/BluetoothGatt;Landroid/bluetooth/BluetoothGattDescriptor;I)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleclientinterface_CALeGattDescriptorWriteCallback -(JNIEnv *, jobject, jobject, jobject, jint); - -/* - * Class: org_iotivity_jar_caleclientinterface - * Method: CALeGattReliableWriteCompletedCallback - * Signature: (Landroid/bluetooth/BluetoothGatt;I)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleclientinterface_CALeGattReliableWriteCompletedCallback -(JNIEnv *, jobject, jobject, jint); - -/* - * Class: org_iotivity_jar_caleclientinterface - * Method: CALeGattReadRemoteRssiCallback - * Signature: (Landroid/bluetooth/BluetoothGatt;II)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleclientinterface_CALeGattReadRemoteRssiCallback -(JNIEnv *, jobject, jobject, jint, jint); - -/* - * Class: org_iotivity_jar_caleclientinterface - * Method: CALeStateChangedCallback - * Signature: (I)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleclientinterface_CALeStateChangedCallback -(JNIEnv *, jobject, jint); - -/* - * Class: org_iotivity_jar_caleclientinterface - * Method: CALeBondStateChangedCallback - * Signature: (I)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleclientinterface_CALeBondStateChangedCallback -(JNIEnv *, jobject, jstring); - -#ifdef __cplusplus -} -#endif -#endif - diff --git a/resource/csdk/connectivity/src/bt_le_adapter/android/org_iotivity_jar_caleserverinterface.h b/resource/csdk/connectivity/src/bt_le_adapter/android/org_iotivity_jar_caleserverinterface.h deleted file mode 100644 index 2f82092..0000000 --- a/resource/csdk/connectivity/src/bt_le_adapter/android/org_iotivity_jar_caleserverinterface.h +++ /dev/null @@ -1,129 +0,0 @@ -#include -/* Header for class org_iotivity_jar_caleserverinterface */ - -#ifndef CA_Included_org_iotivity_jar_caleserverinterface_H_ -#define CA_Included_org_iotivity_jar_caleserverinterface_H_ -#ifdef __cplusplus -extern "C" -{ -#endif - -/* - * Class: org_iotivity_jar_caleserverinterface - * Method: CARegisterLeGattServerCallback - * Signature: (Landroid/bluetooth/BluetoothGattServerCallback;)V - */ -JNIEXPORT void JNICALL - -Java_org_iotivity_jar_caleserverinterface_CARegisterLeGattServerCallback -(JNIEnv *, jobject, jobject); - -/* - * Class: org_iotivity_jar_caleserverinterface - * Method: CARegisterBluetoothLeAdvertiseCallback - * Signature: (Landroid/bluetooth/le/AdvertiseCallback;)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleserverinterface_CARegisterBluetoothLeAdvertiseCallback -(JNIEnv *, jobject, jobject); - -/* - * Class: org_iotivity_jar_caleserverinterface - * Method: CALeGattServerConnectionStateChangeCallback - * Signature: (Landroid/bluetooth/BluetoothDevice;II)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleserverinterface_CALeGattServerConnectionStateChangeCallback -(JNIEnv *, jobject, jobject, jint, jint); - -/* - * Class: org_iotivity_jar_caleserverinterface - * Method: CALeGattServerServiceAddedCallback - * Signature: (ILandroid/bluetooth/BluetoothGattService;)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleserverinterface_CALeGattServerServiceAddedCallback -(JNIEnv *, jobject, jint, jobject); - -/* - * Class: org_iotivity_jar_caleserverinterface - * Method: CALeGattServerCharacteristicReadRequestCallback - * Signature: (Landroid/bluetooth/BluetoothDevice;IILandroid/ - * bluetooth/BluetoothGattCharacteristic;)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleserverinterface_CALeGattServerCharacteristicReadRequestCallback -(JNIEnv *, jobject, jobject, jint, jint, jobject, jbyteArray); - -/* - * Class: org_iotivity_jar_caleserverinterface - * Method: CALeGattServerCharacteristicWriteRequestCallback - * Signature: (Landroid/bluetooth/BluetoothDevice;ILandroid/bluetooth/ - * BluetoothGattCharacteristic;ZZI[B)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleserverinterface_CALeGattServerCharacteristicWriteRequestCallback -(JNIEnv *, jobject, jobject, jint, jobject, jbyteArray, jboolean, jboolean, jint, jbyteArray); - -/* - * Class: org_iotivity_jar_caleserverinterface - * Method: CALeGattServerDescriptorReadRequestCallback - * Signature: (Landroid/bluetooth/BluetoothDevice;IILandroid/bluetooth/ - * BluetoothGattDescriptor;)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleserverinterface_CALeGattServerDescriptorReadRequestCallback -(JNIEnv *, jobject, jobject, jint, jint, jobject); - -/* - * Class: org_iotivity_jar_caleserverinterface - * Method: CALeGattServerDescriptorWriteRequestCallback - * Signature: (Landroid/bluetooth/BluetoothDevice;ILandroid/bluetooth/ - * BluetoothGattDescriptor;ZZI[B)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleserverinterface_CALeGattServerDescriptorWriteRequestCallback -(JNIEnv *, jobject, jobject, jint, jobject, jboolean, jboolean, jint, jbyteArray); - -/* - * Class: org_iotivity_jar_caleserverinterface - * Method: CALeGattServerExecuteWriteCallback - * Signature: (Landroid/bluetooth/BluetoothDevice;IZ)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleserverinterface_CALeGattServerExecuteWriteCallback -(JNIEnv *, jobject, jobject, jint, jboolean); - -/* - * Class: org_iotivity_jar_caleserverinterface - * Method: CALeGattServerNotificationSentCallback - * Signature: (Landroid/bluetooth/BluetoothDevice;I)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleserverinterface_CALeGattServerNotificationSentCallback -(JNIEnv *, jobject, jobject, jint); - -/* - * Class: org_iotivity_jar_caleserverinterface - * Method: CALeAdvertiseStartSuccessCallback - * Signature: (Landroid/bluetooth/le/AdvertiseSettings;)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleserverinterface_CALeAdvertiseStartSuccessCallback -(JNIEnv *, jobject, jobject); - -/* - * Class: org_iotivity_jar_caleserverinterface - * Method: CALeAdvertiseStartFailureCallback - * Signature: (I)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_jar_caleserverinterface_CALeAdvertiseStartFailureCallback -(JNIEnv *, jobject, jint); - - -#ifdef __cplusplus -} -#endif -#endif - diff --git a/resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c b/resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c index 85795f4..a4103eb 100644 --- a/resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c +++ b/resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c @@ -93,7 +93,7 @@ static jobject g_context = NULL; static CAResult_t CAIPUpdateInterfaceInformation(u_arraylist_t **netInterfaceList); /** * @fn CACreateIPJNIInterfaceObject - * @brief creates new instance of caipinterface through JNI + * @brief creates new instance of CaIpInterface through JNI */ static CAResult_t CACreateIPJNIInterfaceObject(jobject context); @@ -175,11 +175,11 @@ CAResult_t CACreateIPJNIInterfaceObject(jobject context) return CA_STATUS_FAILED; } - //Create caipinterface jni instance + //Create CaIpInterface jni instance jclass IPJniInterface = (*env)->FindClass(env, "org/iotivity/ca/CaIpInterface"); if (!IPJniInterface) { - OIC_LOG(ERROR, IP_MONITOR_TAG, "Could not get caipinterface class"); + OIC_LOG(ERROR, IP_MONITOR_TAG, "Could not get CaIpInterface class"); return CA_STATUS_FAILED; } @@ -187,12 +187,12 @@ CAResult_t CACreateIPJNIInterfaceObject(jobject context) "(Landroid/content/Context;)V"); if (!IPInterfaceConstructorMethod) { - OIC_LOG(ERROR, IP_MONITOR_TAG, "Could not get caipinterface constructor method"); + OIC_LOG(ERROR, IP_MONITOR_TAG, "Could not get CaIpInterface constructor method"); return CA_STATUS_FAILED; } (*env)->NewObject(env, IPJniInterface, IPInterfaceConstructorMethod, gApplicationContext); - OIC_LOG(DEBUG, IP_MONITOR_TAG, "Create caipinterface instance, success"); + OIC_LOG(DEBUG, IP_MONITOR_TAG, "Create CaIpInterface instance, success"); OIC_LOG(DEBUG, IP_MONITOR_TAG, "OUT"); return CA_STATUS_OK; @@ -496,7 +496,7 @@ CAResult_t CAIPInitializeNetworkMonitor(const ca_thread_pool_t threadPool) ret = CACreateIPJNIInterfaceObject(g_context); if (CA_STATUS_OK != ret) { - OIC_LOG(ERROR, IP_MONITOR_TAG, "unable to create caipinterface instance"); + OIC_LOG(ERROR, IP_MONITOR_TAG, "unable to create CaIpInterface instance"); return ret; } @@ -769,23 +769,27 @@ void CAIPSendNetworkChangeCallback(CANetworkStatus_t currNetworkStatus) ca_mutex_unlock(g_stopNetworkMonitorMutex); return; } + ca_mutex_unlock(g_stopNetworkMonitorMutex); + ca_mutex_lock(g_networkMonitorContextMutex); - if(!g_networkMonitorContext) + + if (!g_networkMonitorContext) { - OIC_LOG(DEBUG, IP_MONITOR_TAG, "g_networkChangeCb is NULL"); - ca_mutex_unlock(g_networkMonitorContextMutex); - return; + OIC_LOG(ERROR, IP_MONITOR_TAG, "g_networkMonitorContext is NULL"); + ca_mutex_unlock(g_networkMonitorContextMutex); + return; } + if (!g_networkMonitorContext->networkChangeCb) - { - OIC_LOG(ERROR, IP_MONITOR_TAG, "g_networkChangeCb->networkChangeCb is NULL"); + { + OIC_LOG(ERROR, IP_MONITOR_TAG, "g_networkMonitorContext->networkChangeCb is NULL"); ca_mutex_unlock(g_networkMonitorContextMutex); return; } ca_mutex_unlock(g_networkMonitorContextMutex); - + u_arraylist_t *netInterfaceList = u_arraylist_create(); VERIFY_NON_NULL_VOID(netInterfaceList, IP_MONITOR_TAG, @@ -866,20 +870,20 @@ void CAIPSendNetworkChangeCallback(CANetworkStatus_t currNetworkStatus) OIC_LOG(DEBUG, IP_MONITOR_TAG, "OUT"); } -JNIEXPORT void JNICALL Java_org_iotivity_ca_CaIpInterface_stateEnabled - (JNIEnv *env, jclass clazz) +JNIEXPORT void JNICALL +Java_org_iotivity_ca_CaIpInterface_caIpStateEnabled(JNIEnv *env, jclass class) { CANetworkStatus_t currNetworkStatus = CA_INTERFACE_UP; - OIC_LOG(DEBUG, IP_MONITOR_TAG, "CAIPStateEnabled"); + OIC_LOG(DEBUG, IP_MONITOR_TAG, "caIpStateEnabled"); CAIPSendNetworkChangeCallback(currNetworkStatus); } -JNIEXPORT void JNICALL Java_org_iotivity_ca_CaIpInterface_stateDisabled - (JNIEnv *env, jclass clazz) +JNIEXPORT void JNICALL +Java_org_iotivity_ca_CaIpInterface_caIpStateDisabled(JNIEnv *env, jclass class) { CANetworkStatus_t currNetworkStatus = CA_INTERFACE_DOWN; - OIC_LOG(DEBUG, IP_MONITOR_TAG, "CAIPStateDisabled"); + OIC_LOG(DEBUG, IP_MONITOR_TAG, "caIpStateDisabled"); CAIPSendNetworkChangeCallback(currNetworkStatus); } diff --git a/resource/csdk/connectivity/src/ip_adapter/android/org_iotivity_ca_CaIpInterface.h b/resource/csdk/connectivity/src/ip_adapter/android/org_iotivity_ca_CaIpInterface.h index 1d66553..dbd2edf 100644 --- a/resource/csdk/connectivity/src/ip_adapter/android/org_iotivity_ca_CaIpInterface.h +++ b/resource/csdk/connectivity/src/ip_adapter/android/org_iotivity_ca_CaIpInterface.h @@ -1,27 +1,47 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ +/****************************************************************** + * + * 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 /* Header for class org_iotivity_ca_CaIpInterface */ #ifndef _Included_org_iotivity_ca_CaIpInterface #define _Included_org_iotivity_ca_CaIpInterface #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif /* - * Class: org_iotivity_ca_CaIpInterface - * Method: stateEnabled + * Class: org_iotivity_ca_caIpInterface + * Method: CaIpStateEnabled * Signature: ()V */ -JNIEXPORT void JNICALL Java_org_iotivity_ca_CaIpInterface_stateEnabled - (JNIEnv *, jclass); +JNIEXPORT void JNICALL +Java_org_iotivity_ca_CaIpInterface_caIpStateEnabled(JNIEnv *, jclass); /* - * Class: org_iotivity_ca_CaIpInterface - * Method: stateDisabled + * Class: org_iotivity_ca_caIpInterface + * Method: CaIpStateDisabled * Signature: ()V */ -JNIEXPORT void JNICALL Java_org_iotivity_ca_CaIpInterface_stateDisabled - (JNIEnv *, jclass); +JNIEXPORT void JNICALL +Java_org_iotivity_ca_CaIpInterface_caIpStateDisabled(JNIEnv *, jclass); #ifdef __cplusplus } -- 2.7.4