Constructor
new TlvNdef(plug)
构造TlvNdef操作对象
| Name | Type | Description |
|---|---|---|
plug | RktPlug | 插件通讯对象 |
- Source
Members
(static, readonly) DataType :number
Ndef负载数据类型
- number
| Name | Type | Description |
|---|---|---|
EMPTY | number | 空白负载 |
ASCII | number | ASCII负载 |
DATA | number | 数据负载 |
URI | number | URI负载 |
TEXT | number | 文本负载 |
NDEF | number | NDEF负载 |
- Source
(static, readonly) TNF_VALUE :number
Ndef可选TNF值
- number
| Name | Type | Description |
|---|---|---|
EMPTY | number | 空记录 |
WELL_KNOWN | number | 常用RTD记录 |
MIME_MEDIA | number | MIME类型记录 |
ABSOLUTE_URI | number | 绝对URI记录 |
EXTERNAL_TYPE | number | 外部RTD记录 |
UNKNOWN | number | 未知的有效记录 |
UNCHANGED | number | 未变的分块记录 |
RESERVED | number | 未定义预留 |
- Source
(static, readonly) TlvType :number
TLV特殊类型
- number
| Name | Type | Description |
|---|---|---|
NULL | number | 填充占位符 |
LOCK | number | 描述动态锁控制 |
RESERVE | number | 描述保留数据区 |
NDEF | number | 核心NDEF消息 |
FILE | number | 描述文件控制 |
PRIVATE | number | 自定义专有信息 |
EOF | number | TLV终止符 |
- Source
Methods
addAbsoluteURL(uri, str) → {this}
添加一条绝对链接记录
| Name | Type | Description |
|---|---|---|
uri | string | 特殊URI链接 |
str | string | 附加参数字符 默认空 |
- Source
- Type:
- this
addAction(action) → {this}
添加一条Action记录
| Name | Type | Description |
|---|---|---|
action | number | 0=打开,1=保存,2=编辑 |
- Source
- Type:
- this
addData(hexData, mime) → {this}
添加一条MIME数据记录
| Name | Type | Default | Description |
|---|---|---|---|
hexData | string | 十六进制数据 | |
mime | string | application/octet-stream | MIME类型 |
- Source
- Type:
- this
addEmpty() → {this}
添加一条空记录
- Source
- Type:
- this
addExternal(str, type) → {this}
添加一条外部扩展记录
| Name | Type | Default | Description |
|---|---|---|---|
str | string | 记录负载字符 例如APK包名 | |
type | string | android.com:pkg | 记录类型 默认类型=安卓APK包应用启动 |
- Source
- Type:
- this
addSmartPoster(ndefs) → {this}
添加一条SmartPoster记录
| Name | Type | Description |
|---|---|---|
ndefs | Array | 参考getNdefs返回的NDEF简易数组对象 |
- Source
- Type:
- this
addText(text, lang, utf16) → {this}
添加一条文本记录
| Name | Type | Default | Description |
|---|---|---|---|
text | string | 文本内容 | |
lang | string | en | 语言代码 例如en,zh 默认=en |
utf16 | boolean | false | 是否存储为UTF16编码(适合宽字符节省空间) 默认false存储为UTF8 |
- Source
- Type:
- this
addUrl(url) → {this}
添加一条链接记录
| Name | Type | Description |
|---|---|---|
url | string | 完整链接 |
- Source
- Type:
- this
build(tlvs) → {Array}
构建当前所有简易NDEF记录为dump支持的详细数组对象
| Name | Type | Default | Description |
|---|---|---|---|
tlvs | Array | true | false=返回详细ndefs数组对象 默认true=返回dump参数支持的tlvs数组对象 |
- Source
返回dump依赖的详细数组对象
- Type:
- Array
clear() → {this}
清空所有记录变成NDEF空标签
- Source
- Type:
- this
(async) dump(tlvs) → {Promise}
根据对象结构数据生成十六进制数据
| Name | Type | Description |
|---|---|---|
tlvs | object | 参考parseTlvNdef返回的tlvs结构数据 |
- Source
err/msg + retval/data(十六进制字符串数据)
- Type:
- Promise
getNdefs() → {Array}
获取当前NDEF简易数组对象
- Source
[{tnf,type,data,dataType},{...}]
- Type:
- Array
loadNdefs(ndefs) → {this}
加载简易数组对象NDEF记录
| Name | Type | Description |
|---|---|---|
ndefs | Array | 参考getNdefs返回的NDEF简易数组对象 |
- Source
- Type:
- this
loadTlvs(tlvs) → {number}
加载parse返回的tlvs详细数组对象NDEF记录
| Name | Type | Description |
|---|---|---|
tlvs | Array | 参考parse返回的tlvs |
- Source
返回加载后当前NDEF记录数
- Type:
- number
(async) parse(data, strict) → {Promise}
解析TLV-NDEF十六进制数据为对象结构数据
| Name | Type | Default | Description |
|---|---|---|---|
data | string | 十六进制字符串数据 | |
strict | boolean | true | 默认true=严格模式(数据异常返回失败) 否则为宽松模式数据异常继续解析 |
- Source
err/msg + retval/tlvs(TLV结构数据)
- Type:
- Promise