教程 框架 组件 接口 工具 其他

NfcA 1100+

方法

NfcA.close(OBJECT)

断开连接

参数:

参数名类型必填说明
successFunction成功回调
failFunction失败回调
completeFunction调用结束

示例:

nfca.close({
  success: function() {
    console.log(`handling success`)
  },
  fail: function(data, code) {
    console.log(`handling fail, code = ${code}`)
  },
  complete: function() {
    console.log(`handling complete`)
  }
})

NfcA.connect(OBJECT)

连接 NFC 标签

参数:

参数名类型必填说明
successFunction成功回调
failFunction失败回调
completeFunction调用结束

示例:

nfca.connect({
  success: function() {
    console.log(`handling success`)
  },
  fail: function(data, code) {
    console.log(`handling fail, code = ${code}`)
  },
  complete: function() {
    console.log(`handling complete`)
  }
})

NfcA.getMaxTransceiveLength(OBJECT)

获取最大传输长度

参数:

参数名类型必填说明
successFunction成功回调
failFunction失败回调
completeFunction调用结束
success 返回值对象参数:
参数名类型说明
lengthnumber最大传输长度

示例:

nfca.getMaxTransceiveLength({
  success: function(data) {
    console.log(`handling success, length = ` + data.length)
  },
  fail: function(data, code) {
    console.log(`handling fail, code = ${code}`)
  },
  complete: function() {
    console.log(`handling complete`)
  }
})

NfcA.isConnected(OBJECT)

获取当前标签的连接状态

参数:

参数名类型必填说明
successFunction成功回调
failFunction失败回调
completeFunction调用结束
success 返回值对象参数:
参数名类型说明
isConnectedBoolean是否已经建立了连接

示例:

nfca.isConnected({
  success: function(data) {
    console.log(`handling success, isConnected = ` + data.isConnected)
  },
  fail: function(data, code) {
    console.log(`handling fail, code = ${code}`)
  },
  complete: function() {
    console.log(`handling complete`)
  }
})

NfcA.setTimeout(OBJECT)

设置超时时间

参数:

参数名类型必填说明
timeoutNumber超时时间(ms)
successFunction成功回调
failFunction失败回调
completeFunction调用结束

示例:

nfca.setTimeout({
  timeout: 1000,
  success: function(data) {
    console.log(`handling success`)
  },
  fail: function(data, code) {
    console.log(`handling fail, code = ${code}`)
  },
  complete: function() {
    console.log(`handling complete`)
  }
})

NfcA.transceive(OBJECT)

发送数据

参数:

参数名类型必填说明
dataArrayBuffer需要传递的二进制数据
successFunction成功回调
failFunction失败回调
completeFunction调用结束
success 返回值对象参数:
参数名类型说明
dataArrayBuffer标签返回结果

示例:

let arrayBuffer = new ArrayBuffer(1)
let dataView = new DataView(arrayBuffer)
dataView.setUint8(0, 0x60)
nfca.transceive({
  data: arrayBuffer,
  success: function(data) {
    console.log(`handling success, result = ` + new Int8Array(data.data))
  },
  fail: function(data, code) {
    console.log(`handling fail, code = ${code}`)
  },
  complete: function() {
    console.log(`handling complete`)
  }
})

NfcA.getAtqa(OBJECT)

获取ATQA信息

参数:

参数名类型必填说明
successFunction成功回调
failFunction失败回调
completeFunction调用结束
success 返回值对象参数:
参数名类型说明
atqaArrayBuffer返回 ATQA/SENS_RES 数据

示例:

nfca.getAtqa({
  data: arrayBuffer,
  success: function(data) {
    console.log(`handling success, result = ` + new Int8Array(data.atqa))
  },
  fail: function(data, code) {
    console.log(`handling fail, code = ${code}`)
  },
  complete: function() {
    console.log(`handling complete`)
  }
})

NfcA.getSak(OBJECT)

获取SAK信息

参数:

参数名类型必填说明
successFunction成功回调
failFunction失败回调
completeFunction调用结束
success 返回值对象参数:
参数名类型说明
sakNumber返回 SAK/SEL_RES 数据

示例:

nfca.getSak({
  success: function(data) {
    console.log(`handling success, result = ` + data.sak)
  },
  fail: function(data, code) {
    console.log(`handling fail, code = ${code}`)
  },
  complete: function() {
    console.log(`handling complete`)
  }
})

条匹配 "" 的结果

    没有搜索到与 "" 相关的内容