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

NfcV 1100+

方法

NfcV.close(OBJECT)

断开连接

参数:

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

示例:

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

NfcV.connect(OBJECT)

连接 NFC 标签

参数:

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

示例:

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

NfcV.getMaxTransceiveLength(OBJECT)

获取最大传输长度

参数:

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

示例:

nfcv.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`)
  }
})

NfcV.isConnected(OBJECT)

获取当前标签的连接状态

参数:

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

示例:

nfcv.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`)
  }
})

NfcV.transceive(OBJECT)

发送数据

参数:

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

示例:

let arrayBuffer = new ArrayBuffer(1)
let dataView = new DataView(arrayBuffer)
dataView.setUint8(0, 0x60)
nfcv.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`)
  }
})

条匹配 "" 的结果

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