jobject CAManagerConnectGatt(JNIEnv *env, jstring remote_le_address) { VERIFY_NON_NULL_RET(env, TAG, "env", NULL); VERIFY_NON_NULL_RET(remote_le_address, TAG, "remote_le_address", NULL); OIC_LOG(DEBUG, TAG, "IN - CAManagerConnectGatt"); jobject jni_bluetooth = CAManagerGetRemoteDevice(env, remote_le_address); if (!jni_bluetooth) { OIC_LOG(ERROR, TAG, "jni_bluetooth is null"); return NULL; } if (!CAManagerIsDeviceBonded(env, jni_bluetooth)) { OIC_LOG(INFO, TAG, "device is BONDED_NONE"); } // request to connection with AutoConnection Flag OIC_LOG(INFO, TAG, "request gatt connection by CM auto connector"); jobject newGatt = (jobject)CALEClientConnect(env, jni_bluetooth, JNI_TRUE); if (NULL == newGatt) { OIC_LOG(INFO, TAG, "re-connection will be started"); return NULL; } // set flag auto connection is requested. CAManagerSetAutoConnectingFlag(env, remote_le_address, true); OIC_LOG(DEBUG, TAG, "OUT - CAManagerConnectGatt"); return newGatt; }
CAResult_t CAManagerConnectGatt(JNIEnv *env, jstring remote_le_address) { VERIFY_NON_NULL(env, TAG, "env"); VERIFY_NON_NULL(remote_le_address, TAG, "remote_le_address"); OIC_LOG(DEBUG, TAG, "IN - CAManagerConnectGatt"); jobject jni_bluetooth = CAManagerGetRemoteDevice(env, remote_le_address); if (!jni_bluetooth) { OIC_LOG(ERROR, TAG, "jni_bluetooth is null"); return CA_STATUS_FAILED; } if (!CAManagerIsDeviceBonded(env, jni_bluetooth)) { OIC_LOG(INFO, TAG, "device is BONDED_NONE"); } // request to connection with AutoConnection Flag OIC_LOG(INFO, TAG, "request to gatt connection for auto connection"); CAResult_t res = CALEClientDirectConnect(env, jni_bluetooth, JNI_TRUE); if (CA_STATUS_OK != res) { OIC_LOG(INFO, TAG, "re-connection will be started"); return res; } // set flag auto connection is requested. CAManagerSetAutoConnectionFlag(env, remote_le_address, true); OIC_LOG(DEBUG, TAG, "OUT - CAManagerConnectGatt"); return CA_STATUS_OK; }