From 22291a54565cf320542bfe45e5734ee6c77c910f Mon Sep 17 00:00:00 2001 From: "jihwan.seo" Date: Tue, 4 Aug 2015 14:39:16 +0900 Subject: [PATCH] removed warning in Android BLE - to add NULL checker for parameter. - to remove unnecessary code. Change-Id: I197e8339d2757bfa750d171ad74e6064bff2d5e5 Signed-off-by: jihwan.seo Reviewed-on: https://gerrit.iotivity.org/gerrit/2100 Tested-by: jenkins-iotivity Reviewed-by: Erich Keane Reviewed-by: Jon A. Cruz --- .../java/org/iotivity/ca/CaLeClientInterface.java | 39 ++---- .../java/org/iotivity/ca/CaLeServerInterface.java | 33 +---- .../src/bt_le_adapter/android/caleclient.c | 104 ++++------------ .../src/bt_le_adapter/android/caleclient.h | 13 +- .../src/bt_le_adapter/android/calenwmonitor.c | 3 +- .../src/bt_le_adapter/android/caleserver.c | 136 +++++++++------------ .../src/bt_le_adapter/android/caleutils.h | 8 +- .../android/org_iotivity_ca_CaLeClientInterface.h | 42 +------ .../android/org_iotivity_ca_CaLeServerInterface.h | 33 +---- 9 files changed, 104 insertions(+), 307 deletions(-) diff --git a/resource/csdk/connectivity/samples/android/casample/cAInterface/src/main/java/org/iotivity/ca/CaLeClientInterface.java b/resource/csdk/connectivity/samples/android/casample/cAInterface/src/main/java/org/iotivity/ca/CaLeClientInterface.java index 891cb40..5a21786 100755 --- a/resource/csdk/connectivity/samples/android/casample/cAInterface/src/main/java/org/iotivity/ca/CaLeClientInterface.java +++ b/resource/csdk/connectivity/samples/android/casample/cAInterface/src/main/java/org/iotivity/ca/CaLeClientInterface.java @@ -72,8 +72,7 @@ public class CaLeClientInterface { private native static void caLeRegisterGattCallback(BluetoothGattCallback callback); // BluetoothAdapter.LeScanCallback - private native static void caLeScanCallback(BluetoothDevice device, - int rssi, byte[] scanRecord); + private native static void caLeScanCallback(BluetoothDevice device); // BluetoothGattCallback private native static void caLeGattConnectionStateChangeCallback( @@ -81,24 +80,13 @@ public class CaLeClientInterface { 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); + BluetoothGatt gatt, 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); + BluetoothGatt gatt, byte[] data); - private native static void caLeGattDescriptorWriteCallback(BluetoothGatt gatt, - BluetoothGattDescriptor descriptor, - int status); + private native static void caLeGattDescriptorWriteCallback(BluetoothGatt gatt, int status); private native static void caLeGattReliableWriteCompletedCallback(BluetoothGatt gatt, int status); @@ -125,7 +113,7 @@ public class CaLeClientInterface { Log.d(TAG, "UUID : " + uuid.toString()); if(uuid.toString().contains(SERVICE_UUID.toLowerCase())) { Log.d(TAG, "we found that has the Device"); - caLeScanCallback(device, rssi, scanRecord); + caLeScanCallback(device); } } } catch(UnsatisfiedLinkError e) { @@ -202,9 +190,6 @@ public class CaLeClientInterface { public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) { super.onCharacteristicRead(gatt, characteristic, status); - - caLeGattCharacteristicReadCallback(gatt, characteristic, - characteristic.getValue(), status); } @Override @@ -212,8 +197,7 @@ public class CaLeClientInterface { BluetoothGattCharacteristic characteristic, int status) { super.onCharacteristicWrite(gatt, characteristic, status); - caLeGattCharacteristicWriteCallback(gatt, characteristic, - characteristic.getValue(), status); + caLeGattCharacteristicWriteCallback(gatt, characteristic.getValue(), status); } @Override @@ -221,16 +205,13 @@ public class CaLeClientInterface { BluetoothGattCharacteristic characteristic) { super.onCharacteristicChanged(gatt, characteristic); - caLeGattCharacteristicChangedCallback(gatt, characteristic, - characteristic.getValue()); + caLeGattCharacteristicChangedCallback(gatt, characteristic.getValue()); } @Override public void onDescriptorRead(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) { super.onDescriptorRead(gatt, descriptor, status); - - caLeGattDescriptorReadCallback(gatt, descriptor, status); } @Override @@ -238,21 +219,17 @@ public class CaLeClientInterface { int status) { super.onDescriptorWrite(gatt, descriptor, status); - caLeGattDescriptorWriteCallback(gatt, descriptor, status); + caLeGattDescriptorWriteCallback(gatt, 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); } }; diff --git a/resource/csdk/connectivity/samples/android/casample/cAInterface/src/main/java/org/iotivity/ca/CaLeServerInterface.java b/resource/csdk/connectivity/samples/android/casample/cAInterface/src/main/java/org/iotivity/ca/CaLeServerInterface.java index 75f447b..b2ed163 100755 --- a/resource/csdk/connectivity/samples/android/casample/cAInterface/src/main/java/org/iotivity/ca/CaLeServerInterface.java +++ b/resource/csdk/connectivity/samples/android/casample/cAInterface/src/main/java/org/iotivity/ca/CaLeServerInterface.java @@ -56,23 +56,10 @@ public class CaLeServerInterface { BluetoothGattService service); private native static void caLeGattServerCharacteristicReadRequestCallback( - BluetoothDevice device, - int requestId, int offset, BluetoothGattCharacteristic characteristic, byte[] data); + BluetoothDevice device, 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); + BluetoothDevice device, byte[] data); private native static void caLeGattServerNotificationSentCallback(BluetoothDevice device, int status); @@ -107,9 +94,7 @@ public class CaLeServerInterface { BluetoothGattCharacteristic characteristic) { super.onCharacteristicReadRequest(device, requestId, offset, characteristic); - caLeGattServerCharacteristicReadRequestCallback(device, requestId, offset, - characteristic, - characteristic.getValue()); + caLeGattServerCharacteristicReadRequestCallback(device, characteristic.getValue()); } @Override @@ -119,9 +104,7 @@ public class CaLeServerInterface { super.onCharacteristicWriteRequest(device, requestId, characteristic, preparedWrite, responseNeeded, offset, value); - caLeGattServerCharacteristicWriteRequestCallback(device, requestId, characteristic, - value, preparedWrite, responseNeeded, - offset, value); + caLeGattServerCharacteristicWriteRequestCallback(device, value); } @Override @@ -129,8 +112,6 @@ public class CaLeServerInterface { BluetoothDevice device, int requestId, int offset, BluetoothGattDescriptor descriptor) { super.onDescriptorReadRequest(device, requestId, offset, descriptor); - - caLeGattServerDescriptorReadRequestCallback(device, requestId, offset, descriptor); } @Override @@ -140,17 +121,11 @@ public class CaLeServerInterface { 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 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 7eb3bb9..86058b5 100644 --- a/resource/csdk/connectivity/src/bt_le_adapter/android/caleclient.c +++ b/resource/csdk/connectivity/src/bt_le_adapter/android/caleclient.c @@ -31,6 +31,7 @@ #include "logger.h" #include "oic_malloc.h" +#include "oic_string.h" #include "cathreadpool.h" /* for thread pool */ #include "camutex.h" #include "uarraylist.h" @@ -479,12 +480,6 @@ void CASetBLEClientErrorHandleCallback(CABLEErrorHandleCallback callback) g_clientErrorCallback = callback; } -CAResult_t CALEClientGetInterfaceInfo(char **address) -{ - OIC_LOG(INFO, TAG, "CALEClientGetInterfaceInfo is not supported"); - return CA_NOT_SUPPORTED; -} - CAResult_t CALEClientSendUnicastMessageImpl(const char* address, const char* data, const uint32_t dataLen) { @@ -3134,6 +3129,12 @@ CAResult_t CAUpdateCharacteristicsToGattServer(const char *remoteAddress, const VERIFY_NON_NULL(data, TAG, "data is null"); VERIFY_NON_NULL(remoteAddress, TAG, "remoteAddress is null"); + if (LE_UNICAST != type || position < 0) + { + OIC_LOG(ERROR, TAG, "this request is not unicast"); + return CA_STATUS_INVALID_PARAM; + } + return CALEClientSendUnicastMessage(remoteAddress, data, dataLen); } @@ -3167,17 +3168,9 @@ void CASetLEClientThreadPoolHandle(ca_thread_pool_t handle) CAResult_t CAGetLEAddress(char **local_address) { - OIC_LOG(DEBUG, TAG, "IN"); - - VERIFY_NON_NULL(local_address, TAG, "local_address is null"); - CAResult_t res = CALEClientGetInterfaceInfo(local_address); - if (CA_STATUS_OK != res) - { - OIC_LOG(INFO, TAG, "it didn't get local address"); - } - - OIC_LOG(DEBUG, TAG, "OUT"); - return CA_STATUS_OK; + VERIFY_NON_NULL(local_address, TAG, "local_address"); + OIC_LOG(INFO, TAG, "CAGetLEAddress is not support"); + return CA_NOT_SUPPORTED; } JNIEXPORT void JNICALL @@ -3186,6 +3179,7 @@ Java_org_iotivity_ca_CaLeClientInterface_caLeRegisterLeScanCallback(JNIEnv *env, { OIC_LOG(DEBUG, TAG, "CaLeRegisterLeScanCallback"); VERIFY_NON_NULL_VOID(env, TAG, "env is null"); + VERIFY_NON_NULL_VOID(obj, TAG, "obj is null"); VERIFY_NON_NULL_VOID(callback, TAG, "callback is null"); g_leScanCallback = (*env)->NewGlobalRef(env, callback); @@ -3197,6 +3191,7 @@ Java_org_iotivity_ca_CaLeClientInterface_caLeRegisterGattCallback(JNIEnv *env, j { OIC_LOG(DEBUG, TAG, "CaLeRegisterGattCallback"); VERIFY_NON_NULL_VOID(env, TAG, "env is null"); + VERIFY_NON_NULL_VOID(obj, TAG, "obj is null"); VERIFY_NON_NULL_VOID(callback, TAG, "callback is null"); g_leGattCallback = (*env)->NewGlobalRef(env, callback); @@ -3204,10 +3199,10 @@ Java_org_iotivity_ca_CaLeClientInterface_caLeRegisterGattCallback(JNIEnv *env, j JNIEXPORT void JNICALL Java_org_iotivity_ca_CaLeClientInterface_caLeScanCallback(JNIEnv *env, jobject obj, - jobject device, jint rssi, - jbyteArray scanRecord) + jobject device) { VERIFY_NON_NULL_VOID(env, TAG, "env is null"); + VERIFY_NON_NULL_VOID(obj, TAG, "obj is null"); VERIFY_NON_NULL_VOID(device, TAG, "device is null"); CAResult_t res = CALEClientAddScanDeviceToList(env, device); @@ -3232,6 +3227,7 @@ Java_org_iotivity_ca_CaLeClientInterface_caLeGattConnectionStateChangeCallback(J OIC_LOG_V(DEBUG, TAG, "CALeGattConnectionStateChangeCallback - status %d, newstate %d", status, newstate); VERIFY_NON_NULL_VOID(env, TAG, "env is null"); + VERIFY_NON_NULL_VOID(obj, TAG, "obj is null"); VERIFY_NON_NULL_VOID(gatt, TAG, "gatt is null"); if (GATT_SUCCESS == status && STATE_CONNECTED == newstate) // le connected @@ -3358,6 +3354,7 @@ Java_org_iotivity_ca_CaLeClientInterface_caLeGattServicesDiscoveredCallback(JNIE { OIC_LOG_V(DEBUG, TAG, "CALeGattServicesDiscoveredCallback - status %d: ", status); VERIFY_NON_NULL_VOID(env, TAG, "env is null"); + VERIFY_NON_NULL_VOID(obj, TAG, "obj is null"); VERIFY_NON_NULL_VOID(gatt, TAG, "gatt is null"); if (0 != status) // discovery error @@ -3445,32 +3442,17 @@ error_exit: /* * Class: org_iotivity_ca_jar_caleinterface - * Method: CALeGattCharacteristicReadCallback - * Signature: (Landroid/bluetooth/BluetoothGatt;Landroid/bluetooth/BluetoothGattCharacteristic;I)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_ca_CaLeClientInterface_caLeGattCharacteristicReadCallback(JNIEnv *env, - jobject obj, - jobject gatt, - jobject characteristic, - jbyteArray data, - jint status) -{ - OIC_LOG_V(DEBUG, TAG, "CALeGattCharacteristicReadCallback - status : %d", status); -} - -/* - * Class: org_iotivity_ca_jar_caleinterface * Method: CALeGattCharacteristicWritjclasseCallback * Signature: (Landroid/bluetooth/BluetoothGatt;Landroid/bluetooth/BluetoothGattCharacteristic;I)V */ JNIEXPORT void JNICALL Java_org_iotivity_ca_CaLeClientInterface_caLeGattCharacteristicWriteCallback( - JNIEnv *env, jobject obj, jobject gatt, jobject characteristic, jbyteArray data, + JNIEnv *env, jobject obj, jobject gatt, jbyteArray data, jint status) { OIC_LOG_V(DEBUG, TAG, "CALeGattCharacteristicWriteCallback - status : %d", status); VERIFY_NON_NULL_VOID(env, TAG, "env is null"); + VERIFY_NON_NULL_VOID(obj, TAG, "obj is null"); VERIFY_NON_NULL_VOID(gatt, TAG, "gatt is null"); jboolean isCopy; @@ -3531,10 +3513,11 @@ error_exit: */ JNIEXPORT void JNICALL Java_org_iotivity_ca_CaLeClientInterface_caLeGattCharacteristicChangedCallback( - JNIEnv *env, jobject obj, jobject gatt, jobject characteristic, jbyteArray data) + JNIEnv *env, jobject obj, jobject gatt, jbyteArray data) { OIC_LOG(DEBUG, TAG, "CALeGattCharacteristicChangedCallback"); VERIFY_NON_NULL_VOID(env, TAG, "env is null"); + VERIFY_NON_NULL_VOID(obj, TAG, "obj is null"); VERIFY_NON_NULL_VOID(gatt, TAG, "gatt is null"); VERIFY_NON_NULL_VOID(data, TAG, "data is null"); @@ -3588,31 +3571,17 @@ Java_org_iotivity_ca_CaLeClientInterface_caLeGattCharacteristicChangedCallback( /* * Class: org_iotivity_ca_jar_caleinterface - * Method: CALeGattDescriptorReadCallback - * Signature: (Landroid/bluetooth/BluetoothGatt;Landroid/bluetooth/BluetoothGattDescriptor;I)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_ca_CaLeClientInterface_caLeGattDescriptorReadCallback(JNIEnv *env, jobject obj, - jobject gatt, - jobject descriptor, - jint status) -{ - OIC_LOG_V(DEBUG, TAG, "CALeGattDescriptorReadCallback - status %d: ", status); -} - -/* - * Class: org_iotivity_ca_jar_caleinterface * Method: CALeGattDescriptorWriteCallback * Signature: (Landroid/bluetooth/BluetoothGatt;Landroid/bluetooth/BluetoothGattDescriptor;I)V */ JNIEXPORT void JNICALL Java_org_iotivity_ca_CaLeClientInterface_caLeGattDescriptorWriteCallback(JNIEnv *env, jobject obj, - jobject gatt, - jobject descriptor, - jint status) + jobject gatt, + jint status) { OIC_LOG_V(DEBUG, TAG, "CALeGattDescriptorWriteCallback - status %d: ", status); VERIFY_NON_NULL_VOID(env, TAG, "env is null"); + VERIFY_NON_NULL_VOID(obj, TAG, "obj is null"); VERIFY_NON_NULL_VOID(gatt, TAG, "gatt is null"); CAResult_t res = CALEClientWriteCharacteristic(env, gatt); @@ -3629,30 +3598,3 @@ error_exit: CALEClientSendFinish(env, gatt); return; } - -/* - * Class: org_iotivity_ca_jar_caleinterface - * Method: CALeGattReliableWriteCompletedCallback - * Signature: (Landroid/bluetooth/BluetoothGatt;I)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_ca_CaLeClientInterface_caLeGattReliableWriteCompletedCallback(JNIEnv *env, - jobject obj, - jobject gatt, - jint status) -{ - OIC_LOG_V(DEBUG, TAG, "CALeGattReliableWriteCompletedCallback - status %d: ", status); -} - -/* - * Class: org_iotivity_ca_jar_caleinterface - * Method: CALeGattReadRemoteRssiCallback - * Signature: (Landroid/bluetooth/BluetoothGatt;II)V - */ -JNIEXPORT void JNICALL -Java_org_iotivity_ca_CaLeClientInterface_caLeGattReadRemoteRssiCallback(JNIEnv *env, jobject obj, - jobject gatt, jint rssi, - jint status) -{ - OIC_LOG_V(DEBUG, TAG, "CALeGattReadRemoteRssiCallback - rssi %d, status %d: ", rssi, status); -} diff --git a/resource/csdk/connectivity/src/bt_le_adapter/android/caleclient.h b/resource/csdk/connectivity/src/bt_le_adapter/android/caleclient.h index ad1ad8c..870a0a6 100644 --- a/resource/csdk/connectivity/src/bt_le_adapter/android/caleclient.h +++ b/resource/csdk/connectivity/src/bt_le_adapter/android/caleclient.h @@ -43,13 +43,13 @@ static const uint16_t STATE_SEND_NONE = 0; static const uint16_t STATE_SEND_SUCCESS = 1; static const uint16_t STATE_SEND_FAILED = 2; -static const uint32_t STATE_CONNECTED = 2; -static const uint32_t STATE_DISCONNECTED = 0; +static const jint STATE_CONNECTED = 2; +static const jint STATE_DISCONNECTED = 0; typedef struct le_state_info { char address[CA_MACADDR_SIZE]; - uint32_t connectedState; + jint connectedState; uint16_t notificationState; uint16_t sendState; } CALEState_t; @@ -154,13 +154,6 @@ void CALEClientStopMulticastServer(); void CALEClientSetCallback(CAPacketReceiveCallback callback); /** - * @brief get local address (interface) - * @param address [OUT] local address - * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h) - */ -CAResult_t CALEClientGetInterfaceInfo(char **address); - -/** * @brief get local address (implement) * @param address [OUT] local address * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h) 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 328cd3e..ac074d1 100644 --- a/resource/csdk/connectivity/src/bt_le_adapter/android/calenwmonitor.c +++ b/resource/csdk/connectivity/src/bt_le_adapter/android/calenwmonitor.c @@ -214,7 +214,7 @@ Java_org_iotivity_ca_CaLeClientInterface_caLeStateChangedCallback(JNIEnv *env, j jint status) { VERIFY_NON_NULL_VOID(env, TAG, "env is null"); - + VERIFY_NON_NULL_VOID(obj, TAG, "obj is null"); OIC_LOG(DEBUG, TAG, "CaLeClientInterface - Network State Changed"); @@ -261,6 +261,7 @@ Java_org_iotivity_ca_CaLeClientInterface_caLeBondStateChangedCallback(JNIEnv *en { OIC_LOG(DEBUG, TAG, "CaLeClientInterface - Bond State Changed"); VERIFY_NON_NULL_VOID(env, TAG, "env is null"); + VERIFY_NON_NULL_VOID(obj, TAG, "obj is null"); VERIFY_NON_NULL_VOID(addr, TAG, "addr is null"); // remove obj for client 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 4702408..dfa9c15 100644 --- a/resource/csdk/connectivity/src/bt_le_adapter/android/caleserver.c +++ b/resource/csdk/connectivity/src/bt_le_adapter/android/caleserver.c @@ -886,16 +886,9 @@ jobject CALEServerCreateGattService(JNIEnv *env) return NULL; } -#ifdef USE_PROPERTY_WRITE_RESPONSE - jfieldID jni_fid_writeProperties = (*env)->GetStaticFieldID(env, - jni_cid_bluetoothGattCharacteristic, - "PROPERTY_WRITE", "I"); -#else jfieldID jni_fid_writeProperties = (*env)->GetStaticFieldID(env, jni_cid_bluetoothGattCharacteristic, "PROPERTY_WRITE_NO_RESPONSE", "I"); -#endif - if (!jni_fid_writeProperties) { OIC_LOG(ERROR, TAG, "jni_fid_writeProperties is null"); @@ -2076,11 +2069,12 @@ CAResult_t CALEServerReorderinglist(uint32_t index) JNIEXPORT void JNICALL Java_org_iotivity_ca_CaLeServerInterface_caLeRegisterGattServerCallback(JNIEnv *env, jobject obj, - jobject callback) + jobject 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"); + OIC_LOG(DEBUG, TAG, "Register Le Gatt Server Callback"); + VERIFY_NON_NULL_VOID(env, TAG, "env"); + VERIFY_NON_NULL_VOID(obj, TAG, "obj"); + VERIFY_NON_NULL_VOID(callback, TAG, "callback"); g_bluetoothGattServerCallback = (*env)->NewGlobalRef(env, callback); } @@ -2090,9 +2084,10 @@ Java_org_iotivity_ca_CaLeServerInterface_caLeRegisterBluetoothLeAdvertiseCallbac jobject obj, jobject 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"); + OIC_LOG(DEBUG, TAG, "Register Le Advertise Callback"); + VERIFY_NON_NULL_VOID(env, TAG, "env"); + VERIFY_NON_NULL_VOID(obj, TAG, "obj"); + VERIFY_NON_NULL_VOID(callback, TAG, "callback"); g_leAdvertiseCallback = (*env)->NewGlobalRef(env, callback); } @@ -2101,11 +2096,12 @@ JNIEXPORT void JNICALL 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, " Gatt Server ConnectionStateChange Callback"); OIC_LOG_V(DEBUG, TAG, "New connection State: %d", newState); - VERIFY_NON_NULL_VOID(env, TAG, "env is null"); - VERIFY_NON_NULL_VOID(device, TAG, "device is null"); + VERIFY_NON_NULL_VOID(env, TAG, "env"); + VERIFY_NON_NULL_VOID(obj, TAG, "obj"); + VERIFY_NON_NULL_VOID(device, TAG, "device"); jclass jni_cid_bluetoothProfile = (*env)->FindClass(env, "android/bluetooth/BluetoothProfile"); if (!jni_cid_bluetoothProfile) @@ -2182,43 +2178,37 @@ Java_org_iotivity_ca_CaLeServerInterface_caLeGattServerConnectionStateChangeCall JNIEXPORT void JNICALL Java_org_iotivity_ca_CaLeServerInterface_caLeGattServerServiceAddedCallback(JNIEnv *env, - jobject obj, - jint status, - jobject gattService) + jobject obj, + jint status, + jobject gattService) { - OIC_LOG_V(DEBUG, TAG, "CaLeServerInterface - Gatt Service Added Callback(%d)", status); + VERIFY_NON_NULL_VOID(env, TAG, "env"); + VERIFY_NON_NULL_VOID(obj, TAG, "obj"); + VERIFY_NON_NULL_VOID(gattService, TAG, "gattService"); + + OIC_LOG_V(DEBUG, TAG, "Gatt Service Added Callback(%d)", status); } JNIEXPORT void JNICALL Java_org_iotivity_ca_CaLeServerInterface_caLeGattServerCharacteristicReadRequestCallback( - JNIEnv *env, jobject obj, jobject device, jint requestId, jint offset, - jobject characteristic, jbyteArray data) + JNIEnv *env, jobject obj, jobject device, jbyteArray data) { - 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"); - -#ifdef USE_PROPERTY_WRITE_RESPONSE - CALEServerSendResponse(env, device, requestId, 0, offset, NULL); -#endif - + OIC_LOG(DEBUG, TAG, " Gatt Server Characteristic Read Request Callback"); + VERIFY_NON_NULL_VOID(env, TAG, "env"); + VERIFY_NON_NULL_VOID(obj, TAG, "obj"); + VERIFY_NON_NULL_VOID(device, TAG, "device"); + VERIFY_NON_NULL_VOID(data, TAG, "data"); } JNIEXPORT void JNICALL 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) + JNIEnv *env, jobject obj, jobject device, jbyteArray data) { - 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"); - VERIFY_NON_NULL_VOID(data, TAG, "data is null"); - -#ifdef USE_PROPERTY_WRITE_RESPONSE - CALEServerSendResponse(env, device, requestId, 0, offset, value); -#endif + OIC_LOG_V(DEBUG, TAG, "Gatt Server Characteristic Write Request Callback"); + VERIFY_NON_NULL_VOID(env, TAG, "env"); + VERIFY_NON_NULL_VOID(obj, TAG, "obj"); + VERIFY_NON_NULL_VOID(device, TAG, "device"); + VERIFY_NON_NULL_VOID(data, TAG, "data"); // get Byte Array and covert to char* jint length = (*env)->GetArrayLength(env, data); @@ -2266,56 +2256,40 @@ Java_org_iotivity_ca_CaLeServerInterface_caLeGattServerCharacteristicWriteReques } JNIEXPORT void JNICALL -Java_org_iotivity_ca_CaLeServerInterface_caLeGattServerDescriptorReadRequestCallback( - JNIEnv *env, jobject obj, jobject device, jint requestId, jint offset, jobject descriptor) -{ - OIC_LOG(DEBUG, TAG, "CaLeServerInterface_CALeGattServerDescriptorReadRequestCallback"); -} - -JNIEXPORT void JNICALL -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"); -} - -JNIEXPORT void JNICALL -Java_org_iotivity_ca_CaLeServerInterface_caLeGattServerExecuteWriteCallback(JNIEnv *env, - jobject obj, - jobject device, - jint requestId, - jboolean execute) +Java_org_iotivity_ca_CaLeServerInterface_caLeGattServerNotificationSentCallback(JNIEnv *env, + jobject obj, + jobject device, + jint status) { - OIC_LOG(DEBUG, TAG, "CaLeServerInterface_CALeGattServerExecuteWriteCallback"); - VERIFY_NON_NULL_VOID(env, TAG, "env is null"); - VERIFY_NON_NULL_VOID(device, TAG, "device is null"); + VERIFY_NON_NULL_VOID(env, TAG, "env"); + VERIFY_NON_NULL_VOID(obj, TAG, "obj"); + VERIFY_NON_NULL_VOID(device, TAG, "device"); -// CALEServerSendResponse(env, device, requestId, 0, 0, NULL); + OIC_LOG_V(DEBUG, TAG, "Gatt Server Notification Sent Callback(%d)", + status); } JNIEXPORT void JNICALL -Java_org_iotivity_ca_CaLeServerInterface_caLeGattServerNotificationSentCallback(JNIEnv *env, - jobject obj, - jobject device, - jint status) +Java_org_iotivity_ca_CaLeServerInterface_caLeAdvertiseStartSuccessCallback(JNIEnv *env, + jobject obj, + jobject settingsInEffect) { - OIC_LOG(DEBUG, TAG, "CaLeServerInterface - Gatt Server Notification Sent Callback"); -} + VERIFY_NON_NULL_VOID(env, TAG, "env"); + VERIFY_NON_NULL_VOID(obj, TAG, "obj"); + VERIFY_NON_NULL_VOID(settingsInEffect, TAG, "settingsInEffect"); -JNIEXPORT void JNICALL -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, "LE Advertise Start Success Callback"); } JNIEXPORT void JNICALL Java_org_iotivity_ca_CaLeServerInterface_caLeAdvertiseStartFailureCallback(JNIEnv *env, - jobject obj, - jint errorCode) + jobject obj, + jint errorCode) { - OIC_LOG_V(ERROR, TAG, "CaLeServerInterface - LE Advertise Start Failure Callback(%)", + VERIFY_NON_NULL_VOID(env, TAG, "env"); + VERIFY_NON_NULL_VOID(obj, TAG, "obj"); + + OIC_LOG_V(ERROR, TAG, "LE Advertise Start Failure Callback(%d)", errorCode); } diff --git a/resource/csdk/connectivity/src/bt_le_adapter/android/caleutils.h b/resource/csdk/connectivity/src/bt_le_adapter/android/caleutils.h index 8969b3e..aa552d7 100644 --- a/resource/csdk/connectivity/src/bt_le_adapter/android/caleutils.h +++ b/resource/csdk/connectivity/src/bt_le_adapter/android/caleutils.h @@ -42,11 +42,11 @@ static const char OIC_GATT_CHARACTERISTIC_REQUEST_UUID[] = CA_GATT_REQUEST_CHRC_ static const char OIC_GATT_CHARACTERISTIC_RESPONSE_UUID[] = CA_GATT_RESPONSE_CHRC_UUID; static const char OIC_GATT_CHARACTERISTIC_CONFIG_UUID[] = "00002902-0000-1000-8000-00805f9b34fb"; -static const uint32_t GATT_SUCCESS = 0; +static const jint GATT_SUCCESS = 0; -static const uint32_t BOND_BONDED = 12; -static const uint32_t BOND_BONDING = 11; -static const uint32_t BOND_NONE = 10; +static const jint BOND_BONDED = 12; +static const jint BOND_BONDING = 11; +static const jint BOND_NONE = 10; /** * @brief get uuid(jni object) from uuid(character) 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 index 91491bc..a210c6d 100644 --- 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 @@ -53,7 +53,7 @@ Java_org_iotivity_ca_caLeClientInterface_caLeRegisterGattCallback */ JNIEXPORT void JNICALL Java_org_iotivity_ca_caLeClientInterface_caLeScanCallback -(JNIEnv *, jobject, jobject, jint, jbyteArray); +(JNIEnv *, jobject, jobject); /* * Class: org_iotivity_ca_caLeClientInterface @@ -75,21 +75,12 @@ Java_org_iotivity_ca_caLeClientInterface_caLeGattServicesDiscoveredCallback /* * 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); +(JNIEnv *, jobject, jobject, jbyteArray, jint); /* * Class: org_iotivity_ca_caLeClientInterface @@ -98,16 +89,7 @@ Java_org_iotivity_ca_caLeClientInterface_caLeGattCharacteristicWriteCallback */ 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); +(JNIEnv *, jobject, jobject, jbyteArray); /* * Class: org_iotivity_ca_caLeClientInterface @@ -116,28 +98,10 @@ Java_org_iotivity_ca_caLeClientInterface_caLeGattDescriptorReadCallback */ 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 */ 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 index 10c4abe..f8b4810 100644 --- 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 @@ -73,7 +73,7 @@ Java_org_iotivity_ca_caLeServerInterface_caLeGattServerServiceAddedCallback */ JNIEXPORT void JNICALL Java_org_iotivity_ca_caLeServerInterface_caLeGattServerCharacteristicReadRequestCallback -(JNIEnv *, jobject, jobject, jint, jint, jobject, jbyteArray); +(JNIEnv *, jobject, jobject, jbyteArray); /* * Class: org_iotivity_ca_caLeServerInterface @@ -83,36 +83,7 @@ Java_org_iotivity_ca_caLeServerInterface_caLeGattServerCharacteristicReadRequest */ 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); +(JNIEnv *, jobject, jobject, jbyteArray); /* * Class: org_iotivity_ca_caLeServerInterface -- 2.7.4