@@ -9,7 +9,7 @@ System applications can call the APIs to do the following:
...
@@ -9,7 +9,7 @@ System applications can call the APIs to do the following:
- Authenticate or deauthenticate a device.
- Authenticate or deauthenticate a device.
- Query the trusted device list.
- Query the trusted device list.
- Query local device information, including the device name, type, and ID.
- Query local device information, including the device name, type, and ID.
- Publish device information for discovery purposes.
> **NOTE**
> **NOTE**
>
>
> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...
@@ -31,23 +31,24 @@ Creates a **DeviceManager** instance.
...
@@ -31,23 +31,24 @@ Creates a **DeviceManager** instance.
"medium":0,// Automatic. Multiple media can be used for device discovery.
"freq":2,// High frequency
"isSameAccount":false,
"isWakeRemote":false,
"capability":1
};
varfilterOptions={
"filter_op":"OR",// Optional. The default value is OR.
"filters":[
{
"type":"range",
"value":50// Filter discovered devices based on the distance (in cm).
}
]
};
dmInstance.startDeviceDiscovery(subscribeInfo,JSON.stringify(filterOptions));// The deviceFound callback is invoked to notify the application when a device is discovered.
| 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<{ subscribeId: number, device: [DeviceInfo](#deviceinfo) }> | Yes | Callback used for device discovery, which is invoked to return the device information and state.|
| callback | Callback<{ subscribeId: number, device: [DeviceInfo](#deviceinfo) }> | 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 +666,13 @@ Subscribes to device discovery failures.
...
@@ -563,13 +666,13 @@ Subscribes to device discovery failures.
| 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 | () => void | Yes | Callback invoked when a dead event of the **DeviceManager** service occurs. |
| callback | () => 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 +821,13 @@ Unsubscribes from dead events of the **DeviceManager** service.
...
@@ -631,13 +821,13 @@ Unsubscribes from dead events of the **DeviceManager** service.
| 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 | () => void | No | Callback used to return the dead event of the **DeviceManager** service. |
| callback | () => void | No | Callback used to return the dead event of the **DeviceManager** service. |