RHO_GLOBAL void rho_bluetooth_session_write_data(const char* connected_device_name, VALUE data) { int size = rho_ruby_unpack_byte_array(data, 0, 0); if (size <= 0) { return; } JNIEnv *env = jnienv(); jclass cls = getJNIClass(RHODES_JAVA_CLASS_RHOBLUETOOTHMANAGER); if (!cls) return; jmethodID mid = getJNIClassStaticMethod(env, cls, "session_write_data", "(Ljava/lang/String;[BI)V"); if (!mid) return; jhstring objStr1 = rho_cast<jstring>(env, connected_device_name); jbyteArray buf_j = env->NewByteArray(size); jbyte* buf_p = env->GetByteArrayElements(buf_j, 0); size = rho_ruby_unpack_byte_array(data, (unsigned char*)buf_p, size); env->ReleaseByteArrayElements(buf_j, buf_p, 0); env->CallStaticVoidMethod(cls, mid, objStr1.get(), buf_j, size); env->DeleteLocalRef(buf_j); }
void rho_bluetooth_session_write_data(const char* connected_device_name, VALUE data) { int size = rho_ruby_unpack_byte_array(data, 0, 0); if (size <= 0) { return; } unsigned char* buf = (unsigned char*)malloc(size); size = rho_ruby_unpack_byte_array(data, buf, size); RhoBluetoothManager::getInstance()->rho_bluetooth_session_write_data(connected_device_name, buf, size); free(buf); }