+ else if (already_started == errorCode)
+ {
+ OIC_LOG_V(INFO, TAG, "advertising is already started");
+ }
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_ca_CaLeServerInterface_caLeGattServerMtuChangedCallback(JNIEnv * env,
+ jobject obj,
+ jobject device,
+ jint mtu)
+{
+ VERIFY_NON_NULL_VOID(env, TAG, "env");
+ VERIFY_NON_NULL_VOID(obj, TAG, "obj");
+ VERIFY_NON_NULL_VOID(device, TAG, "device");
+
+ OIC_LOG_V(INFO, TAG, "gatt MTU size is changed (%d byte)", mtu);
+
+ 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;
+ }
+
+ // update mtu size
+ CAResult_t res = CALESetMtuSize(address, mtu - CA_BLE_MTU_HEADER_SIZE,
+ g_deviceStateList, g_deviceStateListMutex);
+ if (CA_STATUS_OK != res)
+ {
+ OIC_LOG(ERROR, TAG, "CALESetMtuSize has failed");
+ }
+
+ res = CALEUpdateDeviceState(address, CA_LE_SEND_STATE,
+ STATE_SEND_MTU_NEGO_SUCCESS,
+ g_deviceStateList,
+ g_deviceStateListMutex);
+ if (CA_STATUS_OK != res)
+ {
+ OIC_LOG(ERROR, TAG, "CALEUpdateDeviceState has failed");
+ }
+
+ (*env)->ReleaseStringUTFChars(env, jni_address, address);
+ (*env)->DeleteLocalRef(env, jni_address);