int slotNum = 0;byte block = 0x3E;byte[] command = { (byte)0xFF, (byte)0x86, 0x00, 0x00, 0x05, 0x01, 0x00, block , 0x60, 0x00 };byte[] response = new byte[2];reader.transmit(slotNum, command, command.length, response, response.length);
class NfcReader : public QObject{ Q_OBJECTpublic: ... static NfcReader *getInstance() { return s_instance; } ...signals: void tagDetected(); // Поднесли карту к считывателю void tagReaded(int number); // Номер шкафчика прочитан void tagDisconnected(); // Карту убрали};
void tagDetected(JNIEnv */*env*/, jobject /*thiz*/){ NfcReader::getInstance()->tagDetected();}void tagReaded(JNIEnv */*env*/, jobject /*thiz*/, int number){ NfcReader::getInstance()->tagReaded(number);}void tagDisconnected(JNIEnv */*env*/, jobject /*thiz*/){ NfcReader::getInstance()->tagDisconnected();}static JNINativeMethod methods[] = { {"tagDetected", "()V", (void *)tagDetected}, {"tagReaded", "(I)V", (void *)tagReaded}, {"tagDisconnected", "()V", (void *)tagDisconnected}};
// This method is called immediately after the module is loadJNIEXPORT jint JNI_OnLoad(JavaVM *vm, void */*reserved*/){ JNIEnv *env; if (vm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION_1_6) != JNI_OK) { qCritical() << "Can't get the enviroument"; return -1; } ... // Register our native methods if (env->RegisterNatives(s_classID, methods, sizeof(methods) / sizeof(methods[0])) < 0) { qCritical() << "RegisterNatives failed"; return -1; }}
public static native void tagDetected(); public static native void tagReaded(int number); public static native void tagDisconnected();