diff --git a/c/protocan-transport/ports/android/kotlin/ru/setcorp/setcore/NativeProtoCan.kt b/c/protocan-transport/ports/android/kotlin/ru/setcorp/setcore/NativeProtoCan.kt index 3fba9a8..5dfa233 100644 --- a/c/protocan-transport/ports/android/kotlin/ru/setcorp/setcore/NativeProtoCan.kt +++ b/c/protocan-transport/ports/android/kotlin/ru/setcorp/setcore/NativeProtoCan.kt @@ -18,6 +18,7 @@ object NativeProtoCan { messageType: Int, body: Int, ): Long + external fun nativeUnpackId(raw: Long): IntArray? external fun nativeCrc16(input: ByteArray): Int external fun nativeEncodeFrame( sequence: Int, diff --git a/c/protocan-transport/ports/android/setcore_jni.c b/c/protocan-transport/ports/android/setcore_jni.c index 0ae05de..d28fe9c 100644 --- a/c/protocan-transport/ports/android/setcore_jni.c +++ b/c/protocan-transport/ports/android/setcore_jni.c @@ -32,6 +32,24 @@ Java_ru_setcorp_setcore_NativeProtoCan_nativePackId( (uint8_t)message_type, (uint16_t)body); } +JNIEXPORT jintArray JNICALL +Java_ru_setcorp_setcore_NativeProtoCan_nativeUnpackId( + JNIEnv *env, jobject self, jlong raw) +{ + (void)self; + uint8_t priority, route, device_type, device_id, message_type; + uint16_t body; + pcan_abi_id_unpack((uint32_t)raw, &priority, &route, &device_type, + &device_id, &message_type, &body); + jint values[6] = { (jint)priority, (jint)route, (jint)device_type, + (jint)device_id, (jint)message_type, (jint)body }; + jintArray result = (*env)->NewIntArray(env, 6); + if (result != NULL) { + (*env)->SetIntArrayRegion(env, result, 0, 6, values); + } + return result; +} + JNIEXPORT jint JNICALL Java_ru_setcorp_setcore_NativeProtoCan_nativeCrc16( JNIEnv *env, jobject self, jbyteArray input)