Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 59ea3c63 authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by Gerrit Code Review
Browse files

Merge "Vectors as parameters to GATT write/indicate (2/3)"

parents 5f4d748f 6cef760e
Loading
Loading
Loading
Loading
+14 −6
Original line number Original line Diff line number Diff line
@@ -1087,8 +1087,10 @@ static void gattClientWriteCharacteristicNative(JNIEnv* env, jobject object,
    jbyte *p_value = env->GetByteArrayElements(value, NULL);
    jbyte *p_value = env->GetByteArrayElements(value, NULL);
    if (p_value == NULL) return;
    if (p_value == NULL) return;


    sGattIf->client->write_characteristic(conn_id, handle, write_type, len, auth_req, (char*)p_value);
    std::vector<uint8_t> vect_val(p_value, p_value + len);
    env->ReleaseByteArrayElements(value, p_value, 0);
    env->ReleaseByteArrayElements(value, p_value, 0);

    sGattIf->client->write_characteristic(conn_id, handle, write_type, auth_req, vect_val);
}
}


static void gattClientExecuteWriteNative(JNIEnv* env, jobject object,
static void gattClientExecuteWriteNative(JNIEnv* env, jobject object,
@@ -1112,8 +1114,10 @@ static void gattClientWriteDescriptorNative(JNIEnv* env, jobject object,
    jbyte *p_value = env->GetByteArrayElements(value, NULL);
    jbyte *p_value = env->GetByteArrayElements(value, NULL);
    if (p_value == NULL) return;
    if (p_value == NULL) return;


    sGattIf->client->write_descriptor(conn_id, handle, write_type, len, auth_req, (char*)p_value);
    std::vector<uint8_t> vect_val(p_value, p_value + len);
    env->ReleaseByteArrayElements(value, p_value, 0);
    env->ReleaseByteArrayElements(value, p_value, 0);

    sGattIf->client->write_descriptor(conn_id, handle, write_type, auth_req, vect_val);
}
}


static void gattClientRegisterForNotificationsNative(JNIEnv* env, jobject object,
static void gattClientRegisterForNotificationsNative(JNIEnv* env, jobject object,
@@ -1589,9 +1593,11 @@ static void gattServerSendIndicationNative (JNIEnv *env, jobject object,
    jbyte* array = env->GetByteArrayElements(val, 0);
    jbyte* array = env->GetByteArrayElements(val, 0);
    int val_len = env->GetArrayLength(val);
    int val_len = env->GetArrayLength(val);


    sGattIf->server->send_indication(server_if, attr_handle, conn_id, val_len,
    std::vector<uint8_t> vect_val((uint8_t*)array, (uint8_t*)array + val_len);
                                     /*confirm*/ 1, (char*)array);
    env->ReleaseByteArrayElements(val, array, JNI_ABORT);
    env->ReleaseByteArrayElements(val, array, JNI_ABORT);

    sGattIf->server->send_indication(server_if, attr_handle, conn_id,
                                     /*confirm*/ 1, std::move(vect_val));
}
}


static void gattServerSendNotificationNative (JNIEnv *env, jobject object,
static void gattServerSendNotificationNative (JNIEnv *env, jobject object,
@@ -1602,9 +1608,11 @@ static void gattServerSendNotificationNative (JNIEnv *env, jobject object,
    jbyte* array = env->GetByteArrayElements(val, 0);
    jbyte* array = env->GetByteArrayElements(val, 0);
    int val_len = env->GetArrayLength(val);
    int val_len = env->GetArrayLength(val);


    sGattIf->server->send_indication(server_if, attr_handle, conn_id, val_len,
    std::vector<uint8_t> vect_val((uint8_t*)array, (uint8_t*)array + val_len);
                                     /*confirm*/ 0, (char*)array);
    env->ReleaseByteArrayElements(val, array, JNI_ABORT);
    env->ReleaseByteArrayElements(val, array, JNI_ABORT);

    sGattIf->server->send_indication(server_if, attr_handle, conn_id,
                                     /*confirm*/ 0, std::move(vect_val));
}
}


static void gattServerSendResponseNative (JNIEnv *env, jobject object,
static void gattServerSendResponseNative (JNIEnv *env, jobject object,