{
if (!bluetoothSocketObj)
{
- OIC_LOG(ERROR, TAG, "[EDR] getRemoteAddress: bluetoothSocketObj is null");
+ OIC_LOG(ERROR, TAG, "bluetoothSocketObj is null");
return NULL;
}
jclass jni_cid_BTSocket = (*env)->FindClass(env, CLASSPATH_BT_SOCKET);
if (!jni_cid_BTSocket)
{
- OIC_LOG(ERROR, TAG, "[EDR] getRemoteAddress: jni_cid_BTSocket is null");
+ OIC_LOG(ERROR, TAG, "jni_cid_BTSocket is null");
return NULL;
}
env, jni_cid_BTSocket, "getRemoteDevice", "()Landroid/bluetooth/BluetoothDevice;");
if (!jni_mid_getRemoteDevice)
{
+ OIC_LOG(ERROR, TAG, "jni_mid_getRemoteDevice is null");
(*env)->DeleteLocalRef(env, jni_cid_BTSocket);
-
- OIC_LOG(ERROR, TAG, "[EDR] getRemoteAddress: jni_mid_getRemoteDevice is null");
return NULL;
}
jni_mid_getRemoteDevice);
if (!jni_obj_remoteBTDevice)
{
+ OIC_LOG(ERROR, TAG, "jni_obj_remoteBTDevice is null");
(*env)->DeleteLocalRef(env, jni_cid_BTSocket);
-
- OIC_LOG(ERROR, TAG, "[EDR] getRemoteAddress: jni_obj_remoteBTDevice is null");
return NULL;
}
jclass jni_cid_BTDevice = (*env)->FindClass(env, CLASSPATH_BT_DEVICE);
if (!jni_cid_BTDevice)
{
+ OIC_LOG(ERROR, TAG, "jni_cid_BTDevice is null");
(*env)->DeleteLocalRef(env, jni_obj_remoteBTDevice);
(*env)->DeleteLocalRef(env, jni_cid_BTSocket);
-
- OIC_LOG(ERROR, TAG, "[EDR] getRemoteAddress: jni_cid_BTDevice is null");
return NULL;
}
jmethodID j_mid_getAddress = (*env)->GetMethodID(env, jni_cid_BTDevice, "getAddress",
METHODID_STRINGNONPARAM);
if (!j_mid_getAddress)
{
+ OIC_LOG(ERROR, TAG, "j_mid_getAddress is null");
(*env)->DeleteLocalRef(env, jni_obj_remoteBTDevice);
(*env)->DeleteLocalRef(env, jni_cid_BTDevice);
(*env)->DeleteLocalRef(env, jni_cid_BTSocket);
-
- OIC_LOG(ERROR, TAG, "[EDR] getRemoteAddress: j_mid_getAddress is null");
return NULL;
}
jstring j_str_address = (*env)->CallObjectMethod(env, jni_obj_remoteBTDevice, j_mid_getAddress);
if (!j_str_address)
{
+ OIC_LOG(ERROR, TAG, "j_str_address is null");
(*env)->DeleteLocalRef(env, jni_obj_remoteBTDevice);
(*env)->DeleteLocalRef(env, jni_cid_BTDevice);
(*env)->DeleteLocalRef(env, jni_cid_BTSocket);
-
- OIC_LOG(ERROR, TAG, "[EDR] getRemoteAddress: j_str_address is null");
return NULL;
}
jclass jni_cid_BTAdapter = (*env)->FindClass(env, CLASSPATH_BT_ADPATER);
if (!jni_cid_BTAdapter)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] getAddress: jni_cid_BTAdapter is null");
+ OIC_LOG(ERROR, TAG, "jni_cid_BTAdapter is null");
return NULL;
}
METHODID_OBJECTNONPARAM);
if (!jni_mid_getDefaultAdapter)
{
+ OIC_LOG(ERROR, TAG, "jni_mid_getDefaultAdapter is null");
(*env)->DeleteLocalRef(env, jni_cid_BTAdapter);
-
- OIC_LOG(ERROR, TAG, "[EDR][Native] getAddress: jni_mid_getDefaultAdapter is null");
return NULL;
}
METHODID_STRINGNONPARAM);
if (!jni_mid_getAddress)
{
+ OIC_LOG(ERROR, TAG, "jni_mid_getAddress is null");
(*env)->DeleteLocalRef(env, jni_cid_BTAdapter);
-
- OIC_LOG(ERROR, TAG, "[EDR][Native] getAddress: jni_mid_getAddress is null");
return NULL;
}
jni_mid_getDefaultAdapter);
if (!jni_obj_BTAdapter)
{
+ OIC_LOG(ERROR, TAG, "jni_obj_BTAdapter is null");
(*env)->DeleteLocalRef(env, jni_cid_BTAdapter);
-
- OIC_LOG(ERROR, TAG, "[EDR][Native] getAddress: jni_obj_BTAdapter is null");
return NULL;
}
jni_mid_getAddress);
if (!jni_str_address)
{
+ OIC_LOG(ERROR, TAG, "jni_str_address is null");
(*env)->DeleteLocalRef(env, jni_obj_BTAdapter);
(*env)->DeleteLocalRef(env, jni_cid_BTAdapter);
-
- OIC_LOG(ERROR, TAG, "[EDR][Native] getAddress: jni_str_address is null");
return NULL;
}
jclass jni_cid_BTAdapter = (*env)->FindClass(env, CLASSPATH_BT_ADPATER);
if (!jni_cid_BTAdapter)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] getBondedDevices: jni_cid_BTAdapter is null");
+ OIC_LOG(ERROR, TAG, "jni_cid_BTAdapter is null");
return NULL;
}
METHODID_OBJECTNONPARAM);
if (!jni_mid_getDefaultAdapter)
{
+ OIC_LOG(ERROR, TAG, "default adapter is null");
(*env)->DeleteLocalRef(env, jni_cid_BTAdapter);
-
- OIC_LOG(ERROR, TAG, "[EDR][Native] getBondedDevices: default adapter is null");
return NULL;
}
jni_mid_getDefaultAdapter);
if (!jni_obj_BTAdapter)
{
+ OIC_LOG(ERROR, TAG, "bluetooth adapter is null");
(*env)->DeleteLocalRef(env, jni_cid_BTAdapter);
-
- OIC_LOG(ERROR, TAG, "[EDR][Native] getBondedDevices: bluetooth adapter is null");
return NULL;
}
"()Ljava/util/Set;");
if (!jni_mid_getBondedDevices)
{
+ OIC_LOG(ERROR, TAG, "jni_mid_getBondedDevicesr is null");
(*env)->DeleteLocalRef(env, jni_obj_BTAdapter);
(*env)->DeleteLocalRef(env, jni_cid_BTAdapter);
-
- OIC_LOG(ERROR, TAG, "[EDR][Native] getBondedDevices: jni_mid_getBondedDevicesr is null");
return NULL;
}
jni_mid_getBondedDevices);
if (!jni_obj_setPairedDevices)
{
+ OIC_LOG(ERROR, TAG, "ni_obj_setPairedDevices is null");
(*env)->DeleteLocalRef(env, jni_obj_BTAdapter);
(*env)->DeleteLocalRef(env, jni_cid_BTAdapter);
-
- OIC_LOG(ERROR, TAG, "[EDR][Native] getBondedDevices: jni_obj_setPairedDevices is null");
return NULL;
}
jclass jni_cid_Set = (*env)->FindClass(env, "java/util/Set");
if (!jni_cid_Set)
{
- (*env)->DeleteLocalRef(env, jni_obj_BTAdapter);
- (*env)->DeleteLocalRef(env, jni_cid_BTAdapter);
- (*env)->DeleteLocalRef(env, jni_obj_setPairedDevices);
-
- OIC_LOG(ERROR, TAG, "[EDR][Native] getBondedDevices: jni_cid_Set is null");
- return NULL;
+ OIC_LOG(ERROR, TAG, "jni_cid_Set is null");
+ goto exit;
}
jmethodID jni_mid_toArray = (*env)->GetMethodID(env, jni_cid_Set, "toArray",
"()[Ljava/lang/Object;");
if (!jni_mid_toArray)
{
- (*env)->DeleteLocalRef(env, jni_obj_BTAdapter);
- (*env)->DeleteLocalRef(env, jni_cid_BTAdapter);
- (*env)->DeleteLocalRef(env, jni_obj_setPairedDevices);
-
- OIC_LOG(ERROR, TAG, "[EDR][Native] getBondedDevices: jni_mid_toArray is null");
- return NULL;
+ OIC_LOG(ERROR, TAG, "jni_mid_toArray is null");
+ goto exit;
}
jobjectArray jni_arrayPairedDevices = (jobjectArray)(
(*env)->CallObjectMethod(env, jni_obj_setPairedDevices, jni_mid_toArray));
if (!jni_arrayPairedDevices)
{
- (*env)->DeleteLocalRef(env, jni_obj_BTAdapter);
- (*env)->DeleteLocalRef(env, jni_cid_BTAdapter);
- (*env)->DeleteLocalRef(env, jni_obj_setPairedDevices);
-
- OIC_LOG(ERROR, TAG, "[EDR][Native] getBondedDevices: jni_arrayPairedDevices is null");
- return NULL;
+ OIC_LOG(ERROR, TAG, "jni_arrayPairedDevices is null");
+ goto exit;
}
(*env)->DeleteLocalRef(env, jni_obj_BTAdapter);
(*env)->DeleteLocalRef(env, jni_obj_setPairedDevices);
return jni_arrayPairedDevices;
+
+exit:
+ (*env)->DeleteLocalRef(env, jni_obj_BTAdapter);
+ (*env)->DeleteLocalRef(env, jni_cid_BTAdapter);
+ (*env)->DeleteLocalRef(env, jni_obj_setPairedDevices);
+ return NULL;
}
jint CAEDRNativeGetBTStateOnInfo(JNIEnv *env)
jclass jni_cid_BTAdapter = (*env)->FindClass(env, CLASSPATH_BT_ADPATER);
if (!jni_cid_BTAdapter)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] getBTStateOnInfo: jni_cid_BTAdapter is null");
+ OIC_LOG(ERROR, TAG, "jni_cid_BTAdapter is null");
return ERROR_CODE;
}
{
(*env)->DeleteLocalRef(env, jni_cid_BTAdapter);
- OIC_LOG(ERROR, TAG, "[EDR][Native] get_field_state is 0");
+ OIC_LOG(ERROR, TAG, "get_field_state is 0");
return ERROR_CODE;
}
jint jni_int_val = (*env)->GetStaticIntField(env, jni_cid_BTAdapter, jni_fid_stateon);
- OIC_LOG_V(DEBUG, TAG, "[EDR][Native] bluetooth state integer value : %d", jni_int_val);
+ OIC_LOG_V(DEBUG, TAG, "bluetooth state integer value : %d", jni_int_val);
(*env)->DeleteLocalRef(env, jni_cid_BTAdapter);
jclass jni_cid_BTAdapter = (*env)->FindClass(env, CLASSPATH_BT_ADPATER);
if (!jni_cid_BTAdapter)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] jni_cid_BTAdapter: jni_cid_BTAdapter is null");
+ OIC_LOG(ERROR, TAG, "jni_cid_BTAdapter: jni_cid_BTAdapter is null");
return JNI_FALSE;
}
METHODID_OBJECTNONPARAM);
if (!jni_mid_getDefaultAdapter)
{
+ OIC_LOG(ERROR, TAG, "jni_mid_getDefaultAdapter is null");
(*env)->DeleteLocalRef(env, jni_cid_BTAdapter);
-
- OIC_LOG(ERROR, TAG, "[EDR][Native] jni_mid_getDefaultAdapter is null");
return JNI_FALSE;
}
jni_mid_getDefaultAdapter);
if (!jni_obj_BTAdapter)
{
+ OIC_LOG(ERROR, TAG, "jni_obj_BTAdapter is null");
(*env)->DeleteLocalRef(env, jni_cid_BTAdapter);
-
- OIC_LOG(ERROR, TAG, "[EDR][Native] jni_obj_BTAdapter is null");
return JNI_FALSE;
}
jmethodID jni_mid_isEnable = (*env)->GetMethodID(env, jni_cid_BTAdapter, "isEnabled", "()Z");
if (!jni_mid_isEnable)
{
+ OIC_LOG(ERROR, TAG, "jni_mid_isEnable is null");
(*env)->DeleteLocalRef(env, jni_cid_BTAdapter);
(*env)->DeleteLocalRef(env, jni_obj_BTAdapter);
-
- OIC_LOG(ERROR, TAG, "[EDR][Native] jni_mid_isEnable is null");
return JNI_FALSE;
}
{
if (!bluetoothDevice)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] bluetoothDevice is null");
+ OIC_LOG(ERROR, TAG, "bluetoothDevice is null");
return NULL;
}
jclass jni_cid_device_list = (*env)->FindClass(env, "android/bluetooth/BluetoothDevice");
if (!jni_cid_device_list)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] jni_cid_device_list is null");
+ OIC_LOG(ERROR, TAG, "jni_cid_device_list is null");
return NULL;
}
METHODID_STRINGNONPARAM);
if (!jni_mid_getAddress)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] jni_mid_getAddress is null");
+ OIC_LOG(ERROR, TAG, "jni_mid_getAddress is null");
return NULL;
}
jni_mid_getAddress);
if (!jni_address)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] jni_address is null");
+ OIC_LOG(ERROR, TAG, "jni_address is null");
return NULL;
}
return jni_address;
*/
void CAEDRNativeCreateDeviceStateList()
{
- OIC_LOG(DEBUG, TAG, "[EDR][Native] CAEDRNativeCreateDeviceStateList");
+ OIC_LOG(DEBUG, TAG, "CAEDRNativeCreateDeviceStateList");
// create new object array
if (NULL == g_deviceStateList)
{
if (!address)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] address is null");
+ OIC_LOG(ERROR, TAG, "address is null");
return;
}
- state_t *newstate = (state_t*) OICCalloc(1, sizeof(state_t));
- if (!newstate)
+ CAConnectedDeviceInfo_t *deviceInfo =
+ (CAConnectedDeviceInfo_t *) OICCalloc(1, sizeof(CAConnectedDeviceInfo_t));
+ if (!deviceInfo)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] newstate is null");
+ OIC_LOG(ERROR, TAG, "deviceInfo is null");
return;
}
- OICStrcpy((char*) newstate->address, sizeof(newstate->address), address);
- newstate->state = state;
+ OICStrcpy((char*) deviceInfo->address, sizeof(deviceInfo->address), address);
+ deviceInfo->state = state;
- CAEDRNativeAddDeviceStateToList(newstate);
+ CAEDRNativeAddDeviceStateToList(deviceInfo);
}
-void CAEDRNativeAddDeviceStateToList(state_t *state)
+void CAEDRNativeAddDeviceStateToList(CAConnectedDeviceInfo_t *deviceInfo)
{
- if (!state)
+ if (!deviceInfo)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] device is null");
+ OIC_LOG(ERROR, TAG, "device is null");
return;
}
if (!g_deviceStateList)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] gdevice_list is null");
+ OIC_LOG(ERROR, TAG, "gdevice_list is null");
return;
}
- if (CAEDRNativeIsDeviceInList((const char*) state->address))
+ if (CAEDRNativeIsDeviceInList((const char*) deviceInfo->address))
{
// delete previous state for update new state
- CAEDRNativeRemoveDevice((const char*) state->address);
+ CAEDRNativeRemoveDevice((const char*) deviceInfo->address);
}
- u_arraylist_add(g_deviceStateList, state); // update new state
- OIC_LOG_V(DEBUG, TAG, "Set State Info to List : %d", state->state);
+ u_arraylist_add(g_deviceStateList, deviceInfo); // update new state
+ OIC_LOG_V(DEBUG, TAG, "Set State Info to List : %d", deviceInfo->state);
}
bool CAEDRNativeIsDeviceInList(const char* remoteAddress)
{
-
if (!remoteAddress)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] remoteAddress is null");
+ OIC_LOG(ERROR, TAG, "remoteAddress is null");
return false;
}
- jint index;
+
jint length = u_arraylist_length(g_deviceStateList);
- for (index = 0; index < length; index++)
+ for (jint index = 0; index < length; index++)
{
- state_t* state = (state_t*) u_arraylist_get(g_deviceStateList, index);
- if (!state)
+ CAConnectedDeviceInfo_t* deviceInfo =
+ (CAConnectedDeviceInfo_t*) u_arraylist_get(g_deviceStateList, index);
+ if (!deviceInfo)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] state_t object is null");
+ OIC_LOG(ERROR, TAG, "deviceInfo object is null");
return false;
}
- if (!strcmp(remoteAddress, (const char*) state->address))
+ if (!strcmp(remoteAddress, (const char*) deviceInfo->address))
{
OIC_LOG(DEBUG, TAG, "the device is already set");
return true;
}
- else
- {
- continue;
- }
}
OIC_LOG(DEBUG, TAG, "there are no the device in list.");
if (!g_deviceStateList)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] gdeviceStateList is null");
+ OIC_LOG(ERROR, TAG, "gdeviceStateList is null");
return;
}
jint length = u_arraylist_length(g_deviceStateList);
for (index = 0; index < length; index++)
{
- state_t* state = (state_t*) u_arraylist_get(g_deviceStateList, index);
- if (!state)
+ CAConnectedDeviceInfo_t* deviceInfo =
+ (CAConnectedDeviceInfo_t*) u_arraylist_get(g_deviceStateList, index);
+ if (!deviceInfo)
{
- OIC_LOG(DEBUG, TAG, "[EDR][Native] jarrayObj is null");
+ OIC_LOG(DEBUG, TAG, "jarrayObj is null");
continue;
}
- OICFree(state);
+ OICFree(deviceInfo);
}
OICFree(g_deviceStateList);
if (!g_deviceStateList)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] gdeviceStateList is null");
+ OIC_LOG(ERROR, TAG, "gdeviceStateList is null");
return;
}
if (!remoteAddress)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] remoteAddress is null");
+ OIC_LOG(ERROR, TAG, "remoteAddress is null");
return;
}
- jint index;
jint length = u_arraylist_length(g_deviceStateList);
- for (index = 0; index < length; index++)
+ for (jint index = 0; index < length; index++)
{
- state_t* state = (state_t*) u_arraylist_get(g_deviceStateList, index);
- if (!state)
+ CAConnectedDeviceInfo_t* deviceInfo =
+ (CAConnectedDeviceInfo_t*) u_arraylist_get(g_deviceStateList, index);
+ if (!deviceInfo)
{
- OIC_LOG(DEBUG, TAG, "[EDR][Native] state_t object is null");
+ OIC_LOG(DEBUG, TAG, "deviceInfo object is null");
continue;
}
- if (!strcmp((const char*) state->address, remoteAddress))
+ if (!strcmp((const char*) deviceInfo->address, remoteAddress))
{
- OIC_LOG_V(DEBUG, TAG, "[EDR][Native] remove state : %s", remoteAddress);
- OICFree(state);
+ OIC_LOG_V(DEBUG, TAG, "remove state : %s", remoteAddress);
+ OICFree(deviceInfo);
u_arraylist_remove(g_deviceStateList, index);
break;
if (!remoteAddress)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] remoteAddress is null");
+ OIC_LOG(ERROR, TAG, "remoteAddress is null");
return STATE_DISCONNECTED;
}
if (!g_deviceStateList)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] gdeviceStateList is null");
+ OIC_LOG(ERROR, TAG, "gdeviceStateList is null");
return STATE_DISCONNECTED;
}
- jint index;
jint length = u_arraylist_length(g_deviceStateList);
- for (index = 0; index < length; index++)
+ for (jint index = 0; index < length; index++)
{
- state_t* state = (state_t*) u_arraylist_get(g_deviceStateList, index);
- if (!state)
+ CAConnectedDeviceInfo_t* deviceInfo =
+ (CAConnectedDeviceInfo_t*) u_arraylist_get(g_deviceStateList, index);
+ if (!deviceInfo)
{
- OIC_LOG(DEBUG, TAG, "[EDR][Native] state_t object is null");
+ OIC_LOG(DEBUG, TAG, "deviceInfo object is null");
continue;
}
- if (!strcmp((const char*) state->address, remoteAddress))
+ if (!strcmp((const char*) deviceInfo->address, remoteAddress))
{
- return state->state;
+ return deviceInfo->state;
}
}
return STATE_DISCONNECTED;
*/
void CAEDRNativeCreateDeviceSocketList()
{
- OIC_LOG(DEBUG, TAG, "[EDR][Native] CAEDRNativeCreateDeviceSocketList");
+ OIC_LOG(DEBUG, TAG, "CAEDRNativeCreateDeviceSocketList");
// create new object array
if (NULL == g_deviceObjectList)
void CAEDRNativeAddDeviceSocketToList(JNIEnv *env, jobject deviceSocket)
{
- OIC_LOG(DEBUG, TAG, "[EDR][Native] CANativeAddDeviceobjToList");
+ OIC_LOG(DEBUG, TAG, "CANativeAddDeviceobjToList");
if (!deviceSocket)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] Device is null");
+ OIC_LOG(ERROR, TAG, "Device is null");
return;
}
if (!g_deviceObjectList)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] gdeviceObjectList is null");
+ OIC_LOG(ERROR, TAG, "gdeviceObjectList is null");
return;
}
jstring jni_remoteAddress = CAEDRNativeGetAddressFromDeviceSocket(env, deviceSocket);
if (!jni_remoteAddress)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] jni_remoteAddress is null");
+ OIC_LOG(ERROR, TAG, "jni_remoteAddress is null");
return;
}
bool CAEDRNativeIsDeviceSocketInList(JNIEnv *env, const char* remoteAddress)
{
- OIC_LOG(DEBUG, TAG, "[EDR][Native] CANativeIsDeviceObjInList");
+ OIC_LOG(DEBUG, TAG, "CANativeIsDeviceObjInList");
if (!remoteAddress)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] remoteAddress is null");
+ OIC_LOG(ERROR, TAG, "remoteAddress is null");
return false;
}
- jint index;
+
jint length = u_arraylist_length(g_deviceStateList);
- for (index = 0; index < length; index++)
+ for (jint index = 0; index < length; index++)
{
jobject jarrayObj = (jobject) u_arraylist_get(g_deviceObjectList, index);
if (!jarrayObj)
{
- OIC_LOG(DEBUG, TAG, "[EDR][Native] jarrayObj is null");
+ OIC_LOG(DEBUG, TAG, "jarrayObj is null");
return false;
}
jstring jni_setAddress = CAEDRNativeGetAddressFromDeviceSocket(env, jarrayObj);
if (!jni_setAddress)
{
- OIC_LOG(DEBUG, TAG, "[EDR][Native] jni_setAddress is null");
+ OIC_LOG(DEBUG, TAG, "jni_setAddress is null");
return false;
}
const char* setAddress = (*env)->GetStringUTFChars(env, jni_setAddress, NULL);
if (!setAddress)
{
- OIC_LOG(DEBUG, TAG, "[EDR][Native] setAddress is null");
+ OIC_LOG(DEBUG, TAG, "setAddress is null");
return false;
}
void CAEDRNativeSocketCloseToAll(JNIEnv *env)
{
- OIC_LOG(DEBUG, TAG, "[EDR][Native] CAEDRNativeSocketCloseToAll");
+ OIC_LOG(DEBUG, TAG, "CAEDRNativeSocketCloseToAll");
if (!g_deviceObjectList)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] gdeviceObjectList is null");
+ OIC_LOG(ERROR, TAG, "gdeviceObjectList is null");
return;
}
jclass jni_cid_BTSocket = (*env)->FindClass(env, CLASSPATH_BT_SOCKET);
if (!jni_cid_BTSocket)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] close: jni_cid_BTSocket is null");
+ OIC_LOG(ERROR, TAG, "jni_cid_BTSocket is null");
return;
}
jmethodID jni_mid_close = (*env)->GetMethodID(env, jni_cid_BTSocket, "close", "()V");
if (!jni_mid_close)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] close: jni_mid_close is null");
+ OIC_LOG(ERROR, TAG, "jni_mid_close is null");
return;
}
- jint index;
jint length = u_arraylist_length(g_deviceStateList);
- for (index = 0; index < length; index++)
+ for (jint index = 0; index < length; index++)
{
jobject jni_obj_socket = (jobject) u_arraylist_get(g_deviceObjectList, index);
if (!jni_obj_socket)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] socket obj is null");
+ OIC_LOG(ERROR, TAG, "socket obj is null");
return;
}
if ((*env)->ExceptionCheck(env))
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] close: close is Failed!!!");
+ OIC_LOG(ERROR, TAG, "close is Failed!!!");
(*env)->ExceptionDescribe(env);
(*env)->ExceptionClear(env);
return;
if (!g_deviceObjectList)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] gdeviceObjectList is null");
+ OIC_LOG(ERROR, TAG, "gdeviceObjectList is null");
return;
}
- jint index;
jint length = u_arraylist_length(g_deviceStateList);
- for (index = 0; index < length; index++)
+ for (jint index = 0; index < length; index++)
{
jobject jarrayObj = (jobject) u_arraylist_get(g_deviceObjectList, index);
if (!jarrayObj)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] jarrayObj is null");
+ OIC_LOG(ERROR, TAG, "jarrayObj is null");
return;
}
(*env)->DeleteGlobalRef(env, jarrayObj);
if (!g_deviceObjectList)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] gdeviceObjectList is null");
+ OIC_LOG(ERROR, TAG, "gdeviceObjectList is null");
return;
}
- jint index;
jint length = u_arraylist_length(g_deviceStateList);
- for (index = 0; index < length; index++)
+ for (jint index = 0; index < length; index++)
{
jobject jarrayObj = (jobject) u_arraylist_get(g_deviceObjectList, index);
if (!jarrayObj)
{
- OIC_LOG(DEBUG, TAG, "[EDR][Native] jarrayObj is null");
+ OIC_LOG(DEBUG, TAG, "jarrayObj is null");
continue;
}
jstring jni_setAddress = CAEDRNativeGetAddressFromDeviceSocket(env, jarrayObj);
if (!jni_setAddress)
{
- OIC_LOG(DEBUG, TAG, "[EDR][Native] jni_setAddress is null");
+ OIC_LOG(DEBUG, TAG, "jni_setAddress is null");
continue;
}
jstring jni_remoteAddress = CAEDRNativeGetAddressFromDeviceSocket(env, deviceSocket);
if (!jni_remoteAddress)
{
- OIC_LOG(DEBUG, TAG, "[EDR][Native] jni_remoteAddress is null");
+ OIC_LOG(DEBUG, TAG, "jni_remoteAddress is null");
continue;
}
if (!strcmp(setAddress, remoteAddress))
{
- OIC_LOG_V(DEBUG, TAG, "[EDR][Native] remove object : %s", remoteAddress);
+ OIC_LOG_V(DEBUG, TAG, "remove object : %s", remoteAddress);
(*env)->DeleteGlobalRef(env, jarrayObj);
(*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
(*env)->ReleaseStringUTFChars(env, jni_remoteAddress, remoteAddress);
(*env)->ReleaseStringUTFChars(env, jni_remoteAddress, remoteAddress);
}
- OIC_LOG(DEBUG, TAG, "[EDR][Native] there are no target object");
+ OIC_LOG(DEBUG, TAG, "there are no target object");
return;
}
if (!g_deviceObjectList)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] gdeviceObjectList is null");
+ OIC_LOG(ERROR, TAG, "gdeviceObjectList is null");
return;
}
- jint index;
jint length = u_arraylist_length(g_deviceStateList);
- for (index = 0; index < length; index++)
+ for (jint index = 0; index < length; index++)
{
jobject jarrayObj = (jobject) u_arraylist_get(g_deviceObjectList, index);
if (!jarrayObj)
{
- OIC_LOG(DEBUG, TAG, "[EDR][Native] jarrayObj is null");
+ OIC_LOG(DEBUG, TAG, "jarrayObj is null");
continue;
}
jstring jni_setAddress = CAEDRNativeGetAddressFromDeviceSocket(env, jarrayObj);
if (!jni_setAddress)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] jni_setAddress is null");
+ OIC_LOG(ERROR, TAG, "jni_setAddress is null");
continue;
}
const char* setAddress = (*env)->GetStringUTFChars(env, jni_setAddress, NULL);
if (!strcmp(setAddress, remoteAddress))
{
- OIC_LOG_V(ERROR, TAG, "[EDR][Native] remove object : %s", remoteAddress);
+ OIC_LOG_V(ERROR, TAG, "remove object : %s", remoteAddress);
(*env)->DeleteGlobalRef(env, jarrayObj);
(*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
(*env)->ReleaseStringUTFChars(env, address, remoteAddress);
(*env)->ReleaseStringUTFChars(env, address, remoteAddress);
}
- OIC_LOG(DEBUG, TAG, "[EDR][Native] there are no target object");
+ OIC_LOG(DEBUG, TAG, "there are no target object");
return;
}
{
if (!g_deviceObjectList)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] gdeviceObjectList is null");
+ OIC_LOG(ERROR, TAG, "gdeviceObjectList is null");
return NULL;
}
jobject jarrayObj = (jobject) u_arraylist_get(g_deviceObjectList, idx);
if (!jarrayObj)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] jarrayObj is not available");
+ OIC_LOG(ERROR, TAG, "jarrayObj is not available");
return NULL;
}
return jarrayObj;
if (!g_deviceObjectList)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] gdeviceObjectList is null");
+ OIC_LOG(ERROR, TAG, "gdeviceObjectList is null");
return NULL;
}
- jint index;
jint length = u_arraylist_length(g_deviceStateList);
- for (index = 0; index < length; index++)
+ for (jint index = 0; index < length; index++)
{
jobject jarrayObj = (jobject) u_arraylist_get(g_deviceObjectList, index);
if (!jarrayObj)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] jarrayObj is null");
+ OIC_LOG(ERROR, TAG, "jarrayObj is null");
continue;
}
jstring jni_setAddress = CAEDRNativeGetAddressFromDeviceSocket(env, jarrayObj);
if (!jni_setAddress)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] jni_setAddress is null");
+ OIC_LOG(ERROR, TAG, "jni_setAddress is null");
continue;
}
const char* setAddress = (*env)->GetStringUTFChars(env, jni_setAddress, NULL);
if (!strcmp(setAddress, remoteAddress))
{
- OIC_LOG_V(ERROR, TAG, "[EDR][Native] remove object : %s", remoteAddress);
+ OIC_LOG_V(ERROR, TAG, "remove object : %s", remoteAddress);
(*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
(*env)->DeleteLocalRef(env, jni_setAddress);
return jarrayObj;
{
if (!g_deviceObjectList)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] gdeviceObjectList is null");
+ OIC_LOG(ERROR, TAG, "gdeviceObjectList is null");
return 0;
}
return length;
}
+
+CAConnectedDeviceInfo_t *CAEDRGetDeviceInfoFromAddress(const char *remoteAddress)
+{
+ OIC_LOG(DEBUG, TAG, "CAEDRGetDeviceInfoFromAddress");
+
+ 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++)
+ {
+ CAConnectedDeviceInfo_t* deviceInfo =
+ (CAConnectedDeviceInfo_t*) u_arraylist_get(g_deviceStateList, index);
+ if (!deviceInfo)
+ {
+ OIC_LOG(DEBUG, TAG, "deviceInfo object is null");
+ continue;
+ }
+
+ if (!strcmp((const char*) deviceInfo->address, remoteAddress))
+ {
+ return deviceInfo;
+ }
+ }
+ return NULL;
+}