Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
05e1aadc
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看板
提交
05e1aadc
编写于
8月 19, 2022
作者:
Q
quanli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
quanli1@huawei.com
Signed-off-by:
N
quanli
<
quanli1@huawei.com
>
上级
fa80cf79
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
143 addition
and
657 deletion
+143
-657
communication/bluetooth_ble/src/main/js/test/BleGattManager.test.js
...ion/bluetooth_ble/src/main/js/test/BleGattManager.test.js
+68
-48
communication/bluetooth_ble/src/main/js/test/BleService.test.js
...ication/bluetooth_ble/src/main/js/test/BleService.test.js
+0
-548
communication/bluetooth_on/src/main/js/test/BluetoothPair.test.js
...ation/bluetooth_on/src/main/js/test/BluetoothPair.test.js
+2
-2
communication/bluetooth_standard/src/main/js/test/BRSpp.test.js
...ication/bluetooth_standard/src/main/js/test/BRSpp.test.js
+71
-58
location/geolocation_standard/src/main/js/default/test/LocationTest.test.js
...on_standard/src/main/js/default/test/LocationTest.test.js
+2
-1
未找到文件。
communication/bluetooth_ble/src/main/js/test/BleGattManager.test.js
浏览文件 @
05e1aadc
...
@@ -119,11 +119,11 @@ describe('bluetoothBLETest', function() {
...
@@ -119,11 +119,11 @@ describe('bluetoothBLETest', function() {
console
.
info
(
'
[bluetooth_js] gattClient getrssi2 connect
'
+
JSON
.
stringify
(
ret
))
console
.
info
(
'
[bluetooth_js] gattClient getrssi2 connect
'
+
JSON
.
stringify
(
ret
))
expect
(
ret
).
assertTrue
();
expect
(
ret
).
assertTrue
();
await
gattClient
.
getRssiValue
().
then
((
data
)
=>
{
await
gattClient
.
getRssiValue
().
then
((
data
)
=>
{
console
.
info
(
'
[bluetooth_js] BLE read rssi
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
[bluetooth_js] BLE read rssi
:
'
+
JSON
.
stringify
(
data
));
let
rssiLength
=
Object
.
keys
(
data
).
length
;
let
rssiLength
=
Object
.
keys
(
data
).
length
;
expect
(
rssiLength
).
assertEqual
(
0
);
expect
(
rssiLength
).
assertEqual
(
0
);
}).
catch
(
err
=>
{
}).
catch
(
err
or
=>
{
console
.
error
(
'
bluetooth getRssiValue has error:
'
+
err
);
console
.
info
(
'
bluetooth getRssiValue has error:
'
+
JSON
.
stringify
(
error
)
);
expect
(
true
).
assertEqual
(
true
);
expect
(
true
).
assertEqual
(
true
);
});
});
let
disconnect
=
gattClient
.
disconnect
();
let
disconnect
=
gattClient
.
disconnect
();
...
@@ -146,15 +146,17 @@ describe('bluetoothBLETest', function() {
...
@@ -146,15 +146,17 @@ describe('bluetoothBLETest', function() {
let
ret
=
gattClient
.
connect
();
let
ret
=
gattClient
.
connect
();
console
.
info
(
'
[bluetooth_js] gattClient getRssi connect
'
+
JSON
.
stringify
(
ret
))
console
.
info
(
'
[bluetooth_js] gattClient getRssi connect
'
+
JSON
.
stringify
(
ret
))
expect
(
ret
).
assertTrue
();
expect
(
ret
).
assertTrue
();
gattClient
.
getRssiValue
((
err
,
data
)
=>
{
let
promise
=
new
Promise
((
resolve
)
=>
{
console
.
info
(
'
[bluetooth_js]getRssi value:
'
+
JSON
.
stringify
(
data
));
gattClient
.
getRssiValue
((
err
,
data
)
=>
{
expect
(
data
).
assertNull
();
console
.
info
(
'
[bluetooth_js]getRssi value:
'
+
JSON
.
stringify
(
data
));
let
disconnect
=
gattClient
.
disconnect
();
expect
(
data
).
assertNull
();
console
.
info
(
'
[bluetooth_js] gatt getrssi1 disconnect:
'
+
disconnect
);
let
disconnect
=
gattClient
.
disconnect
();
expect
(
disconnect
).
assertEqual
(
false
);
console
.
info
(
'
[bluetooth_js] gatt getrssi1 disconnect:
'
+
disconnect
);
});
expect
(
disconnect
).
assertEqual
(
false
);
await
sleep
(
2000
);
});
done
();
resolve
()
})
await
promise
.
then
(
done
)
})
})
/**
/**
...
@@ -353,37 +355,40 @@ describe('bluetoothBLETest', function() {
...
@@ -353,37 +355,40 @@ describe('bluetoothBLETest', function() {
* @tc.type Function
* @tc.type Function
* @tc.level Level 2
* @tc.level Level 2
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0100
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0100
'
,
0
,
async
function
(
done
)
{
let
descriptors
=
[];
let
promise
=
new
Promise
((
resolve
)
=>
{
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
descriptors
=
[];
let
desValue
=
new
Uint8Array
(
arrayBuffer
);
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
desValue
=
new
Uint8Array
(
arrayBuffer
);
desValue
[
0
]
=
11
;
desValue
[
0
]
=
11
;
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
descriptors
[
0
]
=
descriptor
;
descriptors
[
0
]
=
descriptor
;
let
arrayBufferCCC
=
new
ArrayBuffer
(
8
);
let
arrayBufferCCC
=
new
ArrayBuffer
(
8
);
let
cccValue
=
new
Uint8Array
(
arrayBufferCCC
);
let
cccValue
=
new
Uint8Array
(
arrayBufferCCC
);
cccValue
[
0
]
=
32
;
cccValue
[
0
]
=
32
;
let
characteristic
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
let
characteristic
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
characteristicValue
:
arrayBufferCCC
,
descriptors
:
descriptors
};
characteristicValue
:
arrayBufferCCC
,
descriptors
:
descriptors
};
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
00:00:00:00:00:00
"
);
await
gattClient
.
readCharacteristicValue
(
characteristic
).
then
((
object
)
=>
{
gattClient
.
readCharacteristicValue
(
characteristic
).
then
((
object
)
=>
{
if
(
object
!=
null
)
{
if
(
object
!=
null
)
{
console
.
error
(
'
bluetooth readCharacteristicValue promise object :
'
expect
(
true
).
assertEqual
(
true
);
+
JSON
.
stringify
(
object
));
}
else
{
console
.
info
(
'
[bluetooth_js] readCharacValue promise data:
'
+
JSON
.
stringify
(
data
));
expect
(
null
).
assertFail
();
}
done
();
}).
catch
(
err
=>
{
console
.
error
(
`bluetooth readCharacteValue promise has error:
${
err
}
`
);
expect
(
true
).
assertEqual
(
true
);
expect
(
true
).
assertEqual
(
true
);
}
else
{
done
();
console
.
info
(
'
[bluetooth_js] readCharacValue promise null:
'
+
JSON
.
stringify
(
object
));
});
expect
(
null
).
assertFail
();
resolve
()
}
done
();
}).
catch
(
error
=>
{
console
.
error
(
'
[bluetooth_js] readCharacteristicValue promise has error:
'
+
JSON
.
stringify
(
error
));
expect
(
true
).
assertEqual
(
true
);
done
();
})
})
await
promise
.
then
(
done
)
})
})
/**
/**
...
@@ -400,6 +405,7 @@ describe('bluetoothBLETest', function() {
...
@@ -400,6 +405,7 @@ describe('bluetoothBLETest', function() {
return
;
return
;
}
}
console
.
log
(
'
bluetooth characteristic uuid:
'
+
BLECharacteristic
.
characteristicUuid
);
console
.
log
(
'
bluetooth characteristic uuid:
'
+
BLECharacteristic
.
characteristicUuid
);
expect
(
true
).
assertEqual
(
data
==
null
);
let
value
=
new
Uint8Array
(
BLECharacteristic
.
characteristicValue
);
let
value
=
new
Uint8Array
(
BLECharacteristic
.
characteristicValue
);
console
.
log
(
'
bluetooth characteristic value:
'
console
.
log
(
'
bluetooth characteristic value:
'
+
value
[
0
]
+
'
,
'
+
value
[
1
]
+
'
,
'
+
value
[
2
]
+
'
,
'
+
value
[
3
]);
+
value
[
0
]
+
'
,
'
+
value
[
1
]
+
'
,
'
+
value
[
2
]
+
'
,
'
+
value
[
3
]);
...
@@ -408,7 +414,8 @@ describe('bluetoothBLETest', function() {
...
@@ -408,7 +414,8 @@ describe('bluetoothBLETest', function() {
let
desValue
=
new
Uint8Array
(
arrayBuffer
);
let
desValue
=
new
Uint8Array
(
arrayBuffer
);
desValue
[
0
]
=
11
;
desValue
[
0
]
=
11
;
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
let
arrayBufferCCC
=
new
ArrayBuffer
(
8
);
let
arrayBufferCCC
=
new
ArrayBuffer
(
8
);
let
cccValue
=
new
Uint8Array
(
arrayBufferCCC
);
let
cccValue
=
new
Uint8Array
(
arrayBufferCCC
);
cccValue
[
0
]
=
32
;
cccValue
[
0
]
=
32
;
...
@@ -416,9 +423,7 @@ describe('bluetoothBLETest', function() {
...
@@ -416,9 +423,7 @@ describe('bluetoothBLETest', function() {
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
characteristicValue
:
arrayBufferCCC
,
descriptors
:
descriptor
};
characteristicValue
:
arrayBufferCCC
,
descriptors
:
descriptor
};
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
data
=
await
gattClient
.
readCharacteristicValue
(
characteristic
,
readCcc
);
gattClient
.
readCharacteristicValue
(
characteristic
,
readCcc
);
console
.
log
(
'
[bluetooth_js] readCharacteristicValue callback:
'
+
JSON
.
stringify
(
data
))
expect
(
true
).
assertEqual
(
data
==
null
);
done
()
done
()
})
})
...
@@ -435,7 +440,8 @@ describe('bluetoothBLETest', function() {
...
@@ -435,7 +440,8 @@ describe('bluetoothBLETest', function() {
let
desValue
=
new
Uint8Array
(
arrayBuffer
);
let
desValue
=
new
Uint8Array
(
arrayBuffer
);
desValue
[
0
]
=
11
;
desValue
[
0
]
=
11
;
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
await
gattClient
.
readDescriptorValue
(
descriptor
).
then
((
object
)
=>
{
await
gattClient
.
readDescriptorValue
(
descriptor
).
then
((
object
)
=>
{
if
(
object
!=
null
)
{
if
(
object
!=
null
)
{
...
@@ -443,12 +449,12 @@ describe('bluetoothBLETest', function() {
...
@@ -443,12 +449,12 @@ describe('bluetoothBLETest', function() {
expect
(
true
).
assertEqual
(
true
);
expect
(
true
).
assertEqual
(
true
);
}
else
{
}
else
{
console
.
info
(
'
[bluetooth_js]readDescrip
tor
Value null:
'
+
JSON
.
stringify
(
object
));
console
.
info
(
'
[bluetooth_js]readDescripValue null:
'
+
JSON
.
stringify
(
object
));
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
done
();
done
();
}).
catch
(
err
or
=>
{
}).
catch
(
err
=>
{
console
.
error
(
'
[bluetooth_js]readDescr
iptorValue promise error:
'
+
JSON
.
stringify
(
erro
r
));
console
.
error
(
'
[bluetooth_js]readDescr
Value promise err:
'
+
JSON
.
stringify
(
er
r
));
expect
(
true
).
assertEqual
(
true
);
expect
(
true
).
assertEqual
(
true
);
done
();
done
();
})
})
...
@@ -466,7 +472,7 @@ describe('bluetoothBLETest', function() {
...
@@ -466,7 +472,7 @@ describe('bluetoothBLETest', function() {
function
readDesc
(
code
,
BLEDescriptor
)
{
function
readDesc
(
code
,
BLEDescriptor
)
{
if
(
code
.
code
!=
0
)
{
if
(
code
.
code
!=
0
)
{
console
.
info
(
'
[bluetooth_js] descriptor code:
'
+
BLEDescriptor
.
descriptorUuid
);
console
.
info
(
'
[bluetooth_js] descriptor code:
'
+
BLEDescriptor
.
descriptorUuid
);
return
;
expect
(
true
).
assertEqual
(
BLEDescriptor
.
descriptorUuid
==
null
)
;
}
}
console
.
info
(
'
[bluetooth_js] descriptor uuid:
'
+
BLEDescriptor
.
descriptorUuid
);
console
.
info
(
'
[bluetooth_js] descriptor uuid:
'
+
BLEDescriptor
.
descriptorUuid
);
let
value
=
new
Uint8Array
(
BLEDescriptor
.
descriptorValue
);
let
value
=
new
Uint8Array
(
BLEDescriptor
.
descriptorValue
);
...
@@ -479,9 +485,7 @@ describe('bluetoothBLETest', function() {
...
@@ -479,9 +485,7 @@ describe('bluetoothBLETest', function() {
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
data1
=
await
gattClient
.
readDescriptorValue
(
descriptor
,
readDesc
);
gattClient
.
readDescriptorValue
(
descriptor
,
readDesc
);
console
.
log
(
'
[bluetooth_js] readDescriptorValue callback:
'
+
JSON
.
stringify
(
data1
))
expect
(
true
).
assertEqual
(
data1
==
null
);
done
()
done
()
})
})
...
@@ -653,6 +657,22 @@ describe('bluetoothBLETest', function() {
...
@@ -653,6 +657,22 @@ describe('bluetoothBLETest', function() {
done
();
done
();
})
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_NotifyCharacteristic_0300
* @tc.name testSetNotifyCharacteristicChanged
* @tc.desc Test SetNotifyCharacteristicChanged api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_GattClose_0100
'
,
0
,
async
function
(
done
)
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
close
();
console
.
info
(
'
[bluetooth_js] gattClient close ret:
'
+
ret
);
expect
(
ret
).
assertEqual
(
true
);
done
();
})
})
})
}
}
communication/bluetooth_ble/src/main/js/test/BleService.test.js
浏览文件 @
05e1aadc
...
@@ -67,554 +67,6 @@ describe('bluetoothBLETest1', function() {
...
@@ -67,554 +67,6 @@ describe('bluetoothBLETest1', function() {
gattServer
.
close
();
gattServer
.
close
();
})
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_GetRssiValue_0100
* @tc.name testgetRssiValue
* @tc.desc Test getRssiValue api by promise.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_GetRssiValue_0100
'
,
0
,
async
function
(
done
)
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
connect
();
console
.
info
(
'
[bluetooth_js] gattClient getrssi2 connect
'
+
JSON
.
stringify
(
ret
))
expect
(
ret
).
assertTrue
();
await
gattClient
.
getRssiValue
().
then
((
data
)
=>
{
console
.
info
(
'
[bluetooth_js] BLE read rssi
'
+
JSON
.
stringify
(
data
));
let
rssiLength
=
Object
.
keys
(
data
).
length
;
expect
(
rssiLength
).
assertEqual
(
0
);
}).
catch
(
err
=>
{
console
.
error
(
'
bluetooth getRssiValue has error:
'
+
err
);
expect
(
true
).
assertEqual
(
true
);
});
let
disconnect
=
gattClient
.
disconnect
();
console
.
info
(
'
[bluetooth_js] gatt getrssi2 disconnect:
'
+
disconnect
);
expect
(
disconnect
).
assertEqual
(
false
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_GetRssiValue_0200
* @tc.name testgetRssiValue
* @tc.desc Test testGetDeviceName api by callback.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_GetRssiValue_0200
'
,
0
,
async
function
(
done
)
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
connect
();
console
.
info
(
'
[bluetooth_js] gattClient getRssi connect
'
+
JSON
.
stringify
(
ret
))
expect
(
ret
).
assertTrue
();
gattClient
.
getRssiValue
((
err
,
data
)
=>
{
console
.
info
(
'
[bluetooth_js]getRssi value:
'
+
JSON
.
stringify
(
data
));
expect
(
data
).
assertNull
();
let
disconnect
=
gattClient
.
disconnect
();
console
.
info
(
'
[bluetooth_js] gatt getrssi1 disconnect:
'
+
disconnect
);
expect
(
disconnect
).
assertEqual
(
false
);
});
await
sleep
(
2000
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_GetDeviceName_0100
* @tc.name testGetDeviceName
* @tc.desc Test GetDeviceName api by promise.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_GetDeviceName_0100
'
,
0
,
async
function
(
done
)
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
connect
();
console
.
info
(
'
[bluetooth_js] gattClient getname2 connect
'
+
JSON
.
stringify
(
ret
))
expect
(
ret
).
assertTrue
();
await
gattClient
.
getDeviceName
().
then
((
data
)
=>
{
console
.
info
(
'
[bluetooth_js] device name
'
+
JSON
.
stringify
(
data
))
expect
(
data
).
assertNull
();
}).
catch
(
err
=>
{
console
.
error
(
'
bluetooth getDeviceName has error:
'
+
err
);
expect
(
true
).
assertEqual
(
true
);
});
let
disconnect
=
gattClient
.
disconnect
();
console
.
info
(
'
[bluetooth_js] gatt getname2 disconnect:
'
+
disconnect
);
expect
(
disconnect
).
assertEqual
(
false
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_getDeviceName_0200
* @tc.name testGetDeviceName
* @tc.desc Test testGetDeviceName api by callback.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_GetDeviceName_0200
'
,
0
,
async
function
(
done
)
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
connect
();
console
.
info
(
'
[bluetooth_js] gattClient getname1 connect
'
+
JSON
.
stringify
(
ret
))
expect
(
ret
).
assertTrue
();
gattClient
.
getDeviceName
((
err
,
data
)
=>
{
console
.
info
(
'
[bluetooth_js]getname value:
'
+
JSON
.
stringify
(
data
));
expect
(
data
).
assertNull
();
let
disconnect
=
gattClient
.
disconnect
();
console
.
info
(
'
[bluetooth_js] gatt getname1 disconnect:
'
+
disconnect
);
expect
(
disconnect
).
assertEqual
(
false
);
});
await
sleep
(
2000
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_GetService_0100
* @tc.name testGetServices
* @tc.desc Test GetServices api by promise.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_GetService_0100
'
,
0
,
async
function
(
done
)
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
connect
();
console
.
info
(
'
[bluetooth_js]gattClient getservices1 connect
'
+
JSON
.
stringify
(
ret
))
expect
(
ret
).
assertTrue
();
await
gattClient
.
getServices
().
then
((
GattService
)
=>
{
console
.
info
(
'
[bluetooth_js] getServices successfully:
'
+
JSON
.
stringify
(
GattService
));
expect
(
GattService
).
assertNull
();
}).
catch
(
err
=>
{
console
.
error
(
'
[bluetooth_js] getServices has error:
'
+
JSON
.
stringify
(
err
));
expect
(
true
).
assertEqual
(
true
);
});
let
disconnect
=
gattClient
.
disconnect
();
console
.
info
(
'
[bluetooth_js] gatt getservices1 disconnect:
'
+
disconnect
);
expect
(
disconnect
).
assertEqual
(
false
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_GetService_0200
* @tc.name testGetServices
* @tc.desc Test GetServices api by callback.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_GetService_0200
'
,
0
,
async
function
(
done
)
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
connect
();
console
.
info
(
'
[bluetooth_js]gattClient getservices2 connect
'
+
JSON
.
stringify
(
ret
))
gattClient
.
getServices
((
code
,
data
)
=>
{
if
(
code
.
code
==
0
){
console
.
info
(
"
bluetooth services size is
"
,
data
.
length
)
expect
(
true
).
assertEqual
(
data
.
length
>=
0
);
}
else
{
console
.
info
(
'
[bluetooth_js] get services code
'
+
JSON
.
stringify
(
code
));
expect
(
true
).
assertEqual
(
code
.
code
==
-
1
);
}
let
disconnect
=
gattClient
.
disconnect
();
console
.
info
(
'
[bluetooth_js] gatt getservices1 disconnect:
'
+
disconnect
);
expect
(
disconnect
).
assertEqual
(
false
);
});
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_MtuSize_0100
* @tc.name testSetBLEMtuSize
* @tc.desc Test SetBLEMtuSize api.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 1
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_MtuSize_0100
'
,
0
,
function
()
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
setBLEMtuSize
(
100
);
console
.
info
(
'
[bluetooth_js] bluetooth setBLEMtuSize 128bit ret:
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_MtuSize_0200
* @tc.name testSetBLEMtuSize
* @tc.desc Test SetBLEMtuSize api.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_MtuSize_0200
'
,
0
,
function
()
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
setBLEMtuSize
(
22
);
console
.
info
(
'
[bluetooth_js] bluetooth setBLEMtuSize 128bit ret:
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_MtuSize_0300
* @tc.name testSetBLEMtuSize
* @tc.desc Test SetBLEMtuSize api.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_MtuSize_0300
'
,
0
,
function
()
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
setBLEMtuSize
(
21
);
console
.
info
(
'
[bluetooth_js] bluetooth setBLEMtuSize 128bit ret:
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_MtuSize_0400
* @tc.name testSetBLEMtuSize
* @tc.desc Test SetBLEMtuSize api.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 1
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_MtuSize_0400
'
,
0
,
function
()
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
setBLEMtuSize
(
512
);
console
.
info
(
'
[bluetooth_js] bluetooth setBLEMtuSize 128bit ret:
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_MtuSize_0500
* @tc.name testSetBLEMtuSize
* @tc.desc Test SetBLEMtuSize api.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_MtuSize_0500
'
,
0
,
function
()
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
setBLEMtuSize
(
513
);
console
.
info
(
'
[bluetooth_js] bluetooth setBLEMtuSize 128bit ret:
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0100
* @tc.name testReadDescriptorValue
* @tc.desc Test ReadDescriptorValue api by promise.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0100
'
,
0
,
async
function
(
done
)
{
let
descriptors
=
[];
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
desValue
=
new
Uint8Array
(
arrayBuffer
);
desValue
[
0
]
=
11
;
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
descriptors
[
0
]
=
descriptor
;
let
arrayBufferCCC
=
new
ArrayBuffer
(
8
);
let
cccValue
=
new
Uint8Array
(
arrayBufferCCC
);
cccValue
[
0
]
=
32
;
let
characteristic
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
characteristicValue
:
arrayBufferCCC
,
descriptors
:
descriptors
};
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
await
gattClient
.
readCharacteristicValue
(
characteristic
).
then
((
object
)
=>
{
if
(
object
!=
null
)
{
console
.
error
(
'
bluetooth readCharacteristicValue promise object :
'
+
JSON
.
stringify
(
object
));
expect
(
true
).
assertEqual
(
true
);
}
else
{
console
.
info
(
'
[bluetooth_js] readCharacValue promise null:
'
+
JSON
.
stringify
(
object
));
expect
(
null
).
assertFail
();
}
done
();
}).
catch
(
error
=>
{
console
.
error
(
'
[bluetooth_js] readCharacteristicValue promise has error:
'
+
JSON
.
stringify
(
error
));
expect
(
true
).
assertEqual
(
true
);
done
();
})
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0200
* @tc.name testReadDescriptorValue
* @tc.desc Test ReadDescriptorValue api by callback.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0200
'
,
0
,
async
function
(
done
)
{
function
readCcc
(
code
,
BLECharacteristic
)
{
if
(
code
.
code
!=
0
)
{
return
;
}
console
.
log
(
'
bluetooth characteristic uuid:
'
+
BLECharacteristic
.
characteristicUuid
);
let
value
=
new
Uint8Array
(
BLECharacteristic
.
characteristicValue
);
console
.
log
(
'
bluetooth characteristic value:
'
+
value
[
0
]
+
'
,
'
+
value
[
1
]
+
'
,
'
+
value
[
2
]
+
'
,
'
+
value
[
3
]);
}
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
desValue
=
new
Uint8Array
(
arrayBuffer
);
desValue
[
0
]
=
11
;
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
let
arrayBufferCCC
=
new
ArrayBuffer
(
8
);
let
cccValue
=
new
Uint8Array
(
arrayBufferCCC
);
cccValue
[
0
]
=
32
;
let
characteristic
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
characteristicValue
:
arrayBufferCCC
,
descriptors
:
descriptor
};
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
data
=
await
gattClient
.
readCharacteristicValue
(
characteristic
,
readCcc
);
console
.
log
(
'
[bluetooth_js] readCharacteristicValue callback:
'
+
JSON
.
stringify
(
data
))
expect
(
true
).
assertEqual
(
data
==
null
);
done
()
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_0100
* @tc.name testReadDescriptorValue
* @tc.desc Test ReadDescriptorValue api by promise.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_0100
'
,
0
,
async
function
(
done
)
{
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
desValue
=
new
Uint8Array
(
arrayBuffer
);
desValue
[
0
]
=
11
;
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
await
gattClient
.
readDescriptorValue
(
descriptor
).
then
((
object
)
=>
{
if
(
object
!=
null
)
{
console
.
error
(
'
readDescriptorValue promise object:
'
+
JSON
.
stringify
(
object
));
expect
(
true
).
assertEqual
(
true
);
}
else
{
console
.
info
(
'
[bluetooth_js]readDescriptorValue null:
'
+
JSON
.
stringify
(
object
));
expect
(
null
).
assertFail
();
}
done
();
}).
catch
(
error
=>
{
console
.
error
(
'
[bluetooth_js]readDescriptorValue promise error:
'
+
JSON
.
stringify
(
error
));
expect
(
true
).
assertEqual
(
true
);
done
();
})
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_0200
* @tc.name testReadDescriptorValue
* @tc.desc Test ReadDescriptorValue api by callback.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_0200
'
,
0
,
async
function
(
done
)
{
function
readDesc
(
code
,
BLEDescriptor
)
{
if
(
code
.
code
!=
0
)
{
console
.
info
(
'
[bluetooth_js] descriptor code:
'
+
BLEDescriptor
.
descriptorUuid
);
return
;
}
console
.
info
(
'
[bluetooth_js] descriptor uuid:
'
+
BLEDescriptor
.
descriptorUuid
);
let
value
=
new
Uint8Array
(
BLEDescriptor
.
descriptorValue
);
console
.
info
(
'
[bluetooth_js] descriptor value:
'
+
value
[
0
]
+
'
,
'
+
value
[
1
]
+
'
,
'
+
value
[
2
]
+
'
,
'
+
value
[
3
]);
}
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
desValue
=
new
Uint8Array
(
arrayBuffer
);
desValue
[
0
]
=
11
;
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
data1
=
await
gattClient
.
readDescriptorValue
(
descriptor
,
readDesc
);
console
.
log
(
'
[bluetooth_js] readDescriptorValue callback:
'
+
JSON
.
stringify
(
data1
))
expect
(
true
).
assertEqual
(
data1
==
null
);
done
()
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0100
* @tc.name testWriteCharacteristicValue
* @tc.desc Test Client WriteCharacteristicValue api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0100
'
,
0
,
function
()
{
let
descriptors
=
[];
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
desValue
=
new
Uint8Array
(
arrayBuffer
);
desValue
[
0
]
=
11
;
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
descriptors
[
0
]
=
descriptor
;
let
arrayBufferCCC
=
new
ArrayBuffer
(
8
);
let
cccValue
=
new
Uint8Array
(
arrayBufferCCC
);
cccValue
[
0
]
=
32
;
let
characteristic
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
characteristicValue
:
arrayBufferCCC
,
descriptors
:
descriptors
};
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
writeCharacteristicValue
(
characteristic
);
console
.
info
(
'
[bluetooth_js] writeCharacteristicValue ret :
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0200
* @tc.name testWriteCharacteristicValue
* @tc.desc Test Client WriteCharacteristicValue api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0200
'
,
0
,
function
()
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
writeCharacteristicValue
(
"
123
"
);
console
.
info
(
'
[bluetooth_js] invaild writeCharacteristicValue ret :
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0100
* @tc.name testWriteDescriptorValue
* @tc.desc Test Client WriteDescriptorValue api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0100
'
,
0
,
function
()
{
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
desValue
=
new
Uint8Array
(
arrayBuffer
);
desValue
[
0
]
=
11
;
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
writeDescriptorValue
(
descriptor
);
console
.
info
(
'
[bluetooth_js] bluetooth writeDescriptorValue ret :
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0200
* @tc.name testWriteDescriptorValue
* @tc.desc Test WriteDescriptorValue api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0200
'
,
0
,
function
()
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
writeDescriptorValue
(
""
);
console
.
info
(
'
[bluetooth_js] bluetooth writeDescriptorValue ret :
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_NotifyCharacteristic_0100
* @tc.name testSetNotifyCharacteristicChanged
* @tc.desc Test SetNotifyCharacteristicChanged api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0100
'
,
0
,
async
function
(
done
)
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
descriptors
=
[];
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
desValue
=
new
Uint8Array
(
arrayBuffer
);
desValue
[
0
]
=
11
;
let
arrayBufferNotify
=
new
ArrayBuffer
(
8
);
let
descNotifyValue
=
new
Uint8Array
(
arrayBufferNotify
);
descNotifyValue
[
0
]
=
1
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
let
descriptorNotify
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00002902-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBufferNotify
};
descriptors
[
0
]
=
descriptor
;
descriptors
[
1
]
=
descriptorNotify
;
let
arrayBufferCCC
=
new
ArrayBuffer
(
8
);
let
cccValue
=
new
Uint8Array
(
arrayBufferCCC
);
cccValue
[
0
]
=
1
;
let
characteristic
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
characteristicValue
:
arrayBufferCCC
,
descriptors
:
descriptors
};
let
ret
=
gattClient
.
setNotifyCharacteristicChanged
(
characteristic
,
true
);
console
.
info
(
'
[bluetooth_js] setNotifyCharacteristicChanged ret:
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_NotifyCharacteristic_0200
* @tc.name testSetNotifyCharacteristicChanged
* @tc.desc Test SetNotifyCharacteristicChanged api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0200
'
,
0
,
async
function
(
done
)
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
descriptors
=
[];
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
desValue
=
new
Uint8Array
(
arrayBuffer
);
desValue
[
0
]
=
11
;
let
arrayBufferNotify
=
new
ArrayBuffer
(
8
);
let
descNotifyValue
=
new
Uint8Array
(
arrayBufferNotify
);
descNotifyValue
[
0
]
=
1
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
let
descriptorNotify
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00002902-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBufferNotify
};
descriptors
[
0
]
=
descriptor
;
descriptors
[
1
]
=
descriptorNotify
;
let
arrayBufferCCC
=
new
ArrayBuffer
(
8
);
let
cccValue
=
new
Uint8Array
(
arrayBufferCCC
);
cccValue
[
0
]
=
1
;
let
characteristic
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
characteristicValue
:
arrayBufferCCC
,
descriptors
:
descriptors
};
let
ret
=
gattClient
.
setNotifyCharacteristicChanged
(
characteristic
,
false
);
console
.
info
(
'
[bluetooth_js] setNotifyCharacteristicChanged ret:
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_NotifyCharacteristic_0300
* @tc.name testSetNotifyCharacteristicChanged
* @tc.desc Test SetNotifyCharacteristicChanged api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0300
'
,
0
,
async
function
(
done
)
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
setNotifyCharacteristicChanged
(
null
,
false
);
console
.
info
(
'
[bluetooth_js] setNotifyCharacteristicChanged is null ret:
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
done
();
})
/**
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0100
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0100
...
...
communication/bluetooth_on/src/main/js/test/BluetoothPair.test.js
浏览文件 @
05e1aadc
...
@@ -226,7 +226,7 @@ describe('bluetoothhostTest2', function() {
...
@@ -226,7 +226,7 @@ describe('bluetoothhostTest2', function() {
bluetooth
.
BLE
.
on
(
'
pinRequired
'
,
PinRequiredParam
);
bluetooth
.
BLE
.
on
(
'
pinRequired
'
,
PinRequiredParam
);
let
result
=
bluetooth
.
pairDevice
(
"
00:00:00:00:00:00
"
);
let
result
=
bluetooth
.
pairDevice
(
"
00:00:00:00:00:00
"
);
console
.
info
(
"
[bluetooth_js] onStartpair007 ->
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[bluetooth_js] onStartpair007 ->
"
+
JSON
.
stringify
(
result
));
expect
(
result
).
assert
Tru
e
();
expect
(
result
).
assert
Fals
e
();
bluetooth
.
BLE
.
off
(
'
pinRequired
'
,
PinRequiredParam
);
bluetooth
.
BLE
.
off
(
'
pinRequired
'
,
PinRequiredParam
);
done
()
done
()
})
})
...
@@ -248,7 +248,7 @@ describe('bluetoothhostTest2', function() {
...
@@ -248,7 +248,7 @@ describe('bluetoothhostTest2', function() {
bluetooth
.
BLE
.
on
(
'
pinRequired
'
,
PinRequiredParam
);
bluetooth
.
BLE
.
on
(
'
pinRequired
'
,
PinRequiredParam
);
let
result
=
bluetooth
.
pairDevice
(
"
00:00:00:00:00:00
"
);
let
result
=
bluetooth
.
pairDevice
(
"
00:00:00:00:00:00
"
);
console
.
info
(
"
[bluetooth_js] onStartpair008 ->
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[bluetooth_js] onStartpair008 ->
"
+
JSON
.
stringify
(
result
));
expect
(
result
).
assert
Tru
e
();
expect
(
result
).
assert
Fals
e
();
bluetooth
.
BLE
.
off
(
'
pinRequired
'
,
PinRequiredParam
);
bluetooth
.
BLE
.
off
(
'
pinRequired
'
,
PinRequiredParam
);
done
()
done
()
})
})
...
...
communication/bluetooth_standard/src/main/js/test/BRSpp.test.js
浏览文件 @
05e1aadc
...
@@ -79,9 +79,10 @@ describe('bluetoothhostTest4', function() {
...
@@ -79,9 +79,10 @@ describe('bluetoothhostTest4', function() {
secure
:
true
,
type
:
SppType
.
SPP_RFCOMM
};
secure
:
true
,
type
:
SppType
.
SPP_RFCOMM
};
let
serverNumber
=
-
1
;
let
serverNumber
=
-
1
;
function
serverSocket
(
code
,
number
)
{
function
serverSocket
(
code
,
number
)
{
console
.
log
(
'
bluetooth error code:
'
+
code
.
code
);
if
(
code
)
{
if
(
code
.
code
==
0
)
{
console
.
log
(
'
bluetooth error code:
'
+
code
);
console
.
log
(
'
bluetooth serverSocket Number:
'
+
number
);
}
else
{
console
.
log
(
'
bluetooth serverSocket Number:
'
+
JSON
.
stringify
(
number
));
serverNumber
=
number
;
serverNumber
=
number
;
expect
(
true
).
assertEqual
(
number
!=
null
);
expect
(
true
).
assertEqual
(
number
!=
null
);
}
}
...
@@ -103,11 +104,12 @@ describe('bluetoothhostTest4', function() {
...
@@ -103,11 +104,12 @@ describe('bluetoothhostTest4', function() {
secure
:
false
,
type
:
0
};
secure
:
false
,
type
:
0
};
let
serverNumber
=
-
1
;
let
serverNumber
=
-
1
;
function
serverSocket
(
code
,
number
)
{
function
serverSocket
(
code
,
number
)
{
console
.
log
(
'
[bluetooth_js] error code:
'
+
code
.
code
);
if
(
code
)
{
if
(
code
.
code
==
0
)
{
console
.
log
(
'
[bluetooth_js] error code:
'
+
code
);
console
.
log
(
'
[bluetooth_js] serverSocket Number:
'
+
number
);
}
else
{
serverNumber
=
number
;
console
.
log
(
'
[bluetooth_js] serverSocket Number:
'
+
JSON
.
stringify
(
number
));
expect
(
true
).
assertEqual
(
number
!=
null
);
serverNumber
=
number
;
expect
(
true
).
assertEqual
(
number
!=
null
);
}
}
}
}
bluetooth
.
sppListen
(
'
server1
'
,
sppOption
,
serverSocket
);
bluetooth
.
sppListen
(
'
server1
'
,
sppOption
,
serverSocket
);
...
@@ -127,12 +129,15 @@ describe('bluetoothhostTest4', function() {
...
@@ -127,12 +129,15 @@ describe('bluetoothhostTest4', function() {
secure
:
true
,
type
:
0
};
secure
:
true
,
type
:
0
};
let
serverNumber
=
-
1
;
let
serverNumber
=
-
1
;
function
serverSocket
(
code
,
number
)
{
function
serverSocket
(
code
,
number
)
{
console
.
log
(
'
[bluetooth_js] error code:
'
+
code
.
code
);
if
(
code
.
code
==
0
)
{
if
(
code
)
{
console
.
log
(
'
[bluetooth_js] serverSocket Number:
'
+
number
);
console
.
log
(
'
[bluetooth_js] error code:
'
+
code
);
serverNumber
=
number
;
expect
(
true
).
assertEqual
(
number
!=
null
);
}
else
{
}
console
.
log
(
'
[bluetooth_js] serverSocket Number:
'
+
JSON
.
stringify
(
number
));
serverNumber
=
number
;
expect
(
true
).
assertEqual
(
serverNumber
!=
null
);
}
}
}
bluetooth
.
sppListen
(
'
server1
'
,
sppOption
,
serverSocket
);
bluetooth
.
sppListen
(
'
server1
'
,
sppOption
,
serverSocket
);
done
();
done
();
...
@@ -151,11 +156,14 @@ describe('bluetoothhostTest4', function() {
...
@@ -151,11 +156,14 @@ describe('bluetoothhostTest4', function() {
secure
:
false
,
type
:
0
};
secure
:
false
,
type
:
0
};
let
serverNumber
=
-
1
;
let
serverNumber
=
-
1
;
function
serverSocket
(
code
,
number
)
{
function
serverSocket
(
code
,
number
)
{
console
.
log
(
'
[bluetooth_js] error code:
'
+
code
.
code
);
if
(
code
.
code
==
0
)
{
if
(
code
)
{
console
.
log
(
'
[bluetooth_js] serverSocket Number:
'
+
number
);
console
.
log
(
'
[bluetooth_js] error code:
'
+
code
);
serverNumber
=
number
;
expect
(
true
).
assertEqual
(
number
!=
null
);
}
else
{
console
.
log
(
'
[bluetooth_js] serverSocket Number:
'
+
JSON
.
stringify
(
number
));
serverNumber
=
number
;
expect
(
true
).
assertEqual
(
serverNumber
!=
null
);
}
}
}
}
bluetooth
.
sppListen
(
'
server1
'
,
sppOption
,
serverSocket
);
bluetooth
.
sppListen
(
'
server1
'
,
sppOption
,
serverSocket
);
...
@@ -172,11 +180,13 @@ describe('bluetoothhostTest4', function() {
...
@@ -172,11 +180,13 @@ describe('bluetoothhostTest4', function() {
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_SPP_0500
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_SPP_0500
'
,
0
,
async
function
(
done
)
{
function
acceptClientSocket
(
code
,
number
)
{
function
acceptClientSocket
(
code
,
number
)
{
console
.
log
(
'
[bluetooth_js] error code:
'
+
code
.
code
);
if
(
code
.
code
==
0
)
{
if
(
code
)
{
console
.
log
(
'
[bluetooth_js] clientSocket Number:
'
+
number
);
console
.
log
(
'
[bluetooth_js] error code:
'
+
code
);
expect
(
true
).
assertEqual
(
number
!=
null
);
}
else
{
}
console
.
log
(
'
[bluetooth_js] clientSocket Number:
'
+
JSON
.
stringify
(
number
));
expect
(
true
).
assertEqual
(
number
!=
null
);
}
}
}
bluetooth
.
sppAccept
(
0
,
acceptClientSocket
);
bluetooth
.
sppAccept
(
0
,
acceptClientSocket
);
done
();
done
();
...
@@ -191,13 +201,13 @@ describe('bluetoothhostTest4', function() {
...
@@ -191,13 +201,13 @@ describe('bluetoothhostTest4', function() {
* @tc.level Level 3
* @tc.level Level 3
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_SPP_0600
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_SPP_0600
'
,
0
,
async
function
(
done
)
{
bluetooth
.
sppAccept
(
-
1
,
function
(
code
,
clientSocketNumber
)
{
bluetooth
.
sppAccept
(
-
1
,
function
(
code
,
clientSocketNumber
)
{
console
.
info
(
'
[bluetooth_js] code is:
'
+
code
.
code
);
if
(
code
)
{
if
(
code
.
code
==
0
)
{
console
.
info
(
'
[bluetooth_js] code is:
'
+
code
);
console
.
log
(
'
[bluetooth_js]sppAccept Number:
'
+
clientSocketNumber
);
expect
(
true
).
assertEqual
(
clientSocketNumber
!=
null
);
}
else
{
}
else
{
expect
(
true
).
assertEqual
(
false
);
console
.
log
(
'
[bluetooth_js]sppAccept Number:
'
+
JSON
.
stringify
(
clientSocketNumber
));
expect
(
true
).
assertEqual
(
clientSocketNumber
!=
null
);
}
}
});
});
done
();
done
();
...
@@ -215,12 +225,12 @@ describe('bluetoothhostTest4', function() {
...
@@ -215,12 +225,12 @@ describe('bluetoothhostTest4', function() {
let
sppOption
=
{
uuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
let
sppOption
=
{
uuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
secure
:
true
,
type
:
0
};
secure
:
true
,
type
:
0
};
bluetooth
.
sppConnect
(
'
00:11:22:33:44:55
'
,
sppOption
,
function
(
code
,
clientSocketNumber
)
{
bluetooth
.
sppConnect
(
'
00:11:22:33:44:55
'
,
sppOption
,
function
(
code
,
clientSocketNumber
)
{
console
.
info
(
'
[bluetooth_js] code is:
'
+
code
.
code
);
if
(
code
)
{
if
(
code
.
code
==
0
)
{
console
.
info
(
'
[bluetooth_js] code is:
'
+
code
);
console
.
log
(
'
[bluetooth_js]sppConnect Number:
'
+
clientSocketNumber
);
expect
(
true
).
assertEqual
(
clientSocketNumber
!=
null
);
}
else
{
}
else
{
expect
(
true
).
assertEqual
(
false
);
console
.
log
(
'
[bluetooth_js]sppConnect Number:
'
+
JSON
.
stringify
(
clientSocketNumber
));
expect
(
true
).
assertEqual
(
clientSocketNumber
!=
null
);
}
}
});
});
done
();
done
();
...
@@ -238,12 +248,12 @@ describe('bluetoothhostTest4', function() {
...
@@ -238,12 +248,12 @@ describe('bluetoothhostTest4', function() {
let
sppOption
=
{
uuid
:
'
0000
'
,
let
sppOption
=
{
uuid
:
'
0000
'
,
secure
:
false
,
type
:
0
};
secure
:
false
,
type
:
0
};
bluetooth
.
sppConnect
(
'
ABC
'
,
sppOption
,
function
(
code
,
clientSocketNumber
)
{
bluetooth
.
sppConnect
(
'
ABC
'
,
sppOption
,
function
(
code
,
clientSocketNumber
)
{
console
.
info
(
'
[bluetooth_js] code is:
'
+
code
.
code
);
if
(
code
)
{
if
(
code
.
code
==
0
)
{
console
.
info
(
'
[bluetooth_js] code is:
'
+
code
);
console
.
log
(
'
[bluetooth_js]sppConnect Number
'
+
clientSocketNumber
);
expect
(
true
).
assertEqual
(
clientSocketNumber
!=
null
);
}
else
{
}
else
{
expect
(
true
).
assertEqual
(
false
);
console
.
log
(
'
[bluetooth_js]sppConnect Number
'
+
JSON
.
stringify
(
clientSocketNumber
));
expect
(
true
).
assertEqual
(
clientSocketNumber
!=
null
);
}
}
});
});
done
();
done
();
...
@@ -261,12 +271,12 @@ describe('bluetoothhostTest4', function() {
...
@@ -261,12 +271,12 @@ describe('bluetoothhostTest4', function() {
let
sppOption
=
{
uuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
let
sppOption
=
{
uuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
secure
:
true
,
type
:
0
};
secure
:
true
,
type
:
0
};
bluetooth
.
sppConnect
(
'
BT
'
,
sppOption
,
function
(
code
,
clientSocketNumber
)
{
bluetooth
.
sppConnect
(
'
BT
'
,
sppOption
,
function
(
code
,
clientSocketNumber
)
{
console
.
info
(
'
[bluetooth_js] code is:
'
+
code
.
code
);
if
(
code
)
{
if
(
code
.
code
==
0
)
{
console
.
info
(
'
[bluetooth_js] code is:
'
+
code
);
console
.
log
(
'
[bluetooth_js]sppConnect Number
'
+
clientSocketNumber
);
expect
(
true
).
assertEqual
(
clientSocketNumber
!=
null
);
}
else
{
}
else
{
expect
(
true
).
assertEqual
(
false
);
console
.
log
(
'
[bluetooth_js]sppConnect Number
'
+
JSON
.
stringify
(
clientSocketNumber
));
expect
(
true
).
assertEqual
(
clientSocketNumber
!=
null
);
}
}
});
});
done
();
done
();
...
@@ -283,11 +293,14 @@ describe('bluetoothhostTest4', function() {
...
@@ -283,11 +293,14 @@ describe('bluetoothhostTest4', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_SPP_1000
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_SPP_1000
'
,
0
,
async
function
(
done
)
{
let
serverNumber
=
-
1
;
let
serverNumber
=
-
1
;
function
serverSocket
(
code
,
number
)
{
function
serverSocket
(
code
,
number
)
{
console
.
log
(
'
bluetooth error code:
'
+
code
.
code
);
if
(
code
)
{
if
(
code
.
code
==
0
)
{
console
.
log
(
'
bluetooth error code:
'
+
code
);
console
.
log
(
'
bluetooth serverSocket Number:
'
+
number
);
}
else
{
console
.
log
(
'
bluetooth serverSocket Number:
'
+
JSON
.
stringify
(
number
));
serverNumber
=
number
;
serverNumber
=
number
;
expect
(
true
).
assertEqual
(
serverNumber
!=
null
);
}
}
}
}
let
SppOption
=
{
uuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
let
SppOption
=
{
uuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
secure
:
true
,
type
:
0
};
secure
:
true
,
type
:
0
};
...
@@ -307,13 +320,13 @@ describe('bluetoothhostTest4', function() {
...
@@ -307,13 +320,13 @@ describe('bluetoothhostTest4', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_SPP_1100
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_SPP_1100
'
,
0
,
async
function
(
done
)
{
let
clientNumber
=
-
1
;
let
clientNumber
=
-
1
;
bluetooth
.
sppAccept
(
-
1
,
function
(
code
,
clientSocketNumber
)
{
bluetooth
.
sppAccept
(
-
1
,
function
(
code
,
clientSocketNumber
)
{
console
.
info
(
'
[bluetooth_js] code is:
'
+
code
.
code
);
if
(
code
)
{
if
(
code
.
code
==
0
)
{
console
.
info
(
'
[bluetooth_js] code is:
'
+
code
);
console
.
log
(
'
[bluetooth_js]sppAccept Number:
'
+
clientSocketNumber
);
}
else
{
console
.
log
(
'
[bluetooth_js]sppAccept Number:
'
+
JSON
.
stringify
(
clientSocketNumber
));
clientNumber
=
clientSocketNumber
;
clientNumber
=
clientSocketNumber
;
expect
(
true
).
assertEqual
(
clientSocketNumber
!=
null
);
expect
(
true
).
assertEqual
(
clientSocketNumber
!=
null
);
}
else
{
expect
(
true
).
assertEqual
(
false
);
}
}
});
});
bluetooth
.
sppCloseClientSocket
(
clientNumber
);
bluetooth
.
sppCloseClientSocket
(
clientNumber
);
...
@@ -331,13 +344,13 @@ describe('bluetoothhostTest4', function() {
...
@@ -331,13 +344,13 @@ describe('bluetoothhostTest4', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_SPP_1200
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_SPP_1200
'
,
0
,
async
function
(
done
)
{
let
clientNumber
=
-
1
;
let
clientNumber
=
-
1
;
bluetooth
.
sppAccept
(
-
1
,
function
(
code
,
clientSocketNumber
)
{
bluetooth
.
sppAccept
(
-
1
,
function
(
code
,
clientSocketNumber
)
{
console
.
info
(
'
[bluetooth_js] code is:
'
+
code
.
code
);
if
(
code
)
{
if
(
code
.
code
==
0
)
{
console
.
info
(
'
[bluetooth_js] code is:
'
+
code
);
console
.
log
(
'
[bluetooth_js]sppAccept Number:
'
+
clientSocketNumber
);
}
else
{
console
.
log
(
'
[bluetooth_js]sppAccept Number:
'
+
JSON
.
stringify
(
clientSocketNumber
));
clientNumber
=
clientSocketNumber
;
clientNumber
=
clientSocketNumber
;
expect
(
true
).
assertEqual
(
clientSocketNumber
!=
null
);
expect
(
true
).
assertEqual
(
clientSocketNumber
!=
null
);
}
else
{
expect
(
true
).
assertEqual
(
false
);
}
}
});
});
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
...
...
location/geolocation_standard/src/main/js/default/test/LocationTest.test.js
浏览文件 @
05e1aadc
...
@@ -888,7 +888,8 @@ describe('geolocationTest_geo3', function () {
...
@@ -888,7 +888,8 @@ describe('geolocationTest_geo3', function () {
'
longitude:
'
+
result
.
longitude
+
'
altitude:
'
+
result
.
altitude
'
longitude:
'
+
result
.
longitude
+
'
altitude:
'
+
result
.
altitude
+
'
accuracy:
'
+
result
.
accuracy
+
'
speed:
'
+
result
.
speed
+
+
'
accuracy:
'
+
result
.
accuracy
+
'
speed:
'
+
result
.
speed
+
'
timeStamp:
'
+
result
.
timeStamp
+
'
direction:
'
+
result
.
direction
+
'
timeSinceBoot:
'
'
timeStamp:
'
+
result
.
timeStamp
+
'
direction:
'
+
result
.
direction
+
'
timeSinceBoot:
'
+
result
.
timeSinceBoot
+
'
additions:
'
+
result
.
additions
+
'
additionSize
'
+
result
.
additionSize
);
+
result
.
timeSinceBoot
+
'
additions:
'
+
result
.
additions
+
'
additionSize
'
+
result
.
additionSize
+
'
isFromMock
'
+
result
.
isFromMock
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] getLastLocation promise then error:
"
+
JSON
.
stringify
(
error
));
console
.
info
(
"
[lbs_js] getLastLocation promise then error:
"
+
JSON
.
stringify
(
error
));
console
.
info
(
'
[lbs_js] not support now
'
);
console
.
info
(
'
[lbs_js] not support now
'
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录