提交 41e0ca97 编写于 作者: S shawn_he

update doc

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 d6686d92
# MDNS Management
## Overview
## Introduction
Multicast DNS (mDNS) provides functions such as adding, removing, discovering, and resolving local services on a LAN.
- Local service: a service provider on a LAN, for example, a printer or scanner.
......@@ -28,9 +28,13 @@ For the complete list of APIs and example code, see [mDNS Management](../referen
| ohos.net.mdns.DiscoveryService | startSearchingMDNS(): void | Searches for mDNS services on the LAN.|
| ohos.net.mdns.DiscoveryService | stopSearchingMDNS(): void | Stops searching for mDNS services on the LAN.|
| ohos.net.mdns.DiscoveryService | on(type: 'discoveryStart', callback: Callback<{serviceInfo: LocalServiceInfo, errorCode?: MdnsError}>): void | Enables listening for **discoveryStart** events.|
| ohos.net.mdns.DiscoveryService | off(type: 'discoveryStart', callback?: Callback<{ serviceInfo: LocalServiceInfo, errorCode?: MdnsError }>): void | Disables listening for **discoveryStart** events.|
| ohos.net.mdns.DiscoveryService | on(type: 'discoveryStop', callback: Callback<{serviceInfo: LocalServiceInfo, errorCode?: MdnsError}>): void | Enables listening for **discoveryStop** events.|
| ohos.net.mdns.DiscoveryService | off(type: 'discoveryStop', callback?: Callback<{ serviceInfo: LocalServiceInfo, errorCode?: MdnsError }>): void | Disables listening for **discoveryStop** events.|
| ohos.net.mdns.DiscoveryService | on(type: 'serviceFound', callback: Callback\<LocalServiceInfo>): void | Enables listening for **serviceFound** events.|
| ohos.net.mdns.DiscoveryService | off(type: 'serviceFound', callback?: Callback\<LocalServiceInfo>): void | Disables listening for **serviceFound** events.|
| ohos.net.mdns.DiscoveryService | on(type: 'serviceLost', callback: Callback\<LocalServiceInfo>): void | Enables listening for **serviceLost** events.|
| ohos.net.mdns.DiscoveryService | off(type: 'serviceLost', callback?: Callback\<LocalServiceInfo>): void | Disables listening for **serviceLost** events.|
## Managing Local Services
......@@ -94,10 +98,11 @@ mdns.removeLocalService(context, localServiceInfo, function (error, data) {
1. Connect the device to the Wi-Fi network.
2. Import the **mdns** namespace from **@ohos.net.mdns**.
3. Creates a **DiscoveryService** object, which is used to discover mDNS services of the specified type.
3. Create a **DiscoveryService** object, which is used to discover mDNS services of the specified type.
4. Subscribe to mDNS service discovery status changes.
5. Enable discovery of mDNS services on the LAN.
6. Stop searching for mDNS services on the LAN.
7. Unsubscribe from mDNS service discovery status changes.
```js
// Import the mdns namespace from @ohos.net.mdns.
......@@ -139,4 +144,18 @@ discoveryService.startSearchingMDNS();
// Stop searching for mDNS services on the LAN.
discoveryService.stopSearchingMDNS();
// Unsubscribe from mDNS service discovery status changes.
discoveryService.off('discoveryStart', (data) => {
console.log(JSON.stringify(data));
});
discoveryService.off('discoveryStop', (data) => {
console.log(JSON.stringify(data));
});
discoveryService.off('serviceFound', (data) => {
console.log(JSON.stringify(data));
});
discoveryService.off('serviceLost', (data) => {
console.log(JSON.stringify(data));
});
```
......@@ -304,6 +304,7 @@
- AI
- [@ohos.ai.mindSporeLite (Inference)](js-apis-mindSporeLite.md)
- [@ohos.ai.intelligentVoice (Intelligent Voice)](js-apis-intelligentVoice.md)
- Telephony Service
- [@ohos.contact (Contacts)](js-apis-contact.md)
......@@ -396,7 +397,7 @@
- [@ohos.charger (Charging Type)](js-apis-charger.md)
- [@ohos.cooperate (Screen Hopping)](js-apis-devicestatus-cooperate.md)
- [@ohos.deviceAttest (Device Attestation)](js-apis-deviceAttest.md)
- [@ohos.deviceStatus.dragInteraction (Drag)](js-apis-devicestatus-draginteraction.md)
- [@ohos.deviceStatus.dragInteraction (Drag Interaction)](js-apis-devicestatus-draginteraction.md)
- [@ohos.deviceInfo (Device Information)](js-apis-device-info.md)
- [@ohos.distributedDeviceManager (Device Management)](js-apis-distributedDeviceManager.md)
- [@ohos.distributedHardware.deviceManager (Device Management)](js-apis-device-manager.md)
......
# @ohos.deviceStatus.dragInteraction (Drag Interaction)
The **dragInteraction** module provides the APIs to enable and disable listening for dragging status changes.
> **NOTE**
>
> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - The APIs provided by this module are system APIs.
## Modules to Import
```js
import dragInteraction from '@ohos.deviceStatus.dragInteraction'
```
## dragInteraction.on('drag')
on(type: 'drag', callback: Callback&lt;DragState&gt;): void;
Enables listening for dragging status changes.
**System capability**: SystemCapability.Msdp.DeviceStatus.Drag
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | ---------------------------- |
| type | string | Yes | Event type. This field has a fixed value of **drag**.|
| callback | Callback&lt;[DragState](#dragstate)&gt; | Yes | Callback used to return the dragging status.|
**Example**
```js
try {
dragInteraction.on('drag', (data) => {
console.log(`Drag interaction event: ${JSON.stringify(data)}`);
});
} catch (error) {
console.log(`Register failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## dragInteraction.off('drag')
off(type: 'drag', callback?: Callback&lt;DragState&gt;): void;
Disables listening for dragging status changes.
**System capability**: SystemCapability.Msdp.DeviceStatus.Drag
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ---------------------------- | ---- | ---------------------------- |
| type | string | Yes | Event type. This field has a fixed value of **drag**.|
| callback | Callback&lt;[DragState](#dragstate)> | No | Callback to be unregistered. If this parameter is not specified, all callbacks registered by the current application will be unregistered.|
**Example**
```js
// Unregister a single callback.
function callback(event) {
console.log(`Drag interaction event: ${JSON.stringify(event)}`);
return false;
}
try {
dragInteraction.on('drag', callback);
dragInteraction.off("drag", callback);
} catch (error) {
console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
```js
// Unregister all callbacks.
function callback(event) {
console.log(`Drag interaction event: ${JSON.stringify(event)}`);
return false;
}
try {
dragInteraction.on('drag', callback);
dragInteraction.off("drag");
} catch (error) {
console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## DragState
Enumerates dragging states.
**System capability**: SystemCapability.Msdp.DeviceStatus.Drag
| Name | Value | Description |
| -------- | ----------------- | ----------------- |
| MSG_DRAG_STATE_START | 1 | Dragging starts.|
| MSG_DRAG_STATE_STOP | 2 | Dragging is ended. |
| MSG_DRAG_STATE_CANCEL | 3 | Dragging is canceled. |
# @ohos. deviceStatus.dragInteraction (Drag)
# @ohos.deviceStatus.dragInteraction (Drag Interaction)
The **dragInteraction** module provides the APIs to enable and disable listening for dragging status changes.
......@@ -14,7 +14,7 @@
import dragInteraction from '@ohos.deviceStatus.dragInteraction'
```
## dragInteraction.on
## dragInteraction.on('drag')
on(type: 'drag', callback: Callback&lt;DragState&gt;): void;
......@@ -41,7 +41,7 @@ try {
}
```
## dragInteraction.off
## dragInteraction.off('drag')
off(type: 'drag', callback?: Callback&lt;DragState&gt;): void;
......
......@@ -874,7 +874,7 @@ Specifies the type and value range of the optional parameters in the HTTP reques
| Name | Type | Mandatory| Description |
| -------------- | --------------------------------------------- | ---- | ------------------------------------------------------------ |
| method | [RequestMethod](#requestmethod) | No | Request method. The default value is **GET**. |
| extraData | string<sup>6+</sup> \| Object<sup>6+</sup> \| ArrayBuffer<sup>8+</sup> | No | Additional data for sending a request. This parameter is not used by default.<br>- If the HTTP request uses a POST or PUT method, this parameter serves as the content of the HTTP request and is encoded in UTF-8 format. If **'Content-Type'** is **'application/x-www-form-urlencoded'**, the data in the request body must be encoded in the format of **key1=value1&key2=value2&key3=value3** after URL transcoding. - If the HTTP request uses the GET, OPTIONS, DELETE, TRACE, or CONNECT method, this parameter serves as a supplement to HTTP request parameters. Parameters of the string type need to be encoded before being passed to the HTTP request. Parameters of the object type do not need to be precoded and will be directly concatenated to the URL. Parameters of the ArrayBuffer type will not be concatenated to the URL.|
| extraData | string<sup>6+</sup> \| Object<sup>6+</sup> \| ArrayBuffer<sup>8+</sup> | No | Additional data for sending a request. This parameter is not used by default.<br>- If the HTTP request uses a POST or PUT method, this parameter serves as the content of the HTTP request and is encoded in UTF-8 format. If **'Content-Type'** is **'application/x-www-form-urlencoded'**, the data in the request body must be encoded in the format of **key1=value1&key2=value2&key3=value3** after URL transcoding and passed to the API as a string.<br>- If the HTTP request uses the GET, OPTIONS, DELETE, TRACE, or CONNECT method, this parameter serves as a supplement to HTTP request parameters. Parameters of the string type need to be encoded before being passed to the HTTP request. Parameters of the object type do not need to be precoded and will be directly concatenated to the URL. Parameters of the ArrayBuffer type will not be concatenated to the URL.|
| expectDataType<sup>9+</sup> | [HttpDataType](#httpdatatype9) | No | Type of the returned data. This parameter is not used by default. If this parameter is set, the system returns the specified type of data preferentially.|
| usingCache<sup>9+</sup> | boolean | No | Whether to use the cache. The default value is **true**. |
| priority<sup>9+</sup> | number | No | Priority. The value range is [1,1000]. The default value is **1**. |
......@@ -883,7 +883,7 @@ Specifies the type and value range of the optional parameters in the HTTP reques
| connectTimeout | number | No | Connection timeout interval. The default value is **60000**, in ms. |
| usingProtocol<sup>9+</sup> | [HttpProtocol](#httpprotocol9) | No | Protocol. The default value is automatically specified by the system. |
| usingProxy<sup>10+</sup> | boolean \| Object | No | Whether to use HTTP proxy. The default value is **false**, which means not to use HTTP proxy.<br>- If **usingProxy** is of the **Boolean** type and the value is **true**, network proxy is used by default.<br>- If **usingProxy** is of the **object** type, the specified network proxy is used.
| caPath<sup>10+</sup> | string | No | Path of the CA certificate. If this parameter is set, the system uses the CA certificate in the specified path. Otherwise, the system uses the preset CA certificate. |
| caPath<sup>10+</sup> | string | No | Path of CA certificates. If a path is set, the system uses the CA certificates in this path. If a path is not set, the system uses the preset CA certificates. The path is the sandbox mapping path, and preset CA certificates are stored in **/etc/ssl/certs/cacert.pem**. You are advised to store CA certificates in this path. Currently, only **.pem** certificates are supported. |
## RequestMethod<sup>6+</sup>
......
......@@ -408,7 +408,7 @@ syscontext.resourceManager.getRawFileContent(inputName).then(async (buffer) => {
let mindSporeLiteModel = await mindSporeLite.loadModelFromFile(model_file);
const modelInputs = mindSporeLiteModel.getInputs();
modelInputs[0].setData(inputBuffer.buffer);
result.predict(modelInputs, (result) => {
mindSporeLiteModel.predict(modelInputs, (result) => {
let output = new Float32Array(result[0].getData());
for (let i = 0; i < output.length; i++) {
console.log(output[i].toString());
......@@ -448,7 +448,7 @@ syscontext.resourceManager.getRawFileContent(inputName).then(async (buffer) => {
let mindSporeLiteModel = await mindSporeLite.loadModelFromFile(model_file);
const modelInputs = mindSporeLiteModel.getInputs();
modelInputs[0].setData(inputBuffer.buffer);
result.predict(modelInputs).then((result) => {
mindSporeLiteModel.predict(modelInputs).then((result) => {
let output = new Float32Array(result[0].getData());
for (let i = 0; i < output.length; i++) {
console.log(output[i].toString());
......@@ -549,7 +549,7 @@ syscontext.resourceManager.getRawFileContent(inputName).then(async (buffer) => {
let mindSporeLiteModel = await mindSporeLite.loadModelFromFile(model_file);
const modelInputs = mindSporeLiteModel.getInputs();
modelInputs[0].setData(inputBuffer.buffer);
result.predict(modelInputs).then((result) => {
mindSporeLiteModel.predict(modelInputs).then((result) => {
let output = new Float32Array(result[0].getData());
for (let i = 0; i < output.length; i++) {
console.log(output[i].toString());
......@@ -579,7 +579,7 @@ import resourceManager from '@ohos.resourceManager'
let inputName = 'input_data.bin';
let syscontext = globalThis.context;
syscontext.resourceManager.getRawFileContent(inputName).then(async (buffer) => {
inputBuffer = buffer;
let inputBuffer = buffer;
let model_file = '/path/to/xxx.ms';
let mindSporeLiteModel = await mindSporeLite.loadModelFromFile(model_file);
const modelInputs = mindSporeLiteModel.getInputs();
......
......@@ -346,7 +346,7 @@ connection.getDefaultHttpProxy((error, data) => {
getDefaultHttpProxy(): Promise\<HttpProxy>;
Obtains the default proxy configuration of the network.
Obtains the default HTTP proxy configuration of the network.
If the global proxy is set, the global HTTP proxy configuration is returned. If [setAppNet](#connectionsetappnet) is used to bind the application to the network specified by [NetHandle](#nethandle), the HTTP proxy configuration of this network is returned. In other cases, the HTTP proxy configuration of the default network is returned.
This API uses a promise to return the result.
......@@ -438,6 +438,34 @@ connection.getAppNet().then((data) => {
})
```
## connection.getAppNetSync<sup>10+</sup>
getAppNetSync(): NetHandle
Obtains information about the network bound to an application. This API returns the result synchronously.
**System capability**: SystemCapability.Communication.NetManager.Core
**Return value**
| Type | Description |
| --------- | ---------------------------------- |
| [NetHandle](#nethandle8) | Handle of the data network bound to the application.|
**Error codes**
| ID| Error Message |
| ------- | ----------------------------- |
| 401 | Parameter error. |
| 2100002 | Operation failed. Cannot connect to service.|
| 2100003 | System internal error. |
**Example**
```js
let netHandle = connection.getAppNetSync();
```
## connection.SetAppNet<sup>9+</sup>
setAppNet(netHandle: NetHandle, callback: AsyncCallback\<void>): void
......@@ -587,6 +615,37 @@ connection.getAllNets().then(function (data) {
});
```
## connection.getAllNetsSync<sup>10+</sup>
getAllNetsSync(): Array&lt;NetHandle&gt;
Obtains the list of all connected networks. This API returns the result synchronously.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core
**Return value**
| Type | Description |
| --------- | ---------------------------------- |
| Array&lt;[NetHandle](#nethandle8)&gt; | List of all activated data networks.|
**Error codes**
| ID| Error Message |
| ------- | ----------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 2100002 | Operation failed. Cannot connect to service.|
| 2100003 | System internal error. |
**Example**
```js
let netHandle = connection.getAllNetsSync();
```
## connection.getConnectionProperties<sup>8+</sup>
getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback\<ConnectionProperties>): void
......@@ -667,6 +726,45 @@ connection.getDefaultNet().then(function (netHandle) {
})
```
## connection.getConnectionPropertiesSync<sup>10+</sup>
getConnectionPropertiesSync(netHandle: NetHandle): ConnectionProperties
Obtains network connection information based on the specified **netHandle**.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ----------------------- | ---- | ---------------- |
| netHandle | [NetHandle](#nethandle8) | Yes | Handle of the data network.|
**Return value**
| Type | Description |
| ------------------------------------------------------- | --------------------------------- |
| [ConnectionProperties](#connectionproperties8) | Network connection information.|
**Error codes**
| ID| Error Message |
| ------- | ----------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 2100001 | Invalid parameter value. |
| 2100002 | Operation failed. Cannot connect to service.|
| 2100003 | System internal error. |
**Example**
```js
let netHandle = connection.getDefaultNetsSync();
let connectionproperties = connection.getConnectionPropertiesSync(netHandle);
```
## connection.getNetCapabilities<sup>8+</sup>
getNetCapabilities(netHandle: NetHandle, callback: AsyncCallback\<NetCapabilities>): void
......@@ -747,6 +845,45 @@ connection.getDefaultNet().then(function (netHandle) {
})
```
## connection.getNetCapabilitiesSync<sup>10+</sup>
getNetCapabilitiesSync(netHandle: NetHandle): NetCapabilities
Obtains capability information of the network corresponding to the **netHandle**. This API returns the result synchronously.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ----------------------- | ---- | ---------------- |
| netHandle | [NetHandle](#nethandle8) | Yes | Handle of the data network.|
**Return value**
| Type | Description |
| --------------------------------------------- | --------------------------------- |
| [NetCapabilities](#netcapabilities8) | Network capability information.|
**Error codes**
| ID| Error Message |
| ------- | ----------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 2100001 | Invalid parameter value. |
| 2100002 | Operation failed. Cannot connect to service.|
| 2100003 | System internal error. |
**Example**
```js
let netHandle = connection.getDefaultNetsSync();
let getNetCapabilitiesSync = connection.getNetCapabilitiesSync(netHandle);
```
## connection.isDefaultNetMetered<sup>9+</sup>
isDefaultNetMetered(callback: AsyncCallback\<boolean>): void
......@@ -814,6 +951,37 @@ connection.isDefaultNetMetered().then(function (data) {
})
```
## connection.isDefaultNetMeteredSync<sup>10+</sup>
isDefaultNetMeteredSync(): boolean
Checks whether the data traffic usage on the current network is metered. This API returns the result synchronously.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core
**Return value**
| Type | Description |
| ----------------- | ----------------------------------------------- |
| boolean | The value **true** indicates the data traffic usage is metered.|
**Error codes**
| ID| Error Message |
| ------- | ----------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 2100002 | Operation failed. Cannot connect to service.|
| 2100003 | System internal error. |
**Example**
```js
let isMetered = connection.isDefaultNetMeteredSync();
```
## connection.hasDefaultNet<sup>8+</sup>
hasDefaultNet(callback: AsyncCallback\<boolean>): void
......@@ -881,6 +1049,37 @@ connection.hasDefaultNet().then(function (data) {
})
```
## connection.hasDefaultNetSync<sup>10+</sup>
hasDefaultNetSync(): boolean
Checks whether the default data network is activated. This API returns the result synchronously.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core
**Return value**
| Type | Description |
| ----------------- | ----------------------------------------------- |
| boolean | The value **true** indicates the default data network is activated.|
**Error codes**
| ID| Error Message |
| ------- | ----------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 2100002 | Operation failed. Cannot connect to service.|
| 2100003 | System internal error. |
**Example**
```js
let isDefaultNet = connection.hasDefaultNetSync();
```
## connection.enableAirplaneMode<sup>8+</sup>
enableAirplaneMode(callback: AsyncCallback\<void>): void
......@@ -1349,7 +1548,7 @@ Registers a listener for **netAvailable** events.
| Name | Type | Mandatory| Description |
| -------- | ---------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type. The value is fixed to **netAvailable**.<br>**netAvailable**: event indicating that the data network is available.|
| type | string | Yes | Event type. This field has a fixed value of **netAvailable**.<br>**netAvailable**: event indicating that the data network is available.|
| callback | Callback\<[NetHandle](#nethandle)> | Yes | Callback used to return the network handle.|
**Example**
......@@ -1388,7 +1587,7 @@ Registers a listener for **netBlockStatusChange** events. This API uses an async
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type. The value is fixed to **netBlockStatusChange**.<br>**netBlockStatusChange**: event indicating a change in the network blocking status.|
| type | string | Yes | Event type. This field has a fixed value of **netBlockStatusChange**.<br>**netBlockStatusChange**: event indicating a change in the network blocking status.|
| callback | Callback&lt;{&nbsp;netHandle:&nbsp;[NetHandle](#nethandle),&nbsp;blocked:&nbsp;boolean&nbsp;}&gt; | Yes | Callback used to return the network handle (**netHandle**) and network status (**blocked**).|
**Example**
......@@ -1415,7 +1614,7 @@ netCon.unregister(function (error) {
### on('netCapabilitiesChange')<sup>8+</sup>
on(type: 'netCapabilitiesChange', callback: Callback<{ netHandle: NetHandle, netCap: NetCapabilities }>): void
on(type: 'netCapabilitiesChange', callback: Callback\<NetCapabilityInfo>): void
Registers a listener for **netCapabilitiesChange** events.
......@@ -1427,8 +1626,8 @@ Registers a listener for **netCapabilitiesChange** events.
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type. The value is fixed to **netCapabilitiesChange**.<br>**netCapabilitiesChange**: event indicating that the network capabilities have changed.|
| callback | Callback<{ netHandle: [NetHandle](#nethandle), netCap: [NetCapabilities](#netcapabilities) }> | Yes | Callback used to return the network handle (**netHandle**) and capability information (**netCap**).|
| type | string | Yes | Event type. This field has a fixed value of **netCapabilitiesChange**.<br>**netCapabilitiesChange**: event indicating that the network capabilities have changed.|
| callback | Callback<[NetCapabilityInfo](#netcapabilityinfo)> | Yes | Callback used to return the network handle (**netHandle**) and capability information (**netCap**).|
**Example**
......@@ -1467,7 +1666,7 @@ Registers a listener for **netConnectionPropertiesChange** events.
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type. The value is fixed to **netConnectionPropertiesChange**.<br>**netConnectionPropertiesChange**: event indicating that network connection properties have changed.|
| type | string | Yes | Event type. This field has a fixed value of **netConnectionPropertiesChange**.<br>**netConnectionPropertiesChange**: event indicating that network connection properties have changed.|
| callback | Callback<{ netHandle: [NetHandle](#nethandle), connectionProperties: [ConnectionProperties](#connectionproperties) }> | Yes | Callback used to return the network handle (**netHandle**) and connection information (**connectionProperties**).|
**Example**
......@@ -1506,7 +1705,7 @@ Registers a listener for **netLost** events.
| Name | Type | Mandatory| Description |
| -------- | ---------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type. The value is fixed to **netLost**.<br>netLost: event indicating that the network is interrupted or normally disconnected.|
| type | string | Yes | Event type. This field has a fixed value of **netLost**.<br>netLost: event indicating that the network is interrupted or normally disconnected.|
| callback | Callback\<[NetHandle](#nethandle)> | Yes | Callback used to return the network handle (**netHandle**).|
**Example**
......@@ -1545,7 +1744,7 @@ Registers a listener for **netUnavailable** events.
| Name | Type | Mandatory| Description |
| -------- | --------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type. The value is fixed to **netUnavailable**.<br>**netUnavailable**: event indicating that the network is unavailable.|
| type | string | Yes | Event type. This field has a fixed value of **netUnavailable**.<br>**netUnavailable**: event indicating that the network is unavailable.|
| callback | Callback\<void> | Yes | Callback used to return the result, which is empty.|
**Example**
......@@ -1950,6 +2149,17 @@ Provides an instance that bears data network capabilities.
| netCapabilities | [NetCapabilities](#netcapabilities) | Yes | Network transmission capabilities and bearer types of the data network. |
| bearerPrivateIdentifier | string | No | Network identifier. The identifier of a Wi-Fi network is **wifi**, and that of a cellular network is **slot0** (corresponding to SIM card 1).|
## NetCapabilityInfo<sup>10+</sup>
Provides an instance that bears data network capabilities.
**System capability**: SystemCapability.Communication.NetManager.Core
| Name | Type | Mandatory | Description |
| ----------------------- | ----------------------------------- | ---- | ------------------------------------------------------------ |
| netHandle | [NetHandle](#nethandle) | Yes | Handle of the data network. |
| netCap | [NetCapabilities](#netcapabilities) | No | Network transmission capabilities and bearer types of the data network.|
## NetCapabilities<sup>8+</sup>
Defines the network capability set.
......
......@@ -63,7 +63,7 @@ let localServiceInfo = {
}]
}
mdns.addLocalService(context, localServiceInfo, function (error, data) {
mdns.addLocalService(context, localServiceInfo, (error: BusinessError, data: Data) => {
console.log(JSON.stringify(error));
console.log(JSON.stringify(data));
});
......@@ -72,14 +72,39 @@ mdns.addLocalService(context, localServiceInfo, function (error, data) {
Stage model:
```ts
// Construct a singleton object.
export class GlobalContext {
private constructor() {}
private static instance: GlobalContext;
private _objects = new Map<string, Object>();
public static getContext(): GlobalContext {
if (!GlobalContext.instance) {
GlobalContext.instance = new GlobalContext();
}
return GlobalContext.instance;
}
getObject(value: string): Object | undefined {
return this._objects.get(value);
}
setObject(key: string, objectClass: Object): void {
this._objects.set(key, objectClass);
}
}
// Obtain the context.
import UIAbility from '@ohos.app.ability.UIAbility';
import { GlobalContext } from '../GlobalContext';
class EntryAbility extends UIAbility {
value:number = 0;
onWindowStageCreate(windowStage){
globalThis.context = this.context;
GlobalContext.getContext().setObject("value", this.value);
}
}
let context = globalThis.context;
let context = GlobalContext.getContext().getObject("value");
let localServiceInfo = {
serviceType: "_print._tcp",
......@@ -94,7 +119,7 @@ let localServiceInfo = {
}]
}
mdns.addLocalService(context, localServiceInfo, function (error, data) {
mdns.addLocalService(context, localServiceInfo, (error: BusinessError, data: Data) => {
console.log(JSON.stringify(error));
console.log(JSON.stringify(data));
});
......@@ -157,7 +182,7 @@ let localServiceInfo = {
}]
}
mdns.addLocalService(context, localServiceInfo).then(function (data) {
mdns.addLocalService(context, localServiceInfo).then((data: Data) => {
console.log(JSON.stringify(data));
});
```
......@@ -167,12 +192,15 @@ Stage model:
```ts
// Obtain the context.
import UIAbility from '@ohos.app.ability.UIAbility';
// Construct a singleton object by referring to addLocalService.
import { GlobalContext } from '../GlobalContext';
class EntryAbility extends UIAbility {
value:number = 0;
onWindowStageCreate(windowStage){
globalThis.context = this.context;
GlobalContext.getContext().setObject("value", this.value);
}
}
let context = globalThis.context;
let context = GlobalContext.getContext().getObject("value");
let localServiceInfo = {
serviceType: "_print._tcp",
......@@ -187,7 +215,7 @@ let localServiceInfo = {
}]
}
mdns.addLocalService(context, localServiceInfo).then(function (data) {
mdns.addLocalService(context, localServiceInfo).then((data: Data) => {
console.log(JSON.stringify(data));
});
```
......@@ -244,7 +272,7 @@ let localServiceInfo = {
}]
}
mdns.removeLocalService(context, localServiceInfo, function (error, data) {
mdns.removeLocalService(context, localServiceInfo, (error: BusinessError, data: Data) => {
console.log(JSON.stringify(error));
console.log(JSON.stringify(data));
});
......@@ -255,12 +283,15 @@ Stage model:
```ts
// Obtain the context.
import UIAbility from '@ohos.app.ability.UIAbility';
// Construct a singleton object by referring to addLocalService.
import { GlobalContext } from '../GlobalContext';
class EntryAbility extends UIAbility {
value:number = 0;
onWindowStageCreate(windowStage){
globalThis.context = this.context;
GlobalContext.getContext().setObject("value", this.value);
}
}
let context = globalThis.context;
let context = GlobalContext.getContext().getObject("value");
let localServiceInfo = {
serviceType: "_print._tcp",
......@@ -275,7 +306,7 @@ let localServiceInfo = {
}]
}
mdns.removeLocalService(context, localServiceInfo, function (error, data) {
mdns.removeLocalService(context, localServiceInfo, (error: BusinessError, data: Data) => {
console.log(JSON.stringify(error));
console.log(JSON.stringify(data));
});
......@@ -338,7 +369,7 @@ let localServiceInfo = {
}]
}
mdns.removeLocalService(context, localServiceInfo).then(function (data) {
mdns.removeLocalService(context, localServiceInfo).then((data: Data) => {
console.log(JSON.stringify(data));
});
```
......@@ -348,12 +379,15 @@ Stage model:
```ts
// Obtain the context.
import UIAbility from '@ohos.app.ability.UIAbility';
// Construct a singleton object by referring to addLocalService.
import { GlobalContext } from '../GlobalContext';
class EntryAbility extends UIAbility {
value:number = 0;
onWindowStageCreate(windowStage){
globalThis.context = this.context;
GlobalContext.getContext().setObject("value", this.value);
}
}
let context = globalThis.context;
let context = GlobalContext.getContext().getObject("value");
let localServiceInfo = {
serviceType: "_print._tcp",
......@@ -368,7 +402,7 @@ let localServiceInfo = {
}]
}
mdns.removeLocalService(context, localServiceInfo).then(function (data) {
mdns.removeLocalService(context, localServiceInfo).then((data: Data) => {
console.log(JSON.stringify(data));
});
```
......@@ -418,12 +452,15 @@ Stage model:
```ts
// Obtain the context.
import UIAbility from '@ohos.app.ability.UIAbility';
// Construct a singleton object by referring to addLocalService.
import { GlobalContext } from '../GlobalContext';
class EntryAbility extends UIAbility {
value:number = 0;
onWindowStageCreate(windowStage){
globalThis.context = this.context;
GlobalContext.getContext().setObject("value", this.value);
}
}
let context = globalThis.context;
let context = GlobalContext.getContext().getObject("value");
let serviceType = "_print._tcp";
let discoveryService = mdns.createDiscoveryService(context, serviceType);
......@@ -481,7 +518,7 @@ let localServiceInfo = {
}]
}
mdns.resolveLocalService(context, localServiceInfo, function (error, data) {
mdns.resolveLocalService(context, localServiceInfo, (error: BusinessError, data: Data) => {
console.log(JSON.stringify(error));
console.log(JSON.stringify(data));
});
......@@ -492,12 +529,15 @@ Stage model:
```ts
// Obtain the context.
import UIAbility from '@ohos.app.ability.UIAbility';
// Construct a singleton object by referring to addLocalService.
import { GlobalContext } from '../GlobalContext';
class EntryAbility extends UIAbility {
value:number = 0;
onWindowStageCreate(windowStage){
globalThis.context = this.context;
GlobalContext.getContext().setObject("value", this.value);
}
}
let context = globalThis.context;
let context = GlobalContext.getContext().getObject("value");
let localServiceInfo = {
serviceType: "_print._tcp",
......@@ -512,7 +552,7 @@ let localServiceInfo = {
}]
}
mdns.resolveLocalService(context, localServiceInfo, function (error, data) {
mdns.resolveLocalService(context, localServiceInfo, (error: BusinessError, data: Data) => {
console.log(JSON.stringify(error));
console.log(JSON.stringify(data));
});
......@@ -575,7 +615,7 @@ let localServiceInfo = {
}]
}
mdns.resolveLocalService(context, localServiceInfo).then(function (data) {
mdns.resolveLocalService(context, localServiceInfo).then((data: Data) => {
console.log(JSON.stringify(data));
});
```
......@@ -585,12 +625,15 @@ Stage model:
```ts
// Obtain the context.
import UIAbility from '@ohos.app.ability.UIAbility';
// Construct a singleton object by referring to addLocalService.
import { GlobalContext } from '../GlobalContext';
class EntryAbility extends UIAbility {
value:number = 0;
onWindowStageCreate(windowStage){
globalThis.context = this.context;
GlobalContext.getContext().setObject("value", this.value);
}
}
let context = globalThis.context;
let context = GlobalContext.getContext().getObject("value");
let localServiceInfo = {
serviceType: "_print._tcp",
......@@ -605,7 +648,7 @@ let localServiceInfo = {
}]
}
mdns.resolveLocalService(context, localServiceInfo).then(function (data) {
mdns.resolveLocalService(context, localServiceInfo).then((data: Data) => {
console.log(JSON.stringify(data));
});
```
......@@ -639,12 +682,15 @@ Stage model:
```ts
// Obtain the context.
import UIAbility from '@ohos.app.ability.UIAbility';
// Construct a singleton object by referring to addLocalService.
import { GlobalContext } from '../GlobalContext';
class EntryAbility extends UIAbility {
value:number = 0;
onWindowStageCreate(windowStage){
globalThis.context = this.context;
GlobalContext.getContext().setObject("value", this.value);
}
}
let context = globalThis.context;
let context = GlobalContext.getContext().getObject("value");
let serviceType = "_print._tcp";
let discoveryService = mdns.createDiscoveryService(context, serviceType);
discoveryService.startSearchingMDNS();
......@@ -676,12 +722,15 @@ Stage model:
```ts
// Obtain the context.
import UIAbility from '@ohos.app.ability.UIAbility';
// Construct a singleton object by referring to addLocalService.
import { GlobalContext } from '../GlobalContext';
class EntryAbility extends UIAbility {
value:number = 0;
onWindowStageCreate(windowStage){
globalThis.context = this.context;
GlobalContext.getContext().setObject("value", this.value);
}
}
let context = globalThis.context;
let context = GlobalContext.getContext().getObject("value");
let serviceType = "_print._tcp";
let discoveryService = mdns.createDiscoveryService(context, serviceType);
discoveryService.stopSearchingMDNS();
......@@ -706,16 +755,51 @@ Enables listening for **discoveryStart** events.
```js
// See mdns.createDiscoveryService.
let context = globalThis.context;
let context = GlobalContext.getContext().getObject("value");
let serviceType = "_print._tcp";
let discoveryService = mdns.createDiscoveryService(context, serviceType);
discoveryService.startSearchingMDNS();
discoveryService.on('discoveryStart', (data: Data) => {
console.log(JSON.stringify(data));
});
discoveryService.stopSearchingMDNS();
```
### off('discoveryStart')<sup>10+</sup>
off(type: 'discoveryStart', callback?: Callback<{ serviceInfo: LocalServiceInfo, errorCode?: MdnsError }>): void
Disables listening for **discoveryStart** events.
**System capability**: SystemCapability.Communication.NetManager.MDNS
**Parameters**
| Name | Type | Mandatory| Description |
|-------------|--------------|-----------|-----------------------------------------------------|
| type | string | Yes |Event type. This field has a fixed value of **discoveryStart**.<br>**discoveryStart**: event of starting discovery of mDNS services on the LAN.|
| callback | Callback<{serviceInfo: [LocalServiceInfo](#localserviceinfo), errorCode?: [MdnsError](#mdnserror)}> | No | Callback used to return the mDNS service and error information. |
**Example**
```js
// See mdns.createDiscoveryService.
let context = GlobalContext.getContext().getObject("value");
let serviceType = "_print._tcp";
let discoveryService = mdns.createDiscoveryService(context, serviceType);
discoveryService.startSearchingMDNS();
discoveryService.on('discoveryStart', (data) => {
discoveryService.on('discoveryStart', (data: Data) => {
console.log(JSON.stringify(data));
});
discoveryService.stopSearchingMDNS();
discoveryService.off('discoveryStart', (data: Data) => {
console.log(JSON.stringify(data));
});
```
### on('discoveryStop')<sup>10+</sup>
......@@ -737,16 +821,51 @@ Enables listening for **discoveryStop** events.
```js
// See mdns.createDiscoveryService.
let context = globalThis.context;
let context = GlobalContext.getContext().getObject("value");
let serviceType = "_print._tcp";
let discoveryService = mdns.createDiscoveryService(context, serviceType);
discoveryService.startSearchingMDNS();
discoveryService.on('discoveryStop', (data: Data) => {
console.log(JSON.stringify(data));
});
discoveryService.stopSearchingMDNS();
```
### off('discoveryStop')<sup>10+</sup>
off(type: 'discoveryStop', callback?: Callback<{ serviceInfo: LocalServiceInfo, errorCode?: MdnsError }>): void
Disables listening for **discoveryStop** events.
**System capability**: SystemCapability.Communication.NetManager.MDNS
**Parameters**
| Name | Type | Mandatory| Description |
|-------------|--------------|-----------|-----------------------------------------------------|
| type | string | Yes |Event type. This field has a fixed value of **discoveryStop**.<br>**discoveryStop**: event of stopping discovery of mDNS services on the LAN.|
| callback | Callback<{serviceInfo: [LocalServiceInfo](#localserviceinfo), errorCode?: [MdnsError](#mdnserror)}> | No | Callback used to return the mDNS service and error information. |
**Example**
```js
// See mdns.createDiscoveryService.
let context = GlobalContext.getContext().getObject("value");
let serviceType = "_print._tcp";
let discoveryService = mdns.createDiscoveryService(context, serviceType);
discoveryService.startSearchingMDNS();
discoveryService.on('discoveryStop', (data) => {
discoveryService.on('discoveryStop', (data: Data) => {
console.log(JSON.stringify(data));
});
discoveryService.stopSearchingMDNS();
discoveryService.off('discoveryStop', (data: Data) => {
console.log(JSON.stringify(data));
});
```
### on('serviceFound')<sup>10+</sup>
......@@ -768,16 +887,51 @@ Enables listening for **serviceFound** events.
```js
// See mdns.createDiscoveryService.
let context = globalThis.context;
let context = GlobalContext.getContext().getObject("value");
let serviceType = "_print._tcp";
let discoveryService = mdns.createDiscoveryService(context, serviceType);
discoveryService.startSearchingMDNS();
discoveryService.on('serviceFound', (data: Data) => {
console.log(JSON.stringify(data));
});
discoveryService.stopSearchingMDNS();
```
### off('serviceFound')<sup>10+</sup>
off(type: 'serviceFound', callback?: Callback\<LocalServiceInfo>): void
Disables listening for **serviceFound** events.
**System capability**: SystemCapability.Communication.NetManager.MDNS
**Parameters**
| Name | Type | Mandatory| Description |
|-------------|--------------|-----------|-----------------------------------------------------|
| type | string | Yes |Event type. This field has a fixed value of **serviceFound**.<br>**serviceFound**: event indicating an mDNS service is found.|
| callback | Callback<[LocalServiceInfo](#localserviceinfo)> | No | mDNS service information. |
**Example**
```js
// See mdns.createDiscoveryService.
let context = GlobalContext.getContext().getObject("value");
let serviceType = "_print._tcp";
let discoveryService = mdns.createDiscoveryService(context, serviceType);
discoveryService.startSearchingMDNS();
discoveryService.on('serviceFound', (data) => {
discoveryService.on('serviceFound', (data: Data) => {
console.log(JSON.stringify(data));
});
discoveryService.stopSearchingMDNS();
discoveryService.off('serviceFound', (data: Data) => {
console.log(JSON.stringify(data));
});
```
### on('serviceLost')<sup>10+</sup>
......@@ -799,16 +953,51 @@ Enables listening for **serviceLost** events.
```js
// See mdns.createDiscoveryService.
let context = globalThis.context;
let context = GlobalContext.getContext().getObject("value");
let serviceType = "_print._tcp";
let discoveryService = mdns.createDiscoveryService(context, serviceType);
discoveryService.startSearchingMDNS();
discoveryService.on('serviceLost', (data: Data) => {
console.log(JSON.stringify(data));
});
discoveryService.stopSearchingMDNS();
```
### off('serviceLost')<sup>10+</sup>
off(type: 'serviceLost', callback?: Callback\<LocalServiceInfo>): void
Disables listening for **serviceLost** events.
**System capability**: SystemCapability.Communication.NetManager.MDNS
**Parameters**
| Name | Type | Mandatory| Description |
|-------------|--------------|-----------|-----------------------------------------------------|
| type | string | Yes |Event type. This field has a fixed value of **serviceLost**.<br>serviceLost: event indicating that an mDNS service is removed.|
| callback | Callback<[LocalServiceInfo](#localserviceinfo)> | No | mDNS service information. |
**Example**
```js
// See mdns.createDiscoveryService.
let context = GlobalContext.getContext().getObject("value");
let serviceType = "_print._tcp";
let discoveryService = mdns.createDiscoveryService(context, serviceType);
discoveryService.startSearchingMDNS();
discoveryService.on('serviceLost', (data) => {
discoveryService.on('serviceLost', (data: Data) => {
console.log(JSON.stringify(data));
});
discoveryService.stopSearchingMDNS();
discoveryService.off('serviceLost', (data: Data) => {
console.log(JSON.stringify(data));
});
```
## LocalServiceInfo<sup>10+</sup>
......
# # @ohos.net.socket (Socket Connection)
# @ohos.net.socket (Socket Connection)
The **socket** module implements data transfer over TCP, UDP, Web, and TLS socket connections.
......@@ -2515,7 +2515,7 @@ tcpServer.on('connect', function(client) {
### off('close')<sup>10+</sup>
on(type: 'close', callback: Callback\<void\>): void
off(type: 'close', callback?: Callback\<void\>): void
Unsubscribes from **close** events of a **TCPSocketConnection** object. This API uses an asynchronous callback to return the result.
......@@ -5708,7 +5708,7 @@ tlsServer.on('connect', function(client) {
### off('close')<sup>10+</sup>
on(type: 'close', callback: Callback\<void\>): void
off(type: 'close', callback?: Callback\<void\>): void
Unsubscribes from **close** events of a **TLSSocketConnection** object. This API uses an asynchronous callback to return the result.
......
......@@ -146,7 +146,7 @@ console.log(bool);
requestRight(deviceName: string): Promise&lt;boolean&gt;
Requests the temporary permission for the application to access a USB device. This API uses a promise to return the result.
Requests the temporary permission for the application to access a USB device. This API uses a promise to return the result. System applications are granted the device access permission by default, and you do not need to apply for the permission separately.
**System capability**: SystemCapability.USB.USBManager
......
......@@ -161,7 +161,7 @@ console.log(`${bool}`);
requestRight(deviceName: string): Promise&lt;boolean&gt;
Requests the temporary permission for the application to access a USB device. This API uses a promise to return the result.
Requests the temporary device access permission for the application. This API uses a promise to return the result. System applications are granted the device access permission by default, and you do not need to apply for the permission separately.
**System capability**: SystemCapability.USB.USBManager
......@@ -190,7 +190,7 @@ usb.requestRight(devicesName).then((ret) => {
removeRight(deviceName: string): boolean
Removes the permission for the application to access a USB device.
Removes the device access permission for the application. System applications are granted the device access permission by default, and calling this API will not revoke the permission.
**System capability**: SystemCapability.USB.USBManager
......@@ -219,7 +219,7 @@ if (usb.removeRight(devicesName)) {
addRight(bundleName: string, deviceName: string): boolean
Adds the permission for the application to access a USB device.
Adds the device access permission for the application. System applications are granted the device access permission by default, and calling this API will not revoke the permission.
[requestRight](#usbrequestright) triggers a dialog box to request for user authorization, whereas **addRight** adds the access permission directly without displaying a dialog box.
......
......@@ -538,7 +538,7 @@ ws.off('message');
### on('close')<sup>6+</sup>
on(type: 'close', callback: AsyncCallback\<{ code: number, reason: string }\>): void
on(type: 'close', callback: AsyncCallback\<CloseResult\>): void
Enables listening for the **close** events of a WebSocket connection. This API uses an asynchronous callback to return the result.
......@@ -549,7 +549,7 @@ Enables listening for the **close** events of a WebSocket connection. This API u
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------- | ---- | ------------------------------ |
| type | string | Yes | Event type. <br />**close**: event indicating that a WebSocket connection has been closed.|
| callback | AsyncCallback\<{ code: number, reason: string }\> | Yes | Callback used to return the result.<br>**close** indicates the close error code and **reason** indicates the error code description.|
| callback | AsyncCallback\<CloseResult\> | Yes | Callback used to return the result.<br>**close** indicates the close error code and **reason** indicates the error code description.|
**Example**
......@@ -562,7 +562,7 @@ ws.on('close', (err, value) => {
### off('close')<sup>6+</sup>
off(type: 'close', callback?: AsyncCallback\<{ code: number, reason: string }\>): void
off(type: 'close', callback?: AsyncCallback\<CloseResult\>): void
Disables listening for the **close** events of a WebSocket connection. This API uses an asynchronous callback to return the result.
......@@ -576,7 +576,7 @@ Disables listening for the **close** events of a WebSocket connection. This API
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------- | ---- | ------------------------------ |
| type | string | Yes | Event type. <br />**close**: event indicating that a WebSocket connection has been closed.|
| callback | AsyncCallback\<{ code: number, reason: string }\> | No | Callback used to return the result.<br>**close** indicates the close error code and **reason** indicates the error code description.|
| callback | AsyncCallback\<CloseResult\> | No | Callback used to return the result.<br>**close** and **reason** indicate the error code and error cause for closing the connection, respectively.|
**Example**
......@@ -655,6 +655,17 @@ Defines the optional parameters carried in the request for closing a WebSocket c
| code | number | No | Error code. Set this parameter based on the actual situation. The default value is **1000**.|
| reason | string | No | Error cause. Set this parameter based on the actual situation. The default value is an empty string ("").|
## CloseResult<sup>10+</sup>
Represents the result obtained from the **close** event reported when the WebSocket connection is closed.
**System capability**: SystemCapability.Communication.NetStack
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| code | number | Yes | Error code for closing the connection.|
| reason | string | Yes | Error cause for closing the connection.|
## Result Codes for Closing a WebSocket Connection
You can customize the result codes sent to the server. The result codes in the following table are for reference only.
......
......@@ -5,6 +5,8 @@
- [Ability Error Codes](errorcode-ability.md)
- [Distributed Scheduler Error Codes](errorcode-DistributedSchedule.md)
- [Form Error Codes](errorcode-form.md)
- AI
- [Intelligent Voice Error Codes](errorcode-intelligentVoice.md)
- Bundle Management
- [Bundle Error Codes](errorcode-bundle.md)
- [zlib Error Codes](errorcode-zlib.md)
......
# Intelligent Voice Error Codes
> **NOTE**
>
> This topic describes only module-specific error codes. For details about universal error codes, see [Universal Error Codes](errorcode-universal.md).
## 22700101 Insufficient Memory
**Error Message**
No memory.
**Error Description**
This error code is reported if a memory allocation failure or null pointer occurs when an API is called.
**Possible Causes**
1. The system does not have sufficient memory for mapping.
2. Invalid instances are not destroyed in time to release the memory.
**Solution**
1. Stop the current operation or suspend other applications to free up memory.
2. Clear invalid instances to free up memory, and then create new instances as needed. If the problem persists, stop related operations.
## 22700102 Invalid Parameter
**Error Message**
Input parameter value error.
**Error Description**
This error code is reported if a certain parameter passed in the API is invalid.
**Possible Cause**
The parameter is invalid. For example, the parameter value is not within the range supported.
**Solution**
Pass the correct parameters in the API.
## 22700103 Initialization Failed
**Error Message**
Init failed.
**Error Description**
This error code is reported if an error occurs while the enrollment engine is initialized.
**Possible Cause**
1. Repeated initialization.
2. Lack of resources for initialization of the enrollment engine.
**Solution**
1. Avoid performing initialization repeatedly.
2. Ensure that the resources required for initialization, such as acoustic model files, are ready.
## 22700104 Enrollment Commit Failure
**Error Message**
Commit enroll failed.
**Error Description**
This error code is reported if an error occurs after the [commit()](../apis/js-apis-intelligentVoice.md#commit) API of the enrollment engine is called.
**Possible Cause**
The specified number of enrollment procedures are not completed.
**Solution**
Commit the enrollment after the specified number of enrollment procedures are completed.
......@@ -1091,7 +1091,7 @@
- [@ohos.charger (Charging Type)](reference/apis/js-apis-charger.md)
- [@ohos.cooperate (Screen Hopping)](reference/apis/js-apis-devicestatus-cooperate.md)
- [@ohos.deviceAttest (Device Attestation)](reference/apis/js-apis-deviceAttest.md)
- [@ohos.deviceStatus.dragInteraction (Drag)](reference/apis/js-apis-devicestatus-draginteraction.md)
- [@ohos.deviceStatus.dragInteraction (Drag Interaction)](reference/apis/js-apis-devicestatus-draginteraction.md)
- [@ohos.deviceInfo (Device Information)](reference/apis/js-apis-device-info.md)
- [@ohos.distributedDeviceManager (Device Management) (Recommended)](reference/apis/js-apis-distributedDeviceManager.md)
- [@ohos.distributedHardware.deviceManager (Device Management) (To Be Deprecated Soon)](reference/apis/js-apis-device-manager.md)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册