Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
3b3fb325
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
大约 1 年 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3b3fb325
编写于
10月 31, 2022
作者:
Q
quanli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
quanli1@huawei.com
Signed-off-by:
N
quanli
<
quanli1@huawei.com
>
上级
02e1bd1f
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
28 addition
and
22 deletion
+28
-22
communication/nfc_Controller/src/main/js/test/nfc.NDEFTag.js
communication/nfc_Controller/src/main/js/test/nfc.NDEFTag.js
+28
-22
未找到文件。
communication/nfc_Controller/src/main/js/test/nfc.NDEFTag.js
浏览文件 @
3b3fb325
...
...
@@ -32,9 +32,9 @@ let NdefRecord = {
NFC_F
:
4
,
NFC_V
:
5
,
NDEF
:
6
,
NDEF_FORMATABLE
:
7
,
MIFARE_CLASSIC
:
8
,
MIFARE_ULTRALIGHT
:
9
,
NDEF_FORMATABLE
:
10
,
};
let
NfcForumType
=
{
...
...
@@ -82,7 +82,7 @@ let FeatureType = {
let
NdefFormatableTag
=
{
"
uid
"
:
[
0x01
,
0x02
,
0x03
,
0x04
],
"
technology
"
:
[
1
,
10
],
"
technology
"
:
[
1
,
7
],
"
extrasData
"
:
[
{
"
Sak
"
:
0x08
,
"
Atqa
"
:
"
B000
"
,
...
...
@@ -132,7 +132,7 @@ export default function nfcNDEFTagTest() {
if
(
NdefTag
!=
undefined
){
console
.
info
(
"
ndefRecords is object1
"
);
try
{
ndefMessage
=
NdefTag
.
createNdefMessage
(
rawData
);
ndefMessage
=
tag
.
ndef
.
createNdefMessage
(
rawData
);
expect
(
ndefMessage
!=
null
).
assertTrue
();
expect
(
ndefMessage
instanceof
Object
).
assertTrue
();
console
.
info
(
"
[NFC_test]ndef ndefMessage1:
"
+
ndefMessage
);
...
...
@@ -166,7 +166,7 @@ export default function nfcNDEFTagTest() {
if
(
NdefTag
!=
undefined
){
console
.
info
(
"
ndefRecords is object2
"
);
try
{
let
ndefMessage
=
NdefTag
.
createNdefMessage
(
rawData
);
let
ndefMessage
=
tag
.
ndef
.
createNdefMessage
(
rawData
);
console
.
info
(
"
[NFC_test]ndefMessage result:
"
);
if
(
ndefMessage
!=
null
&&
ndefMessage
!=
undefined
)
{
console
.
info
(
"
[NFC_test]ndef 1111111111:
"
);
...
...
@@ -209,7 +209,7 @@ export default function nfcNDEFTagTest() {
if
(
NdefTag
!=
undefined
){
console
.
info
(
"
ndefRecords is object3
"
);
try
{
ndefMessage
=
NdefTag
.
createNdefMessage
(
ndefRecords
);
ndefMessage
=
tag
.
ndef
.
createNdefMessage
(
ndefRecords
);
if
(
ndefMessage
!=
null
&&
ndefMessage
!=
undefined
)
{
console
.
info
(
"
[NFC_test]ndef ndefMessage1113:
"
+
ndefMessage
);
expect
(
ndefMessage
!=
null
).
assertTrue
();
...
...
@@ -377,7 +377,10 @@ export default function nfcNDEFTagTest() {
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfcNDEF_js_0900 error
'
+
error
)
}
let
ndefMessage
=
NdefTag
.
createNdefMessage
([
0x01
,
0x02
]);
let
rawData
=
[
0xD1
,
0x01
,
0x03
,
0x54
,
0x4E
,
0x46
,
0x43
];
let
ndefMessage
=
tag
.
ndef
.
createNdefMessage
(
rawData
);
await
NdefTag
.
writeNdef
(
ndefMessage
).
then
((
data
)
=>
{
expect
(
data
).
assertInstanceOf
(
'
Number
'
)
console
.
info
(
"
[NFC_test]ndef writeNdef1 data:
"
+
data
);
...
...
@@ -405,7 +408,10 @@ export default function nfcNDEFTagTest() {
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfcNDEF_js_1000 error
'
+
error
)
}
let
ndefMessage
=
NdefTag
.
createNdefMessage
([
0x01
,
0x02
]);
let
rawData
=
[
0xD1
,
0x01
,
0x03
,
0x54
,
0x4E
,
0x46
,
0x43
];
let
ndefMessage
=
tag
.
ndef
.
createNdefMessage
(
rawData
);
NdefTag
.
writeNdef
(
ndefMessage
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
"
[NFC_test]ndef writeNdef2 err:
"
+
err
);
...
...
@@ -532,7 +538,7 @@ export default function nfcNDEFTagTest() {
console
.
info
(
'
SUB_Communication_NFC_nfcNDEF_js_1600 error
'
+
error
)
}
let
rawData
=
[
0xD1
,
0x01
,
0x03
,
0x54
,
0x4E
,
0x46
,
0x43
];
let
ndefmessage
=
NdefTag
.
createNdefMessage
(
rawData
);
let
ndefmessage
=
tag
.
ndef
.
createNdefMessage
(
rawData
);
let
NdefFormatable
=
tag
.
getNdefFormatable
(
NdefFormatableTag
);
await
NdefFormatable
.
format
(
ndefmessage
).
then
(()
=>
{
console
.
info
(
"
[NFC_test]ndefFormatable format1
"
);
...
...
@@ -558,7 +564,7 @@ export default function nfcNDEFTagTest() {
console
.
info
(
'
SUB_Communication_NFC_nfcNDEF_js_1700 error
'
+
error
)
}
let
rawData
=
[
0xD1
,
0x01
,
0x03
,
0x54
,
0x4E
,
0x46
,
0x43
];
let
ndefmessage
=
NdefTag
.
createNdefMessage
(
rawData
);
let
ndefmessage
=
tag
.
ndef
.
createNdefMessage
(
rawData
);
let
NdefFormatable
=
tag
.
getNdefFormatable
(
NdefFormatableTag
);
NdefFormatable
.
format
(
ndefmessage
,
(
err
,
data
)
=>
{
if
(
err
)
{
...
...
@@ -589,7 +595,7 @@ export default function nfcNDEFTagTest() {
let
rawData
=
[
0xD1
,
0x01
,
0x03
,
0x54
,
0x4E
,
0x46
,
0x43
];
let
ndefmessage
=
NdefTag
.
createNdefMessage
(
rawData
);
let
ndefmessage
=
tag
.
ndef
.
createNdefMessage
(
rawData
);
let
NdefFormatable
=
tag
.
getNdefFormatable
(
NdefFormatableTag
);
await
NdefFormatable
.
formatReadOnly
(
ndefmessage
).
then
(()
=>
{
console
.
info
(
"
[NFC_test]ndefFormatable formatReadOnly1
"
+
data
);
...
...
@@ -617,7 +623,7 @@ export default function nfcNDEFTagTest() {
let
rawData
=
[
0xD1
,
0x01
,
0x03
,
0x54
,
0x4E
,
0x46
,
0x43
];
let
ndefmessage
=
NdefTag
.
createNdefMessage
(
rawData
);
let
ndefmessage
=
tag
.
ndef
.
createNdefMessage
(
rawData
);
let
NdefFormatable
=
tag
.
getNdefFormatable
(
NdefFormatableTag
);
NdefFormatable
.
formatReadOnly
(
ndefmessage
,
(
err
,
data
)
=>
{
if
(
err
)
{
...
...
@@ -650,9 +656,9 @@ export default function nfcNDEFTagTest() {
if
(
NdefTag
!=
undefined
){
console
.
info
(
"
makeUriRecord is object3
"
);
try
{
let
ndefMessage
=
NdefTag
.
createNdefMessage
(
rawData
);
let
ndefMessage
=
tag
.
ndef
.
createNdefMessage
(
rawData
);
console
.
info
(
"
[NFC_test]ndefMessage result:
"
+
JSON
.
stringify
(
ndefMessage
));
let
makeRecords
=
ndefMessage
.
makeUriRecord
(
"
D4010354787473
"
);
let
makeRecords
=
tag
.
ndef
.
makeUriRecord
(
"
D4010354787473
"
);
console
.
info
(
"
[NFC_test]makeUriRecord result:
"
+
JSON
.
stringify
(
makeRecords
));
expect
(
JSON
.
stringify
(
makeRecords
)
!=
null
).
assertTrue
();
...
...
@@ -683,9 +689,9 @@ export default function nfcNDEFTagTest() {
if
(
NdefTag
!=
undefined
){
console
.
info
(
"
makeTextRecord is object4
"
);
try
{
let
ndefMessage
=
NdefTag
.
createNdefMessage
(
rawData
);
let
ndefMessage
=
tag
.
ndef
.
createNdefMessage
(
rawData
);
console
.
info
(
"
[NFC_test]ndefMessage result1:
"
+
JSON
.
stringify
(
ndefMessage
));
let
makeTRecords
=
ndefMessage
.
makeTextRecord
(
"
test112HW
"
,
"
test
"
);
let
makeTRecords
=
tag
.
ndef
.
makeTextRecord
(
"
test112HW
"
,
"
test
"
);
console
.
info
(
"
[NFC_test]makeTextRecord result1:
"
+
JSON
.
stringify
(
makeTRecords
));
expect
(
JSON
.
stringify
(
makeTRecords
)
!=
null
).
assertTrue
();
...
...
@@ -716,9 +722,9 @@ export default function nfcNDEFTagTest() {
if
(
NdefTag
!=
undefined
){
console
.
info
(
"
makeMimeRecord is object5
"
);
try
{
let
ndefMessage
=
NdefTag
.
createNdefMessage
(
rawData
);
let
ndefMessage
=
tag
.
ndef
.
createNdefMessage
(
rawData
);
console
.
info
(
"
[NFC_test]ndefMessage result2:
"
+
JSON
.
stringify
(
ndefMessage
));
let
makeMRecords
=
ndefMessage
.
makeMimeRecord
(
"
BYTE
"
,
"
0112
"
);
let
makeMRecords
=
tag
.
ndef
.
makeMimeRecord
(
"
BYTE
"
,
"
0112
"
);
console
.
info
(
"
[NFC_test]makeMimeRecord result2:
"
+
JSON
.
stringify
(
makeMRecords
));
expect
(
JSON
.
stringify
(
makeMRecords
)
!=
null
).
assertTrue
();
...
...
@@ -749,9 +755,9 @@ export default function nfcNDEFTagTest() {
if
(
NdefTag
!=
undefined
){
console
.
info
(
"
makeExternalRecord is object6
"
);
try
{
let
ndefMessage
=
NdefTag
.
createNdefMessage
(
rawData
);
let
ndefMessage
=
tag
.
ndef
.
createNdefMessage
(
rawData
);
console
.
info
(
"
[NFC_test]ndefMessage result3:
"
+
JSON
.
stringify
(
ndefMessage
));
let
makeERecords
=
ndefMessage
.
makeExternalRecord
(
"
NFC
"
,
"
NFCtest
"
,[
0x01
,
0x02
]);
let
makeERecords
=
tag
.
ndef
.
makeExternalRecord
(
"
NFC
"
,
"
NFCtest
"
,[
0x01
,
0x02
]);
console
.
info
(
"
[NFC_test]makeExternalRecord result13:
"
+
JSON
.
stringify
(
makeERecords
));
expect
(
makeERecords
instanceof
Object
).
assertTrue
();
}
catch
(
error
){
...
...
@@ -781,9 +787,9 @@ export default function nfcNDEFTagTest() {
if
(
NdefTag
!=
undefined
){
console
.
info
(
"
messageToBytes is object7
"
);
try
{
let
ndefMessage
=
NdefTag
.
createNdefMessage
(
rawData
);
let
ndefMessage
=
tag
.
ndef
.
createNdefMessage
(
rawData
);
console
.
info
(
"
[NFC_test]ndefMessage result4:
"
+
JSON
.
stringify
(
ndefMessage
));
let
makeERecords
=
ndefMessage
.
messageToBytes
(
ndefMessage
);
let
makeERecords
=
tag
.
ndef
.
messageToBytes
(
ndefMessage
);
console
.
info
(
"
[NFC_test]messageToBytes result4:
"
+
JSON
.
stringify
(
makeERecords
));
expect
(
makeERecords
).
assertInstanceOf
(
'
Array
'
)
}
catch
(
error
){
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录