提交 1fd81c47 编写于 作者: L lverpeng

示例代码一致性修改

Signed-off-by: Nlverpeng <lverpeng118@163.com>
上级 a997b810
......@@ -893,7 +893,7 @@ try {
on(type: "stateChange", callback: Callback&lt;BluetoothState&gt;): void
订阅蓝牙连接状态改变事件。
订阅蓝牙设备开关状态事件。
**需要权限**:ohos.permission.USE_BLUETOOTH
......@@ -932,7 +932,7 @@ try {
off(type: "stateChange", callback?: Callback&lt;BluetoothState&gt;): void
取消订阅蓝牙连接状态改变事件。
取消订阅蓝牙设备开关状态事件。
**需要权限**:ohos.permission.USE_BLUETOOTH
......@@ -2075,7 +2075,7 @@ connect(device: string): void
```js
try {
let hidHostProfile = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile;
let hidHostProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile;
hidHostProfile.connect('XX:XX:XX:XX:XX:XX');
} catch (err) {
console.error("errCode:" + err.code + ",errMessage:" + err.message);
......@@ -2116,7 +2116,7 @@ disconnect(device: string): void
```js
try {
let hidHostProfile = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile;
let hidHostProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile;
hidHostProfile.disconnect('XX:XX:XX:XX:XX:XX');
} catch (err) {
console.error("errCode:" + err.code + ",errMessage:" + err.message);
......@@ -2145,7 +2145,7 @@ on(type: "connectionStateChange", callback: Callback&lt;[StateChangeParam](#Stat
function onReceiveEvent(data) {
console.info('hidHost state = '+ JSON.stringify(data));
}
let hidHost = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile;
let hidHost = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile;
hidHost.on('connectionStateChange', onReceiveEvent);
```
......@@ -2171,7 +2171,7 @@ off(type: "connectionStateChange", callback?: Callback&lt;[StateChangeParam](#St
function onReceiveEvent(data) {
console.info('hidHost state = '+ JSON.stringify(data));
}
let hidHost = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile;
let hidHost = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile;
hidHost.on('connectionStateChange', onReceiveEvent);
hidHost.off('connectionStateChange', onReceiveEvent);
```
......@@ -2215,7 +2215,7 @@ disconnect(device: string): void
```js
try {
let panProfile = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile;
let panProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile;
panProfile.disconnect('XX:XX:XX:XX:XX:XX');
} catch (err) {
console.error("errCode:" + err.code + ",errMessage:" + err.message);
......@@ -2244,7 +2244,7 @@ on(type: "connectionStateChange", callback: Callback&lt;[StateChangeParam](#Stat
function onReceiveEvent(data) {
console.info('pan state = '+ JSON.stringify(data));
}
let panProfile = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile;
let panProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile;
panProfile.on('connectionStateChange', onReceiveEvent);
```
......@@ -2270,7 +2270,7 @@ off(type: "connectionStateChange", callback?: Callback&lt;[StateChangeParam](#St
function onReceiveEvent(data) {
console.info('pan state = '+ JSON.stringify(data));
}
let panProfile = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile;
let panProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile;
panProfile.on('connectionStateChange', onReceiveEvent);
panProfile.off('connectionStateChange', onReceiveEvent);
```
......@@ -2309,7 +2309,7 @@ setTethering(enable: boolean): void
```js
try {
let panProfile = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile;
let panProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile;
panProfile.setTethering(true);
} catch (err) {
console.error("errCode:" + err.code + ",errMessage:" + err.message);
......@@ -2337,7 +2337,7 @@ isTetheringOn(): boolean
```js
try {
let panProfile = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile;
let panProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile;
let ret = panProfile.isTetheringOn();
} catch (err) {
console.error("errCode:" + err.code + ",errMessage:" + err.message);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册