From e502658ef0da9a5d4a4cd7465be9ebb3f7e11348 Mon Sep 17 00:00:00 2001 From: Jaewook Jung Date: Thu, 28 Apr 2016 18:34:07 +0900 Subject: [PATCH] code clean up for android edr Change-Id: Ic901a29cecd1376f416b049c71c693b77be0b3a5 Signed-off-by: Jaewook Jung Reviewed-on: https://gerrit.iotivity.org/gerrit/7977 Tested-by: jenkins-iotivity Reviewed-by: Jon A. Cruz --- .../src/bt_edr_adapter/android/caedrserver.c | 87 +++++++----- .../src/bt_edr_adapter/android/caedrutils.c | 152 +++++--------------- .../connectivity/src/bt_edr_adapter/caedradapter.c | 158 ++++++++++----------- 3 files changed, 164 insertions(+), 233 deletions(-) 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 1979eee..3d4dcb6 100644 --- a/resource/csdk/connectivity/src/bt_edr_adapter/android/caedrserver.c +++ b/resource/csdk/connectivity/src/bt_edr_adapter/android/caedrserver.c @@ -555,7 +555,7 @@ CAResult_t CAEDRStopReceiveThread() return CA_STATUS_OK; } -CAResult_t CAEDRNativeReadData(JNIEnv *env, uint32_t id) +CAResult_t CAEDRNativeReadData(JNIEnv *env, uint32_t idx) { if ((*env)->ExceptionCheck(env)) { @@ -565,7 +565,7 @@ CAResult_t CAEDRNativeReadData(JNIEnv *env, uint32_t id) return CA_STATUS_FAILED; } - jobject jni_obj_inputStream = CAEDRNativeGetInputStream(id); + jobject jni_obj_inputStream = CAEDRNativeGetInputStream(idx); if (!jni_obj_inputStream) { OIC_LOG(ERROR, TAG, "jni_obj_inputStream is null"); @@ -583,12 +583,13 @@ CAResult_t CAEDRNativeReadData(JNIEnv *env, uint32_t id) if (0 < available) { - jobject jni_obj_socket = CAEDRNativeGetDeviceSocket(id); + jobject jni_obj_socket = CAEDRNativeGetDeviceSocket(idx); if (!jni_obj_socket) { OIC_LOG(ERROR, TAG, "jni_obj_socket is null"); return CA_STATUS_FAILED; } + jstring jni_str_address = CAEDRNativeGetAddressFromDeviceSocket(env, jni_obj_socket); if (!jni_str_address) { @@ -604,35 +605,26 @@ CAResult_t CAEDRNativeReadData(JNIEnv *env, uint32_t id) return CA_STATUS_FAILED; } - OIC_LOG_V(DEBUG, TAG, "get InputStream..%d, %s", id, address); - jmethodID jni_mid_read = CAGetJNIMethodID(env, "java/io/InputStream", "read", "([BII)I"); - if (!jni_mid_read) - { - OIC_LOG(ERROR, TAG, "jni_mid_read is null"); - (*env)->ReleaseStringUTFChars(env, jni_str_address, address); - (*env)->DeleteLocalRef(env, jni_str_address); - return CA_STATUS_FAILED; - } - CAConnectedDeviceInfo_t *deviceInfo = (CAConnectedDeviceInfo_t *) CAEDRGetDeviceInfoFromAddress(address); - - (*env)->ReleaseStringUTFChars(env, jni_str_address, address); - (*env)->DeleteLocalRef(env, jni_str_address); if (!deviceInfo) { OIC_LOG(ERROR, TAG, "failed to get device info from list"); + (*env)->ReleaseStringUTFChars(env, jni_str_address, address); + (*env)->DeleteLocalRef(env, jni_str_address); return CA_STATUS_FAILED; } - jint bufSize = (deviceInfo->totalDataLen == 0) ? - EDR_MAX_HEADER_LEN : deviceInfo->totalDataLen; + jint bufSize = (deviceInfo->totalDataLen == 0) ? EDR_MAX_HEADER_LEN + : deviceInfo->totalDataLen; if (!deviceInfo->recvData) { deviceInfo->recvData = OICCalloc(1, bufSize); if (!deviceInfo->recvData) { OIC_LOG(ERROR, TAG, "out of memory"); + (*env)->ReleaseStringUTFChars(env, jni_str_address, address); + (*env)->DeleteLocalRef(env, jni_str_address); return CA_STATUS_FAILED; } } @@ -641,29 +633,50 @@ CAResult_t CAEDRNativeReadData(JNIEnv *env, uint32_t id) if (0 >= remainSize) { OIC_LOG(ERROR, TAG, "remainSize value is invalid."); + (*env)->ReleaseStringUTFChars(env, jni_str_address, address); + (*env)->DeleteLocalRef(env, jni_str_address); return CA_STATUS_FAILED; } + jbyteArray jbuf = (*env)->NewByteArray(env, remainSize); if (!jbuf) { OIC_LOG(ERROR, TAG, "jbuf is null"); + (*env)->ReleaseStringUTFChars(env, jni_str_address, address); + (*env)->DeleteLocalRef(env, jni_str_address); + return CA_STATUS_FAILED; + } + + jmethodID jni_mid_read = CAGetJNIMethodID(env, "java/io/InputStream", "read", "([BII)I"); + if (!jni_mid_read) + { + OIC_LOG(ERROR, TAG, "jni_mid_read is null"); + (*env)->DeleteLocalRef(env, jbuf); + (*env)->ReleaseStringUTFChars(env, jni_str_address, address); + (*env)->DeleteLocalRef(env, jni_str_address); return CA_STATUS_FAILED; } + OIC_LOG_V(DEBUG, TAG, "read InputStream (idx:%d, addr:%s)", idx, address); jint recvLen = (*env)->CallIntMethod(env, jni_obj_inputStream, jni_mid_read, jbuf, (jint) 0, remainSize); if (-1 == recvLen) { OIC_LOG(ERROR, TAG, "recvLen is -1"); (*env)->DeleteLocalRef(env, jbuf); + (*env)->ReleaseStringUTFChars(env, jni_str_address, address); + (*env)->DeleteLocalRef(env, jni_str_address); return CA_STATUS_FAILED; } + OIC_LOG_V(DEBUG, TAG, "read success (length: %d bytes)", recvLen); jbyte* buf = (*env)->GetByteArrayElements(env, jbuf, NULL); if (!buf) { OIC_LOG(ERROR, TAG, "buf is null"); (*env)->DeleteLocalRef(env, jbuf); + (*env)->ReleaseStringUTFChars(env, jni_str_address, address); + (*env)->DeleteLocalRef(env, jni_str_address); return CA_STATUS_FAILED; } memcpy(deviceInfo->recvData + deviceInfo->recvDataLen, (const char*) buf, recvLen); @@ -672,8 +685,6 @@ CAResult_t CAEDRNativeReadData(JNIEnv *env, uint32_t id) (*env)->ReleaseByteArrayElements(env, jbuf, buf, 0); (*env)->DeleteLocalRef(env, jbuf); - OIC_LOG(DEBUG, TAG, "read something from InputStream"); - if (!deviceInfo->totalDataLen) { coap_transport_type transport = coap_get_tcp_header_type_from_initbyte( @@ -689,6 +700,8 @@ CAResult_t CAEDRNativeReadData(JNIEnv *env, uint32_t id) if (!newBuf) { OIC_LOG(ERROR, TAG, "out of memory"); + (*env)->ReleaseStringUTFChars(env, jni_str_address, address); + (*env)->DeleteLocalRef(env, jni_str_address); return CA_STATUS_FAILED; } deviceInfo->recvData = newBuf; @@ -709,13 +722,15 @@ CAResult_t CAEDRNativeReadData(JNIEnv *env, uint32_t id) CAEDRUpdateDeviceState(STATE_DISCONNECTED, address); ca_mutex_unlock(g_mutexStateList); + (*env)->ReleaseStringUTFChars(env, jni_str_address, address); + (*env)->DeleteLocalRef(env, jni_str_address); return CA_STATUS_FAILED; } if (g_edrPacketReceivedCallback) { - OIC_LOG_V(DEBUG, TAG,"data will be sent to callback routine: \ - %s, %d", deviceInfo->recvData, deviceInfo->recvDataLen); + OIC_LOG_V(DEBUG, TAG, "data will be sent to callback routine: %s, %d", + deviceInfo->recvData, deviceInfo->recvDataLen); uint32_t sentLength = 0; g_edrPacketReceivedCallback(address, (void*) deviceInfo->recvData, @@ -727,6 +742,9 @@ CAResult_t CAEDRNativeReadData(JNIEnv *env, uint32_t id) deviceInfo->totalDataLen = 0; } } + + (*env)->ReleaseStringUTFChars(env, jni_str_address, address); + (*env)->DeleteLocalRef(env, jni_str_address); } return CA_STATUS_OK; @@ -882,7 +900,16 @@ void CAEDRNativeAccept(JNIEnv *env, jobject serverSocketObject) } const char* address = (*env)->GetStringUTFChars(env, j_str_address, NULL); - OIC_LOG_V(DEBUG, TAG, "received the connection request from [%s]", address); + + OIC_LOG_V(INFO, TAG, "accept a new connection from [%s]", address); + + // update state + ca_mutex_lock(g_mutexStateList); + CAEDRUpdateDeviceState(STATE_CONNECTED, address); + ca_mutex_unlock(g_mutexStateList); + + (*env)->ReleaseStringUTFChars(env, j_str_address, address); + (*env)->DeleteLocalRef(env, j_str_address); // set socket to list jobject jni_socket = (*env)->NewGlobalRef(env, jni_obj_BTSocket); @@ -892,21 +919,13 @@ void CAEDRNativeAccept(JNIEnv *env, jobject serverSocketObject) (*env)->DeleteLocalRef(env, jni_obj_BTSocket); return; } + ca_mutex_lock(g_mutexObjectList); CAEDRNativeAddDeviceSocketToList(env, jni_socket); - (*env)->DeleteGlobalRef(env, jni_socket); - (*env)->DeleteLocalRef(env, jni_obj_BTSocket); ca_mutex_unlock(g_mutexObjectList); - // update state - ca_mutex_lock(g_mutexStateList); - CAEDRUpdateDeviceState(STATE_CONNECTED, address); - ca_mutex_unlock(g_mutexStateList); - - (*env)->ReleaseStringUTFChars(env, j_str_address, address); - (*env)->DeleteLocalRef(env, j_str_address); - - OIC_LOG_V(DEBUG, TAG, "connected with [%s]", address); + (*env)->DeleteGlobalRef(env, jni_socket); + (*env)->DeleteLocalRef(env, jni_obj_BTSocket); } else { diff --git a/resource/csdk/connectivity/src/bt_edr_adapter/android/caedrutils.c b/resource/csdk/connectivity/src/bt_edr_adapter/android/caedrutils.c index 885ceef..6dc604d 100644 --- a/resource/csdk/connectivity/src/bt_edr_adapter/android/caedrutils.c +++ b/resource/csdk/connectivity/src/bt_edr_adapter/android/caedrutils.c @@ -44,11 +44,7 @@ static u_arraylist_t *g_deviceObjectList = NULL; // get address from bluetooth socket jstring CAEDRNativeGetAddressFromDeviceSocket(JNIEnv *env, jobject bluetoothSocketObj) { - if (!bluetoothSocketObj) - { - OIC_LOG(ERROR, TAG, "bluetoothSocketObj is null"); - return NULL; - } + VERIFY_NON_NULL_RET(bluetoothSocketObj, TAG, "bluetoothSocketObj", NULL); jmethodID jni_mid_getRemoteDevice = CAGetJNIMethodID( env, CLASSPATH_BT_SOCKET, "getRemoteDevice", "()Landroid/bluetooth/BluetoothDevice;"); @@ -298,11 +294,7 @@ jboolean CAEDRNativeIsEnableBTAdapter(JNIEnv *env) jstring CAEDRNativeGetAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice) { - if (!bluetoothDevice) - { - OIC_LOG(ERROR, TAG, "bluetoothDevice is null"); - return NULL; - } + VERIFY_NON_NULL_RET(bluetoothDevice, TAG, "bluetoothDevice", NULL); jmethodID jni_mid_getAddress = CAGetJNIMethodID(env, CLASSPATH_BT_DEVICE, @@ -342,11 +334,8 @@ void CAEDRNativeCreateDeviceStateList() void CAEDRUpdateDeviceState(CAConnectedState_t state, const char *address) { - if (!address) - { - OIC_LOG(ERROR, TAG, "address is null"); - return; - } + VERIFY_NON_NULL_VOID(address, TAG, "address"); + CAConnectedDeviceInfo_t *deviceInfo = (CAConnectedDeviceInfo_t *) OICCalloc(1, sizeof(CAConnectedDeviceInfo_t)); if (!deviceInfo) @@ -362,11 +351,7 @@ void CAEDRUpdateDeviceState(CAConnectedState_t state, const char *address) void CAEDRNativeAddDeviceStateToList(CAConnectedDeviceInfo_t *deviceInfo) { - if (!deviceInfo) - { - OIC_LOG(ERROR, TAG, "device is null"); - return; - } + VERIFY_NON_NULL_VOID(deviceInfo, TAG, "deviceInfo"); if (!g_deviceStateList) { @@ -385,11 +370,7 @@ void CAEDRNativeAddDeviceStateToList(CAConnectedDeviceInfo_t *deviceInfo) bool CAEDRNativeIsDeviceInList(const char* remoteAddress) { - if (!remoteAddress) - { - OIC_LOG(ERROR, TAG, "remoteAddress is null"); - return false; - } + VERIFY_NON_NULL_RET(remoteAddress, TAG, "remoteAddress", false); jint length = u_arraylist_length(g_deviceStateList); for (jint index = 0; index < length; index++) @@ -445,17 +426,13 @@ void CAEDRNativeRemoveAllDeviceState() void CAEDRNativeRemoveDevice(const char *remoteAddress) { OIC_LOG(DEBUG, TAG, "CAEDRNativeRemoveDeviceforStateList"); + VERIFY_NON_NULL_VOID(remoteAddress, TAG, "remoteAddress"); if (!g_deviceStateList) { OIC_LOG(ERROR, TAG, "gdeviceStateList is null"); return; } - if (!remoteAddress) - { - OIC_LOG(ERROR, TAG, "remoteAddress is null"); - return; - } jint length = u_arraylist_length(g_deviceStateList); for (jint index = 0; index < length; index++) @@ -483,12 +460,7 @@ void CAEDRNativeRemoveDevice(const char *remoteAddress) CAConnectedState_t CAEDRIsConnectedDevice(const char *remoteAddress) { OIC_LOG(DEBUG, TAG, "CAEDRIsConnectedDevice"); - - if (!remoteAddress) - { - OIC_LOG(ERROR, TAG, "remoteAddress is null"); - return STATE_DISCONNECTED; - } + VERIFY_NON_NULL_RET(remoteAddress, TAG, "remoteAddress", STATE_DISCONNECTED); if (!g_deviceStateList) { @@ -534,12 +506,7 @@ void CAEDRNativeCreateDeviceSocketList() void CAEDRNativeAddDeviceSocketToList(JNIEnv *env, jobject deviceSocket) { OIC_LOG(DEBUG, TAG, "CANativeAddDeviceobjToList"); - - if (!deviceSocket) - { - OIC_LOG(ERROR, TAG, "Device is null"); - return; - } + VERIFY_NON_NULL_VOID(deviceSocket, TAG, "deviceSocket"); if (!g_deviceObjectList) { @@ -607,12 +574,7 @@ void CAEDRNativeAddDeviceSocketToList(JNIEnv *env, jobject deviceSocket) bool CAEDRNativeIsDeviceSocketInList(JNIEnv *env, const char* remoteAddress) { OIC_LOG(DEBUG, TAG, "CANativeIsDeviceObjInList"); - - if (!remoteAddress) - { - OIC_LOG(ERROR, TAG, "remoteAddress is null"); - return false; - } + VERIFY_NON_NULL_RET(remoteAddress, TAG, "remoteAddress", false); jint length = u_arraylist_length(g_deviceObjectList); for (jint index = 0; index < length; index++) @@ -716,7 +678,6 @@ void CAEDRNativeRemoveAllDeviceSocket(JNIEnv *env) jint length = u_arraylist_length(g_deviceObjectList); for (jint index = 0; index < length; index++) { - CAEDRSocketInfo_t *socketInfo = (CAEDRSocketInfo_t *) u_arraylist_get(g_deviceObjectList, index); if (!socketInfo) @@ -746,74 +707,24 @@ void CAEDRNativeRemoveAllDeviceSocket(JNIEnv *env) void CAEDRNativeRemoveDeviceSocket(JNIEnv *env, jobject deviceSocket) { OIC_LOG(DEBUG, TAG, "CAEDRNativeRemoveDeviceSocket"); + VERIFY_NON_NULL_VOID(deviceSocket, TAG, "deviceSocket"); - if (!g_deviceObjectList) + jstring jni_address = CAEDRNativeGetAddressFromDeviceSocket(env, deviceSocket); + if (!jni_address) { - OIC_LOG(ERROR, TAG, "gdeviceObjectList is null"); + OIC_LOG(ERROR, TAG, "jni_address is null"); return; } - jint length = u_arraylist_length(g_deviceObjectList); - for (jint index = 0; index < length; index++) - { - CAEDRSocketInfo_t *socketInfo = (CAEDRSocketInfo_t *) u_arraylist_get(g_deviceObjectList, - index); - if (!socketInfo) - { - OIC_LOG(ERROR, TAG, "socketInfo is null"); - continue; - } + CAEDRNativeRemoveDeviceSocketBaseAddr(env, jni_address); - jobject jarrayObj = socketInfo->deviceSocket; - if (!jarrayObj) - { - OIC_LOG(DEBUG, TAG, "jarrayObj is null"); - continue; - } - - jstring jni_setAddress = CAEDRNativeGetAddressFromDeviceSocket(env, jarrayObj); - if (!jni_setAddress) - { - OIC_LOG(DEBUG, TAG, "jni_setAddress is null"); - continue; - } - - jstring jni_remoteAddress = CAEDRNativeGetAddressFromDeviceSocket(env, deviceSocket); - if (!jni_remoteAddress) - { - OIC_LOG(DEBUG, TAG, "jni_remoteAddress is null"); - continue; - } - - const char* setAddress = (*env)->GetStringUTFChars(env, jni_setAddress, NULL); - const char* remoteAddress = (*env)->GetStringUTFChars(env, jni_remoteAddress, NULL); - - if (!strcmp(setAddress, remoteAddress)) - { - OIC_LOG_V(DEBUG, TAG, "remove object : %s", remoteAddress); - (*env)->DeleteGlobalRef(env, jarrayObj); - jobject jinputStream = socketInfo->inputStream; - if (jinputStream) - { - (*env)->DeleteGlobalRef(env, jinputStream); - } - (*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress); - (*env)->ReleaseStringUTFChars(env, jni_remoteAddress, remoteAddress); - - u_arraylist_remove(g_deviceObjectList, index); - break; - } - (*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress); - (*env)->ReleaseStringUTFChars(env, jni_remoteAddress, remoteAddress); - } - - OIC_LOG(DEBUG, TAG, "there are no target object"); return; } void CAEDRNativeRemoveDeviceSocketBaseAddr(JNIEnv *env, jstring address) { - OIC_LOG(DEBUG, TAG, "CAEDRNativeRemoveDeviceSocket"); + OIC_LOG(DEBUG, TAG, "CAEDRNativeRemoveDeviceSocketBaseAddr"); + VERIFY_NON_NULL_VOID(address, TAG, "address"); if (!g_deviceObjectList) { @@ -821,6 +732,8 @@ void CAEDRNativeRemoveDeviceSocketBaseAddr(JNIEnv *env, jstring address) return; } + const char* targetAddress = (*env)->GetStringUTFChars(env, address, NULL); + jint length = u_arraylist_length(g_deviceObjectList); for (jint index = 0; index < length; index++) { @@ -845,29 +758,33 @@ void CAEDRNativeRemoveDeviceSocketBaseAddr(JNIEnv *env, jstring address) OIC_LOG(ERROR, TAG, "jni_setAddress is null"); continue; } + const char* setAddress = (*env)->GetStringUTFChars(env, jni_setAddress, NULL); - const char* remoteAddress = (*env)->GetStringUTFChars(env, address, NULL); - if (!strcmp(setAddress, remoteAddress)) + if (!strcmp(setAddress, targetAddress)) { - OIC_LOG_V(DEBUG, TAG, "remove object : %s", remoteAddress); + OIC_LOG_V(DEBUG, TAG, "remove object : %s", targetAddress); (*env)->DeleteGlobalRef(env, jarrayObj); jobject jinputStream = socketInfo->inputStream; if (jinputStream) { (*env)->DeleteGlobalRef(env, jinputStream); } + (*env)->ReleaseStringUTFChars(env, address, targetAddress); (*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress); - (*env)->ReleaseStringUTFChars(env, address, remoteAddress); + (*env)->DeleteLocalRef(env, jni_setAddress); u_arraylist_remove(g_deviceObjectList, index); - break; + return; } (*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress); - (*env)->ReleaseStringUTFChars(env, address, remoteAddress); + (*env)->DeleteLocalRef(env, jni_setAddress); } - OIC_LOG(DEBUG, TAG, "there are no target object"); + OIC_LOG_V(DEBUG, TAG, "the target object doesn't exist in deviceObjectList (addr: %s)", + targetAddress); + (*env)->ReleaseStringUTFChars(env, address, targetAddress); + return; } @@ -898,7 +815,8 @@ jobject CAEDRNativeGetDeviceSocket(uint32_t index) jobject CAEDRNativeGetDeviceSocketBaseAddr(JNIEnv *env, const char* remoteAddress) { - OIC_LOG(DEBUG, TAG, "CAEDRNativeGetDeviceSocket"); + OIC_LOG(DEBUG, TAG, "CAEDRNativeGetDeviceSocketBaseAddr"); + VERIFY_NON_NULL_RET(remoteAddress, TAG, "remoteAddress", NULL); if (!g_deviceObjectList) { @@ -985,17 +903,13 @@ uint32_t CAEDRGetSocketListLength() CAConnectedDeviceInfo_t *CAEDRGetDeviceInfoFromAddress(const char *remoteAddress) { OIC_LOG(DEBUG, TAG, "CAEDRGetDeviceInfoFromAddress"); + VERIFY_NON_NULL_RET(remoteAddress, TAG, "remoteAddress", NULL); if (!g_deviceStateList) { OIC_LOG(ERROR, TAG, "gdeviceStateList is null"); return NULL; } - if (!remoteAddress) - { - OIC_LOG(ERROR, TAG, "remoteAddress is null"); - return NULL; - } jint length = u_arraylist_length(g_deviceStateList); for (jint index = 0; index < length; index++) diff --git a/resource/csdk/connectivity/src/bt_edr_adapter/caedradapter.c b/resource/csdk/connectivity/src/bt_edr_adapter/caedradapter.c index fb036ed..f0b3fdf 100644 --- a/resource/csdk/connectivity/src/bt_edr_adapter/caedradapter.c +++ b/resource/csdk/connectivity/src/bt_edr_adapter/caedradapter.c @@ -37,7 +37,7 @@ /** * Logging tag for module name. */ -#define EDR_ADAPTER_TAG "OIC_CA_EDR_ADAP" +#define TAG "OIC_CA_EDR_ADAP" /** * Reference to threadpool. @@ -134,11 +134,11 @@ CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback, CAErrorHandleCallback errorCallback, ca_thread_pool_t handle) { // Input validation - VERIFY_NON_NULL(registerCallback, EDR_ADAPTER_TAG, "register callback is NULL"); - VERIFY_NON_NULL(packetReceivedCallback, EDR_ADAPTER_TAG, "data receive callback is NULL"); - VERIFY_NON_NULL(netCallback, EDR_ADAPTER_TAG, "adapter state change callback is NULL"); - VERIFY_NON_NULL(connCallback, EDR_ADAPTER_TAG, "connection state change callback is NULL"); - VERIFY_NON_NULL(handle, EDR_ADAPTER_TAG, "Thread pool handle is NULL"); + VERIFY_NON_NULL(registerCallback, TAG, "register callback is NULL"); + VERIFY_NON_NULL(packetReceivedCallback, TAG, "data receive callback is NULL"); + VERIFY_NON_NULL(netCallback, TAG, "adapter state change callback is NULL"); + VERIFY_NON_NULL(connCallback, TAG, "connection state change callback is NULL"); + VERIFY_NON_NULL(handle, TAG, "Thread pool handle is NULL"); // Register the callbacks g_edrThreadPool = handle; @@ -150,8 +150,7 @@ CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback, CAResult_t res = CAEDRInitializeNetworkMonitor(handle); if (CA_STATUS_OK != res) { - OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "EDR N/w Monitor Initialize failed!, error number [%d]", - res); + OIC_LOG_V(ERROR, TAG, "EDR N/w Monitor Initialize failed!, error number [%d]", res); return res; } @@ -161,14 +160,14 @@ CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback, res = CAEDRClientInitialize(); if (CA_STATUS_OK != res) { - OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "EDR Client Initialize failed, error number [%d]", res); + OIC_LOG_V(ERROR, TAG, "EDR Client Initialize failed, error number [%d]", res); return res; } res = CAEDRServerInitialize(handle); if (CA_STATUS_OK != res) { - OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "EDR Server Initialize failed, error number [%d]", res); + OIC_LOG_V(ERROR, TAG, "EDR Server Initialize failed, error number [%d]", res); return res; } @@ -188,7 +187,7 @@ CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback, }; registerCallback(handler); - OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT"); + OIC_LOG(DEBUG, TAG, "OUT"); return CA_STATUS_OK; } @@ -198,34 +197,34 @@ CAResult_t CAStartEDR() CAResult_t ret = CAEDRStartNetworkMonitor(); if (CA_STATUS_OK != ret) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to Start n/w monitor"); + OIC_LOG(ERROR, TAG, "Failed to Start n/w monitor"); } // Get Bluetooth adapter state bool adapterState = false; if (CA_STATUS_OK != CAEDRGetAdapterEnableState(&adapterState)) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to get adapter enable state"); + OIC_LOG(ERROR, TAG, "Failed to get adapter enable state"); return CA_STATUS_FAILED; } if (false == adapterState) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Bluetooth adapter is disabled!"); + OIC_LOG(ERROR, TAG, "Bluetooth adapter is disabled!"); g_adapterState = false; return CA_ADAPTER_NOT_ENABLED; } if (CA_STATUS_OK != (ret = CAEDRClientSetCallbacks())) { - OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Start Network Monitor failed!, error number [%d] ", + OIC_LOG_V(ERROR, TAG, "Start Network Monitor failed!, error number [%d] ", ret); } // Initialize Send/Receive data message queues if (CA_STATUS_OK != (ret = CAEDRInitializeQueueHandlers())) { - OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, + OIC_LOG_V(ERROR, TAG, "CAAdapterInitializeQueues failed!, error number [%d] ", ret); CATerminateEDR(); return CA_STATUS_FAILED; @@ -234,7 +233,7 @@ CAResult_t CAStartEDR() // Start Send/Receive data message queues if (CA_STATUS_OK != (ret = CAAdapterStartQueue())) { - OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "CAAdapterStartQueue failed!, error number [%d] ", ret); + OIC_LOG_V(ERROR, TAG, "CAAdapterStartQueue failed!, error number [%d] ", ret); } return ret; @@ -257,7 +256,7 @@ CAResult_t CAStartEDRDiscoveryServer() CAResult_t result = CAEDRStartDeviceDiscovery(); if(CA_STATUS_OK != result) { - OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "Failed to Start Device discovery"); + OIC_LOG(DEBUG, TAG, "Failed to Start Device discovery"); } #endif @@ -268,18 +267,18 @@ int32_t CASendEDRUnicastData(const CAEndpoint_t *remoteEndpoint, const void *dat uint32_t dataLength) { // Input validation - VERIFY_NON_NULL_RET(remoteEndpoint, EDR_ADAPTER_TAG, "Remote endpoint is null", -1); - VERIFY_NON_NULL_RET(data, EDR_ADAPTER_TAG, "Data is null", -1); + VERIFY_NON_NULL_RET(remoteEndpoint, TAG, "Remote endpoint is null", -1); + VERIFY_NON_NULL_RET(data, TAG, "Data is null", -1); if (0 == dataLength) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Invalid input: data length is zero!"); + OIC_LOG(ERROR, TAG, "Invalid input: data length is zero!"); return -1; } if (0 == strlen(remoteEndpoint->addr)) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Invalid input: EDR Address is empty!"); + OIC_LOG(ERROR, TAG, "Invalid input: EDR Address is empty!"); return -1; } @@ -289,7 +288,7 @@ int32_t CASendEDRUnicastData(const CAEndpoint_t *remoteEndpoint, const void *dat CAResult_t err = CAAdapterSendData(address, serviceUUID, data, dataLength, &sentLength); if (CA_STATUS_OK != err) { - OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Send unicast data failed!, error num [%d]", err); + OIC_LOG_V(ERROR, TAG, "Send unicast data failed!, error num [%d]", err); g_errorCallback(remoteEndpoint, data, dataLength, err); return -1; } @@ -299,14 +298,14 @@ int32_t CASendEDRUnicastData(const CAEndpoint_t *remoteEndpoint, const void *dat int32_t CASendEDRMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLength) { - OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN - CASendEDRMulticastData"); + OIC_LOG(DEBUG, TAG, "IN - CASendEDRMulticastData"); // Input validation - VERIFY_NON_NULL_RET(data, EDR_ADAPTER_TAG, "Data is null", -1); + VERIFY_NON_NULL_RET(data, TAG, "Data is null", -1); if (0 == dataLength) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Invalid input: data length is zero!"); + OIC_LOG(ERROR, TAG, "Invalid input: data length is zero!"); return -1; } @@ -315,25 +314,24 @@ int32_t CASendEDRMulticastData(const CAEndpoint_t *endpoint, const void *data, u CAResult_t err = CAAdapterSendData(NULL, serviceUUID, data, dataLength, &sentLen); if (CA_STATUS_OK != err) { - OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Send multicast data failed!, error num [%d]", err); + OIC_LOG_V(ERROR, TAG, "Send multicast data failed!, error num [%d]", err); g_errorCallback(endpoint, data, dataLength, err); return -1; } - OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT - CASendEDRMulticastData"); + OIC_LOG(DEBUG, TAG, "OUT - CASendEDRMulticastData"); return sentLen; } CAResult_t CAGetEDRInterfaceInformation(CAEndpoint_t **info, uint32_t *size) { - VERIFY_NON_NULL(info, EDR_ADAPTER_TAG, "LocalConnectivity info is null"); + VERIFY_NON_NULL(info, TAG, "LocalConnectivity info is null"); CAResult_t err = CA_STATUS_OK; *size = 0; if (CA_STATUS_OK != (err = CAEDRGetInterfaceInformation(info))) { - OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, - "Failed to get local interface information!, error num [%d]", err); + OIC_LOG_V(ERROR, TAG, "Failed to get local interface information!, error num [%d]", err); return err; } @@ -395,7 +393,7 @@ CAResult_t CAStartServer() { if (false == g_adapterState) { - OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "Bluetooth adapter is disabled!"); + OIC_LOG(DEBUG, TAG, "Bluetooth adapter is disabled!"); // Setting g_serverState for starting Rfcommserver when adapter starts g_serverState = true; return CA_STATUS_OK; @@ -404,7 +402,7 @@ CAResult_t CAStartServer() CAResult_t err = CA_STATUS_OK; if (CA_STATUS_OK != (err = CAEDRServerStart())) { - OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Failed to start RFCOMM server!, error num [%d]", + OIC_LOG_V(ERROR, TAG, "Failed to start RFCOMM server!, error num [%d]", err); return err; } @@ -417,7 +415,7 @@ CAResult_t CAEDRInitializeQueueHandlers() if (CA_STATUS_OK == CAEDRInitializeSendHandler() && CA_STATUS_OK == CAEDRInitializeReceiveHandler()) { - OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "Queue is initialized!"); + OIC_LOG(DEBUG, TAG, "Queue is initialized!"); return CA_STATUS_OK; } @@ -429,21 +427,21 @@ CAResult_t CAEDRInitializeSendHandler() // Check if the message queue is already initialized if (g_sendQueueHandle) { - OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "Already queue is initialized!"); + OIC_LOG(DEBUG, TAG, "Already queue is initialized!"); return CA_STATUS_OK; } g_sendQueueHandle = (CAQueueingThread_t *) OICMalloc(sizeof(CAQueueingThread_t)); if (!g_sendQueueHandle) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Memory allocation failed!"); + OIC_LOG(ERROR, TAG, "Memory allocation failed!"); return CA_MEMORY_ALLOC_FAILED; } if (CA_STATUS_OK != CAQueueingThreadInitialize(g_sendQueueHandle, g_edrThreadPool, CAAdapterDataSendHandler, CAEDRDataDestroyer)) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to Initialize send queue thread"); + OIC_LOG(ERROR, TAG, "Failed to Initialize send queue thread"); return CA_STATUS_FAILED; } return CA_STATUS_OK; @@ -454,14 +452,14 @@ CAResult_t CAEDRInitializeReceiveHandler() // Check if the message queue is already initialized if (g_recvQueueHandle) { - OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "Already queue is initialized!"); + OIC_LOG(DEBUG, TAG, "Already queue is initialized!"); return CA_STATUS_OK; } g_recvQueueHandle = (CAQueueingThread_t *) OICMalloc(sizeof(CAQueueingThread_t)); if (!g_recvQueueHandle) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Memory allocation failed!"); + OIC_LOG(ERROR, TAG, "Memory allocation failed!"); return CA_MEMORY_ALLOC_FAILED; } @@ -470,7 +468,7 @@ CAResult_t CAEDRInitializeReceiveHandler() CAAdapterDataReceiverHandler, CAEDRDataDestroyer)) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to Initialize send queue thread"); + OIC_LOG(ERROR, TAG, "Failed to Initialize send queue thread"); OICFree(g_recvQueueHandle); g_recvQueueHandle = NULL; return CA_STATUS_FAILED; @@ -495,25 +493,25 @@ void CAAdapterTerminateQueues() void CAAdapterDataSendHandler(void *context) { - OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN - CAAdapterDataSendHandler"); + OIC_LOG(DEBUG, TAG, "IN - CAAdapterDataSendHandler"); CAEDRData *message = (CAEDRData *) context; if (!message) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to get message!"); + OIC_LOG(ERROR, TAG, "Failed to get message!"); return; } if (!message->remoteEndpoint) { - OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "remoteEndpoint is not available"); + OIC_LOG(DEBUG, TAG, "remoteEndpoint is not available"); return; } const char *remoteAddress = message->remoteEndpoint->addr; if(!remoteAddress) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "EDR Send Message error"); + OIC_LOG(ERROR, TAG, "EDR Send Message error"); //Error cannot be sent if remote address is NULL return; } @@ -521,12 +519,12 @@ void CAAdapterDataSendHandler(void *context) CAResult_t result = CAEDRClientSendData(remoteAddress, message->data, message->dataLen); if(CA_STATUS_OK != result) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "CAEDRClientSendData API failed"); + OIC_LOG(ERROR, TAG, "CAEDRClientSendData API failed"); CAEDRErrorHandler(remoteAddress, message->data, message->dataLen, result); return; } - OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT"); + OIC_LOG(DEBUG, TAG, "OUT"); } CAResult_t CAEDRClientSendData(const char *remoteAddress, const uint8_t *data, @@ -540,18 +538,18 @@ CAResult_t CAEDRClientSendData(const char *remoteAddress, const uint8_t *data, result = CAEDRClientSendUnicastData(remoteAddress, data, dataLength); if (CA_STATUS_OK != result) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to send unicast data !"); + OIC_LOG(ERROR, TAG, "Failed to send unicast data !"); return result; } } else { - OIC_LOG_V(DEBUG, EDR_ADAPTER_TAG, "sending multicast data : %s", data); + OIC_LOG_V(DEBUG, TAG, "sending multicast data : %s", data); result = CAEDRClientSendMulticastData(data, dataLength); if (CA_STATUS_OK != result) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to send multicast data !"); + OIC_LOG(ERROR, TAG, "Failed to send multicast data !"); return result; } } @@ -560,18 +558,18 @@ CAResult_t CAEDRClientSendData(const char *remoteAddress, const uint8_t *data, void CAAdapterDataReceiverHandler(void *context) { - OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN_CAAdapterDataReceiverHandler"); + OIC_LOG(DEBUG, TAG, "IN_CAAdapterDataReceiverHandler"); if (NULL == g_networkPacketReceivedCallback) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "g_networkPacketReceivedCallback is NULL"); + OIC_LOG(ERROR, TAG, "g_networkPacketReceivedCallback is NULL"); return; } CAEDRData *message = (CAEDRData *) context; if (NULL == message || NULL == message->remoteEndpoint) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to get message!"); + OIC_LOG(ERROR, TAG, "Failed to get message!"); return; } @@ -582,11 +580,11 @@ void CAAdapterDataReceiverHandler(void *context) if (!remoteEndpoint) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "remoteEndpoint is NULL"); + OIC_LOG(ERROR, TAG, "remoteEndpoint is NULL"); return; } - OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "Sending data up !"); + OIC_LOG(DEBUG, TAG, "Sending data up !"); const CASecureEndpoint_t sep = { .endpoint = *remoteEndpoint }; @@ -594,7 +592,7 @@ void CAAdapterDataReceiverHandler(void *context) CAFreeEndpoint(remoteEndpoint); - OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT_CAAdapterDataReceiverHandler"); + OIC_LOG(DEBUG, TAG, "OUT_CAAdapterDataReceiverHandler"); } CAResult_t CAAdapterStartQueue() @@ -602,7 +600,7 @@ CAResult_t CAAdapterStartQueue() // Start send queue thread if (CA_STATUS_OK != CAQueueingThreadStart(g_sendQueueHandle)) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to Start Send Data Thread"); + OIC_LOG(ERROR, TAG, "Failed to Start Send Data Thread"); CAEDRClientUnsetCallbacks(); //Disconnect all the client connections CAEDRClientDisconnectAll(); @@ -612,7 +610,7 @@ CAResult_t CAAdapterStartQueue() // Start receive queue thread if (CA_STATUS_OK != CAQueueingThreadStart(g_recvQueueHandle)) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to Start Receive Data Thread"); + OIC_LOG(ERROR, TAG, "Failed to Start Receive Data Thread"); CAEDRClientUnsetCallbacks(); //Disconnect all the client connections CAEDRClientDisconnectAll(); @@ -638,14 +636,14 @@ void CAAdapterRecvData(const char *remoteAddress, const uint8_t *data, uint32_t { if (false == g_adapterState) { - OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Bluetooth adapter is disabled!"); + OIC_LOG_V(ERROR, TAG, "Bluetooth adapter is disabled!"); *sentLength = 0; return; } // Input validation - VERIFY_NON_NULL_VOID(data, EDR_ADAPTER_TAG, "Data is null"); - VERIFY_NON_NULL_VOID(sentLength, EDR_ADAPTER_TAG, "Sent data length holder is null"); + VERIFY_NON_NULL_VOID(data, TAG, "Data is null"); + VERIFY_NON_NULL_VOID(sentLength, TAG, "Sent data length holder is null"); // Create remote endpoint CAEndpoint_t *remoteEndpoint = CACreateEndpointObject(CA_DEFAULT_FLAGS, @@ -653,7 +651,7 @@ void CAAdapterRecvData(const char *remoteAddress, const uint8_t *data, uint32_t remoteAddress, 0); if (NULL == remoteEndpoint) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to create remote endpoint !"); + OIC_LOG(ERROR, TAG, "Failed to create remote endpoint !"); return; } @@ -670,14 +668,14 @@ void CAEDRErrorHandler(const char *remoteAddress, const uint8_t *data, uint32_t dataLength, CAResult_t result) { // Input validation - VERIFY_NON_NULL_VOID(data, EDR_ADAPTER_TAG, "Data is null"); + VERIFY_NON_NULL_VOID(data, TAG, "Data is null"); // Create remote endpoint CAEndpoint_t *remoteEndpoint = CACreateEndpointObject(0, CA_ADAPTER_RFCOMM_BTEDR, remoteAddress, 0); if (!remoteEndpoint) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to create remote endpoint !"); + OIC_LOG(ERROR, TAG, "Failed to create remote endpoint !"); return; } @@ -690,18 +688,18 @@ void CAEDRErrorHandler(const char *remoteAddress, const uint8_t *data, CAResult_t CAAdapterSendData(const char *remoteAddress, const char *serviceUUID, const uint8_t *data, uint32_t dataLength, uint32_t *sentLength) { - OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN - CAAdapterSendData"); + OIC_LOG(DEBUG, TAG, "IN - CAAdapterSendData"); if (false == g_adapterState) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Bluetooth adapter is disabled!"); + OIC_LOG(ERROR, TAG, "Bluetooth adapter is disabled!"); *sentLength = 0; return CA_ADAPTER_NOT_ENABLED; } // Input validation - VERIFY_NON_NULL(serviceUUID, EDR_ADAPTER_TAG, "service UUID is null"); - VERIFY_NON_NULL(data, EDR_ADAPTER_TAG, "Data is null"); - VERIFY_NON_NULL(sentLength, EDR_ADAPTER_TAG, "Sent data length holder is null"); + VERIFY_NON_NULL(serviceUUID, TAG, "service UUID is null"); + VERIFY_NON_NULL(data, TAG, "Data is null"); + VERIFY_NON_NULL(sentLength, TAG, "Sent data length holder is null"); // Create remote endpoint CAEndpoint_t *remoteEndpoint = CACreateEndpointObject(CA_DEFAULT_FLAGS, @@ -709,7 +707,7 @@ CAResult_t CAAdapterSendData(const char *remoteAddress, const char *serviceUUID, remoteAddress, 0); if (NULL == remoteEndpoint) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to create remote endpoint !"); + OIC_LOG(ERROR, TAG, "Failed to create remote endpoint !"); return CA_MEMORY_ALLOC_FAILED; } @@ -721,7 +719,7 @@ CAResult_t CAAdapterSendData(const char *remoteAddress, const char *serviceUUID, // Free remote endpoint CAFreeEndpoint(remoteEndpoint); - OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT - CAAdapterSendData"); + OIC_LOG(DEBUG, TAG, "OUT - CAAdapterSendData"); return CA_STATUS_OK; } @@ -741,13 +739,13 @@ void CAEDRNotifyNetworkStatus(CANetworkStatus_t status) bool adapterState = false; if (CA_STATUS_OK != CAEDRGetAdapterEnableState(&adapterState)) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to get adapter enable state"); + OIC_LOG(ERROR, TAG, "Failed to get adapter enable state"); return; } if (false == adapterState) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Bluetooth adapter is disabled!"); + OIC_LOG(ERROR, TAG, "Bluetooth adapter is disabled!"); g_adapterState = false; return; } @@ -777,7 +775,7 @@ void CAEDRNotifyNetworkStatus(CANetworkStatus_t status) if (CA_STATUS_OK != ca_thread_pool_add_task(g_edrThreadPool, CAEDROnNetworkStatusChanged,event)) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to create threadpool!"); + OIC_LOG(ERROR, TAG, "Failed to create threadpool!"); return; } } @@ -788,7 +786,7 @@ void CAEDROnNetworkStatusChanged(void *context) { if (NULL == context) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "context is NULL!"); + OIC_LOG(ERROR, TAG, "context is NULL!"); return; } @@ -807,13 +805,13 @@ void CAEDROnNetworkStatusChanged(void *context) CAEDRNetworkEvent *CAEDRCreateNetworkEvent(CAEndpoint_t *connectivity, CANetworkStatus_t status) { - VERIFY_NON_NULL_RET(connectivity, EDR_ADAPTER_TAG, "connectivity is NULL", NULL); + VERIFY_NON_NULL_RET(connectivity, TAG, "connectivity is NULL", NULL); // Create CAEDRNetworkEvent CAEDRNetworkEvent *event = (CAEDRNetworkEvent *) OICMalloc(sizeof(CAEDRNetworkEvent)); if (NULL == event) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to allocate memory to network event!"); + OIC_LOG(ERROR, TAG, "Failed to allocate memory to network event!"); return NULL; } @@ -838,7 +836,7 @@ CAEDRData *CACreateEDRData(const CAEndpoint_t *remoteEndpoint, CAEDRData *edrData = (CAEDRData *) OICCalloc(1, sizeof(*edrData)); if (!edrData) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Memory allocation failed!"); + OIC_LOG(ERROR, TAG, "Memory allocation failed!"); return NULL; } @@ -847,7 +845,7 @@ CAEDRData *CACreateEDRData(const CAEndpoint_t *remoteEndpoint, edrData->data = OICMalloc(dataLength); if (NULL == edrData->data) { - OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Memory allocation failed!"); + OIC_LOG(ERROR, TAG, "Memory allocation failed!"); CAFreeEDRData(edrData); return NULL; } @@ -859,7 +857,7 @@ CAEDRData *CACreateEDRData(const CAEndpoint_t *remoteEndpoint, void CAFreeEDRData(CAEDRData *edrData) { - VERIFY_NON_NULL_VOID(edrData, EDR_ADAPTER_TAG, "edrData is NULL"); + VERIFY_NON_NULL_VOID(edrData, TAG, "edrData is NULL"); CAFreeEndpoint(edrData->remoteEndpoint); OICFree(edrData->data); @@ -870,7 +868,7 @@ void CAEDRDataDestroyer(void *data, uint32_t size) { if ((size_t)size < sizeof(CAEDRData)) { - OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Destroy data too small %p %d", data, size); + OIC_LOG_V(ERROR, TAG, "Destroy data too small %p %d", data, size); } CAEDRData *edrdata = (CAEDRData *) data; -- 2.7.4