You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在iOS中用react-native-nfc-manager的Iso15693IOS执行ST25 NFC自定义命令失败排查

iOS 下 Iso15693HandlerIOS 自定义命令执行失败排查

我在iOS上使用iso15693HandlerIOS时,readSingleBlock等基础命令可正常运行,但无法执行自定义命令。根据ISO 15693-3规范,0xA0至0xDF为自定义命令段,不同芯片对应命令可能不同。我尝试执行Write Config命令(0xA1),期望通过PWD_1写入RFA1SS寄存器以锁定Area 1,编写的代码如下:

async function writeConfigIos(
  setTagInfo: any,
  setTagStatus: any,
  icMfgCode: number
) {
  try {
    await NfcManager.requestTechnology(NfcTech.Iso15693IOS);
    const tag = await NfcManager.getTag();
    const tagID = tag?.id;
    console.log("Tag Found: ", tagID);

    setTagInfo(tagID);

    // Writing to Config Registers
    const res = await NfcManager.iso15693HandlerIOS.customCommand({
      flags: 0x02,
      customCommandCode: 0xa1,
      customRequestParameters: [0x04, 0x05],
    });
    console.log("Write Config Reg (RFA1SS) Response: ", res);

  } catch (ex) {
    console.log("iOS Custom Command Response: ", ex);
  } finally {
    NfcManager.cancelTechnologyRequest();
    setTimeout(() => setTagStatus(0), 1000);
  }
}

但运行该命令时出现错误,请问是否是命令配置存在问题?


可能的配置问题排查点

  • Flags参数缺失必要标志:当前flags设为0x02(仅Address标志),但写入配置寄存器通常需要密码验证,需添加Password标志位(0x08),即flags应改为0x0A,同时要在customRequestParameters中追加对应密码的字节数据。
  • 自定义命令参数格式不匹配:不同厂商的0xA1命令参数定义可能不同,需核对芯片手册:比如是否需要先指定RFA1SS寄存器地址、密码长度、锁定值的顺序是否正确,当前的[0x04,0x05]是否符合芯片要求的参数结构。
  • 标签选择逻辑缺失:如果场中有多个标签,需添加Select标志位(0x01)到flags中,确保命令发送到目标标签。
  • iOS权限或框架限制:确认Info.plist中已配置NFCReaderUsageDescription权限,部分iOS版本可能对未标准化的自定义命令有过滤限制。

内容的提问来源于stack exchange,提问作者Shahbaz Khan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 07:43:11