.connect
该 方法 使用方式为 NfcV.connect()
功能说明:连接 NFC 标签。
参数及说明:Object object。
属性 | 类型 | 默认值 | 必填 | 说明 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
错误码
错误码 | 错误信息 | 说明 |
13000 | 设备不支持 NFC | - |
13001 | 系统 NFC 开关未打开 | - |
13010 | 未知错误 | - |
13019 | user is not authorized | 用户未授权 |
13011 | invalid parameter | 参数无效 |
13012 | parse NdefMessage failed | 将参数解析为 NdefMessage 失败 |
13021 | NFC discovery already started | 已经开始 NFC 扫描 |
13018 | NFC discovery has not started | 尝试在未开始 NFC 扫描时停止 NFC 扫描 |
13022 | Tech already connected | 标签已经连接 |
13023 | Tech has not connected | 尝试在未连接标签时断开连接 |
13013 | NFC tag has not been discovered | 未扫描到 NFC 标签 |
13014 | invalid tech | 无效的标签技术 |
13015 | unavailable tech | 从标签上获取对应技术失败 |
13024 | function not support | 当前标签技术不支持该功能 |
13017 | system internal error | 相关读写操作失败 |
13016 | connect fail | 连接失败 |
.close
该 方法 使用方式为 NfcV.close()
功能说明:断开连接。
参数及说明:Object object。
属性 | 类型 | 默认值 | 必填 | 说明 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
错误码
错误码 | 错误信息 | 说明 |
13000 | 设备不支持 NFC | - |
13001 | 系统 NFC 开关未打开 | - |
13010 | 未知错误 | - |
13019 | user is not authorized | 用户未授权 |
13011 | invalid parameter | 参数无效 |
13012 | parse NdefMessage failed | 将参数解析为 NdefMessage 失败 |
13021 | NFC discovery already started | 已经开始 NFC 扫描 |
13018 | NFC discovery has not started | 尝试在未开始 NFC 扫描时停止 NFC 扫描 |
13022 | Tech already connected | 标签已经连接 |
13023 | Tech has not connected | 尝试在未连接标签时断开连接 |
13013 | NFC tag has not been discovered | 未扫描到 NFC 标签 |
13014 | invalid tech | 无效的标签技术 |
13015 | unavailable tech | 从标签上获取对应技术失败 |
13024 | function not support | 当前标签技术不支持该功能 |
13017 | system internal error | 相关读写操作失败 |
13016 | connect fail | 连接失败 |
.setTimeout
该 方法 使用方式为 NfcV.setTimeout(Object object)
功能说明:设置超时时间。
参数及说明:Object object
属性 | 类型 | 默认值 | 必填 | 说明 |
timeout | number | - | 是 | 设置超时时间(ms) |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
错误码
错误码 | 错误信息 | 说明 |
13000 | 设备不支持 NFC | - |
13001 | 系统 NFC 开关未打开 | - |
13010 | 未知错误 | - |
13019 | user is not authorized | 用户未授权 |
13011 | invalid parameter | 参数无效 |
13012 | parse NdefMessage failed | 将参数解析为 NdefMessage 失败 |
13021 | NFC discovery already started | 已经开始 NFC 扫描 |
13018 | NFC discovery has not started | 尝试在未开始 NFC 扫描时,停止 NFC 扫描 |
13022 | Tech already connected | 标签已经连接 |
13023 | Tech has not connected | 尝试在未连接标签时断开连接 |
13013 | NFC tag has not been discovered | 未扫描到 NFC 标签 |
13014 | invalid tech | 无效的标签技术 |
13015 | unavailable tech | 从标签上获取对应技术失败 |
13024 | function not support | 当前标签技术不支持该功能 |
13017 | system internal error | 相关读写操作失败 |
13016 | connect fail | 连接失败 |
.isConnected
该 方法 使用方式为 NfcV.isConnected()
说明:
该接口已废弃,连接状态开发者自行维护即可。
功能说明:检查是否已连接。
参数及说明:Object object。
属性 | 类型 | 默认值 | 必填 | 说明 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
错误码
错误码 | 错误信息 | 说明 |
13000 | 设备不支持 NFC | - |
13001 | 系统 NFC 开关未打开 | - |
13010 | 未知错误 | - |
13019 | user is not authorized | 用户未授权 |
13011 | invalid parameter | 参数无效 |
13012 | parse NdefMessage failed | 将参数解析为 NdefMessage 失败 |
13021 | NFC discovery already started | 已经开始 NFC 扫描 |
13018 | NFC discovery has not started | 尝试在未开始 NFC 扫描时,停止 NFC 扫描 |
13022 | Tech already connected | 标签已经连接 |
13023 | Tech has not connected | 尝试在未连接标签时断开连接 |
13013 | NFC tag has not been discovered | 未扫描到 NFC 标签 |
13014 | invalid tech | 无效的标签技术 |
13015 | unavailable tech | 从标签上获取对应技术失败 |
13024 | function not support | 当前标签技术不支持该功能 |
13017 | system internal error | 相关读写操作失败 |
13016 | connect fail | 连接失败 |
.getMaxTransceiveLength
该 方法 使用方式为 NfcV.getMaxTransceiveLength()
功能说明:获取最大传输长度。
参数及说明:Object object。
属性 | 类型 | 默认值 | 必填 | 说明 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
object.success 回调函数参数:Object res。
属性 | 类型 | 说明 |
length | number | 最大传输长度 |
错误码
错误码 | 错误信息 | 说明 |
13000 | 设备不支持 NFC | - |
13001 | 系统 NFC 开关未打开 | - |
13010 | 未知错误 | - |
13019 | user is not authorized | 用户未授权 |
13011 | invalid parameter | 参数无效 |
13012 | parse NdefMessage failed | 将参数解析为 NdefMessage 失败 |
13021 | NFC discovery already started | 已经开始 NFC 扫描 |
13018 | NFC discovery has not started | 尝试在未开始 NFC 扫描时,停止 NFC 扫描 |
13022 | Tech already connected | 标签已经连接 |
13023 | Tech has not connected | 尝试在未连接标签时断开连接 |
13013 | NFC tag has not been discovered | 未扫描到 NFC 标签 |
13014 | invalid tech | 无效的标签技术 |
13015 | unavailable tech | 从标签上获取对应技术失败 |
13024 | function not support | 当前标签技术不支持该功能 |
13017 | system internal error | 相关读写操作失败 |
13016 | connect fail | 连接失败 |
.transceive
该 方法 使用方式为 NfcV.transceive(Object object)
功能说明:发送数据。
参数及说明:Object object。
属性 | 类型 | 默认值 | 必填 | 说明 |
data | ArrayBuffer | - | 是 | 需要传递的二进制数据 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
object.success 回调函数参数:Object res。
属性 | 类型 | 说明 |
data | ArrayBuffer | - |
错误码
错误码 | 错误信息 | 说明 |
13000 | 设备不支持 NFC | - |
13001 | 系统 NFC 开关未打开 | - |
13010 | 未知错误 | - |
13019 | user is not authorized | 用户未授权 |
13011 | invalid parameter | 参数无效 |
13012 | parse NdefMessage failed | 将参数解析为 NdefMessage 失败 |
13021 | NFC discovery already started | 已经开始 NFC 扫描 |
13018 | NFC discovery has not started | 尝试在未开始 NFC 扫描时,停止 NFC 扫描 |
13022 | Tech already connected | 标签已经连接 |
13023 | Tech has not connected | 尝试在未连接标签时断开连接 |
13013 | NFC tag has not been discovered | 未扫描到 NFC 标签 |
13014 | invalid tech | 无效的标签技术 |
13015 | unavailable tech | 从标签上获取对应技术失败 |
13024 | function not support | 当前标签技术不支持该功能 |
13017 | system internal error | 相关读写操作失败 |
13016 | connect fail | 连接失败 |