+
+ jstring jni_address = CALEGetAddressFromBTDevice(env, device);
+ if (!jni_address)
+ {
+ OIC_LOG(ERROR, TAG, "jni_address is null");
+ return;
+ }
+
+ const char* address = (*env)->GetStringUTFChars(env, jni_address, NULL);
+ if (!address)
+ {
+ OIC_LOG(ERROR, TAG, "address is not available");
+ (*env)->DeleteLocalRef(env, jni_address);
+ return;
+ }
+
+ jint gatt_success = CALEGetConstantsValue(env, CLASSPATH_BT_GATT, "GATT_SUCCESS");
+ if (gatt_success != status) // error case
+ {
+ OIC_LOG(ERROR, TAG, "it will be sent again.");
+
+ CAResult_t res = CALEServerSend(env, device, g_sendBuffer);
+ if (CA_STATUS_OK != res)
+ {
+ OIC_LOG(ERROR, TAG, "send has failed");
+
+ if (g_obj_bluetoothDevice)
+ {
+ (*env)->DeleteGlobalRef(env, g_obj_bluetoothDevice);
+ g_obj_bluetoothDevice = NULL;
+ }
+
+ oc_mutex_lock(g_threadSendNotifyMutex);
+ g_isSignalSetFlag = true;
+ oc_cond_signal(g_threadSendNotifyCond);
+ oc_mutex_unlock(g_threadSendNotifyMutex);
+
+ (*env)->ReleaseStringUTFChars(env, jni_address, address);
+ (*env)->DeleteLocalRef(env, jni_address);
+ return;
+ }
+
+ CALogSendStateInfo(CA_ADAPTER_GATT_BTLE, address, 0, -1,
+ false, "notifyChar failure");
+ }
+ else
+ {
+ OIC_LOG(DEBUG, TAG, "notify success");
+
+ if (g_obj_bluetoothDevice)
+ {
+ (*env)->DeleteGlobalRef(env, g_obj_bluetoothDevice);
+ g_obj_bluetoothDevice = NULL;
+ }
+
+ // next data can be sent
+ oc_mutex_lock(g_threadSendNotifyMutex);
+ OIC_LOG(DEBUG, TAG, "g_isSignalSetFlag is set true and signal");
+ g_isSignalSetFlag = true;
+ oc_cond_signal(g_threadSendNotifyCond);
+ oc_mutex_unlock(g_threadSendNotifyMutex);
+
+ CALogSendStateInfo(CA_ADAPTER_GATT_BTLE, address, 0, -1,
+ true, "notifyChar success");
+ }
+ (*env)->ReleaseStringUTFChars(env, jni_address, address);
+ (*env)->DeleteLocalRef(env, jni_address);
+