未验证 提交 91ea7a7a 编写于 作者: O openharmony_ci 提交者: Gitee

!11118 [翻译完成】#I5TR4Z

Merge pull request !11118 from Annie_wang/PR10064
......@@ -223,7 +223,7 @@ cancelPairedDevice(deviceId: string): boolean
Cancels a paired remote device.
This is a system API.
**System API**: This is a system API.
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
......@@ -389,7 +389,7 @@ startBluetoothDiscovery(): boolean
Starts Bluetooth scan to discover remote devices.
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION
**System capability**: SystemCapability.Communication.Bluetooth.Core
......@@ -1293,7 +1293,7 @@ No value is returned.
**Example**
```js
let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE)
let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE) as bluetooth.A2dpSourceProfile;
let retArray = a2dpSrc.getConnectionDevices();
```
......@@ -1322,7 +1322,7 @@ Obtains the connection state of the profile.
**Example**
```js
let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE)
let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE) as bluetooth.A2dpSourceProfile;
let ret = a2dpSrc.getDeviceState('XX:XX:XX:XX:XX:XX');
```
......@@ -1356,7 +1356,7 @@ Sets up an Advanced Audio Distribution Profile (A2DP) connection.
**Example**
```js
let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE)
let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE) as bluetooth.A2dpSourceProfile;
let ret = a2dpSrc.connect('XX:XX:XX:XX:XX:XX');
```
......@@ -1386,7 +1386,7 @@ Disconnects an A2DP connection.
**Example**
```js
let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE);
let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE) as bluetooth.A2dpSourceProfile;
let ret = a2dpSrc.disconnect('XX:XX:XX:XX:XX:XX');
```
......@@ -1416,7 +1416,7 @@ No value is returned.
function onReceiveEvent(data) {
console.info('a2dp state = '+ JSON.stringify(data));
}
let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE);
let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE) as bluetooth.A2dpSourceProfile;
a2dpSrc.on('connectionStateChange', onReceiveEvent);
```
......@@ -1446,7 +1446,7 @@ No value is returned.
function onReceiveEvent(data) {
console.info('a2dp state = '+ JSON.stringify(data));
}
let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE);
let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE) as bluetooth.A2dpSourceProfile;
a2dpSrc.on('connectionStateChange', onReceiveEvent);
a2dpSrc.off('connectionStateChange', onReceiveEvent);
```
......@@ -1475,7 +1475,7 @@ Obtains the playing state of a device.
**Example**
```js
let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE);
let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE) as bluetooth.A2dpSourceProfile;
let state = a2dpSrc.getPlayingState('XX:XX:XX:XX:XX:XX');
```
......@@ -1510,7 +1510,8 @@ Sets up a Hands-free Profile (HFP) connection of a device.
**Example**
```js
let hfpAg = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY);
let hfpAg = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY) as
bluetooth.HandsFreeAudioGatewayProfile;
let ret = hfpAg.connect('XX:XX:XX:XX:XX:XX');
```
......@@ -1540,7 +1541,8 @@ Disconnects the HFP connection of a device.
**Example**
```js
let hfpAg = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY);
let hfpAg = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY) as
bluetooth.HandsFreeAudioGatewayProfile;
let ret = hfpAg.disconnect('XX:XX:XX:XX:XX:XX');
```
......@@ -1570,7 +1572,8 @@ No value is returned.
function onReceiveEvent(data) {
console.info('hfp state = '+ JSON.stringify(data));
}
let hfpAg = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY);
let hfpAg = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY) as
bluetooth.HandsFreeAudioGatewayProfile;
hfpAg.on('connectionStateChange', onReceiveEvent);
```
......@@ -1600,7 +1603,8 @@ No value is returned.
function onReceiveEvent(data) {
console.info('hfp state = '+ JSON.stringify(data));
}
let hfpAg = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY);
let hfpAg = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY) as
bluetooth.HandsFreeAudioGatewayProfile;
hfpAg.on('connectionStateChange', onReceiveEvent);
hfpAg.off('connectionStateChange', onReceiveEvent);
```
......@@ -1617,7 +1621,7 @@ connect(device: string): boolean
Connects to the HidHost service of a device.
This is a system API.
**System API**: This is a system API.
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
......@@ -1638,7 +1642,7 @@ This is a system API.
**Example**
```js
let hidHostProfile = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HID_HOST);
let hidHostProfile = bluetooth.getProfileInst(bluetooth.ProfileId.PROFILE_HID_HOST) as bluetooth.HidHostProfile;
let ret = hidHostProfile.connect('XX:XX:XX:XX:XX:XX');
```
......@@ -1649,7 +1653,7 @@ disconnect(device: string): boolean
Disconnects from the HidHost service of a device.
This is a system API.
**System API**: This is a system API.
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
......@@ -1670,7 +1674,7 @@ This is a system API.
**Example**
```js
let hidHostProfile = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HID_HOST);
let hidHostProfile = bluetooth.getProfileInst(bluetooth.ProfileId.PROFILE_HID_HOST) as bluetooth.HidHostProfile;
let ret = hidHostProfile.disconnect('XX:XX:XX:XX:XX:XX');
```
......@@ -1700,7 +1704,7 @@ No value is returned.
function onReceiveEvent(data) {
console.info('hidHost state = '+ JSON.stringify(data));
}
let hidHost = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HID_HOST);
let hidHost = bluetooth.getProfileInst(bluetooth.ProfileId.PROFILE_HID_HOST) as bluetooth.HidHostProfile;
hidHost.on('connectionStateChange', onReceiveEvent);
```
......@@ -1730,7 +1734,7 @@ No value is returned.
function onReceiveEvent(data) {
console.info('hidHost state = '+ JSON.stringify(data));
}
let hidHost = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HID_HOST);
let hidHost = bluetooth.getProfileInst(bluetooth.ProfileId.PROFILE_HID_HOST) as bluetooth.HidHostProfile;
hidHost.on('connectionStateChange', onReceiveEvent);
hidHost.off('connectionStateChange', onReceiveEvent);
```
......@@ -1747,7 +1751,7 @@ disconnect(device: string): boolean
Disconnects from the Personal Area Network (PAN) service of a device.
This is a system API.
**System API**: This is a system API.
**Required permissions**: ohos.permission.USE_BLUETOOTH
......@@ -1768,7 +1772,7 @@ This is a system API.
**Example**
```js
let panProfile = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_PAN_NETWORK);
let panProfile = bluetooth.getProfileInst(bluetooth.ProfileId.PROFILE_PAN_NETWORK) as bluetooth.PanProfile;
let ret = panProfile.disconnect('XX:XX:XX:XX:XX:XX');
```
......@@ -1798,7 +1802,7 @@ No value is returned.
function onReceiveEvent(data) {
console.info('pan state = '+ JSON.stringify(data));
}
let panProfile = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_PAN_NETWORK);
let panProfile = bluetooth.getProfileInst(bluetooth.ProfileId.PROFILE_PAN_NETWORK) as bluetooth.PanProfile;
panProfile.on('connectionStateChange', onReceiveEvent);
```
......@@ -1828,7 +1832,7 @@ No value is returned.
function onReceiveEvent(data) {
console.info('pan state = '+ JSON.stringify(data));
}
let panProfile = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_PAN_NETWORK);
let panProfile = bluetooth.getProfileInst(bluetooth.ProfileId.PROFILE_PAN_NETWORK) as bluetooth.PanProfile;
panProfile.on('connectionStateChange', onReceiveEvent);
panProfile.off('connectionStateChange', onReceiveEvent);
```
......@@ -1840,7 +1844,7 @@ setTethering(enable: boolean): void
Sets tethering.
This is a system API.
**System API**: This is a system API.
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
......@@ -1861,7 +1865,7 @@ This is a system API.
**Example**
```js
let panProfile = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_PAN_NETWORK);
let panProfile = bluetooth.getProfileInst(bluetooth.ProfileId.PROFILE_PAN_NETWORK) as bluetooth.PanProfile;
let ret = panProfile.setTethering(true);
```
......@@ -1872,7 +1876,7 @@ isTetheringOn(): boolean
Obtains the tethering state.
This is a system API.
**System API**: This is a system API.
**System capability**: SystemCapability.Communication.Bluetooth.Core
......@@ -1885,7 +1889,7 @@ This is a system API.
**Example**
```js
let panProfile = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_PAN_NETWORK);
let panProfile = bluetooth.getProfileInst(bluetooth.ProfileId.PROFILE_PAN_NETWORK) as bluetooth.PanProfile;
let ret = panProfile.isTetheringOn();
```
......@@ -2217,7 +2221,7 @@ function ReadCharacteristicReq(CharacteristicReadReq) {
let characteristicUuid = CharacteristicReadReq.characteristicUuid;
let serverResponse = {deviceId: deviceId, transId: transId, status: 0, offset: offset, value:arrayBufferCCC};
let ret = gattServer.sendResponse(serverResponse);
if (ret) {
console.log('bluetooth sendResponse successfully');
......@@ -2294,10 +2298,10 @@ function WriteCharacteristicReq(CharacteristicWriteReq) {
let needRsp = CharacteristicWriteReq.needRsp;
let value = new Uint8Array(CharacteristicWriteReq.value);
let characteristicUuid = CharacteristicWriteReq.characteristicUuid;
cccValue[0] = value[0];
let serverResponse = {deviceId: deviceId, transId: transId, status: 0, offset: offset, value:arrayBufferCCC};
let ret = gattServer.sendResponse(serverResponse);
if (ret) {
console.log('bluetooth sendResponse successfully');
......@@ -2374,7 +2378,7 @@ function ReadDescriptorReq(DescriptorReadReq) {
let descriptorUuid = DescriptorReadReq.descriptorUuid;
let serverResponse = {deviceId: deviceId, transId: transId, status: 0, offset: offset, value:arrayBufferDesc};
let ret = gattServer.sendResponse(serverResponse);
if (ret) {
console.log('bluetooth sendResponse successfully');
......@@ -2454,7 +2458,7 @@ function WriteDescriptorReq(DescriptorWriteReq) {
descValue[0] = value[0];
let serverResponse = {deviceId: deviceId, transId: transId, status: 0, offset: offset, value:arrayBufferDesc};
let ret = gattServer.sendResponse(serverResponse);
if (ret) {
console.log('bluetooth sendResponse successfully');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册