读取智能手机和 pn532 之间的 ndef 消息

问题描述

我正在创建一个应用程序来使用 react native 读取 ndef 消息。我正在使用 pn532 卡。在arduino上输入的代码如下:

void loop() {
Serial.println("Send a message to Peer");

NdefMessage message = NdefMessage();
message.addTextRecord("Hello");
int messageSize = message.getEncodedSize();
if (messageSize > sizeof(ndefBuf)) {
    Serial.println("ndefBuf is too small");
    while (1) {
    }
}

message.encode(ndefBuf);
if (0 >= nfc.write(ndefBuf,messageSize)) {
    Serial.println("Failed");
} else {
    Serial.println("Success");
}

delay(3000);}

虽然阅读时的应用代码是这个

NfcManager.setEventListener(NfcEvents.discoverTag,tag => {
    console.log('tag',tag);
    console.log(this.parseText(tag));
    console.log(JSON.stringify(tag.data));
    //NfcManager.unregisterTagEvent().catch(() => 0);
  });

为什么当我将智能手机靠近arduino时操作会失败? 使用的库如下:https://github.com/whitedogg13/react-native-nfc-manager

我想澄清一下,如果我在没有打开任何应用程序的情况下接近智能手机,则可以毫无问题地读取 ndef 消息(Android 系统的本机应用程序)。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...