未验证 提交 2e5942d7 编写于 作者: O openharmony_ci 提交者: Gitee

!8509 翻译完成:7335 DM md 3.2beta文档优化

Merge pull request !8509 from wusongqing/TR7335
...@@ -31,13 +31,13 @@ Creates a **DeviceManager** instance. ...@@ -31,13 +31,13 @@ Creates a **DeviceManager** instance.
**System capability**: SystemCapability.DistributedHardware.DeviceManager **System capability**: SystemCapability.DistributedHardware.DeviceManager
- **Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---------- | ---------------------------------------- | ---- | ------------------------------------ | | ---------- | ---------------------------------------- | ---- | ------------------------------------ |
| bundleName | string | Yes | Bundle name of an application. | | bundleName | string | Yes | Bundle name of an application. |
| callback | AsyncCallback<[DeviceManager](#devicemanager)> | Yes | Callback used to return the **DeviceManager** instance created.| | callback | AsyncCallback<[DeviceManager](#devicemanager)> | Yes | Callback used to return the **DeviceManager** instance created.|
- Example **Example**
``` ```
deviceManager.createDeviceManager("ohos.samples.jshelloworld", (err, data) => { deviceManager.createDeviceManager("ohos.samples.jshelloworld", (err, data) => {
if (err) { if (err) {
...@@ -198,7 +198,7 @@ Releases this **DeviceManager** instance when it is no longer used. ...@@ -198,7 +198,7 @@ Releases this **DeviceManager** instance when it is no longer used.
**System capability**: SystemCapability.DistributedHardware.DeviceManager **System capability**: SystemCapability.DistributedHardware.DeviceManager
- Example **Example**
```js ```js
dmInstance.release(); dmInstance.release();
``` ```
...@@ -212,12 +212,13 @@ Obtains all trusted devices synchronously. ...@@ -212,12 +212,13 @@ Obtains all trusted devices synchronously.
**System capability**: SystemCapability.DistributedHardware.DeviceManager **System capability**: SystemCapability.DistributedHardware.DeviceManager
- Return value **Return value**
| Name | Description |
| -------------------------------------- | --------- | | Name | Description |
| Array<[DeviceInfo](#deviceinfo)> | List of trusted devices obtained.| | -------------------------------------- | --------- |
| Array<[DeviceInfo](#deviceinfo)> | List of trusted devices obtained.|
- Example **Example**
```js ```js
var deviceInfoList = dmInstance.getTrustedDeviceListSync(); var deviceInfoList = dmInstance.getTrustedDeviceListSync();
``` ```
...@@ -231,12 +232,12 @@ Obtains all trusted devices. This API uses an asynchronous callback to return th ...@@ -231,12 +232,12 @@ Obtains all trusted devices. This API uses an asynchronous callback to return th
**System capability**: SystemCapability.DistributedHardware.DeviceManager **System capability**: SystemCapability.DistributedHardware.DeviceManager
- **Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | --------------------- | | -------- | ---------------------------------------- | ---- | --------------------- |
| callback | AsyncCallback<Array<[DeviceInfo](#deviceinfo)>> | Yes | Callback used to return the list of trusted devices.| | callback | AsyncCallback<Array<[DeviceInfo](#deviceinfo)>> | Yes | Callback used to return the list of trusted devices.|
- Example **Example**
```js ```js
dmInstance.getTrustedDeviceList((err, data) => { dmInstance.getTrustedDeviceList((err, data) => {
console.log("getTrustedDeviceList err: " + JSON.stringify(err)); console.log("getTrustedDeviceList err: " + JSON.stringify(err));
...@@ -253,12 +254,12 @@ Obtains all trusted devices. This API uses a promise to return the result. ...@@ -253,12 +254,12 @@ Obtains all trusted devices. This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedHardware.DeviceManager **System capability**: SystemCapability.DistributedHardware.DeviceManager
- Return value **Return value**
| Type | Description | | Type | Description |
| ---------------------------------------- | --------------------- | | ---------------------------------------- | --------------------- |
| Promise<Array<[DeviceInfo](#deviceinfo)>> | Promise used to return the list of trusted devices.| | Promise<Array<[DeviceInfo](#deviceinfo)>> | Promise used to return the list of trusted devices.|
- Example **Example**
```js ```js
dmInstance.getTrustedDeviceList().then((data) => { dmInstance.getTrustedDeviceList().then((data) => {
console.log('get trusted device info: ' + JSON.stringify(data)); console.log('get trusted device info: ' + JSON.stringify(data));
...@@ -275,12 +276,12 @@ Obtains local device information synchronously. ...@@ -275,12 +276,12 @@ Obtains local device information synchronously.
**System capability**: SystemCapability.DistributedHardware.DeviceManager **System capability**: SystemCapability.DistributedHardware.DeviceManager
- Return value **Return value**
| Name | Description | | Name | Description |
| -------------------------------------- | --------- | | -------------------------------------- | --------- |
| Array<[DeviceInfo](#deviceinfo)> | List of local devices obtained.| | Array<[DeviceInfo](#deviceinfo)> | List of local devices obtained.|
- Example **Example**
```js ```js
var deviceInfo = dmInstance.getLocalDeviceInfoSync(); var deviceInfo = dmInstance.getLocalDeviceInfoSync();
``` ```
...@@ -294,12 +295,12 @@ Obtains local device information. This API uses an asynchronous callback to retu ...@@ -294,12 +295,12 @@ Obtains local device information. This API uses an asynchronous callback to retu
**System capability**: SystemCapability.DistributedHardware.DeviceManager **System capability**: SystemCapability.DistributedHardware.DeviceManager
- **Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | --------- | | -------- | ---------------------------------------- | ---- | --------- |
| callback | AsyncCallback<[DeviceInfo](#deviceinfo)> | Yes | Callback used to return the local device information.| | callback | AsyncCallback<[DeviceInfo](#deviceinfo)> | Yes | Callback used to return the local device information.|
- Example **Example**
```js ```js
dmInstance.getLocalDeviceInfo((err, data) => { dmInstance.getLocalDeviceInfo((err, data) => {
console.log("getLocalDeviceInfo err: " + JSON.stringify(err)); console.log("getLocalDeviceInfo err: " + JSON.stringify(err));
...@@ -316,12 +317,12 @@ Obtains local device information. This API uses a promise to return the result. ...@@ -316,12 +317,12 @@ Obtains local device information. This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedHardware.DeviceManager **System capability**: SystemCapability.DistributedHardware.DeviceManager
- Return value **Return value**
| Type | Description | | Type | Description |
| ---------------------------------------- | --------------------- | | ---------------------------------------- | --------------------- |
| Promise<[DeviceInfo](#deviceinfo)> | Promise used to return the local device information.| | Promise<[DeviceInfo](#deviceinfo)> | Promise used to return the local device information.|
- Example **Example**
```js ```js
dmInstance.getLocalDeviceInfo().then((data) => { dmInstance.getLocalDeviceInfo().then((data) => {
console.log('get local device info: ' + JSON.stringify(data)); console.log('get local device info: ' + JSON.stringify(data));
...@@ -338,12 +339,12 @@ Starts to discover peripheral devices. ...@@ -338,12 +339,12 @@ Starts to discover peripheral devices.
**System capability**: SystemCapability.DistributedHardware.DeviceManager **System capability**: SystemCapability.DistributedHardware.DeviceManager
- **Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------------- | ------------------------------- | ---- | ----- | | ------------- | ------------------------------- | ---- | ----- |
| subscribeInfo | [SubscribeInfo](#subscribeinfo) | Yes | Subscription information.| | subscribeInfo | [SubscribeInfo](#subscribeinfo) | Yes | Subscription information.|
- Example **Example**
```js ```js
// Automatically generate a unique subscription ID. // Automatically generate a unique subscription ID.
var subscribeId = Math.floor(Math.random() * 10000 + 1000); var subscribeId = Math.floor(Math.random() * 10000 + 1000);
...@@ -367,12 +368,12 @@ Stops device discovery. ...@@ -367,12 +368,12 @@ Stops device discovery.
**System capability**: SystemCapability.DistributedHardware.DeviceManager **System capability**: SystemCapability.DistributedHardware.DeviceManager
- **Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----------- | ------ | ---- | ----- | | ----------- | ------ | ---- | ----- |
| subscribeId | number | Yes | Subscription ID.| | subscribeId | number | Yes | Subscription ID.|
- Example **Example**
```js ```js
// The subscribeId input must be the same as that automatically generated in startDeviceDiscovery. // The subscribeId input must be the same as that automatically generated in startDeviceDiscovery.
dmInstance.stopDeviceDiscovery(subscribeId); dmInstance.stopDeviceDiscovery(subscribeId);
...@@ -386,14 +387,14 @@ Authenticates a device. ...@@ -386,14 +387,14 @@ Authenticates a device.
**System capability**: SystemCapability.DistributedHardware.DeviceManager **System capability**: SystemCapability.DistributedHardware.DeviceManager
- **Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---------- | ---------------------------------------- | ---- | ------- | | ---------- | ---------------------------------------- | ---- | ------- |
| deviceInfo | [DeviceInfo](#deviceinfo) | Yes | Device information. | | deviceInfo | [DeviceInfo](#deviceinfo) | Yes | Device information. |
| authParam | [AuthParam](#authparam) | Yes | Authentication parameter. | | authParam | [AuthParam](#authparam) | Yes | Authentication parameter. |
| callback | AsyncCallback<{ deviceId: string, pinToken ?: number }> | Yes | Callback used to return the authentication result.| | callback | AsyncCallback<{ deviceId: string, pinToken ?: number }> | Yes | Callback used to return the authentication result.|
- Example **Example**
```js ```js
// Information about the device to authenticate. The information can be obtained from the device discovery result. // Information about the device to authenticate. The information can be obtained from the device discovery result.
var deviceInfo ={ var deviceInfo ={
...@@ -423,12 +424,13 @@ Deauthenticates a device. ...@@ -423,12 +424,13 @@ Deauthenticates a device.
**System capability**: SystemCapability.DistributedHardware.DeviceManager **System capability**: SystemCapability.DistributedHardware.DeviceManager
- **Parameters** **Parameters**
| Name | Type | Mandatory | Description |
| ---------- | ------------------------- | ---- | ----- | | Name | Type | Mandatory | Description |
| deviceInfo | [DeviceInfo](#deviceinfo) | Yes | Device information.| | ---------- | ------------------------- | ---- | ----- |
| deviceInfo | [DeviceInfo](#deviceinfo) | Yes | Device information.|
- Example **Example**
```js ```js
dmInstance.unAuthenticateDevice(deviceInfo); dmInstance.unAuthenticateDevice(deviceInfo);
``` ```
...@@ -442,13 +444,13 @@ Verifies authentication information. ...@@ -442,13 +444,13 @@ Verifies authentication information.
**System capability**: SystemCapability.DistributedHardware.DeviceManager **System capability**: SystemCapability.DistributedHardware.DeviceManager
- **Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ------- | | -------- | ---------------------------------------- | ---- | ------- |
| authInfo | [AuthInfo](#authinfo) | Yes | Authentication information. | | authInfo | [AuthInfo](#authinfo) | Yes | Authentication information. |
| authInfo | AsyncCallback<{ deviceId: string, level: number }> | Yes | Callback used to return the verification result.| | authInfo | AsyncCallback<{ deviceId: string, level: number }> | Yes | Callback used to return the verification result.|
- Example **Example**
```js ```js
let authInfo = { let authInfo = {
"authType": 1, "authType": 1,
...@@ -473,13 +475,13 @@ Subscribes to changes in the device state. ...@@ -473,13 +475,13 @@ Subscribes to changes in the device state.
**System capability**: SystemCapability.DistributedHardware.DeviceManager **System capability**: SystemCapability.DistributedHardware.DeviceManager
- **Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ------------------------------ | | -------- | ---------------------------------------- | ---- | ------------------------------ |
| type | string | Yes | Event type. The value **'deviceStateChange'** indicates a device state change event.| | type | string | Yes | Event type. The value **'deviceStateChange'** indicates a device state change event.|
| callback | Callback&lt;{ action: [DeviceStateChangeAction](#devicestatechangeaction), device: [DeviceInfo](#deviceinfo) }&gt; | Yes | Callback invoked to return the device information and state. | | callback | Callback&lt;{ action: [DeviceStateChangeAction](#devicestatechangeaction), device: [DeviceInfo](#deviceinfo) }&gt; | Yes | Callback invoked to return the device information and state. |
- Example **Example**
```js ```js
dmInstance.on('deviceStateChange', (data) => { dmInstance.on('deviceStateChange', (data) => {
console.info("deviceStateChange on:" + JSON.stringify(data)); console.info("deviceStateChange on:" + JSON.stringify(data));
...@@ -496,13 +498,13 @@ Unsubscribes from changes in the device state. ...@@ -496,13 +498,13 @@ Unsubscribes from changes in the device state.
**System capability**: SystemCapability.DistributedHardware.DeviceManager **System capability**: SystemCapability.DistributedHardware.DeviceManager
- **Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | --------------------------- | | -------- | ---------------------------------------- | ---- | --------------------------- |
| type | string | Yes | Event type. The value **'deviceStateChange'** indicates a device state change event. | | type | string | Yes | Event type. The value **'deviceStateChange'** indicates a device state change event. |
| callback | Callback&lt;{ action: [DeviceStateChangeAction](#devicestatechangeaction), device: [DeviceInfo](#deviceinfo) }&gt; | Yes | Callback invoked to return the device information and state.| | callback | Callback&lt;{ action: [DeviceStateChangeAction](#devicestatechangeaction), device: [DeviceInfo](#deviceinfo) }&gt; | Yes | Callback invoked to return the device information and state.|
- Example **Example**
```js ```js
dmInstance.off('deviceStateChange', (data) => { dmInstance.off('deviceStateChange', (data) => {
console.info('deviceStateChange' + JSON.stringify(data)); console.info('deviceStateChange' + JSON.stringify(data));
...@@ -519,13 +521,13 @@ Subscribes to device discovery events. ...@@ -519,13 +521,13 @@ Subscribes to device discovery events.
**System capability**: SystemCapability.DistributedHardware.DeviceManager **System capability**: SystemCapability.DistributedHardware.DeviceManager
- **Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | -------------------------- | | -------- | ---------------------------------------- | ---- | -------------------------- |
| type | string | Yes | Event type. The value **'deviceFound'** indicates an event reported when a device is discovered.| | type | string | Yes | Event type. The value **'deviceFound'** indicates an event reported when a device is discovered.|
| callback | Callback&lt;{ subscribeId: number, device: DeviceInfo }&gt; | Yes | Callback used for device discovery. | | callback | Callback&lt;{ subscribeId: number, device: DeviceInfo }&gt; | Yes | Callback used for device discovery. |
- Example **Example**
```js ```js
dmInstance.on('deviceFound', (data) => { dmInstance.on('deviceFound', (data) => {
console.info("deviceFound:" + JSON.stringify(data)); console.info("deviceFound:" + JSON.stringify(data));
...@@ -541,13 +543,13 @@ Unsubscribes from device discovery events. ...@@ -541,13 +543,13 @@ Unsubscribes from device discovery events.
**System capability**: SystemCapability.DistributedHardware.DeviceManager **System capability**: SystemCapability.DistributedHardware.DeviceManager
- **Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | --------------------------- | | -------- | ---------------------------------------- | ---- | --------------------------- |
| type | string | Yes | Event type. The value **'deviceFound'** indicates an event reported when a device is discovered. | | type | string | Yes | Event type. The value **'deviceFound'** indicates an event reported when a device is discovered. |
| callback | Callback&lt;{ subscribeId: number, device: [DeviceInfo](#deviceinfo) }&gt; | Yes | Callback used for device discovery, which is invoked to return the device information and state.| | callback | Callback&lt;{ subscribeId: number, device: [DeviceInfo](#deviceinfo) }&gt; | Yes | Callback invoked to return the device information and state.|
- Example **Example**
```js ```js
dmInstance.off('deviceFound', (data) => { dmInstance.off('deviceFound', (data) => {
console.info('deviceFound' + JSON.stringify(data)); console.info('deviceFound' + JSON.stringify(data));
...@@ -563,13 +565,13 @@ Subscribes to device discovery failures. ...@@ -563,13 +565,13 @@ Subscribes to device discovery failures.
**System capability**: SystemCapability.DistributedHardware.DeviceManager **System capability**: SystemCapability.DistributedHardware.DeviceManager
- **Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ------------------------------ | | -------- | ---------------------------------------- | ---- | ------------------------------ |
| type | string | Yes | Event type. The event **'discoverFail'** indicates an event reported when device discovery fails.| | type | string | Yes | Event type. The event **'discoverFail'** indicates an event reported when device discovery fails.|
| callback | Callback&lt;{ subscribeId: number, reason: number }&gt; | Yes | Callback used for the device discovery failure. | | callback | Callback&lt;{ subscribeId: number, reason: number }&gt; | Yes | Callback used for the device discovery failure. |
- Example **Example**
```js ```js
dmInstance.on('discoverFail', (data) => { dmInstance.on('discoverFail', (data) => {
this.log("discoverFail on:" + JSON.stringify(data)); this.log("discoverFail on:" + JSON.stringify(data));
...@@ -585,13 +587,13 @@ Unsubscribes from device discovery failures. ...@@ -585,13 +587,13 @@ Unsubscribes from device discovery failures.
**System capability**: SystemCapability.DistributedHardware.DeviceManager **System capability**: SystemCapability.DistributedHardware.DeviceManager
- **Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ----------------- | | -------- | ---------------------------------------- | ---- | ----------------- |
| type | string | Yes | Event type. The event **'discoverFail'** indicates an event reported when device discovery fails. | | type | string | Yes | Event type. The event **'discoverFail'** indicates an event reported when device discovery fails. |
| callback | Callback&lt;{ subscribeId: number, reason: number }&gt; | Yes | Callback used for the device discovery failure.| | callback | Callback&lt;{ subscribeId: number, reason: number }&gt; | Yes | Callback used for the device discovery failure.|
- Example **Example**
```js ```js
dmInstance.off('deviceFound', (data) => { dmInstance.off('deviceFound', (data) => {
console.info('deviceFound' + JSON.stringify(data)); console.info('deviceFound' + JSON.stringify(data));
...@@ -608,13 +610,13 @@ Subscribes to dead events of the **DeviceManager** service. ...@@ -608,13 +610,13 @@ Subscribes to dead events of the **DeviceManager** service.
**System capability**: SystemCapability.DistributedHardware.DeviceManager **System capability**: SystemCapability.DistributedHardware.DeviceManager
- **Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ----------------------- | ---- | ---------------------------------------- | | -------- | ----------------------- | ---- | ---------------------------------------- |
| type | string | Yes | Event type. The value **'serviceDie'** indicates an event reported when the **DeviceManager** service is terminated unexpectedly.| | type | string | Yes | Event type. The value **'serviceDie'** indicates an event reported when the **DeviceManager** service is terminated unexpectedly.|
| callback | () =&gt; void | Yes | Callback invoked when a dead event of the **DeviceManager** service occurs. | | callback | () =&gt; void | Yes | Callback invoked when a dead event of the **DeviceManager** service occurs. |
- Example **Example**
```js ```js
dmInstance.on("serviceDie", () => { dmInstance.on("serviceDie", () => {
console.info("serviceDie on"); console.info("serviceDie on");
...@@ -631,13 +633,13 @@ Unsubscribes from dead events of the **DeviceManager** service. ...@@ -631,13 +633,13 @@ Unsubscribes from dead events of the **DeviceManager** service.
**System capability**: SystemCapability.DistributedHardware.DeviceManager **System capability**: SystemCapability.DistributedHardware.DeviceManager
- **Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ----------------------- | ---- | ---------------------------------------- | | -------- | ----------------------- | ---- | ---------------------------------------- |
| type | string | Yes | Event type. The value **'serviceDie'** indicates an event reported when the **DeviceManager** service is terminated unexpectedly.| | type | string | Yes | Event type. The value **'serviceDie'** indicates an event reported when the **DeviceManager** service is terminated unexpectedly.|
| callback | () =&gt; void | No | Callback used to return the dead event of the **DeviceManager** service. | | callback | () =&gt; void | No | Callback used to return the dead event of the **DeviceManager** service. |
- Example **Example**
```js ```js
dmInstance.off("serviceDie", () => { dmInstance.off("serviceDie", () => {
console.info("serviceDie off"); console.info("serviceDie off");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册