replace strcmp with strcasecmp in android BLE
authorjihwan.seo <jihwan.seo@samsung.com>
Mon, 13 Feb 2017 09:59:29 +0000 (18:59 +0900)
committerDan Mihai <Daniel.Mihai@microsoft.com>
Fri, 17 Feb 2017 03:19:18 +0000 (03:19 +0000)
since there is no difference between upper case and lower case
for BLE MAC address.
strcmp method should be replaced.

Change-Id: I729a55216551d1062679148bc9511a4fb9164163
Signed-off-by: jihwan.seo <jihwan.seo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/17221
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
resource/csdk/connectivity/src/bt_le_adapter/android/caleclient.c
resource/csdk/connectivity/src/bt_le_adapter/android/caleserver.c
resource/csdk/connectivity/src/bt_le_adapter/android/calestate.c
resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c

index 95860df..2f29cc6 100644 (file)
@@ -944,7 +944,7 @@ CAResult_t CALEClientSendUnicastMessageImpl(const char* address, const uint8_t*
                 goto error_exit;
             }
 
-            if (!strcmp(setAddress, address))
+            if (!strcasecmp(setAddress, address))
             {
                 (*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
                 (*env)->DeleteLocalRef(env, jni_setAddress);
@@ -2714,7 +2714,7 @@ CAResult_t CALEClientDisconnectforAddress(JNIEnv *env, jstring remote_address)
         }
 
         OIC_LOG_V(DEBUG, TAG, "target address : %s, set address : %s", address, setAddress);
-        if (!strcmp(address, setAddress))
+        if (!strcasecmp(address, setAddress))
         {
             CAResult_t res = CALEClientDisconnect(env, jarrayObj);
             if (CA_STATUS_OK != res)
@@ -3592,7 +3592,7 @@ bool CALEClientIsDeviceInScanDeviceList(JNIEnv *env, const char* remoteAddress)
             return true;
         }
 
-        if (!strcmp(remoteAddress, setAddress))
+        if (!strcasecmp(remoteAddress, setAddress))
         {
             (*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
             (*env)->DeleteLocalRef(env, jni_setAddress);
@@ -3693,7 +3693,7 @@ CAResult_t CALEClientRemoveDeviceInScanDeviceList(JNIEnv *env, jstring address)
             return CA_STATUS_FAILED;
         }
 
-        if (!strcmp(setAddress, remoteAddress))
+        if (!strcasecmp(setAddress, remoteAddress))
         {
             OIC_LOG_V(DEBUG, TAG, "remove object : %s", remoteAddress);
             (*env)->DeleteGlobalRef(env, jarrayObj);
@@ -3802,7 +3802,7 @@ bool CALEClientIsGattObjInList(JNIEnv *env, const char* remoteAddress)
             return true;
         }
 
-        if (!strcmp(remoteAddress, setAddress))
+        if (!strcasecmp(remoteAddress, setAddress))
         {
             OIC_LOG(DEBUG, TAG, "the device is already set");
             (*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
@@ -3853,7 +3853,7 @@ jobject CALEClientGetGattObjInList(JNIEnv *env, const char* remoteAddress)
             return NULL;
         }
 
-        if (!strcmp(remoteAddress, setAddress))
+        if (!strcasecmp(remoteAddress, setAddress))
         {
             OIC_LOG(DEBUG, TAG, "the device is already set");
             (*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
@@ -3963,7 +3963,7 @@ CAResult_t CALEClientRemoveGattObj(JNIEnv *env, jobject gatt)
             return CA_STATUS_FAILED;
         }
 
-        if (!strcmp(setAddress, remoteAddress))
+        if (!strcasecmp(setAddress, remoteAddress))
         {
             OIC_LOG_V(DEBUG, TAG, "remove object : %s", remoteAddress);
             (*env)->DeleteGlobalRef(env, jarrayObj);
@@ -4040,7 +4040,7 @@ CAResult_t CALEClientRemoveGattObjForAddr(JNIEnv *env, jstring addr)
             return CA_STATUS_FAILED;
         }
 
-        if (!strcmp(setAddress, remoteAddress))
+        if (!strcasecmp(setAddress, remoteAddress))
         {
             OIC_LOG_V(DEBUG, TAG, "remove object : %s", remoteAddress);
             (*env)->DeleteGlobalRef(env, jarrayObj);
@@ -4146,7 +4146,7 @@ jstring CALEClientGetLEAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice)
         }
 
         OIC_LOG_V(DEBUG, TAG, "btAddress : %s (idx: %d)", btAddress, index);
-        if (!strcmp(targetAddress, btAddress))
+        if (!strcasecmp(targetAddress, btAddress))
         {
             OIC_LOG(DEBUG, TAG, "Found Gatt object from BT device");
 
index 11ccf9c..3cbb821 100644 (file)
@@ -1900,7 +1900,7 @@ CAResult_t CALEServerSendUnicastMessageImpl(JNIEnv *env, const char* address, co
         OIC_LOG_V(DEBUG, TAG, "setAddress : %s", setAddress);
         OIC_LOG_V(DEBUG, TAG, "address : %s", address);
 
-        if (!strcmp(setAddress, address))
+        if (!strcasecmp(setAddress, address))
         {
             OIC_LOG(DEBUG, TAG, "found the device");
 
@@ -2123,7 +2123,7 @@ bool CALEServerIsDeviceInList(JNIEnv *env, const char* remoteAddress)
             return false;
         }
 
-        if (!strcmp(remoteAddress, setAddress))
+        if (!strcasecmp(remoteAddress, setAddress))
         {
             OIC_LOG(ERROR, TAG, "the device is already set");
             (*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
@@ -2257,7 +2257,7 @@ CAResult_t CALEServerRemoveDevice(JNIEnv *env, jstring address)
                 continue;
             }
 
-            if (!strcmp(setAddress, remoteAddress))
+            if (!strcasecmp(setAddress, remoteAddress))
             {
                 OIC_LOG_V(DEBUG, TAG, "device address : %s", remoteAddress);
 
index d9f7d96..c1b7101 100644 (file)
@@ -132,7 +132,7 @@ bool CALEIsDeviceInList(const char* remoteAddress,
             return false;
         }
 
-        if (!strcmp(remoteAddress, state->address))
+        if (!strcasecmp(remoteAddress, state->address))
         {
             return true;
         }
@@ -214,7 +214,7 @@ CAResult_t CALERemoveDeviceState(const char* remoteAddress,
             continue;
         }
 
-        if (!strcmp(state->address, remoteAddress))
+        if (!strcasecmp(state->address, remoteAddress))
         {
             OIC_LOG_V(DEBUG, TAG, "remove state : %s", state->address);
 
@@ -250,7 +250,7 @@ CALEState_t* CALEGetStateInfo(const char* remoteAddress,
             continue;
         }
 
-        if (!strcmp(state->address, remoteAddress))
+        if (!strcasecmp(state->address, remoteAddress))
         {
             return state;
         }
index 1a1fe21..a7b82fd 100644 (file)
@@ -3750,7 +3750,7 @@ static void CALERemoveSendQueueData(CAQueueingThread_t *queueHandle, oc_mutex mu
             CALEData_t *bleData = (CALEData_t *) message->msg;
             if (bleData && bleData->remoteEndpoint)
             {
-                if (!strcmp(bleData->remoteEndpoint->addr, address))
+                if (!strcasecmp(bleData->remoteEndpoint->addr, address))
                 {
                     OIC_LOG(DEBUG, CALEADAPTER_TAG, "found the message of disconnected device");
                     if (NULL != queueHandle->destroy)